@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500&display=swap');

/* ─── 五色板 ─────────────────────────────────────
   #0A3323 最深绿（正文字色） #839958 苔绿 #F7F4D5 米色（底色）
   #D3968C 玫瑰棕 #105666 午夜绿 */
:root {
  --deep:  #0A3323;
  --moss:  #839958;
  --cream: #F7F4D5;
  --rose:  #D3968C;
  --night: #105666;

  --bg:         var(--cream);
  --bg-raised:  #FBF9E8;
  --bg-code:    #EFEBCF;
  --text:       var(--deep);
  --text-sub:   #3D5C48;
  --text-muted: #7C8A72;
  --accent:     var(--moss);
  --accent-2:   var(--night);
  --accent-bg:  #E9EBC9;
  --border:     #E2DDB9;
  --shadow:     0 1px 4px rgba(10,51,35,.08);

  --font: 'Hiragino Sans GB', '冬青黑体简体中文', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --radius: 5px;
  --nav-h: 56px;
  --max-w: 740px;
}

/* ─── 夜色页（posts 列表与主页同款夜空渐变） ───────── */
.night-body {
  --bg:         var(--deep);
  --bg-raised:  rgba(247, 244, 213, .05);
  --bg-code:    rgba(247, 244, 213, .08);
  --text:       var(--cream);
  --text-sub:   #D9E0C2;
  --text-muted: #A8BFB0;
  --accent:     var(--moss);
  --accent-2:   var(--cream);
  --accent-bg:  rgba(131, 153, 88, .28);
  --border:     rgba(247, 244, 213, .18);
  --shadow:     0 1px 4px rgba(0, 0, 0, .25);
  background: linear-gradient(180deg, var(--deep) 0%, #0C4437 45%, var(--night) 100%) fixed;
}

/* ─── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 24px); scrollbar-gutter: stable; }

body {
  font-family: var(--font);
  font-weight: 300;
  font-size: 15px;
  line-height: 1.85;
  letter-spacing: .03em;
  color: var(--text);
  background: var(--bg);
  transition: background .25s, color .25s;
  -webkit-font-smoothing: antialiased;
  /* sticky footer：内容不满一屏时页脚也贴底 */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
body > .container, body > div:not(.moonland) { width: 100%; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--rose); text-decoration: underline; }

img { max-width: 100%; border-radius: var(--radius); }

/* ─── 阅读进度条 ─────────────────────────────────── */
#reading-progress {
  position: fixed; top: 0; left: 0;
  width: 0%; height: 2px;
  background: var(--rose);
  z-index: 200;
  transition: width .08s linear;
}

/* ─── Nav ────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 22px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
}

.nav-logo {
  font-weight: 500; font-size: 16px;
  color: var(--text); letter-spacing: .06em;
  margin-right: auto;
}
.nav-logo:hover { text-decoration: none; color: var(--accent); }

.nav-link { font-size: 13.5px; color: var(--text-sub); letter-spacing: .04em; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--accent-2); }

/* 落地页的 nav 悬浮在夜空上 */
.landing-body .nav {
  position: fixed; width: 100%;
  border-bottom: none;
  background: transparent;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.landing-body .nav-logo, .landing-body .nav-link { color: rgba(247,244,213,.82); }
.landing-body .nav-link:hover, .landing-body .nav-logo:hover { color: var(--cream); }
.landing-body .nav-link.active { color: var(--rose); }
.landing-body footer { display: none; }

/* ─── 月亮落地页 ─────────────────────────────────── */
.moonland { min-height: 100vh; }

.sky {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--deep) 0%, #0C4437 45%, var(--night) 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 34px;
  position: relative; overflow: hidden;
  padding: 24px;
}

.stars, .stars::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 22%, rgba(247,244,213,.9), transparent 55%),
    radial-gradient(1px 1px   at 28% 64%, rgba(247,244,213,.55), transparent 55%),
    radial-gradient(1.6px 1.6px at 41% 15%, rgba(211,150,140,.75), transparent 55%),
    radial-gradient(1px 1px   at 57% 42%, rgba(247,244,213,.5), transparent 55%),
    radial-gradient(1.3px 1.3px at 68% 74%, rgba(247,244,213,.8), transparent 55%),
    radial-gradient(1px 1px   at 79% 28%, rgba(247,244,213,.6), transparent 55%),
    radial-gradient(1.5px 1.5px at 88% 58%, rgba(211,150,140,.6), transparent 55%),
    radial-gradient(1px 1px   at 18% 84%, rgba(247,244,213,.5), transparent 55%),
    radial-gradient(1.2px 1.2px at 93% 12%, rgba(247,244,213,.7), transparent 55%),
    radial-gradient(1px 1px   at 48% 90%, rgba(247,244,213,.45), transparent 55%);
  animation: twinkle 5s ease-in-out infinite;
}
.stars::after { transform: rotate(180deg); animation-delay: 2.5s; }
@keyframes twinkle { 50% { opacity: .35; } }

.moon {
  width: 168px; height: 168px;
  border-radius: 50%;
  position: relative; z-index: 1;
  background: radial-gradient(circle at 36% 34%, #FDFBEE, var(--cream) 52%, #E7E2B8 100%);
  box-shadow:
    0 0 46px rgba(247,244,213,.38),
    0 0 130px rgba(247,244,213,.16),
    inset -20px -16px 44px rgba(16,86,102,.28);
  animation: moonfloat 7s ease-in-out infinite;
}
@keyframes moonfloat { 50% { transform: translateY(-12px); } }

.moon-line {
  position: relative; z-index: 1;
  color: var(--cream);
  font-size: 15px;
  letter-spacing: .52em;
  text-indent: .52em;
  text-transform: lowercase;
  text-align: center;
  opacity: .92;
  min-height: 1.85em;
}
.type-caret {
  display: inline-block;
  animation: caret-blink 1s steps(1) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }

.moon-enter {
  position: relative; z-index: 1;
  color: rgba(247,244,213,.75);
  font-size: 13px;
  letter-spacing: .18em;
  border: 1px solid rgba(247,244,213,.32);
  border-radius: 999px;
  padding: 9px 26px;
  transition: all .25s;
}
.moon-enter:hover {
  color: var(--deep);
  background: var(--cream);
  border-color: var(--cream);
  text-decoration: none;
}

/* ─── Layout ─────────────────────────────────────── */
.container {
  max-width: calc(var(--max-w) + 280px);
  margin: 0 auto;
  padding: 0 24px;
}

.page-header {
  padding: 52px 0 36px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}
.page-header h1 { font-size: 22px; font-weight: 400; color: var(--text); margin-bottom: 6px; }
.page-header p { font-size: 13.5px; color: var(--text-muted); letter-spacing: .04em; }

/* ─── Tag chip ───────────────────────────────────── */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 11.5px;
  color: var(--text-sub);
  cursor: pointer;
  transition: all .15s;
  letter-spacing: .04em;
}
.tag:hover, .tag.active {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent-2);
  text-decoration: none;
}

.tag-count { font-style: normal; font-size: 10.5px; color: var(--text-muted); margin-left: 2px; }
.tag.active .tag-count { color: var(--accent-2); opacity: .8; }

/* ─── Stats / 筛选 ───────────────────────────────── */
.stats-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 16px;
  font-size: 12.5px; color: var(--text-muted); letter-spacing: .03em;
}
.stats-total em { font-style: normal; font-weight: 400; color: var(--accent-2); }
.stats-divider { opacity: .4; }

.tag-bar { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 28px; }

/* ─── 文章列表（豆腐块卡片，整块可点） ─────────────── */
.post-list { list-style: none; }

.post-item { margin-bottom: 16px; }
.post-item[hidden] { display: none; }

.post-card {
  display: block;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
  color: inherit;
  transition: transform .16s ease, background .16s, border-color .16s;
}
.post-card:hover {
  transform: translateY(3px);   /* hover 下沉 */
  background: rgba(247, 244, 213, .09);
  border-color: rgba(247, 244, 213, .3);
  text-decoration: none;
  color: inherit;
}

.post-item-title {
  font-size: 17px; font-weight: 400;
  color: var(--text); line-height: 1.5;
  margin-bottom: 6px; display: block;
}

.post-item-meta {
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
  letter-spacing: .03em;
}

.post-item-excerpt { font-size: 13.5px; color: var(--text-sub); line-height: 1.7; margin-bottom: 12px; }
.post-item-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.empty-state { padding: 48px 0; text-align: center; color: var(--text-muted); font-size: 13.5px; }
.section-title { font-size: 13px; color: var(--text-muted); letter-spacing: .05em; margin-bottom: 14px; }

/* ─── 标签云 ─────────────────────────────────────── */
.tags-cloud { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 34px; }
.tag-cloud-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px;
  border: 1px solid var(--border); border-radius: 20px;
  font-size: 13px; color: var(--text-sub);
  cursor: pointer; transition: all .15s;
}
.tag-cloud-item:hover, .tag-cloud-item.active {
  background: var(--accent-bg); border-color: var(--accent); color: var(--accent-2);
  text-decoration: none;
}
.tag-cloud-count { font-size: 11px; color: var(--text-muted); }
.tag-cloud-item.active .tag-cloud-count { color: var(--accent-2); }

/* ─── 文章页 ─────────────────────────────────────── */
.post-layout {
  display: grid;
  grid-template-columns: minmax(0, var(--max-w)) 220px;
  gap: 44px;
  justify-content: center;
  padding-top: 44px;
}
.post-main { min-width: 0; }

.post-header { margin-bottom: 34px; }
.post-title { font-size: 26px; font-weight: 500; line-height: 1.5; margin-bottom: 12px; }
.post-meta { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; letter-spacing: .03em; }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.post-body { font-size: 15.5px; letter-spacing: .04em; }
.post-body > * + * { margin-top: 1em; }
.post-body h2 { font-size: 19px; font-weight: 500; margin-top: 2em; padding-bottom: .35em; border-bottom: 1px solid var(--border); }
.post-body h3 { font-size: 16px; font-weight: 500; margin-top: 1.6em; }
.post-body ul, .post-body ol { padding-left: 1.4em; }
.post-body li + li { margin-top: .35em; }
.post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: .3em 1em;
  color: var(--text-sub);
  background: var(--bg-raised);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.post-body code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--bg-code);
  padding: .15em .45em;
  border-radius: 4px;
}
.post-body pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
}
.post-body pre code { background: none; padding: 0; font-size: 13px; line-height: 1.7; }
.post-body img { display: block; margin: 1.4em auto; box-shadow: var(--shadow); }
.post-body hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
.post-body table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.post-body th, .post-body td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; }
.post-body th { background: var(--bg-raised); font-weight: 500; }

.post-footer {
  margin-top: 44px; padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 16px;
  font-size: 12.5px; color: var(--text-muted);
}

/* ─── TOC：宽屏右侧固定 ──────────────────────────── */
.toc-sidebar {
  position: sticky;
  top: calc(var(--nav-h) + 36px);
  align-self: start;
  max-height: calc(100vh - var(--nav-h) - 72px);
  overflow-y: auto;
  font-size: 12.5px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}
.toc-label { font-size: 11px; letter-spacing: .14em; color: var(--text-muted); margin-bottom: 10px; }

.toc-progress { margin-bottom: 12px; }
.toc-progress-track {
  position: relative; height: 3px;
  background: var(--border); border-radius: 3px;
}
.toc-progress-fill { position: absolute; left: 0; top: 0; height: 100%; width: 0%; background: var(--rose); border-radius: 3px; transition: width .1s linear; }
.toc-progress-pct { position: absolute; right: 0; top: 7px; font-size: 10.5px; color: var(--text-muted); }

.toc-list { list-style: none; margin-top: 16px; }
.toc-item { line-height: 1.5; margin-bottom: 7px; }
.toc-item.depth-3 { padding-left: 14px; }
.toc-link { color: var(--text-muted); display: block; }
.toc-link:hover { color: var(--text); text-decoration: none; }
.toc-link.active { color: var(--accent-2); }

/* ─── TOC：窄屏折叠到文章顶部 ────────────────────── */
.toc-mobile {
  display: none;
  margin-bottom: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-raised);
  font-size: 13px;
}
.toc-mobile summary {
  padding: 10px 14px;
  cursor: pointer;
  color: var(--text-sub);
  letter-spacing: .08em;
  list-style: none;
}
.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile summary::after { content: '▾'; float: right; color: var(--text-muted); transition: transform .15s; }
.toc-mobile[open] summary::after { transform: rotate(180deg); }
.toc-mobile .toc-list { margin: 0; padding: 2px 14px 12px; }

/* ─── 评论 ───────────────────────────────────────── */
.comments-section { margin-top: 48px; }
.comments-title { font-size: 13px; letter-spacing: .1em; color: var(--text-muted); margin-bottom: 16px; }

/* ─── me 页 ──────────────────────────────────────── */
.me-body { max-width: var(--max-w); padding-bottom: 60px; }

/* ─── Footer ─────────────────────────────────────── */
footer {
  margin-top: auto;
  padding: 60px 24px 34px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: .04em;
}

/* ─── 响应式 ─────────────────────────────────────── */
@media (max-width: 960px) {
  .post-layout { grid-template-columns: minmax(0, 1fr); padding-top: 32px; }
  .toc-sidebar { display: none; }
  .toc-mobile { display: block; }
}

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .nav { padding: 0 16px; gap: 14px; }
  .container { padding: 0 16px; }
  .page-header { padding: 36px 0 26px; margin-bottom: 26px; }
  .post-title { font-size: 22px; }
  .moon { width: 132px; height: 132px; }
  .moon-line { font-size: 12.5px; letter-spacing: .34em; text-indent: .34em; }
}
