/* 拾光随笔 — 纸感编辑部风格：宣纸底、衬线标题、留白、朱红点缀 */
/* 仅样式层改动；结构、类名、脚本逻辑保持原样 */

:root {
  color-scheme: light;

  /* 纸与墨 */
  --bg: #f7f3ea;
  --bg-soft: #efe9dc;
  --ink: #1b1916;
  --ink-soft: #433d34;
  --muted: #6f6759;
  --line: rgba(27, 25, 22, 0.13);
  --line-strong: rgba(27, 25, 22, 0.26);
  --card: #fbf8f1;

  /* 朱红点缀 */
  --accent: #b04a2a;
  --accent-ink: #9d4023;
  --accent-soft: #e8d7cb;

  --shadow: 0 16px 34px -26px rgba(27, 25, 22, 0.5);
  --shadow-hover: 0 20px 40px -30px rgba(27, 25, 22, 0.55);

  --serif: "Iowan Old Style", "Palatino Linotype", "Songti SC", "STSong", "Source Han Serif SC",
    "Noto Serif SC", "Noto Serif CJK SC", "SimSun", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
    "Microsoft YaHei", "Segoe UI", sans-serif;

  --max: 1120px;
  --gutter: 48px;
  --radius: 18px;

  /* 字号节奏 */
  --fs-body: 16px;
  --fs-small: 13px;
  --lh-body: 1.8;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #14120f;
  --bg-soft: #1d1a16;
  --ink: #f1ece2;
  --ink-soft: #cfc7b8;
  --muted: #a09889;
  --line: rgba(241, 236, 226, 0.12);
  --line-strong: rgba(241, 236, 226, 0.26);
  --card: #1b1814;

  --accent: #d4734f;
  --accent-ink: #e08a68;
  --accent-soft: #35251e;

  --shadow: 0 16px 34px -26px rgba(0, 0, 0, 0.7);
  --shadow-hover: 0 20px 40px -30px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  background:
    radial-gradient(1100px 560px at 84% -12%, var(--bg-soft), transparent 62%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* 中文正文：避免末行只剩一两个字，标题保持自然换行 */
p, li, dd, .lead, .poem { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

/* 键盘焦点：只在键盘操作时出现；不支持的浏览器保留系统默认外框 */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}
:focus:not(:focus-visible) { outline: none; }
a:focus-visible,
button:focus-visible { outline-offset: 4px; }

::selection {
  background: color-mix(in srgb, var(--accent) 26%, transparent);
  color: var(--ink);
}

/* 极简滚动条（可选增强，不影响默认行为） */
@supports (scrollbar-width: thin) {
  html { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
}

.wrap { width: min(100% - var(--gutter), var(--max)); margin: 0 auto; }

/* 锚点跳转要避开吸顶导航 */
[id] { scroll-margin-top: 88px; }

/* ── 顶部 ─────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 68px;
}
.brand {
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}
.brand small {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-transform: uppercase;
}
.nav { display: flex; gap: 26px; font-size: 14px; color: var(--ink-soft); }
.nav a {
  position: relative;
  padding: 4px 0;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.nav a::after {
  content: "";
  position: absolute; left: 0; bottom: -2px;
  width: 0; height: 1px; background: var(--accent);
  transition: width 0.25s ease;
}
.nav a:hover::after,
.nav a[aria-current="page"]::after { width: 100%; }
.nav a[aria-current="page"] { color: var(--ink); }

.header-actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: grid; place-items: center;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ── 首屏 ─────────────────────────────── */
.hero { padding: clamp(56px, 9vw, 124px) 0 clamp(40px, 6vw, 72px); }
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}
.kicker::before { content: ""; width: 28px; height: 1px; background: var(--accent); flex: none; }

.hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.1rem, 9.2vw, 4.9rem);
  line-height: 1.14;
  letter-spacing: -0.012em;
  margin: 22px 0 26px;
  max-width: 15ch;
  overflow-wrap: break-word;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lead {
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.9;
  color: var(--ink-soft);
  max-width: 33rem;
}
.hero-meta {
  margin-top: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 40px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.hero-meta strong { color: var(--ink); font-weight: 500; }

/* ── 段落 ─────────────────────────────── */
.section { padding: clamp(44px, 6.5vw, 84px) 0; border-top: 1px solid var(--line); }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px 40px;
  margin-bottom: 32px;
}
.section-num {
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--accent);
}
.section-head h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(25px, 3.2vw, 36px);
  line-height: 1.3;
  margin: 6px 0 0;
  letter-spacing: -0.008em;
}
.section-head p { color: var(--muted); font-size: 14px; line-height: 1.75; margin: 0; max-width: 26rem; }

/* ── 卡片 ─────────────────────────────── */
.grid { display: grid; gap: 20px; align-items: stretch; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: clamp(22px, 2.4vw, 28px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, background-color 0.22s ease;
}
.card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-hover);
}
.card:hover .arrow { color: var(--accent-ink); }
.card-tag {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1.6;
}
.card h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(21px, 2.1vw, 24px);
  line-height: 1.34;
  letter-spacing: -0.004em;
  margin: 0;
}
.card .poem { font-family: var(--serif); color: var(--ink-soft); line-height: 1.85; margin: 0; }
.card p { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.8; }
.card .meta { font-size: var(--fs-small); color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.card .arrow { margin-top: auto; padding-top: 4px; font-size: var(--fs-small); color: var(--accent); letter-spacing: 0.02em; }

.card.feature { grid-column: 1 / -1; }
@media (min-width: 860px) {
  .card.feature { flex-direction: row; align-items: stretch; gap: 40px; }
  .card.feature .feature-body { flex: 1; display: flex; flex-direction: column; gap: 12px; }
  .card.feature .feature-aside {
    width: 220px;
    flex: none;
    border-left: 1px solid var(--line);
    padding-left: 28px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    font-size: var(--fs-small);
    color: var(--muted);
  }
}

/* ── 空状态 ───────────────────────────── */
.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 40px 26px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.85;
}
.empty strong { display: block; font-family: var(--serif); color: var(--ink); font-size: 20px; margin-bottom: 6px; }

/* ── 页脚 ─────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 44px 0 56px;
  color: var(--muted);
  font-size: var(--fs-small);
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 18px 40px; align-items: baseline; justify-content: space-between; }
.footer-inner a { color: var(--ink-soft); }
.footer-inner a:hover { color: var(--accent); }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }

/* ── 子页面 ───────────────────────────── */
.page-hero { padding: clamp(44px, 7vw, 88px) 0 40px; }
.page-hero h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 5.6vw, 3.8rem);
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 18px 0 16px;
  max-width: 22ch;
  overflow-wrap: break-word;
}
.page-hero .lead { font-size: clamp(16px, 1.9vw, 19px); line-height: 1.9; max-width: 34rem; }
.page-hero .poem {
  font-family: var(--serif);
  font-size: clamp(17px, 2.2vw, 23px);
  line-height: 1.85;
  color: var(--ink-soft);
}

/* 统计条：用「容器底色 + 1px 间隙」做细线，列数按断点写死，
   保证 4 格内容不会在最后一行留出空洞（自动列数会留） */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  margin: 40px 0;
}
@media (max-width: 900px) {
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat { background: var(--card); padding: 20px 22px; min-width: 0; }
.stat dt { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.stat dd { margin: 6px 0 0; font-size: 15px; line-height: 1.7; color: var(--ink); overflow-wrap: break-word; }

.timeline { display: grid; gap: 0; margin: 8px 0 0; }
.day {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 28px;
  padding: 30px 0;
  border-top: 1px solid var(--line);
}
.day:first-child { border-top: 0; }
.day-label { font-family: var(--serif); color: var(--accent); font-size: 14px; letter-spacing: 0.08em; }
.day-label small { display: block; color: var(--muted); font-family: var(--sans); font-size: 12px; letter-spacing: 0; margin-top: 4px; }
.day h3 { font-family: var(--serif); font-weight: 600; font-size: 22px; line-height: 1.4; margin: 0 0 10px; }
.day p { margin: 0 0 12px; color: var(--ink-soft); }
.day ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.85; }
.day li { margin: 4px 0; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.info-block { padding: 22px 24px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.info-block h3 { font-family: var(--serif); font-size: 18px; line-height: 1.5; margin: 0 0 10px; }
.info-block p, .info-block li { color: var(--ink-soft); font-size: 14px; line-height: 1.8; margin: 0; }
.info-block ul { margin: 0; padding-left: 18px; }
.info-block li { margin: 3px 0; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 10px;
  transition: color 0.2s ease;
}
.back-link:hover { color: var(--accent); }

/* ── 文章详情：中文阅读栏宽 36em 左右 ──── */
.post-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: var(--fs-small);
  letter-spacing: 0.04em;
  margin-top: 12px;
}

.post-body {
  max-width: 36em;          /* ≈ 630px @17.5px，中文单行 34–38 字 */
  font-family: var(--serif);
  font-size: 17.5px;
  line-height: 1.95;
  color: var(--ink-soft);
  letter-spacing: 0.012em;
  text-align: justify;
  text-justify: inter-ideograph;
}
.post-body > *:first-child { margin-top: 0; }
.post-body p { margin: 0 0 1.35em; }
.post-body p:last-child { margin-bottom: 0; }

.post-body h2 {
  font-family: var(--serif);
  font-size: 25px;
  line-height: 1.5;
  letter-spacing: 0;
  margin: 2em 0 0.7em;
  color: var(--ink);
}
.post-body h2::before {
  content: "";
  display: block;
  width: 26px;
  height: 1px;
  background: var(--accent);
  margin-bottom: 14px;
}
.post-body h3 {
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.6;
  margin: 1.7em 0 0.6em;
  color: var(--ink);
}
.post-body a { color: var(--accent-ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.post-body a:hover { color: var(--accent); text-decoration-color: currentColor; }
.post-body strong { color: var(--ink); font-weight: 600; }

.post-body blockquote {
  margin: 1.8em 0;
  padding: 4px 0 4px 22px;
  border-left: 2px solid var(--accent);
  color: var(--ink);
  font-size: 1.02em;
  line-height: 1.9;
}
.post-body blockquote p:last-child { margin-bottom: 0; }

.post-body ul, .post-body ol { margin: 0 0 1.35em; padding-left: 1.35em; }
.post-body li { margin: 0.4em 0; }
.post-body li::marker { color: var(--accent); }

.post-body code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  padding: 0.14em 0.4em;
  border-radius: 5px;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
  letter-spacing: 0;
}
.post-body pre {
  margin: 1.6em 0;
  padding: 18px 20px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  font-size: 14.5px;
  line-height: 1.7;
  text-align: left;
}
.post-body pre code { background: none; padding: 0; font-size: inherit; }

.post-body hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 2.4em auto;
  width: 40%;
}
.post-body img { max-width: 100%; height: auto; border-radius: 10px; }
.post-body figure { margin: 1.8em 0; }
.post-body figcaption { font-family: var(--sans); font-size: 13px; color: var(--muted); margin-top: 8px; text-align: center; }

/* ── 平板 ─────────────────────────────── */
@media (max-width: 900px) {
  :root { --gutter: 40px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .section-head p { max-width: 32rem; }
}

/* ── 手机：单列、导航横向可读、字号自动降级 ── */
@media (max-width: 700px) {
  :root { --gutter: 32px; --fs-body: 15.5px; --lh-body: 1.78; }

  .header-inner {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand actions"
      "nav   nav";
    align-items: center;
    column-gap: 12px;
    row-gap: 8px;
    height: auto;
    padding: 12px 0 0;
  }
  .brand { grid-area: brand; font-size: 19px; gap: 6px; }
  .brand small { font-size: 10px; letter-spacing: 0.16em; }
  .header-actions { grid-area: actions; }
  .theme-toggle { width: 36px; height: 36px; }
  .theme-toggle svg { width: 16px; height: 16px; }

  .nav {
    grid-area: nav;
    width: 100%;
    gap: 24px;
    font-size: 13.5px;
    padding: 2px 0 12px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { padding: 2px 0; }
  .nav a::after { bottom: 0; }

  .hero { padding-top: clamp(40px, 11vw, 64px); }
  .hero h1 { margin: 18px 0 20px; max-width: 100%; }
  .hero .lead { font-size: 16px; line-height: 1.85; }
  .hero-meta { margin-top: 32px; gap: 10px 24px; font-size: 13px; }

  .section { padding: 40px 0; }
  .section-head { margin-bottom: 24px; }
  .section-head h2 { font-size: 26px; }
  .section-head p { font-size: 13.5px; }

  .grid, .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 16px; }

  .card.feature .feature-aside {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 14px 0 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12.5px;
  }

  .page-hero { padding: 36px 0 32px; }
  .page-hero h1 { max-width: 100%; }
  .page-hero .poem { font-size: 17px; }
  .back-link { margin-bottom: 14px; }

  .stat-row {
    grid-template-columns: 1fr;
    margin: 28px 0;
    border-radius: 14px;
  }
  .stat { padding: 16px 16px; }
  .stat dd { font-size: 14px; }

  .day {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 24px 0;
  }
  .day-label { display: flex; align-items: baseline; gap: 10px; }
  .day-label small { margin-top: 0; }
  .day h3 { font-size: 20px; margin-bottom: 8px; }
  .day ul { font-size: 13.5px; }

  .info-grid { grid-template-columns: 1fr; gap: 14px; }
  .info-block { padding: 18px 20px; }

  .empty { padding: 30px 20px; font-size: 14px; }

  .site-footer { padding: 36px 0 44px; }
  .footer-inner { flex-direction: column; gap: 14px; align-items: flex-start; }
  .footer-links { gap: 16px; }

  /* 阅读页：手机上优先不被两端对齐拉出大片字间空隙 */
  .post-body { font-size: 16.5px; line-height: 1.9; text-align: left; max-width: none; }
  .post-body h2 { font-size: 22px; }
  .post-body pre { font-size: 13.5px; padding: 14px 16px; }
}

@media (max-width: 380px) {
  :root { --gutter: 28px; }
  .hero h1 { font-size: 2rem; }
  .nav { gap: 18px; font-size: 13px; }
  .brand small { display: none; }
}

/* ── 减少动效 ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* ── 滚动入场 ─────────────────────────── */
.will-reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.7s ease, transform 0.7s ease; }
.will-reveal.is-in { opacity: 1; transform: none; }

/* ── 打印 ─────────────────────────────── */
@media print {
  :root {
    --bg: #fff;
    --bg-soft: #fff;
    --card: #fff;
    --ink: #000;
    --ink-soft: #222;
    --muted: #555;
    --line: #ccc;
    --line-strong: #999;
    --accent: #000;
    --accent-ink: #000;
    --shadow: none;
    --shadow-hover: none;
  }
  html { overflow: visible; }
  .site-header, .site-footer, .back-link, .theme-toggle, .kicker::before { display: none !important; }
  body {
    background: #fff !important;
    color: #000;
    font-size: 11pt;
    line-height: 1.7;
  }
  .wrap { width: 100%; max-width: none; }
  a { color: #000; text-decoration: underline; }
  .card, .info-block, .empty, .stat-row { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); background: #bbb; }
  .section { padding: 16pt 0; }
  .hero, .page-hero { padding: 0 0 14pt; }
  .post-body { max-width: none; font-size: 11pt; text-align: left; }
  .post-body h2::before { display: none; }
  h1, h2, h3 { break-after: avoid; }
  .will-reveal { opacity: 1 !important; transform: none !important; }
}
