/* site.css — TopicLLM design system.
 * An exhibition-catalogue register for a measurement instrument: warm paper
 * and ink, a single ember-gold accent, serif display type, monospaced labels.
 * Light and dark are each selected (not inverted); every text color clears
 * WCAG AA on its surface. Chart roles follow a validated categorical palette. */

:root {
  color-scheme: light;
  --paper: #f6f2e9;
  --surface: #fbf9f4;
  --surface-2: #f0ebdf;
  --ink: #1c1a16;
  --ink-2: #4d473d;
  --muted: #6e675a;
  --rule: #d9cfbd;
  --rule-strong: #b9ad97;
  --accent: #7a5a0f;          /* link / emphasis text (5.7:1 on paper) */
  --ornament: #c9a227;        /* ember gold: rules, marks, never body text */
  --accent-wash: rgba(201, 162, 39, 0.12);
  --code-bg: #1a1814;
  --code-ink: #ece5d6;
  --series-1: #2a78d6;        /* pre-pandemic  */
  --series-2: #eb6834;        /* peri-pandemic */
  --series-3: #1baf7a;        /* post-pandemic */
  --grid: #e4dccd;
  --shadow: 0 1px 0 rgba(28, 26, 22, 0.04), 0 18px 40px -28px rgba(28, 26, 22, 0.35);
  --serif-display: "Cormorant Garamond", "Cormorant", Garamond, "Times New Roman", serif;
  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --measure: 68ch;
  --wide: 1140px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --paper: #0d0c0a;
    --surface: #16140f;
    --surface-2: #1d1a14;
    --ink: #ece5d6;
    --ink-2: #bdb3a1;
    --muted: #8f8676;
    --rule: #2f2a22;
    --rule-strong: #4a4235;
    --accent: #d4b048;
    --ornament: #c9a227;
    --accent-wash: rgba(201, 162, 39, 0.10);
    --code-bg: #0a0907;
    --code-ink: #ece5d6;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --grid: #26221b;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 18px 40px -28px rgba(0, 0, 0, 0.8);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0d0c0a;
  --surface: #16140f;
  --surface-2: #1d1a14;
  --ink: #ece5d6;
  --ink-2: #bdb3a1;
  --muted: #8f8676;
  --rule: #2f2a22;
  --rule-strong: #4a4235;
  --accent: #d4b048;
  --ornament: #c9a227;
  --accent-wash: rgba(201, 162, 39, 0.10);
  --code-bg: #0a0907;
  --code-ink: #ece5d6;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #26221b;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 18px 40px -28px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.62;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--accent-wash); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ornament); outline-offset: 3px; border-radius: 2px; }
img, svg { max-width: 100%; }
.wrap { max-width: var(--wide); margin: 0 auto; padding: 0 28px; }
@media (max-width: 640px) { .wrap { padding: 0 16px; } body { font-size: 17px; } }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ----------------------------------------------------------------- labels */
.label, .eyebrow {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.eyebrow { color: var(--accent); }
.numeral { font-family: var(--serif-display); font-weight: 600; color: var(--ornament); }

/* ------------------------------------------------------------------- bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.topbar .wrap { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand svg { width: 28px; height: 28px; flex: none; color: var(--ornament); }
.brand b { font-family: var(--serif-display); font-size: 25px; font-weight: 700; letter-spacing: 0.01em; }
.topnav { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  font-family: var(--sans); font-size: 14px; color: var(--ink-2); text-decoration: none;
  padding: 8px 11px; border-radius: 6px; white-space: nowrap;
}
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--ink); background: var(--accent-wash); }
.theme-toggle {
  flex: none; appearance: none; border: 1px solid var(--rule); background: var(--surface);
  color: var(--ink-2); width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center;
}
.theme-toggle svg { width: 17px; height: 17px; }
@media (max-width: 760px) { .topnav a { padding: 8px 7px; font-size: 13px; } .brand b { font-size: 22px; } }
@media (max-width: 520px) { .topnav { display: none; } .topbar .wrap { justify-content: space-between; } }

/* ------------------------------------------------------------------- hero */
.hero { padding: 76px 0 40px; border-bottom: 1px solid var(--rule); position: relative; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 56px; align-items: center; }
.hero h1 {
  font-family: var(--serif-display); font-weight: 600; line-height: 1.02;
  font-size: clamp(2.6rem, 5.4vw, 4.6rem); letter-spacing: -0.01em; margin: 14px 0 22px;
}
.hero h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.lede { font-size: 1.16em; color: var(--ink-2); max-width: 36em; margin: 0 0 28px; }
.byline { font-family: var(--sans); font-size: 14px; color: var(--muted); margin-top: 26px; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; cursor: pointer;
  font-family: var(--sans); font-size: 15px; font-weight: 500; line-height: 1;
  padding: 13px 18px; border-radius: 999px; border: 1px solid var(--rule-strong);
  color: var(--ink); background: var(--surface); transition: transform .15s, background .15s;
}
.btn:hover { transform: translateY(-1px); background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); }
.btn.small { font-size: 13px; padding: 8px 12px; }
.btn svg { width: 15px; height: 15px; }
.seal { justify-self: center; width: min(360px, 100%); aspect-ratio: 1; color: var(--ornament); }
.seal text { font-family: var(--mono); font-size: 7.2px; letter-spacing: 0.32em; fill: var(--muted); }
@media (max-width: 860px) {
  .hero { padding: 48px 0 32px; }
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .seal { width: 220px; order: -1; justify-self: start; }
}

/* --------------------------------------------------------------- sections */
section.room { padding: 84px 0; border-bottom: 1px solid var(--rule); scroll-margin-top: 60px; }
@media (max-width: 640px) { section.room { padding: 56px 0; } }
.room-head { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 32px; margin-bottom: 40px; }
.room-head .numeral { font-size: 64px; line-height: .9; }
.room-head h2 {
  font-family: var(--serif-display); font-weight: 600; font-size: clamp(2rem, 3.6vw, 3rem);
  line-height: 1.05; margin: 6px 0 14px;
}
.room-head p { margin: 0; color: var(--ink-2); max-width: var(--measure); }
@media (max-width: 760px) {
  .room-head { grid-template-columns: 1fr; gap: 6px; }
  .room-head .numeral { font-size: 44px; }
}
.prose { max-width: var(--measure); }
.prose p { margin: 0 0 1em; }
.indent { margin-left: 152px; }
@media (max-width: 760px) { .indent { margin-left: 0; } }

/* ----------------------------------------------------------- stage rooms */
.stages { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--rule-strong); }
.stage { padding: 22px 20px 10px 0; border-right: 1px solid var(--rule); }
.stage + .stage { padding-left: 20px; }
.stage:last-child { border-right: none; }
.stage .numeral { font-size: 34px; display: block; line-height: 1; }
.stage h3 { font-family: var(--serif-display); font-size: 25px; font-weight: 600; line-height: 1.1; margin: 10px 0 8px; }
.stage p { font-size: 15.5px; line-height: 1.55; color: var(--ink-2); margin: 0 0 14px; }
.stage .fact { font-family: var(--mono); font-size: 12px; color: var(--ink); border-top: 1px dashed var(--rule-strong); padding-top: 10px; }
.stage .fact span { display: block; color: var(--muted); }
@media (max-width: 980px) {
  .stages { grid-template-columns: 1fr 1fr; }
  .stage, .stage + .stage { padding: 22px 18px 12px 0; border-right: none; border-bottom: 1px solid var(--rule); }
}
@media (max-width: 560px) { .stages { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ plates */
.plate {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  padding: 28px 30px 22px; margin: 44px 0 0; box-shadow: var(--shadow);
}
.plate figcaption { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 20px; margin-top: 18px;
  border-top: 1px solid var(--rule); padding-top: 14px; font-size: 15px; color: var(--ink-2); }
.plate figcaption .label { padding-top: 3px; }
@media (max-width: 640px) {
  .plate { padding: 18px 14px 14px; }
  .plate figcaption { grid-template-columns: 1fr; gap: 4px; }
}

.flow-list { display: none; list-style: none; margin: 0; padding: 0; }
.flow-list li { display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.flow-list .numeral { grid-row: span 3; font-size: 24px; line-height: 1.1; }
.flow-list b { font-family: var(--serif-display); font-size: 21px; font-weight: 600; }
.flow-list em { font-style: normal; font-family: var(--sans); font-size: 13px; color: var(--muted); }
.flow-list code { font-size: 12px; color: var(--accent); background: none; padding: 0; }
@media (max-width: 640px) { svg.flow { display: none; } .flow-list { display: block; } }

/* ------------------------------------------------------------------ stats */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule); }
.stat { padding: 22px 16px 20px 0; }
.stat + .stat { border-left: 1px solid var(--rule); padding-left: 18px; }
.stat b { display: block; font-family: var(--serif-display); font-weight: 600; font-size: clamp(2rem, 3.4vw, 2.9rem); line-height: 1; }
.stat span { display: block; margin-top: 8px; font-size: 14.5px; color: var(--ink-2); line-height: 1.4; }
@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat, .stat + .stat { border-left: none; padding-left: 0; border-bottom: 1px solid var(--rule); }
}

/* ------------------------------------------------------------- volumes */
.volumes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.volume {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--rule);
  border-top: 3px solid var(--ornament); border-radius: 4px; padding: 24px 24px 20px; box-shadow: var(--shadow);
}
.volume h3 { font-family: var(--serif-display); font-size: 25px; font-weight: 600; line-height: 1.12; margin: 10px 0 10px; }
.volume .authors { font-family: var(--sans); font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.volume blockquote { margin: 0 0 18px; font-size: 15.5px; color: var(--ink-2); line-height: 1.55; }
.volume .actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 980px) { .volumes { grid-template-columns: 1fr; } }

/* ----------------------------------------------------------------- tables */
.ledger { width: 100%; border-collapse: collapse; font-family: var(--sans); font-size: 14.5px; }
.ledger th, .ledger td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger th { font-family: var(--mono); font-weight: 500; font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.ledger td.num { font-variant-numeric: tabular-nums; }
.ledger code { font-size: 13px; }
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------------------- code */
code, pre, kbd { font-family: var(--mono); }
:not(pre) > code { font-size: 0.86em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.codeblock { position: relative; margin: 18px 0; }
.codeblock pre {
  margin: 0; background: var(--code-bg); color: var(--code-ink); border-radius: 6px;
  padding: 18px 92px 18px 20px; overflow-x: auto; font-size: 13.5px; line-height: 1.65;
}
.codeblock pre .c { color: #9b927f; }
.copy {
  position: absolute; top: 10px; right: 10px; appearance: none; cursor: pointer;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: #d8cfbd; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px; padding: 5px 9px;
}
.copy:hover { background: rgba(255, 255, 255, 0.12); }

/* ------------------------------------------------------------------ cards */
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; gap: 24px; } }
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; padding: 24px 26px; }
.panel h3 { font-family: var(--serif-display); font-size: 26px; font-weight: 600; margin: 4px 0 10px; line-height: 1.1; }
.panel p { font-size: 16px; color: var(--ink-2); }
.panel p.label, .notice p.label, .volume p.label { font-size: 11.5px; color: var(--muted); }
.notice { border-left: 3px solid var(--ornament); background: var(--accent-wash); padding: 16px 20px; border-radius: 0 4px 4px 0; font-size: 16px; }
.notice h3 { margin-top: 0; }
.files { list-style: none; padding: 0; margin: 0; }
.files li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--rule); font-size: 15.5px; }
.files li a { font-family: var(--mono); font-size: 13.5px; word-break: break-all; }
.files li span { color: var(--muted); font-family: var(--sans); font-size: 13px; white-space: nowrap; }
.files li p { grid-column: 1 / -1; margin: 2px 0 0; font-size: 14.5px; color: var(--ink-2); }

/* -------------------------------------------------------------------- cite */
.cite-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 0; }
.cite-tabs button {
  appearance: none; cursor: pointer; font-family: var(--sans); font-size: 14px;
  padding: 9px 14px; border: 1px solid var(--rule); border-bottom: none; background: var(--surface-2);
  color: var(--ink-2); border-radius: 6px 6px 0 0;
}
.cite-tabs button[aria-selected="true"] { background: var(--code-bg); color: var(--code-ink); border-color: var(--code-bg); }
.cite-panel .codeblock { margin-top: 0; }
.cite-panel .codeblock pre { border-top-left-radius: 0; white-space: pre-wrap; }

/* ------------------------------------------------------------------ chart */
.viz { position: relative; }
.viz svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz .axis text, .viz .tick text { font-family: var(--sans); font-size: 12px; fill: var(--muted); }
.viz .theme-label { font-family: var(--serif); font-size: 15px; fill: var(--ink); }
.viz .grid line { stroke: var(--grid); stroke-width: 1; }
.viz .span { stroke: var(--rule-strong); stroke-width: 2; stroke-linecap: round; }
.viz .dot { stroke: var(--surface); stroke-width: 2; cursor: default; }
.viz .hit { fill: transparent; cursor: pointer; }
.viz .sig { font-family: var(--sans); font-size: 12px; fill: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 18px; font-family: var(--sans); font-size: 13.5px; color: var(--ink-2); margin-bottom: 12px; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend i.sq { border-radius: 2px; transform: rotate(45deg) scale(.85); }
.legend i.ring { background: transparent !important; box-shadow: inset 0 0 0 2.5px currentColor; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 180px;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 6px;
  box-shadow: var(--shadow); padding: 10px 12px; font-family: var(--sans); font-size: 13px; color: var(--ink);
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.tooltip.on { opacity: 1; transform: none; }
.tooltip b { display: block; font-size: 13.5px; margin-bottom: 4px; }
.tooltip .row { display: flex; justify-content: space-between; gap: 14px; color: var(--ink-2); }
.tooltip .row span:last-child { color: var(--ink); font-variant-numeric: tabular-nums; }
details.data-table { margin-top: 14px; font-family: var(--sans); font-size: 14px; }
details.data-table summary { cursor: pointer; color: var(--accent); }

/* ------------------------------------------------------------------ footer */
footer.colophon { padding: 56px 0 72px; color: var(--muted); font-family: var(--sans); font-size: 14px; }
footer.colophon .wrap { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }
footer.colophon h4 { font-family: var(--mono); font-weight: 500; font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 10px; }
footer.colophon p { margin: 0 0 8px; }
footer.colophon a { color: var(--ink-2); }
@media (max-width: 760px) { footer.colophon .wrap { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------- reveal */
@media (prefers-reduced-motion: no-preference) {
  .reveal { opacity: 0; transform: translateY(14px); transition: opacity .7s ease, transform .7s ease; }
  .reveal.in { opacity: 1; transform: none; }
}
@media print {
  .topbar, .theme-toggle, .copy, .cta { display: none !important; }
  body { background: #fff; color: #000; }
  section.room { padding: 24px 0; }
}
