:root {
  --ink: #0b0b0e;
  --ink-2: #131318;
  --ink-3: #1c1c24;
  --paper: #f4f1ea;
  --paper-dim: #a8a49a;
  --paper-faint: #6b6860;
  --accent: #f5a524;
  --accent-soft: rgba(245, 165, 36, .14);
  --rule: rgba(244, 241, 234, .12);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1100px; margin-inline: auto; padding-inline: clamp(20px, 5vw, 48px); }

.num, .v {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.acc { color: var(--accent); }
.fine { font-size: .78rem; color: var(--paper-faint); }

a { color: inherit; }

::selection { background: var(--accent); color: var(--ink); }

/* ── header ─────────────────────────── */
.site-header {
  position: fixed; inset-inline: 0; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.header-row { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { text-decoration: none; font-weight: 700; letter-spacing: .04em; font-size: 1.05rem; }
.brand-latin { font-family: var(--mono); font-size: .62rem; letter-spacing: .32em; color: var(--paper-dim); margin-left: .6em; vertical-align: .18em; }
.top-nav { display: flex; gap: 1.4rem; }
.top-nav a { text-decoration: none; font-size: .85rem; color: var(--paper-dim); transition: color .15s; }
.top-nav a:hover { color: var(--accent); }

main { padding-top: 52px; }

/* ── hero ───────────────────────────── */
.hero { position: relative; min-height: min(92vh, 860px); display: flex; align-items: center; overflow: hidden; border-bottom: 1px solid var(--rule); }
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-inner { position: relative; z-index: 1; padding-block: 96px 72px; pointer-events: none; }
.hero-inner a, .hero-inner button { pointer-events: auto; }

.eyebrow { font-family: var(--mono); font-size: .7rem; letter-spacing: .28em; color: var(--accent); margin-bottom: 1.4rem; }

h1 {
  font-size: clamp(3.2rem, 9vw, 6.5rem);
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1.05;
}
.h1-latin {
  display: block;
  font-family: var(--mono);
  font-size: clamp(.8rem, 2vw, 1.15rem);
  font-weight: 400;
  letter-spacing: .55em;
  color: var(--paper-dim);
  margin-top: .9rem;
}
.tagline { margin-top: 1.6rem; font-size: clamp(1.05rem, 2.4vw, 1.45rem); color: var(--paper); }
.hero-note { margin-top: 1.1rem; max-width: 34em; font-size: .95rem; color: var(--paper-dim); }
.hero-note .num { color: var(--accent); }

.scroll-hint {
  display: inline-block; margin-top: 3rem;
  font-family: var(--mono); font-size: .8rem; letter-spacing: .22em;
  color: var(--paper-dim); text-decoration: none;
  animation: bob 2.4s ease-in-out infinite;
}
.scroll-hint:hover { color: var(--accent); }
@keyframes bob { 50% { transform: translateY(6px); } }

/* ── sections ───────────────────────── */
.section { padding-block: clamp(72px, 12vh, 130px); border-bottom: 1px solid var(--rule); }
.section--alt { background: var(--ink-2); }

.sec-head { margin-bottom: clamp(2.5rem, 6vh, 4.5rem); }
.sec-no { font-family: var(--mono); font-size: .8rem; letter-spacing: .3em; color: var(--accent); margin-bottom: .5rem; }
h2 { font-size: clamp(1.9rem, 4.5vw, 3rem); font-weight: 800; letter-spacing: .01em; }
h2 .latin { font-family: var(--mono); font-size: .38em; font-weight: 400; letter-spacing: .3em; color: var(--paper-dim); margin-left: 1em; }
.sec-lead { margin-top: .8rem; color: var(--paper-dim); max-width: 36em; }

.big { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; }
.big .v { font-size: clamp(2rem, 5vw, 3rem); color: var(--accent); }
.big .u { font-size: clamp(.95rem, 2vw, 1.25rem); color: var(--paper-dim); margin-left: .45em; font-weight: 400; }
.big.huge .v { font-size: clamp(3.4rem, 8vw, 5.2rem); }

/* ── §1 scale ───────────────────────── */
.minimap {
  position: relative;
  height: 46px;
  margin-bottom: clamp(2rem, 5vh, 3.2rem);
  border-block: 1px solid var(--rule);
}
.minimap::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%;
  height: 1px; background: var(--rule);
}
.dot {
  position: absolute; top: 50%;
  width: 9px; height: 9px;
  border-radius: 50%;
  translate: -50% -50%;
  background: var(--ink);
  border: 1.6px solid var(--paper-faint);
  transition: all .25s;
}
.dot.is-lit {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 0 14px rgba(245, 165, 36, .55);
}
.dot--slope { border-radius: 2px; rotate: 45deg; }
.mm-label {
  position: absolute; bottom: -1px;
  translate: -50% 0;
  font-family: var(--mono); font-size: .58rem; letter-spacing: .16em;
  color: var(--paper-faint);
  background: var(--ink); padding-inline: .5em;
}

.scale-wrap { position: relative; display: grid; grid-template-columns: 56px 1fr; gap: 0 clamp(16px, 4vw, 44px); }
.scale-rail { position: relative; }
.rail-fill {
  position: absolute; left: 26px; top: 0; bottom: 0; width: 2px;
  background: var(--rule);
}
.rail-fill::after {
  content: ""; position: absolute; inset-inline: 0; top: 0;
  height: calc(var(--progress, 0) * 100%);
  background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 30%, transparent));
}

.stops { list-style: none; position: relative; }
.stop { position: relative; padding-block: 1.1rem; }
.stop::before {
  content: ""; position: absolute; left: calc(-1 * clamp(16px, 4vw, 44px) + 21px); top: 50%;
  width: 12px; height: 12px; border-radius: 50%;
  translate: 0 -50%;
  background: var(--ink); border: 2px solid var(--paper-faint);
  transition: border-color .3s, box-shadow .3s;
}
.stop.is-active::before { border-color: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }

.card {
  background: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.35rem 1.5rem;
  transition: border-color .3s, transform .3s, opacity .3s;
}
.js .card { opacity: .45; transform: scale(.985); transform-origin: left center; }
.stop.is-active .card { opacity: 1; border-color: color-mix(in srgb, var(--accent) 55%, transparent); transform: none; }

.card h3 { font-size: 1.02rem; font-weight: 700; margin-top: .55rem; letter-spacing: .01em; }
.card h3 small { font-weight: 400; color: var(--paper-dim); font-size: .8em; margin-left: .5em; }
.ana { margin-top: .35rem; font-size: .88rem; color: var(--paper-dim); }

.card--slope { border-style: dashed; background: transparent; }
.slope-badge {
  display: inline-block;
  font-family: var(--mono); font-size: .62rem; letter-spacing: .24em;
  color: var(--ink); background: var(--paper-dim);
  padding: .18em .7em; border-radius: 99px;
}

.noscript-note { padding-block: 2rem; color: var(--paper-dim); font-size: .85rem; }

/* ── §2 frame budget ────────────────── */
.fps-picker { display: flex; flex-wrap: wrap; gap: .7rem; margin-bottom: 2.6rem; }
.fps-btn {
  appearance: none; cursor: pointer;
  background: var(--ink-3); color: var(--paper-dim);
  border: 1px solid var(--rule); border-radius: 8px;
  padding: .65rem 1.2rem;
  font: inherit; font-weight: 600; font-size: .95rem;
  display: flex; flex-direction: column; align-items: flex-start; gap: .1em;
  transition: all .18s;
}
.fps-btn small { font-size: .7rem; font-weight: 400; letter-spacing: .08em; }
.fps-btn:hover { border-color: var(--paper-dim); color: var(--paper); }
.fps-btn.is-active { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.fps-btn.is-active small { color: color-mix(in srgb, var(--ink) 70%, transparent); }

.budget-grid { display: grid; gap: 2.5rem; grid-template-columns: minmax(240px, 1fr) 1.6fr; align-items: start; }
.budget-label { font-family: var(--mono); font-size: .72rem; letter-spacing: .26em; color: var(--paper-dim); margin-bottom: .6rem; }
.budget-bar { margin-top: 1.4rem; height: 6px; background: var(--ink-3); border-radius: 99px; overflow: hidden; }
.budget-bar-fill { height: 100%; width: 40%; background: var(--accent); border-radius: 99px; transition: width .5s cubic-bezier(.22, 1, .36, 1); }

.budget-facts { display: grid; gap: 1.2rem; }
.fact { background: var(--ink-3); border: 1px solid var(--rule); border-radius: 10px; padding: 1.3rem 1.5rem; }
.fact-head { font-size: .92rem; color: var(--paper-dim); margin-bottom: .4rem; }
.fact-note { margin-top: .45rem; font-size: .84rem; color: var(--paper-faint); }

/* ── §3 race ────────────────────────── */
.race-box { background: var(--ink-2); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
#race-canvas { display: block; width: 100%; height: auto; }
.race-summary { padding: 1.1rem 1.5rem; border-top: 1px solid var(--rule); font-size: .95rem; }
.race-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.5rem; border-top: 1px solid var(--rule); }

.ghost-btn {
  appearance: none; cursor: pointer;
  background: transparent; color: var(--paper);
  border: 1px solid var(--paper-dim); border-radius: 8px;
  padding: .5rem 1.1rem; font: inherit; font-size: .88rem; font-weight: 600;
  transition: all .18s;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── §4 essay ───────────────────────── */
.why-wrap { max-width: 780px; }
.essay p + p { margin-top: 1.2rem; }
.cta {
  display: inline-block; margin-top: 2.4rem;
  background: var(--accent); color: var(--ink);
  text-decoration: none; font-weight: 700; font-size: .95rem;
  padding: .85rem 1.6rem; border-radius: 8px;
  transition: transform .18s, box-shadow .18s;
}
.cta:hover { transform: translateY(-2px); box-shadow: 0 8px 30px var(--accent-soft); }

/* ── footer ─────────────────────────── */
.site-footer { padding-block: 64px 80px; }
.foot-title { font-weight: 700; margin-bottom: 1rem; }
.family { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem 1.6rem; }
.family a { text-decoration: none; color: var(--paper-dim); font-size: .9rem; transition: color .15s; }
.family a:hover { color: var(--accent); }
.site-footer .fine { margin-top: 2.2rem; }

/* ── responsive ─────────────────────── */
@media (max-width: 760px) {
  .top-nav { display: none; }
  .budget-grid { grid-template-columns: 1fr; }
  .scale-wrap { grid-template-columns: 34px 1fr; }
  .rail-fill { left: 13px; }
  .stop::before { left: calc(-1 * clamp(16px, 4vw, 44px) + 8px); width: 10px; height: 10px; }
  .decades { display: none; }
  .race-foot { flex-direction: column; align-items: flex-start; }
}

/* ── reduced motion ─────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scroll-hint { animation: none; }
  * { transition-duration: .01ms !important; }
}
