/* ============================================================
   基因组科学概论 · 学术风格设计系统 v2
   Based on Gibson & Muse, A Primer of Genome Science, 3rd ed.
   学术期刊排版：衬线正文、细线分隔、克制用色、编号图表公式
   ============================================================ */

:root {
  --ink: #1d232b;
  --ink-soft: #4a5462;
  --paper: #ffffff;
  --paper-warm: #fbfaf7;
  --hairline: #d9d6cd;
  --hairline-soft: #e8e5dc;

  --ch1: #2e5f66;  /* 第1章 石青 */
  --ch2: #35507e;  /* 第2章 靛蓝 */
  --ch3: #6b4d8f;  /* 第3章 紫檀 */
  --ch4: #3d6b4a;  /* 第4章 苔绿 */
  --ch5: #9c5230;  /* 第5章 赭石 */
  --ch6: #8f3d5c;  /* 第6章 绛红 */

  --accent: var(--ch1);
  --accent-soft: rgba(46, 95, 102, 0.06);
  --accent-line: rgba(46, 95, 102, 0.30);

  --serif: "Source Han Serif SC", "Noto Serif SC", "Songti SC", SimSun, Georgia, "Times New Roman", serif;
  --sans: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, "JetBrains Mono", Menlo, monospace;

  --maxw: 860px;
}

body.ch1 { --accent: var(--ch1); --accent-soft: rgba(46,95,102,.06);  --accent-line: rgba(46,95,102,.30); }
body.ch2 { --accent: var(--ch2); --accent-soft: rgba(53,80,126,.06); --accent-line: rgba(53,80,126,.30); }
body.ch3 { --accent: var(--ch3); --accent-soft: rgba(107,77,143,.06);--accent-line: rgba(107,77,143,.30); }
body.ch4 { --accent: var(--ch4); --accent-soft: rgba(61,107,74,.06); --accent-line: rgba(61,107,74,.30); }
body.ch5 { --accent: var(--ch5); --accent-soft: rgba(156,82,48,.06); --accent-line: rgba(156,82,48,.30); }
body.ch6 { --accent: var(--ch6); --accent-soft: rgba(143,61,92,.06); --accent-line: rgba(143,61,92,.30); }

/* ---------------- 基础 ---------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.95;
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
::selection { background: var(--accent-soft); color: var(--ink); }

strong, b { font-weight: 700; }

/* ---------------- 顶部题头 ---------------- */
.progress-bar {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: var(--accent); z-index: 60; transition: width .12s linear;
}
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--hairline);
}
.site-header .bar {
  display: flex; align-items: baseline; gap: 20px;
  max-width: 1140px; margin: 0 auto; padding: 12px 24px 10px;
}
.brand {
  font-family: var(--serif); font-weight: 700; font-size: 16.5px;
  color: var(--ink); white-space: nowrap; letter-spacing: .02em;
}
.brand small {
  display: block; font-weight: 400; font-size: 10.5px; color: var(--ink-soft);
  letter-spacing: .14em; line-height: 1.3;
}
.site-header nav { margin-left: auto; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.site-header nav::-webkit-scrollbar { display: none; }
.site-header nav a {
  font-family: var(--sans); font-size: 13.5px; color: var(--ink-soft);
  padding: 4px 10px; white-space: nowrap; border-bottom: 2px solid transparent;
}
.site-header nav a:hover { color: var(--accent); text-decoration: none; }
.site-header nav a[aria-current] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }

/* ---------------- 面包屑 ---------------- */
.crumbs {
  max-width: 1140px; margin: 0 auto; padding: 14px 24px 0;
  font-family: var(--sans); font-size: 12.5px; color: var(--ink-soft); letter-spacing: .02em;
}
.crumbs a { color: var(--ink-soft); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 7px; color: var(--hairline); }
.crumbs .cur { color: var(--ink); }

/* ---------------- 节页题区 ---------------- */
/* 题区容器与 .layout 同宽同内边距（1140/24），保证标题、摘要与正文列左对齐；
   内容再 capped 到正文列宽。曾经题区 980 vs 正文区 1140 两套居中宽度，题头整体右移 80px。 */
.page-head {
  max-width: 1140px; margin: 0 auto; padding: 30px 24px 0;
}
.page-head > *, .chapter-head > *, .front-head > * { max-width: var(--maxw); }
.page-head .eyebrow {
  font-family: var(--sans); font-size: 12.5px; letter-spacing: .22em;
  color: var(--accent); font-weight: 600; margin-bottom: 10px;
}
.page-head h1 {
  font-family: var(--serif); font-size: 31px; line-height: 1.4; margin: 0 0 4px;
  padding-bottom: 14px; border-bottom: 3px double var(--ink);
}
.page-head h1 .secno { color: var(--accent); margin-right: 14px; }
.page-head .en {
  font-style: italic; font-size: 15px; color: var(--ink-soft); margin: 10px 0 0;
}
.page-head .abstract {
  margin: 18px 0 0; padding: 14px 18px; background: var(--paper-warm);
  border-left: 3px solid var(--accent-line); font-size: 15px; color: var(--ink-soft); line-height: 1.9;
}
.page-head .abstract b { color: var(--ink); }

/* 章级页题区复用 */
.chapter-head { max-width: 1140px; margin: 0 auto; padding: 40px 24px 0; }
.chapter-head h1 { font-size: 34px; }

/* ---------------- 主体布局 ---------------- */
.layout {
  max-width: 1140px; margin: 0 auto; padding: 26px 24px 20px;
  display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 48px;
}
.layout > .main { min-width: 0; }
@media (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; }
  .toc-side { display: none; }
}

.prose { max-width: var(--maxw); }
.prose > * { max-width: var(--maxw); }
.prose h3 {
  font-family: var(--serif); font-size: 21.5px; margin: 44px 0 6px; font-weight: 700;
}
.prose h3 .subno { color: var(--accent); margin-right: 10px; font-size: .88em; }
.prose h4 { font-family: var(--serif); font-size: 17.5px; margin: 28px 0 4px; color: var(--ink); }
.prose p { margin: 13px 0; text-align: justify; }
.prose ul, .prose ol { padding-left: 1.9em; margin: 11px 0; }
.prose li { margin: 5px 0; }
.prose code { font-family: var(--mono); font-size: .86em; background: var(--paper-warm); border: 1px solid var(--hairline-soft); padding: 0 5px; border-radius: 3px; }
.prose hr.foot-rule { border: none; border-top: 1px solid var(--hairline); margin: 40px 0 6px; }

/* 术语 */
.term { color: var(--accent); font-weight: 700; }
.term-en { color: var(--ink-soft); font-size: .8em; font-style: italic; white-space: nowrap; }

/* ---------------- 侧栏 ---------------- */
.toc-side {
  position: sticky; top: 74px; align-self: start;
  max-height: calc(100vh - 96px); overflow-y: auto;
  font-family: var(--sans); font-size: 13px; padding: 4px 4px 24px 16px;
  border-left: 1px solid var(--hairline);
}
.toc-side .toc-title {
  font-size: 11px; letter-spacing: .18em; color: var(--ink-soft); font-weight: 600; margin-bottom: 10px;
}
.toc-side a { display: block; color: var(--ink-soft); padding: 4px 10px; line-height: 1.55; border-radius: 3px; }
.toc-side a:hover { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.toc-side a.active { color: var(--accent); font-weight: 600; border-left: 2px solid var(--accent); margin-left: -2px; }
.toc-side a.cur-page { color: var(--ink); font-weight: 600; }
.toc-side .toc-part { font-size: 11px; letter-spacing: .1em; color: var(--accent); margin: 14px 0 4px; font-weight: 600; }

/* ---------------- 学术框 ---------------- */
.sbox {
  margin: 26px 0; padding: 14px 20px 12px;
  background: var(--paper-warm);
  border: 1px solid var(--hairline-soft);
  border-left: 3px solid var(--accent);
}
.sbox .box-label {
  display: block; font-family: var(--sans); font-size: 11.5px; font-weight: 700;
  letter-spacing: .2em; color: var(--accent); margin-bottom: 8px;
}
.sbox p:first-of-type { margin-top: 0; }
.sbox p:last-child { margin-bottom: 0; }
.sbox ul, .sbox ol { margin: 8px 0; }
.sbox-def   { border-left-color: var(--ch2); }
.sbox-def .box-label { color: var(--ch2); }
.sbox-method{ border-left-color: var(--ch4); }
.sbox-method .box-label { color: var(--ch4); }
.sbox-note  { border-left-color: var(--ink-soft); }
.sbox-note .box-label { color: var(--ink-soft); }
.sbox-case  { border-left-color: var(--ch5); }
.sbox-case .box-label { color: var(--ch5); }
.sbox-warn  { border-left-color: #9c3b34; background: rgba(156,59,52,.04); }
.sbox-warn .box-label { color: #9c3b34; }

/* ---------------- 公式 ---------------- */
.formula {
  margin: 20px 0; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: var(--paper-warm); border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
  font-size: 18px; overflow-x: auto;
}
.formula .eq { font-family: var(--serif); text-align: center; flex: 1; }
.formula .eqno { font-family: var(--sans); font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.formula .note {
  display: block; flex-basis: 100%; font-family: var(--sans); font-size: 12.5px;
  color: var(--ink-soft); margin-top: 8px; text-align: left; line-height: 1.8;
}
.formula:has(.note) { flex-wrap: wrap; }

/* ---------------- 表（booktabs 风格） ---------------- */
.tablewrap { overflow-x: auto; margin: 22px 0; max-width: var(--maxw); }
table.data {
  border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 13.5px; line-height: 1.7;
  border-top: 2px solid var(--ink);
}
table.data caption {
  caption-side: top; text-align: left; font-size: 13px; padding-bottom: 8px;
  color: var(--ink); font-weight: 600; font-family: var(--sans);
}
table.data caption .tabno { color: var(--accent); margin-right: 8px; }
table.data th {
  text-align: left; font-weight: 600; padding: 7px 12px;
  border-bottom: 1px solid var(--ink); white-space: nowrap;
}
table.data td { padding: 7px 12px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
table.data tr:last-child td { border-bottom: 2px solid var(--ink); }
table.data tr:nth-child(even) td { background: rgba(0,0,0,.016); }

/* ---------------- 图 ---------------- */
.figure { margin: 28px 0; max-width: var(--maxw); }
.figure .fig-inner { background: #fff; border: 1px solid var(--hairline); padding: 18px 16px 8px; }
.figure svg { display: block; width: 100%; height: auto; }
.figure figcaption {
  font-family: var(--sans); font-size: 13px; color: var(--ink-soft);
  padding: 10px 4px 6px; line-height: 1.75; text-align: justify;
}
.figure figcaption b { color: var(--ink); }

/* ---------------- 习题 ---------------- */
details.ex {
  max-width: var(--maxw); margin: 14px 0; border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
}
details.ex summary {
  cursor: pointer; padding: 11px 6px; font-family: var(--sans); font-size: 14.5px; font-weight: 600;
  list-style: none; display: flex; gap: 10px; align-items: baseline; color: var(--ink);
}
details.ex summary::-webkit-details-marker { display: none; }
details.ex summary::before { content: "＋"; color: var(--accent); font-weight: 400; }
details.ex[open] summary::before { content: "－"; }
details.ex summary:hover { color: var(--accent); }
details.ex .ex-body { padding: 6px 6px 16px 26px; font-size: 15.5px; }
details.ex .ex-body .sol-label {
  display: block; font-family: var(--sans); font-size: 11.5px; letter-spacing: .18em;
  color: var(--ink-soft); font-weight: 700; margin: 10px 0 4px;
}
details.ex .ex-body .sol { color: var(--ink-soft); }

/* ---------------- 关键术语 & 参考文献 ---------------- */
.keyterms { max-width: var(--maxw); margin: 26px 0; }
.keyterms dl {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 28px; margin: 0;
  font-size: 14.5px;
}
.keyterms dt { font-weight: 700; color: var(--accent); }
.keyterms dt .term-en { font-weight: 400; }
.keyterms dd { margin: 0; color: var(--ink-soft); grid-column: auto; font-size: 13.5px; line-height: 1.7; }
.keyterms .kt-row { display: contents; }
@media (max-width: 640px) { .keyterms dl { grid-template-columns: 1fr; } }

.refs { max-width: var(--maxw); margin: 20px 0 8px; }
.refs h3 { font-size: 17px; margin: 0 0 8px; padding-top: 14px; border-top: 2px solid var(--ink); }
.refs ol { margin: 0; padding-left: 1.7em; font-size: 13.5px; color: var(--ink-soft); line-height: 1.85; }
.refs li { margin: 4px 0; padding-left: 4px; }
.refs li i { font-style: italic; }

/* ---------------- 章级页小节目录 ---------------- */
.section-list { max-width: var(--maxw); margin: 24px 0; border-top: 2px solid var(--ink); }
.section-list .srow {
  display: grid; grid-template-columns: 64px 1fr; gap: 16px;
  padding: 14px 6px; border-bottom: 1px solid var(--hairline); align-items: baseline;
}
.section-list .srow:hover { background: var(--accent-soft); }
.section-list .srow .sno {
  font-family: var(--serif); font-size: 19px; font-weight: 700; color: var(--accent);
}
.section-list .srow .stitle { font-size: 16.5px; font-weight: 700; }
.section-list .srow .sdesc { font-size: 13.5px; color: var(--ink-soft); font-family: var(--sans); line-height: 1.75; margin-top: 3px; }
.section-list .srow a { color: var(--ink); }
.section-list .srow a:hover { color: var(--accent); text-decoration: none; }

/* ---------------- 章末/节末导航 ---------------- */
.prev-next {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 44px 0 10px;
  max-width: var(--maxw); border-top: 2px solid var(--ink);
}
.prev-next a {
  padding: 13px 16px 13px 0; color: var(--ink); font-family: var(--sans);
}
.prev-next a:hover { text-decoration: none; background: var(--accent-soft); }
.prev-next .dir { display: block; font-size: 11px; letter-spacing: .18em; color: var(--ink-soft); margin-bottom: 4px; }
.prev-next .t { font-family: var(--serif); font-size: 15.5px; font-weight: 700; }
.prev-next a.next { text-align: right; border-left: 1px solid var(--hairline); padding: 13px 0 13px 16px; }
@media (max-width: 640px) { .prev-next { grid-template-columns: 1fr; } .prev-next a.next { border-left: none; border-top: 1px solid var(--hairline); text-align: left; } }

/* ---------------- 页脚 ---------------- */
.site-footer {
  border-top: 1px solid var(--hairline); margin-top: 44px; padding: 24px 24px 40px;
  color: var(--ink-soft); font-family: var(--sans); font-size: 12.5px; text-align: center; line-height: 2;
}
.site-footer .fine { font-size: 11.5px; opacity: .85; }

/* ---------------- 杂项 ---------------- */
.btn-top {
  position: fixed; right: 22px; bottom: 26px; z-index: 40;
  width: 40px; height: 40px; border-radius: 3px; border: 1px solid var(--hairline);
  background: #fff; color: var(--accent); font-size: 17px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
}
.btn-top.show { display: flex; }
.btn-top:hover { border-color: var(--accent); }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 22px 0; max-width: var(--maxw); border-top: 2px solid var(--ink); }
.compare .cmp { padding: 12px 18px 12px 0; font-size: 14.5px; }
.compare .cmp + .cmp { border-left: 1px solid var(--hairline); padding: 12px 0 12px 18px; }
.compare .cmp h4 { margin: 0 0 6px; font-family: var(--sans); font-size: 14px; color: var(--accent); }
@media (max-width: 640px) { .compare { grid-template-columns: 1fr; } .compare .cmp + .cmp { border-left: none; border-top: 1px solid var(--hairline); padding: 12px 18px 12px 0; } }

.timeline { list-style: none; padding: 0; margin: 20px 0; max-width: var(--maxw); font-size: 15px; }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 10px; bottom: -2px; width: 1px; background: var(--hairline); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 1px; top: 9px; width: 7px; height: 7px; border-radius: 50%; background: var(--paper); border: 2px solid var(--accent); }
.timeline .t-date { font-family: var(--sans); font-weight: 700; color: var(--accent); font-size: 13.5px; letter-spacing: .04em; }
.timeline .t-body { font-size: 14.5px; color: var(--ink-soft); }

pre.code { background: #1e2630; color: #dce6ef; border-radius: 4px; padding: 15px 18px; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.75; max-width: var(--maxw); }

.hover-pop { transition: transform .15s ease, filter .15s ease; cursor: pointer; }
.hover-pop:hover { transform: scale(1.015); filter: drop-shadow(0 3px 6px rgba(0,0,0,.15)); }

/* 首页结构总览表复用 table.data；首页题区 */
.front-head { max-width: 1140px; margin: 0 auto; padding: 48px 24px 0; }
.front-head h1 { font-family: var(--serif); font-size: 37px; margin: 0 0 6px; padding-bottom: 16px; border-bottom: 3px double var(--ink); }
.front-head .sub { font-style: italic; color: var(--ink-soft); font-size: 16px; }
.front-head .lead { margin: 22px 0 0; font-size: 16px; color: var(--ink-soft); max-width: 720px; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .page-head h1 { font-size: 25px; }
  .front-head h1 { font-size: 28px; }
  .chapter-head h1 { font-size: 27px; }
}
@media print {
  .site-header, .toc-side, .btn-top, .progress-bar, .prev-next { display: none !important; }
  .layout { display: block; }
}
