/* Hallmark · genre: editorial · macrostructure: Narrative Workflow · theme: Almanac(域锁定,不轮换)
 * nav: N10 Floating-on-scroll morph(报头 → 进度条 + 阶段胶囊) · footer: Ft1 Mast-headed(上一课/下一课)
 * enrichment: 手写 SVG + canvas 教学仪器(Tier-B)
 * 说明:本站已用 Long Document+N3+Ft4(精读页)、Index-First+N6+Ft2(索引页),本组合与两者均不同。
 */

/* ═══════════════ N10 · 滚动变形顶栏 ═══════════════ */
.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background: var(--color-paper);
  border-bottom: var(--rule-hair) solid var(--color-rule);
  transition: padding var(--dur-short) var(--ease-out);
}
.nav__inner {
  max-width: 58rem;
  margin-inline: auto;
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-height: 2.75rem;
}
.nav__home {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  color: var(--color-ink);
  text-decoration: none;
  white-space: nowrap;
}
.nav__home:hover { color: var(--color-accent-text); }
.nav__sep {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-rule-soft);
  user-select: none;
}
.nav__where {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-neutral);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.nav__where b { color: var(--color-accent-text); font-weight: 400; }

/* 阶段跳转(details 弹出) */
.nav__jump { position: relative; flex: 0 0 auto; }
.nav__jump summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-muted);
  padding: var(--space-2xs) var(--space-sm);
  border: var(--rule-hair) solid var(--color-rule-soft);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  min-height: 1.9rem;
  display: grid;
  align-items: center;
}
.nav__jump summary::-webkit-details-marker { display: none; }
.nav__jump[open] summary { background: var(--color-paper-2); }
.nav__pop {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-xs));
  min-width: 17rem;
  max-height: 70dvh;
  overflow-y: auto;
  background: var(--color-paper);
  border: var(--rule-hair) solid var(--color-rule-soft);
  padding: var(--space-2xs);
}
.nav__pop a {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-sm);
  color: var(--color-ink);
  text-decoration: none;
  line-height: 1.4;
}
.nav__pop a span:first-child {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-accent-text);
}
.nav__pop a:hover { background: var(--color-paper-2); }
.nav__pop a[aria-current="true"] { background: var(--color-paper-2); }

/* 阅读进度(压在纸上的一道印子,不是浮起来的条) */
.nav__progress {
  height: 2px;
  background: var(--color-paper-3);
}
.nav__progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--color-accent);
  transition: width 90ms linear;
}

/* ═══════════════ 版心 ═══════════════ */
.page { padding: var(--space-2xl) var(--space-lg) var(--space-xl); }
.wrap { max-width: 38.75rem; margin-inline: auto; }

/* 宽出血:相对阅读栏居中撑开 */
.bleed {
  width: min(52rem, calc(100vw - 3rem));
  margin-left: calc((100% - min(52rem, calc(100vw - 3rem))) / 2);
}

/* ═══════════════ 报头 ═══════════════ */
.head { max-width: 38.75rem; margin: 0 auto var(--space-2xl); }
.head__kicker {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  color: var(--color-accent-text);
  margin: 0 0 var(--space-md);
}
.head__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-display);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-md);
}
.head__sub {
  font-size: var(--text-md);
  color: var(--color-muted);
  line-height: 1.55;
  margin: 0 0 var(--space-lg);
}
.head__meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-neutral);
  line-height: 2;
  border-top: var(--rule-hair) solid var(--color-rule);
  border-bottom: var(--rule-hair) solid var(--color-rule);
  padding: var(--space-sm) 0;
  margin: 0;
}
.head__meta a { color: var(--color-accent-text); }

/* ═══════════════ Narrative Workflow · 阶段 ═══════════════ */
.stage {
  position: relative;
  max-width: 38.75rem;
  margin: var(--space-3xl) auto 0;
  scroll-margin-top: 5rem;
}
.stage__rail {
  position: absolute;
  right: 100%;
  margin-right: var(--space-xl);
  top: 0.1rem;
  width: 7rem;
  text-align: right;
  user-select: none;
}
.stage__no {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-2xl);
  line-height: 1;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
}
.stage__tag {
  display: block;
  margin-top: var(--space-xs);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-neutral);
}
.stage > h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xl);
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-lg);
  padding-top: var(--space-sm);
  border-top: 2px solid var(--color-ink);
}
.stage h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-md);
  margin: var(--space-xl) 0 var(--space-sm);
}
.stage h4 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--text-base);
  margin: var(--space-lg) 0 var(--space-xs);
}

/* ═══════════════ 正文元素 ═══════════════ */
p { margin: 0 0 1.875rem; }
.page a { color: var(--color-accent-text); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.page a:hover { text-decoration-thickness: 2px; }
strong { font-weight: 600; }
mark { background: var(--color-accent-soft); color: inherit; padding: 0 0.15em; }
ul.plain, ol.plain { margin: 0 0 1.875rem; padding-left: 1.35rem; }
ul.plain li, ol.plain li { margin-bottom: var(--space-xs); }
ol.plain li::marker { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-accent-text); }

/* 定位卡:这条知识要学到什么程度 */
.level {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
  padding: 0.05rem 0.45rem;
  border: var(--rule-hair) solid var(--color-rule-soft);
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  white-space: nowrap;
}
.level--must { background: var(--color-accent-soft); border-color: var(--color-accent); color: var(--color-accent-text); }
.level--idea { background: var(--color-paper-2); }
.level--fyi  { color: var(--color-neutral); }

/* 旁注带 */
.aside {
  background: var(--color-paper-2);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-lg) 0;
}
.aside > .aside__tag {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  color: var(--color-accent-text);
  margin-bottom: var(--space-xs);
}
.aside p:last-child { margin-bottom: 0; }
.aside--warn { background: var(--color-paper-3); }
.aside--warn > .aside__tag { color: var(--color-ink); }

/* 公式 */
.eq { margin: var(--space-lg) 0; overflow-x: auto; overflow-y: clip; padding: var(--space-2xs) 0; }
.katex { font-size: 1.06em; }

/* 代码 */
pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  background: var(--color-paper-2);
  padding: var(--space-md) var(--space-lg);
  overflow-x: auto;
  margin: var(--space-lg) 0;
  border-top: 2px solid var(--color-ink);
  border-bottom: var(--rule-hair) solid var(--color-rule);
}
pre .c { color: var(--color-neutral); }
pre .k { color: var(--color-accent-text); }
code { font-family: var(--font-mono); font-size: 0.92em; background: var(--color-paper-2); padding: 0.1em 0.3em; }
pre code { background: none; padding: 0; font-size: 1em; }

/* 表格 */
.tbl { overflow-x: auto; margin: var(--space-lg) 0; }
.tbl--wide {
  width: min(52rem, calc(100vw - 3rem));
  margin-left: calc((100% - min(52rem, calc(100vw - 3rem))) / 2);
}
@media (max-width: 66rem) {
  .tbl--wide { width: 100%; margin-left: 0; }
}
table { border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; min-width: 100%; }
caption { text-align: left; font-size: var(--text-sm); color: var(--color-neutral); padding-bottom: var(--space-xs); }
th, td {
  text-align: left;
  padding: var(--space-xs) var(--space-md) var(--space-xs) 0;
  border-bottom: var(--rule-hair) solid var(--color-rule-soft);
  vertical-align: top;
  /* 默认让散文换行 —— 全局 nowrap 会把最后一列挤出可视区 */
  white-space: normal;
  line-height: 1.6;
}
/* 只有这两类不该断：数字，和「整格就是一个代码标识符」的键 */
td.num, th.num { white-space: nowrap; }
td > code:only-child { white-space: nowrap; }
/* 散文列给个下限宽度，免得被挤成一条 */
tbody td:last-child { min-width: 11rem; }
thead th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--color-neutral);
  border-bottom: 2px solid var(--color-ink);
}
td.num, th.num { text-align: right; }
td.hi { color: var(--color-accent-text); font-weight: 600; }
tr.rowhi td { background: var(--color-accent-soft); }

/* 图 */
figure { margin: var(--space-xl) 0; }
figure svg, figure img { display: block; max-width: 100%; height: auto; }
figcaption {
  font-size: var(--text-sm);
  color: var(--color-neutral);
  margin-top: var(--space-sm);
  line-height: 1.6;
}
figcaption .fno {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-accent-text);
  margin-right: 0.5em;
}

/* 交互仪器 */
.lab {
  border: var(--rule-hair) solid var(--color-rule-soft);
  background: var(--color-paper);
  padding: var(--space-lg);
  margin: var(--space-xl) 0;
}
.lab__title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  color: var(--color-accent-text);
  margin: 0 0 var(--space-xs);
}
.lab__lead { font-size: var(--text-sm); color: var(--color-muted); margin: 0 0 var(--space-md); }
.lab__ctl { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-xs) var(--space-md); align-items: center; }
.lab__ctl label { font-size: var(--text-sm); color: var(--color-muted); white-space: nowrap; }
.lab__ctl input[type="range"] { accent-color: var(--color-accent-text); min-height: 1.6rem; width: 100%; }
.lab__ctl output {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--color-ink);
  white-space: nowrap;
  min-width: 4.5rem;
  text-align: right;
}
.lab__row { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: center; margin-top: var(--space-md); }
.lab__btn {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-muted);
  background: var(--color-paper-2);
  border: var(--rule-hair) solid var(--color-rule-soft);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  min-height: 1.9rem;
}
.lab__btn:hover { background: var(--color-paper-3); color: var(--color-ink); }
.lab__btn[aria-pressed="true"] { background: var(--color-accent-soft); border-color: var(--color-accent); color: var(--color-accent-text); }
.lab__out {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-neutral);
  line-height: 1.9;
  margin-top: var(--space-md);
  border-top: var(--rule-hair) solid var(--color-rule-soft);
  padding-top: var(--space-sm);
}
.lab__out b { color: var(--color-ink); font-weight: 400; }
.lab__out .good { color: var(--color-accent-text); }
.lab svg, .lab canvas { display: block; max-width: 100%; height: auto; margin-top: var(--space-md); }
.lab__note { font-size: var(--text-sm); color: var(--color-neutral); margin: var(--space-md) 0 0; }
.lab__grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: var(--space-lg); }


/* —— 第三课：可选列表 + 详情面板 —— */
.lab__grid2 > div { min-width: 0; }
.lab__detail {
  background: var(--color-paper-2);
  padding: var(--space-md) var(--space-lg);
  align-self: start;
  position: sticky;
  top: 5rem;
}
.lab__detail .d-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-md);
  line-height: 1.35;
  margin: 0 0 var(--space-sm);
}
.lab__detail .d-title--code {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: var(--text-base);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.lab__detail .d-lines {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-neutral);
  font-weight: 400;
  margin-left: 0.5em;
}
.lab__detail .d-body {
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--color-ink);
  margin: 0 0 var(--space-md);
}
.lab__detail .d-meta {
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--color-muted);
  margin: 0 0 var(--space-sm);
}
.lab__detail .d-meta:last-child { margin-bottom: 0; }
.lab__detail .d-meta b {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--color-accent-text);
}
.lab__detail code { background: var(--color-paper-3); }

/* 左侧可选项 */
#mapTree, #stackList, #wantList {
  max-height: 26rem;
  overflow-y: auto;
  overflow-x: hidden;
  border-top: var(--rule-hair) solid var(--color-rule-soft);
  scrollbar-width: thin;
}
.pick {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-bottom: var(--rule-hair) solid var(--color-rule-soft);
  padding: 0.42rem var(--space-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--color-muted);
  cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out);
  white-space: normal;
  overflow-wrap: anywhere;
}
.pick:hover { background: var(--color-paper-2); color: var(--color-ink); }
.pick[aria-current="true"] {
  background: var(--color-paper-3);
  color: var(--color-ink);
  box-shadow: inset 2px 0 0 var(--color-accent);
}
.pick--hot { color: var(--color-accent-text); }
.pick b { font-weight: 400; color: var(--color-ink); letter-spacing: 0.04em; }
.pick i { font-style: normal; color: var(--color-neutral); font-size: 0.92em; margin-left: 0.4em; }
.pick--d1 { padding-left: 1.5rem; }
.pick--d2 { padding-left: 2.6rem; }
.pick--d3 { padding-left: 3.7rem; }

@media (max-width: 48rem) {
  .lab__detail { position: static; }
  #mapTree, #stackList, #wantList { max-height: 18rem; }
}

/* 折叠推导 */
details.derive {
  margin: var(--space-lg) 0;
  border-top: var(--rule-hair) solid var(--color-rule);
  border-bottom: var(--rule-hair) solid var(--color-rule);
}
details.derive > summary {
  cursor: pointer;
  padding: var(--space-sm) 0;
  font-size: var(--text-sm);
  color: var(--color-muted);
  list-style: none;
}
details.derive > summary::-webkit-details-marker { display: none; }
details.derive > summary::before {
  content: "+";
  font-family: var(--font-mono);
  color: var(--color-accent-text);
  margin-right: 0.6em;
}
details.derive[open] > summary::before { content: "−"; }
details.derive .derive__body { padding: 0 0 var(--space-md) 1.4rem; }
details.derive .derive__body > p:last-child { margin-bottom: 0; }

/* 术语表 */
dl.gloss { margin: var(--space-lg) 0 0; }
dl.gloss dt { font-weight: 600; margin-top: var(--space-md); }
dl.gloss dt em { font-family: var(--font-mono); font-style: normal; font-weight: 400; color: var(--color-neutral); font-size: var(--text-sm); margin-left: 0.5em; }
dl.gloss dd { margin: var(--space-2xs) 0 0; font-size: var(--text-sm); color: var(--color-muted); }

/* 自查清单 */
ul.check { list-style: none; margin: var(--space-lg) 0; padding: 0; }
ul.check li {
  position: relative;
  padding: 0 0 var(--space-sm) 1.8rem;
  font-size: var(--text-base);
}
ul.check li::before {
  content: "□";
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font-mono);
  color: var(--color-accent-text);
}

/* 花饰 */
.fleuron { text-align: center; color: var(--color-neutral); font-size: var(--text-md); margin: var(--space-3xl) 0 calc(-1 * var(--space-lg)); user-select: none; }

/* ═══════════════ Ft1 · 报头式页脚 ═══════════════ */
.foot {
  margin-top: var(--space-3xl);
  border-top: 2px solid var(--color-ink);
}
.foot__inner { max-width: 38.75rem; margin-inline: auto; padding: var(--space-xl) 0 var(--space-2xl); }
.foot__mark { font-family: var(--font-display); font-weight: 600; font-size: var(--text-xl); margin: 0 0 var(--space-2xs); }
.foot__tag { font-size: var(--text-sm); color: var(--color-muted); margin: 0 0 var(--space-lg); }
.foot__nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--space-md); margin-bottom: var(--space-lg); }
.foot__nav a {
  display: block;
  background: var(--color-paper-2);
  padding: var(--space-sm) var(--space-md);
  text-decoration: none;
  color: var(--color-ink);
}
.foot__nav a:hover { background: var(--color-paper-3); }
.foot__nav span {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-accent-text);
  margin-bottom: var(--space-3xs);
}
.foot__nav.is-empty a { opacity: 0.55; pointer-events: none; }
.foot__meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 2;
  color: var(--color-neutral);
  border-top: var(--rule-hair) solid var(--color-rule-soft);
  padding-top: var(--space-md);
  margin: 0;
}

/* ═══════════════ 课程索引页专用 ═══════════════ */
.map { max-width: 38.75rem; margin: 0 auto; }
.map__lead { font-size: var(--text-md); color: var(--color-muted); line-height: 1.6; margin-bottom: var(--space-2xl); }
.lesson {
  position: relative;
  display: grid;
  grid-template-columns: 3.2rem 1fr;
  gap: var(--space-lg);
  padding: var(--space-lg) 0;
  border-top: var(--rule-hair) solid var(--color-rule-soft);
  text-decoration: none;
  color: inherit;
}
.lesson:last-of-type { border-bottom: var(--rule-hair) solid var(--color-rule-soft); }
a.lesson:hover .lesson__title { color: var(--color-accent-text); }
.lesson__no {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xl);
  line-height: 1.1;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
}
.lesson--todo .lesson__no { color: var(--color-rule-soft); }
.lesson__title { display: block; font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); line-height: 1.4; margin: 0 0 var(--space-xs); }
.lesson__desc { display: block; font-size: var(--text-sm); color: var(--color-muted); line-height: 1.7; margin: 0 0 var(--space-sm); }
.lesson__meta { display: block; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-neutral); margin: 0; }
.lesson__no { display: block; }
.lesson--todo .lesson__title { color: var(--color-muted); }

/* ═══════════════ 响应式 ═══════════════ */
@media (max-width: 66rem) {
  .stage__rail {
    position: static;
    width: auto;
    text-align: left;
    margin: 0 0 var(--space-sm);
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
  }
  .stage__no { font-size: var(--text-lg); }
  .stage__tag { margin-top: 0; }
}
/* 手机上宁可让长标识符断行，也别让整张表横着滑 */
@media (max-width: 40rem) {
  td > code:only-child { white-space: normal; overflow-wrap: anywhere; }
  tbody td:last-child { min-width: 0; }
  table { font-size: var(--text-xs); }
}
@media (max-width: 48rem) {
  .page { padding: var(--space-xl) var(--space-md); }
  .nav__inner { padding: var(--space-sm) var(--space-md); }
  .nav__where { display: none; }
  .head__title { font-size: clamp(1.7rem, 7vw, 2.25rem); }
  .stage > h2 { font-size: var(--text-lg); }
  .bleed { width: 100%; margin-left: 0; }
  .lab { padding: var(--space-md); }
  .lab__ctl { grid-template-columns: auto 1fr; }
  .lab__ctl output { grid-column: 2; text-align: left; }
}
