/* ============================================================
   口袋大脑 · Pocket Brain — 纸上书房（编辑风格）
   Design Tokens → Components → Utilities
   ============================================================ */

/* ---------- 1. Design Tokens ---------- */
:root {
  /* 色彩（纸感 + 墨色 + 朱砂点缀） */
  --bg: #f7f2e7;              /* 纸底 */
  --bg-deep: #efe7d6;         /* 深一层的纸 */
  --surface: #fdfaf3;         /* 卡片面 */
  --text: #26221c;            /* 墨色 */
  --text-secondary: #5c544a;
  --text-muted: #8a8073;
  --border: #ddd2bd;
  --border-subtle: #e8e0cf;
  --accent: #a83f2e;          /* 朱砂红 */
  --accent-hover: #8f3325;
  --accent-subtle: #f3e2dc;
  --accent-foreground: #fdfaf3;
  --gold: #9a7b2d;            /* 鎏金：评分星 */
  --leaf: #5a6e46;            /* 苔绿：读书标签 */
  --focus-ring: rgba(168, 63, 46, 0.45);
  --shadow-sm: 0 1px 2px rgba(58, 48, 32, 0.08);
  --shadow-md: 0 4px 16px rgba(58, 48, 32, 0.10);
  --shadow-lg: 0 12px 40px rgba(58, 48, 32, 0.14);

  /* 字体 */
  --font-serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-kai: "LXGW WenKai Screen", "Noto Serif SC", serif;

  /* 字号阶梯 */
  --fs-display: clamp(2.5rem, 5.5vw + 1rem, 4.25rem);
  --fs-h1: clamp(1.9rem, 2.6vw + 1rem, 2.6rem);
  --fs-h2: clamp(1.4rem, 1.4vw + 1rem, 1.75rem);
  --fs-h3: 1.2rem;
  --fs-body: 1rem;
  --fs-small: 0.875rem;
  --fs-caption: 0.75rem;

  /* 间距（8px 体系） */
  --sp-1: 8px; --sp-2: 16px; --sp-3: 24px; --sp-4: 32px;
  --sp-5: 40px; --sp-6: 48px; --sp-8: 64px; --sp-12: 96px;

  /* 圆角 / 动效 */
  --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px; --radius-full: 999px;
  --dur-fast: 150ms; --dur-base: 220ms; --dur-slow: 320ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --bg: #191612;
  --bg-deep: #12100c;
  --surface: #221e18;
  --text: #e8e1d4;
  --text-secondary: #b5ac9c;
  --text-muted: #7d7466;
  --border: #3a342a;
  --border-subtle: #2e2921;
  --accent: #d4593f;
  --accent-hover: #e06a4f;
  --accent-subtle: #3a251f;
  --accent-foreground: #fdfaf3;
  --gold: #d1a545;
  --leaf: #93a578;
  --focus-ring: rgba(212, 89, 63, 0.5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ---------- 2. 基础 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.75;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(168, 63, 46, 0.04), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(154, 123, 45, 0.05), transparent 45%);
  transition: background-color var(--dur-slow) ease, color var(--dur-slow) ease;
  -webkit-font-smoothing: antialiased;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 var(--sp-3); }

a { color: var(--accent); text-decoration: none; transition: color var(--dur-fast) ease; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-sm); }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-foreground);
  padding: var(--sp-1) var(--sp-2); border-radius: 0 0 var(--radius-sm) 0; z-index: 200;
}
.skip-link:focus { left: 0; color: var(--accent-foreground); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 3. 页头 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
.header-inner { display: flex; align-items: center; gap: var(--sp-3); min-height: 64px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; color: var(--accent); }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: var(--radius-md);
  background: var(--accent); color: var(--accent-foreground);
  font-family: var(--font-serif); font-weight: 900; font-size: 1.15rem;
  box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; font-family: var(--font-serif); font-weight: 700; font-size: 1.05rem; }
.brand-text small { font-family: var(--font-sans); font-weight: 400; font-size: var(--fs-caption); color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; }

.site-nav { margin-left: auto; display: flex; gap: 4px; }
.site-nav a {
  color: var(--text-secondary); font-weight: 500; font-size: var(--fs-small);
  padding: 8px 12px; border-radius: var(--radius-full);
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.site-nav a:hover { background: var(--bg-deep); color: var(--text); text-decoration: none; }
.site-nav a[aria-current="page"] { background: var(--accent-subtle); color: var(--accent); font-weight: 700; }

.header-tools { display: flex; gap: 4px; margin-left: 8px; }
.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; border: 1px solid transparent; border-radius: var(--radius-full);
  background: transparent; color: var(--text-secondary); cursor: pointer;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.icon-btn:hover { background: var(--bg-deep); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }
.menu-btn { display: none; }

/* ---------- 4. 搜索 ---------- */
.search-overlay[hidden] { display: none; }
.search-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: color-mix(in srgb, var(--bg-deep) 72%, transparent);
  backdrop-filter: blur(6px);
  display: flex; flex-direction: column; align-items: center;
  padding: 14vh var(--sp-3) var(--sp-3);
  animation: fadeIn var(--dur-base) var(--ease-out);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.search-box {
  display: flex; align-items: center; gap: var(--sp-1);
  width: 100%; max-width: 560px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 12px 16px;
  box-shadow: var(--shadow-lg); color: var(--text-muted);
}
.search-box input {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: 1.05rem; color: var(--text); font-family: inherit;
}
.search-box kbd {
  font-family: var(--font-sans); font-size: var(--fs-caption);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 2px 6px; color: var(--text-muted);
}
.search-results {
  width: 100%; max-width: 560px; margin-top: var(--sp-2);
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-height: 52vh; overflow-y: auto; padding: var(--sp-1);
}
.search-result-item {
  display: block; padding: 12px 16px; border-radius: var(--radius-md);
  color: var(--text); cursor: pointer;
}
.search-result-item:hover { background: var(--bg-deep); text-decoration: none; }
.search-result-item .sr-type { font-size: var(--fs-caption); color: var(--accent); font-weight: 700; margin-right: 8px; }
.search-result-item .sr-title { font-weight: 600; }
.search-result-item .sr-desc { display: block; font-size: var(--fs-small); color: var(--text-muted); margin-top: 2px; }
.search-empty { padding: var(--sp-4); text-align: center; color: var(--text-muted); font-size: var(--fs-small); }

/* ---------- 5. 首页 Hero ---------- */
.hero { padding: var(--sp-12) 0 var(--sp-8); }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-small); font-weight: 500; letter-spacing: 0.2em;
  color: var(--accent); text-transform: uppercase;
  margin-bottom: var(--sp-2);
}
.hero-eyebrow::before { content: ""; width: 32px; height: 1px; background: var(--accent); }
.hero-title {
  font-family: var(--font-serif); font-weight: 900;
  font-size: var(--fs-display); line-height: 1.15; letter-spacing: 0.02em;
  margin-bottom: var(--sp-3);
}
.hero-title em { font-style: normal; color: var(--accent); position: relative; }
.hero-title em::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 6px; height: 10px;
  background: var(--accent-subtle); z-index: -1; border-radius: 2px;
}
.hero-desc { max-width: 44ch; font-size: 1.1rem; color: var(--text-secondary); margin-bottom: var(--sp-4); }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-8); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 10px 22px;
  border-radius: var(--radius-full); border: 1px solid transparent;
  font-family: inherit; font-size: var(--fs-small); font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: background var(--dur-fast) ease, border-color var(--dur-fast) ease, transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-foreground); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-foreground); box-shadow: var(--shadow-md); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

/* 首页统计条 */
.stats-band {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px; background: var(--border-subtle);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  overflow: hidden;
}
.stat-cell { background: var(--surface); padding: var(--sp-3) var(--sp-4); }
.stat-num { font-family: var(--font-serif); font-size: 1.8rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.stat-label { font-size: var(--fs-small); color: var(--text-muted); }

/* ---------- 6. 通用区块 ---------- */
.section { padding: var(--sp-8) 0; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2);
  margin-bottom: var(--sp-4); padding-bottom: var(--sp-2);
  border-bottom: 2px solid var(--text);
}
.section-title { font-family: var(--font-serif); font-weight: 700; font-size: var(--fs-h2); }
.section-title .section-title-en { color: var(--text-muted); font-size: var(--fs-small); font-weight: 400; margin-left: 10px; letter-spacing: 0.1em; }
.section-more { font-size: var(--fs-small); font-weight: 500; white-space: nowrap; }

/* 文章列表 */
.post-list { display: flex; flex-direction: column; }
.post-row {
  display: grid; grid-template-columns: 96px 1fr auto; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-2); border-bottom: 1px solid var(--border-subtle);
  color: var(--text); border-radius: var(--radius-sm);
  transition: background var(--dur-fast) ease;
}
.post-row:hover { background: var(--surface); text-decoration: none; }
.post-row:hover .post-title { color: var(--accent); }
.post-date {
  font-family: var(--font-serif); text-align: center; line-height: 1.3;
  color: var(--text-muted);
}
.post-date .d { font-size: 1.6rem; font-weight: 700; color: var(--text-secondary); display: block; }
.post-date .ym { font-size: var(--fs-caption); letter-spacing: 0.1em; }
.post-title { font-family: var(--font-serif); font-size: var(--fs-h3); font-weight: 700; margin-bottom: 4px; transition: color var(--dur-fast) ease; }
.post-excerpt { color: var(--text-secondary); font-size: var(--fs-small); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag {
  font-size: var(--fs-caption); font-weight: 500;
  color: var(--accent); background: var(--accent-subtle);
  padding: 2px 10px; border-radius: var(--radius-full);
}
.tag--leaf { color: var(--leaf); background: color-mix(in srgb, var(--leaf) 14%, transparent); }
.post-arrow { align-self: center; color: var(--text-muted); font-size: 1.2rem; transition: transform var(--dur-fast) ease, color var(--dur-fast) ease; }
.post-row:hover .post-arrow { transform: translateX(4px); color: var(--accent); }

/* 书籍卡片 */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--sp-3); }
.book-card {
  display: flex; gap: var(--sp-2); padding: var(--sp-3);
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--dur-base) ease, border-color var(--dur-base) ease, transform var(--dur-base) ease;
}
.book-card:hover { box-shadow: var(--shadow-md); border-color: var(--border); transform: translateY(-2px); }
.book-spine {
  flex-shrink: 0; width: 64px; height: 92px; border-radius: var(--radius-sm);
  display: grid; place-items: center; text-align: center;
  font-family: var(--font-serif); font-weight: 700; font-size: 0.85rem; line-height: 1.3;
  color: #fdfaf3; padding: 8px; word-break: break-word;
  box-shadow: var(--shadow-sm), inset -4px 0 8px rgba(0, 0, 0, 0.15);
}
.book-info { min-width: 0; flex: 1; }
.book-title { font-family: var(--font-serif); font-weight: 700; font-size: 1.05rem; margin-bottom: 2px; }
.book-author { font-size: var(--fs-small); color: var(--text-muted); margin-bottom: 6px; }
.book-stars { color: var(--gold); font-size: var(--fs-small); letter-spacing: 2px; margin-bottom: 6px; }
.book-status {
  font-size: var(--fs-caption); font-weight: 700;
  padding: 2px 10px; border-radius: var(--radius-full);
}
.book-status.reading { color: var(--accent); background: var(--accent-subtle); }
.book-status.done { color: var(--leaf); background: color-mix(in srgb, var(--leaf) 14%, transparent); }
.book-status.wish { color: var(--text-muted); background: var(--bg-deep); }
.book-note { font-family: var(--font-kai); font-size: var(--fs-small); color: var(--text-secondary); margin-top: 8px; }

/* 作品卡片 */
.work-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-3); }
.work-card {
  display: flex; flex-direction: column; gap: var(--sp-1);
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: var(--sp-4);
  color: var(--text); position: relative; overflow: hidden;
  transition: box-shadow var(--dur-base) ease, transform var(--dur-base) ease, border-color var(--dur-base) ease;
}
.work-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); border-color: var(--border); text-decoration: none; }
.work-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  opacity: 0; transition: opacity var(--dur-base) ease;
}
.work-card:hover::before { opacity: 1; }
.work-emoji { font-size: 1.8rem; line-height: 1; margin-bottom: 4px; }
.work-title { font-family: var(--font-serif); font-weight: 700; font-size: var(--fs-h3); }
.work-title a { color: inherit; }
.work-card:hover .work-title a { color: var(--accent); text-decoration: none; }
.work-desc { font-size: var(--fs-small); color: var(--text-secondary); flex: 1; }
.work-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.work-links { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); font-size: var(--fs-small); font-weight: 600; }

/* ---------- 7. 文章阅读页 ---------- */
.article { max-width: 720px; margin: 0 auto; padding: var(--sp-6) 0 var(--sp-8); }
.article-back { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-small); font-weight: 500; margin-bottom: var(--sp-4); }
.article-head { margin-bottom: var(--sp-5); }
.article-meta { font-size: var(--fs-small); color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: var(--sp-2); }
.article-title { font-family: var(--font-serif); font-weight: 900; font-size: var(--fs-h1); line-height: 1.3; margin-bottom: var(--sp-2); }
.article-body {
  font-family: var(--font-kai); font-size: 1.08rem; line-height: 2; color: var(--text);
}
.article-body p { margin-bottom: 1.4em; text-indent: 0; }
.article-body h2 {
  font-family: var(--font-serif); font-size: var(--fs-h2); font-weight: 700;
  margin: 1.8em 0 0.8em; padding-left: 12px; border-left: 4px solid var(--accent);
}
.article-body blockquote {
  margin: 1.5em 0; padding: 8px 20px;
  border-left: 3px solid var(--gold); background: var(--bg-deep);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
}
.article-body code {
  font-family: "JetBrains Mono", Consolas, monospace; font-size: 0.9em;
  background: var(--bg-deep); padding: 2px 6px; border-radius: var(--radius-sm);
}
.article-body ul, .article-body ol { margin: 1em 0 1.4em; padding-left: 1.5em; }
.article-body li { margin-bottom: 0.5em; }
.article-body hr { border: none; border-top: 1px dashed var(--border); margin: 2.2em auto; width: 60%; }
.article-footer { margin-top: var(--sp-6); padding-top: var(--sp-3); border-top: 1px solid var(--border-subtle); display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-2); }

/* ---------- 8. 关于页 ---------- */
.about-card {
  max-width: 720px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
}
.about-bio { font-family: var(--font-kai); font-size: 1.05rem; line-height: 2; }
.about-bio p { margin-bottom: 1.2em; }

/* ---------- 9. 空状态 ---------- */
.empty-state {
  text-align: center; padding: var(--sp-12) var(--sp-4);
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: var(--sp-2); }
.empty-state .empty-title { font-family: var(--font-serif); font-weight: 700; font-size: var(--fs-h3); margin-bottom: 8px; }
.empty-state .empty-desc { color: var(--text-muted); font-size: var(--fs-small); margin-bottom: var(--sp-3); }

/* ---------- 10. 页脚 ---------- */
.site-footer { margin-top: var(--sp-8); border-top: 1px solid var(--border-subtle); background: var(--bg-deep); }
.footer-inner { padding: var(--sp-5) var(--sp-3); text-align: center; }
.footer-brand { font-family: var(--font-serif); font-weight: 700; margin-bottom: 8px; }
.footer-meta { font-size: var(--fs-small); color: var(--text-muted); margin-bottom: 4px; }

/* ---------- 11. 入场动画 ---------- */
.stagger-item { animation: riseIn 0.5s var(--ease-out) backwards; }
.stagger-item:nth-child(1) { animation-delay: 0ms; }
.stagger-item:nth-child(2) { animation-delay: 60ms; }
.stagger-item:nth-child(3) { animation-delay: 120ms; }
.stagger-item:nth-child(4) { animation-delay: 180ms; }
.stagger-item:nth-child(5) { animation-delay: 240ms; }
.stagger-item:nth-child(6) { animation-delay: 300ms; }
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- 12. 响应式 ---------- */
@media (max-width: 860px) {
  .site-nav {
    position: fixed; top: 64px; left: 0; right: 0;
    flex-direction: column; padding: var(--sp-2) var(--sp-3);
    background: var(--bg); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateY(-120%); transition: transform var(--dur-base) var(--ease-out);
    z-index: 90; margin-left: 0;
  }
  .site-nav.open { transform: translateY(0); }
  .site-nav a { padding: 12px 16px; font-size: 1rem; border-radius: var(--radius-md); }
  .menu-btn { display: grid; }
  .brand-text small { display: none; }
  .hero { padding-top: var(--sp-8); }
}

@media (max-width: 560px) {
  .post-row { grid-template-columns: 1fr; gap: 8px; }
  .post-date { display: flex; align-items: baseline; gap: 8px; text-align: left; }
  .post-date .d { font-size: 1rem; display: inline; }
  .post-arrow { display: none; }
  .section-head { flex-direction: column; gap: 4px; }
  .stats-band { grid-template-columns: repeat(2, 1fr); }
}
