/* 桃之若 · 文章详情页样式
   与首页（styles.css）共用同一套 token；--bg/--ink-soft 等旧名仅作别名。 */
:root {
  --paper: #ebe7da;
  --paper-deep: #e1dccd;
  --ink: #272320;
  --ink-2: #4e4639;
  --muted: #756c5e;
  --faint: #a39a89;
  --line: #d9d3c3;
  --line-ink: #c2bbab;
  --cinnabar: #b1503a;
  --cinnabar-deep: #97412e;
  --header-bg: rgba(235, 231, 218, .9);

  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 14px;

  /* 楷体声部：引文、落款；系统字体，零加载成本，缺字时退回宋体 */
  --font-kai: "Kaiti SC", "STKaiti", KaiTi, "AR PL UKai CN", "TW-Kai", "Noto Serif SC", serif;

  /* 历史别名，一律指向主站 token，避免两套数值漂移 */
  --bg: var(--paper);
  --ink-soft: var(--muted);
  --ink-faint: var(--faint);
  --accent: var(--cinnabar);
  --maxw: 42rem;
}

/* 夜间模式：手动切换或跟随系统（脚本在 <html data-theme> 上解析） */
:root[data-theme="dark"] {
  --paper: #1d1b17;
  --paper-deep: #15130f;
  --ink: #ece4d4;
  --ink-2: #c3bba8;
  --muted: #978d7e;
  --faint: #6d6558;
  --line: #322e27;
  --line-ink: #463f37;
  --cinnabar: #cd6c52;
  --cinnabar-deep: #b1503a;
  --header-bg: rgba(22, 20, 16, .86);
}

/* ---------- 墨染：点击导航时，一滴墨在纸上晕开（theme.js 注入） ---------- */
.nav a, .nav .brand { position: relative; }
.ink-drop {
  position: absolute;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, var(--ink) 0%, transparent 70%);
  mix-blend-mode: multiply;
  animation: inkBleed .8s cubic-bezier(.16, 1, .3, 1) forwards;
}
:root[data-theme="dark"] .ink-drop { mix-blend-mode: screen; }
@keyframes inkBleed {
  0%   { opacity: .45; transform: scale(.35); filter: blur(1px); }
  45%  { opacity: .3; }
  100% { opacity: 0; transform: scale(6); filter: blur(5px); }
}

/* 日/夜切换按钮（由 theme.js 注入到导航末尾） */
.theme-toggle {
  display: inline-grid; place-items: center;
  width: 2rem; height: 2rem; padding: 0;
  align-self: center;
  border: 1px solid var(--line); border-radius: 50%;
  background: transparent; color: var(--ink-soft); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color .25s ease, border-color .25s ease, transform .45s cubic-bezier(.34, 1.4, .64, 1);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: rotate(20deg); }
.theme-toggle svg { width: 1rem; height: 1rem; display: block; }
.theme-toggle .i-sun { display: none; }
.theme-toggle .i-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
/* 霞鹜文楷 · 导航子集（仅 12 字，3.5KB，自托管） */
@font-face {
  font-family: "LXGW WenKai Nav";
  src: url("/assets/fonts/wenkai-nav.woff2?v=3") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  font-size: 17px;
  line-height: 1.95;
  -webkit-font-smoothing: antialiased;
}
/* 宣纸颗粒：与首页同一张纸 */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .40 0 0 0 0 .33 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] body::after { opacity: .26; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* 顶部导航：与首页同款 sticky 毛玻璃条 */
.nav {
  position: sticky; top: 0; z-index: 50;
  margin: 0;
  min-height: 60px;
  padding: 0 max(1.5rem, calc((100% - 64rem) / 2));
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.nav .brand { font-family: "LXGW WenKai Nav", "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif; font-size: 1.05rem; letter-spacing: .12em; }
.nav .brand .seal {
  display: inline-block; width: 1.5em; height: 1.5em; line-height: 1.5em;
  text-align: center; color: #fdf1ea;
  /* 印泥不匀：盖在宣纸上的朱砂印 */
  background:
    radial-gradient(38% 34% at 30% 26%, rgba(255, 244, 238, .22), transparent 70%),
    radial-gradient(46% 42% at 74% 80%, rgba(118, 28, 18, .34), transparent 72%),
    var(--accent);
  border-radius: 5px 3px 6px 3px / 3px 6px 3px 5px;   /* 手工凿刻的不规则边 */
  transform: rotate(-3deg);
  box-shadow:
    inset 0 0 0 1px rgba(250, 246, 238, .42),
    inset 0 0 3px 1px rgba(118, 28, 18, .42),
    0 1px 4px rgba(151, 65, 46, .26);
  font-size: .8em; margin-right: .6em; vertical-align: .02em;
  transition: transform .45s cubic-bezier(.34, 1.4, .64, 1);
}
.nav .brand:hover .seal { transform: rotate(0deg) scale(1.05); }
.nav .links { display: flex; gap: 1.4rem; font-size: .92rem; color: var(--ink-soft); flex-wrap: wrap; }
.nav .links a {
  font-family: "LXGW WenKai Nav", "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  /* hover 墨迹：一笔从左向右渗开的淡墨下划线，末端洇散 */
  background: linear-gradient(90deg, currentColor 0%, currentColor 72%, transparent 100%) no-repeat left bottom / 0 1px;
  transition: color .2s ease, background-size .45s cubic-bezier(.16, 1, .3, 1);
}
.nav .links a:hover { background-size: 100% 1px; }

/* 文章主体 */
.article { max-width: var(--maxw); margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }
/* 界栏：古籍版框的两道细边，宽屏才有 */
@media (min-width: 900px) {
  .article {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding-left: 2.4rem;
    padding-right: 2.4rem;
  }
}
.eyebrow {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .72rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--muted);
}
.eyebrow .cat { color: var(--accent); }
h1 {
  font-size: clamp(1.7rem, 4.5vw, 2.4rem);
  line-height: 1.45; font-weight: 600;
  margin: .9rem 0 1rem;
}
.lede { color: var(--ink-soft); font-size: 1.02rem; margin: 0 0 2rem; }
.meta-row {
  display: flex; gap: 1.2rem; flex-wrap: wrap;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .78rem; color: var(--muted);
  padding: 1rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin-bottom: 2.4rem;
}
.article img.cover { width: 100%; border-radius: var(--radius-m); margin: 0 0 2.4rem; display: block; }

h2 { font-size: 1.28rem; font-weight: 600; margin: 2.8rem 0 .9rem; }
h3 { font-size: 1.05rem; font-weight: 600; margin: 2rem 0 .6rem; }
p { margin: 0 0 1.4rem; }
ul, ol { padding-left: 1.4em; margin: 0 0 1.4rem; }
li { margin-bottom: .45rem; }
blockquote {
  margin: 2rem 0; padding: .2rem 0 .2rem 1.2rem;
  border-left: 2px solid var(--line-ink);
  color: var(--ink-soft);
  font-family: var(--font-kai);
  font-size: 1.02rem;
}
hr { border: 0; border-top: 1px solid var(--line); margin: 3rem 0; }

/* 表格 · 细线文人风：无底色无斑马，表头下唯一一条朱砂细线 */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 0 0 1.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}
.table-title {
  font-size: .8rem; color: var(--muted); letter-spacing: .14em;
  margin: 2.6rem 0 .9rem; padding-left: .7rem;
  border-left: 2px solid var(--line-ink);
}
table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem; line-height: 1.8;
}
caption { caption-side: top; text-align: left; color: var(--ink-faint); font-size: .82rem; padding: 0 0 .6rem; }
th, td {
  padding: .74rem 1.05rem; vertical-align: top; text-align: left;
  border-bottom: 1px solid var(--line);            /* 仅保留淡淡的行间线 */
}
thead th {
  font-weight: 600; color: var(--ink); letter-spacing: .1em;
  white-space: nowrap;
  border-bottom: 1.5px solid var(--cinnabar);      /* 整张表唯一的朱砂 */
}
tbody th {                                         /* 栏目列：墨字 + 唯一竖分隔 */
  font-weight: 600; color: var(--ink-2);
  white-space: nowrap;
  border-right: 1px solid var(--line);
}
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }

/* 代码 */
code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .84em; background: var(--paper-deep); padding: .15em .45em; border-radius: 4px;
}
pre {
  background: var(--paper-deep); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 1.1rem 1.3rem; overflow-x: auto;
  font-size: .82rem; line-height: 1.7; margin: 0 0 1.6rem;
}
pre code { background: none; padding: 0; font-size: inherit; }

/* 文末导航与页脚 */
.post-nav {
  max-width: var(--maxw); margin: 0 auto; padding: 0 1.5rem 3rem;
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: .88rem; color: var(--ink-soft);
}
footer {
  border-top: 1px solid var(--line);
  max-width: 64rem; margin: 0 auto; padding: 2rem 1.5rem 3rem;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
  font-size: .82rem; color: var(--ink-faint);
}
footer .links { display: flex; gap: 1.2rem; }

/* 折叠的引用文献 */
.refs { margin: 2.6rem 0 0; border-top: 1px solid var(--line); padding-top: 1.3rem; }
.refs > summary {
  cursor: pointer; list-style: none;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: .82rem; letter-spacing: .12em; color: var(--accent);
}
.refs > summary::-webkit-details-marker { display: none; }
.refs > summary::before { content: "▸ "; }
.refs[open] > summary::before { content: "▾ "; }
.refs ol { margin: 1.1rem 0 0; padding-left: 1.7em; }
.refs li { font-size: .8rem; line-height: 1.7; color: var(--muted); margin-bottom: .5rem; }
.refs a { color: var(--ink-soft); border-bottom: 1px solid var(--line); }
.refs a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- 排印装饰（纯 CSS，无配图）---------- */

/* 开篇首字下沉：朱砂大字，像手抄本起首 */
.article h2:first-of-type + p::first-letter {
  float: left;
  margin: .04em .14em -.04em 0;
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  font-size: 3.05em;
  font-weight: 600;
  line-height: .82;
  color: var(--accent);
}

/* 第二节起，留出更明显的换气，让每节像翻过一页 */
.article h2:not(:first-of-type) {
  margin-top: 3.4rem;
}
/* 鱼尾：古籍版心的分节记号，居中一枚，墨色不抢戏 */
.article h2:not(:first-of-type)::before {
  content: "";
  display: block;
  width: 2.6rem;
  height: .72rem;
  margin: 0 auto 2.6rem;
  background: var(--muted);
  opacity: .7;
  clip-path: polygon(0 0, 100% 0, 100% 32%, 50% 100%, 0 32%);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* 页脚访客计数 */
.visit-stat { color: var(--ink-faint); font-size: .8rem; letter-spacing: .03em; }

/* ===== 文末落款 · 干支纪年 + 小印（post-extras.js 注入） ===== */
.colophon {
  margin: 3.2rem 0 0;
  display: flex; align-items: center; justify-content: flex-end; gap: .7rem;
  font-family: "LXGW WenKai Nav", var(--font-kai);
  font-size: .95rem; letter-spacing: .12em;
  color: var(--muted);
}
.colophon-seal {
  display: inline-grid; place-items: center;
  width: 1.7em; height: 1.7em;
  color: #fdf1ea; font-size: .82em;
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  font-weight: 600; line-height: 1;
  background:
    radial-gradient(38% 34% at 30% 26%, rgba(255, 244, 238, .22), transparent 70%),
    radial-gradient(46% 42% at 74% 80%, rgba(118, 28, 18, .34), transparent 72%),
    var(--cinnabar);
  border-radius: 5px 3px 6px 3px / 3px 6px 3px 5px;   /* 手工凿刻的不规则边 */
  transform: rotate(-2.5deg);
  box-shadow:
    inset 0 0 0 1px rgba(250, 246, 238, .42),
    inset 0 0 3px 1px rgba(118, 28, 18, .42),
    0 1px 4px rgba(151, 65, 46, .26);
}


/* ===== 阅读进度条（post-extras.js 注入） ===== */
.read-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent); transform-origin: 0 50%;
  transform: scaleX(0); z-index: 60; pointer-events: none;
  opacity: .85;
}

/* ===== 返回顶部 · 小印章（post-extras.js 注入） ===== */
.to-top {
  position: fixed; right: 1.4rem; bottom: 1.6rem; z-index: 50;
  width: 2.6rem; height: 2.6rem; padding: 0;
  display: grid; place-items: center;
  font-family: inherit; font-size: 1rem; line-height: 1;
  color: var(--accent); background: var(--bg);
  border: 1px solid var(--accent); border-radius: var(--radius-s);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .3s ease, visibility .3s ease, transform .3s ease,
              color .25s ease, background-color .25s ease;
  box-shadow: 0 2px 10px rgba(39, 35, 32, .08);
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { color: #fff; background: var(--accent); }
:root[data-theme="dark"] .to-top { box-shadow: 0 2px 10px rgba(0, 0, 0, .35); }

/* ===== 浮动目录（桌面端，post-extras.js 注入） ===== */
.toc { display: none; }
@media (min-width: 1200px) {
  .toc {
    display: block;
    position: fixed; top: 7.5rem;
    left: max(1.5rem, calc(50vw - 21rem - 15.5rem));
    width: 13rem;
    max-height: calc(100vh - 11rem);
    overflow-y: auto;
    font-size: .8rem; line-height: 1.6;
    scrollbar-width: none;
  }
  .toc::-webkit-scrollbar { display: none; }
  .toc-label {
    display: block; margin: 0 0 .7rem;
    font-size: .68rem; letter-spacing: .35em;
    color: var(--ink-faint);
  }
  .toc ol { list-style: none; margin: 0; padding: 0; }
  .toc li { margin: 0; padding: 0; }
  .toc a {
    display: block; padding: .32rem 0 .32rem .85rem;
    color: var(--ink-faint);
    border-left: 1px solid var(--line);
    transition: color .2s ease, border-color .2s ease;
  }
  .toc a:hover { color: var(--ink); }
  .toc a.is-active { color: var(--accent); border-left-color: var(--accent); }
}

/* ---------- editorial graph preview · article pages ---------- */
:root {
  --paper: #f5f0e7;
  --paper-deep: #ece6db;
  --ink: #34383b;
  --ink-2: #50565a;
  --muted: #73787a;
  --faint: #969895;
  --line: #ddd6cb;
  --line-ink: #c8c1b7;
  --cinnabar: #7786a6;
  --cinnabar-deep: #637290;
  --header-bg: rgba(245,240,231,.9);
  --graph-teal: #6f968c;
  --font-mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", ui-monospace, monospace;
}
:root[data-theme="dark"] {
  --paper: #1c2021;
  --paper-deep: #15191a;
  --ink: #eceae4;
  --ink-2: #c6c8c5;
  --muted: #a3a6a2;
  --faint: #777c7b;
  --line: #343a3b;
  --line-ink: #4a5152;
  --cinnabar: #9ba8c4;
  --cinnabar-deep: #b1bdd6;
  --header-bg: rgba(28,32,33,.9);
  --graph-teal: #86aa9f;
}
body {
  background-color: var(--paper);
  background-image:
    linear-gradient(color-mix(in srgb, var(--ink) 3.8%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 3.8%, transparent) 1px, transparent 1px);
  background-size: 32px 32px;
}
body::after { opacity: .045; }
.nav { border-bottom-color: var(--line-ink); backdrop-filter: blur(14px) saturate(120%); }
.nav .brand .seal {
  background: var(--cinnabar);
  border-radius: 7px 4px 7px 4px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.4), 0 4px 14px rgba(70,79,104,.14);
}
.nav .links a, .eyebrow, .meta-row, .toc-label, .table-title { font-family: var(--font-mono); }
.article {
  background: color-mix(in srgb, var(--paper) 92%, transparent);
}
.eyebrow .cat { color: var(--graph-teal); }
.meta-row { border-color: var(--line-ink); }
h2 { position: relative; }
h2::before {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 2px;
  margin: 0 .7rem .35rem 0;
  background: linear-gradient(90deg, var(--cinnabar) 0 68%, var(--graph-teal) 68%);
}
blockquote { border-left-color: var(--cinnabar); }
.table-wrap { border-color: var(--line-ink); background: color-mix(in srgb, var(--paper) 86%, transparent); }
thead th { border-bottom-color: var(--cinnabar); }
.read-progress { background: linear-gradient(90deg, var(--cinnabar), var(--graph-teal)); }
.to-top { border-radius: 8px; }
.toc a.is-active { color: var(--cinnabar); border-left-color: var(--graph-teal); }
.colophon-seal { background: var(--cinnabar); }
@media (max-width: 640px) {
  .nav { padding-left: 1rem; padding-right: 1rem; }
  .nav .links { gap: .7rem; font-size: .78rem; }
  .article { padding-left: 1.1rem; padding-right: 1.1rem; }
  h2::before { width: 1rem; margin-right: .45rem; }
}
