/* Overclocked — base tokens, layout, typography, chapters.
 * Module-specific styles live in their own files (chart.css, widgets.css, …). */

@font-face { font-family: 'et-book'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/edwardtufte/tufte-css@1.8.0/et-book/et-book-roman-line-figures/et-book-roman-line-figures.woff') format('woff'); }
@font-face { font-family: 'et-book'; font-style: italic; font-weight: 400; font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/edwardtufte/tufte-css@1.8.0/et-book/et-book-display-italic-old-style-figures/et-book-display-italic-old-style-figures.woff') format('woff'); }
@font-face { font-family: 'et-book'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/edwardtufte/tufte-css@1.8.0/et-book/et-book-bold-line-figures/et-book-bold-line-figures.woff') format('woff'); }

/* Animatable accent (Chromium/Safari/Firefox 128+) so the HUD re-tints smoothly at the fork */
@property --accent { syntax: '<color>'; inherits: true; initial-value: #2b6039; }
@property --accent-soft { syntax: '<color>'; inherits: true; initial-value: #5a8a68; }

:root {
  --bg: #fffff8;          /* ai-2027 paper */
  --bg-sunk: #f6f5ea;
  --ink: #111111;
  --ink-2: #3a3a3a;
  --muted: #74746c;
  --rule: #d9d8cc;
  --line: #1a1a1a;
  --green: #2b6039;       /* trunk + slowdown accent */
  --green-soft: #5a8a68;
  --red: #8b0000;         /* race accent (AI 2040 red) */
  --red-soft: #b86868;
  --china: #3b3b3b;       /* DeepCent series */
  --others: #8f8f86;      /* other US labs */
  --accent: var(--green);
  --accent-soft: var(--green-soft);
  --serif: 'et-book', Palatino, 'Palatino Linotype', 'Palatino LT STD', 'Book Antiqua', Georgia, serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  --story-w: 600px;
  --hud-w: 452px;
  --gap: clamp(28px, 4vw, 64px);
  --radius: 6px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  transition: --accent 900ms var(--ease), --accent-soft 900ms var(--ease);
}
:root[data-branch='race'] { --accent: var(--red); --accent-soft: var(--red-soft); }
:root[data-branch='slowdown'] { --accent: var(--green); --accent-soft: var(--green-soft); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--serif); font-size: 21px; line-height: 30px;
  font-feature-settings: 'onum' 0, 'kern' 1;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
.mono { font-family: var(--mono); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; background: var(--ink); color: var(--bg); padding: 6px 10px; z-index: 100; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ---------- pills (ai-2027 outline buttons) ---------- */
.pill {
  font: inherit; font-size: 18px; line-height: 1.2; color: var(--ink); background: transparent;
  border: 1.5px solid var(--ink); border-radius: var(--radius); padding: 5px 9px; cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease), transform .18s var(--ease);
}
.pill:hover { background: var(--ink); color: var(--bg); }
.pill:active { transform: translateY(1px); }
.pill[aria-expanded='true'] { background: var(--ink); color: var(--bg); }
.pill:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.site-header { max-width: calc(var(--story-w) + var(--hud-w) + var(--gap) + 48px); margin: 0 auto; padding: 36px 24px 8px; }
.masthead { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.site-title { font-weight: 400; font-size: clamp(48px, 7vw, 68px); line-height: 1; margin: 0 0 14px; letter-spacing: -.01em; }
.byline { font-size: 19px; line-height: 26px; margin: 0; max-width: 640px; color: var(--ink-2); }
.site-nav { display: flex; gap: 22px; align-items: center; font-size: 18px; white-space: nowrap; padding-top: 8px; }
.site-nav a { text-decoration: none; }
.intro-grid { max-width: var(--story-w); margin-top: 36px; }
.publine { font-size: 11px; color: var(--muted); letter-spacing: .02em; margin: 18px 0 0; }

/* ---------- two-column layout ---------- */
.layout {
  max-width: calc(var(--story-w) + var(--hud-w) + var(--gap) + 48px); margin: 0 auto; padding: 0 24px;
  display: grid; grid-template-columns: minmax(0, var(--story-w)) var(--hud-w); gap: var(--gap); align-items: start;
}
.story { min-width: 0; outline: none; }
.hud { position: sticky; top: 14px; height: calc(100vh - 28px); max-height: 900px; }
.hud-inner { height: 100%; display: flex; flex-direction: column; gap: 12px; }
.hud-block { position: relative; }
.hud-chart { flex: 1 1 auto; min-height: 190px; max-height: 330px; }
.hud-globe { position: absolute; inset: 0; pointer-events: none; }
.hud-mid { display: grid; grid-template-columns: 1fr 118px; gap: 12px; align-items: center; }

/* ---------- Act III: deep-time dashboard slot (visuals live in cosmos.css / deepgauges.css) ---------- */
.hud-inner { position: relative; }
.hud-inner > .hud-block { transition: opacity 700ms var(--ease), transform 700ms var(--ease); }
.hud-cosmos { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 900ms var(--ease), visibility 0s linear 900ms; }
.hud-cosmos-scene { position: relative; flex: 1 1 auto; min-height: 260px; }
.hud-deep { flex: 0 0 auto; }
:root[data-act='3'] .hud-cosmos { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 900ms var(--ease), visibility 0s; }
:root[data-act='3'] .hud-inner > .hud-block { opacity: 0; transform: scale(.985); pointer-events: none; }
.ch-beyond { color: var(--accent); letter-spacing: .05em; }

/* ---------- chapters ---------- */
.chapter { padding: 56px 0 8px; }
.chapter + .chapter { border-top: 0; }
.ch-head { margin-bottom: 18px; }
.ch-meta { font-family: var(--mono); font-size: 11px; letter-spacing: .03em; color: var(--muted); display: flex; gap: 10px; align-items: center; margin-bottom: 8px; text-transform: uppercase; }
.ch-date { background: var(--ink); color: var(--bg); padding: 2px 7px; border-radius: 4px; }
.chapter.is-active .ch-date { background: var(--accent); }
.ch-was { text-decoration: line-through; text-decoration-thickness: 1px; text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent); }
.ch-title { font-weight: 400; font-size: 36px; line-height: 40px; margin: 0 0 12px; letter-spacing: -.005em; }
.ch-title-date { color: var(--ink); }
.ch-dek { font-style: italic; font-size: 22px; line-height: 30px; color: var(--ink-2); margin: 0; }
.ch-body p { margin: 0 0 20px; hyphens: auto; }
.ch-body .ch-block { margin: 0 0 20px; }
.ch-body h3 { font-weight: 400; font-style: italic; font-size: 24px; margin: 30px 0 10px; }
.ch-body blockquote { margin: 0 0 20px; padding-left: 18px; border-left: 2px solid var(--accent); font-style: italic; color: var(--ink-2); }
.ch-body ul, .ch-body ol { padding-left: 24px; margin: 0 0 20px; }
.ch-pending { color: var(--muted); font-style: italic; }
.sn-ref { font-size: 12px; line-height: 0; margin-left: 1px; }
.sn-ref a { text-decoration: none; color: var(--accent); font-family: var(--serif); }
.ch-notes-wrap { margin: 4px 0 0; font-size: 16px; line-height: 23px; color: var(--ink-2); }
.ch-notes-wrap summary { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); cursor: pointer; list-style: none; }
.ch-notes-wrap summary::-webkit-details-marker { display: none; }
.ch-notes-wrap summary::before { content: '+ '; }
.ch-notes-wrap[open] summary::before { content: '– '; }
.ch-notes { padding-left: 22px; margin: 10px 0 0; }
.ch-notes li { margin-bottom: 8px; }
.ch-notes li:target { background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* ---------- endings ---------- */
.ending-banner { margin: 40px 0 0; padding: 26px 0 8px; border-top: 2px solid var(--accent); }
.ending-kicker { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ending-title { font-weight: 400; font-size: 48px; line-height: 1.05; margin: 6px 0 0; color: var(--accent); }
.fin { text-align: center; padding: 72px 0 40vh; }
.fin-mark { color: var(--accent); font-size: 20px; margin: 0; }
.fin-text { font-style: italic; margin: 6px 0 18px; }
.fin-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- footer ---------- */
.site-footer { max-width: calc(var(--story-w) + var(--hud-w) + var(--gap) + 48px); margin: 0 auto; padding: 32px 24px 64px; font-size: 15px; line-height: 22px; color: var(--muted); border-top: 1px solid var(--rule); }
.site-footer p { max-width: var(--story-w); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --hud-w: 400px; --story-w: 560px; }
}
@media (max-width: 960px) {
  body { font-size: 19px; line-height: 28px; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0 16px; }
  .site-header, .site-footer { padding-left: 16px; padding-right: 16px; }
  .hud { display: none; }
  .masthead { flex-direction: column; gap: 12px; }
  .site-nav { gap: 16px; font-size: 16px; padding-top: 0; flex-wrap: wrap; }
  .ch-title { font-size: 30px; line-height: 34px; }
  .chapter { padding-top: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
