/* Geist and Geist Mono, variable (weight 100 to 900, no width axis), latin subset, self-hosted.
   SIL Open Font License 1.1: fonts/OFL.txt. */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/geist-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/geist-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --paper: #fbfcfd;
  --band: #e8edf2;
  --panel: #f2f5f8;
  --ink: #111b27;
  --ink-2: #435163;
  --ink-3: #5d6b7b;
  --rule: #c7d0da;
  --rule-soft: #dde3ea;
  --attack: #c0122c;
  --attack-soft: #f7dde1;
  --model: #1d4f91;
  --model-soft: #dbe6f4;
  --night-hints: #2a78d6;
  --night-nohint: #1baf7a;
  --night-zscore: #eb6834;
  --night-range: #8b97a4;

  --f: "Geist", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gut: 16px;
  --max: 1240px;
  --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
@media (min-width: 720px) { :root { --gut: 32px; } }

/* Dark ground for the control room. Same token names, so the header and anything built on the
   tokens is right on both grounds. --attack and --model pass WCAG AA (4.5:1) on --paper, --band
   and --panel here. */
body[data-view="demo"] {
  color-scheme: dark;
  --paper: #14171b;
  --band: #1b1f24;
  --panel: #20252b;
  --ink: #e9ecef;
  --ink-2: #b3bbc4;
  --ink-3: #8e98a3;
  --rule: #343b43;
  --rule-soft: #262c33;
  --attack: #ff5c70;
  --attack-soft: #3b1b22;
  --model: #7eb0f5;
  --model-soft: #17273c;
}
html:has(body[data-view="demo"]) { color-scheme: dark; scrollbar-color: #5b646e #14171b; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f);
  font-size: 1.0625rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}
::selection { background: var(--model); color: var(--paper); }
a { color: var(--model); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--model); outline-offset: 2px; border-radius: 2px; }
b, strong { font-weight: 600; }
h1, h2, h3, h4 { text-wrap: balance; margin: 0; }
p { margin: 0; text-wrap: pretty; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
html { scrollbar-color: var(--ink-3) var(--band); }

/* ---- top bar ---- */
.bar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--rule-soft); }
.bar__in { max-width: var(--max); margin: 0 auto; padding: 0 var(--gut); display: flex; align-items: center; gap: var(--s5); height: 52px; }
.bar__name { font-weight: 650; color: var(--ink); text-decoration: none; letter-spacing: -.02em; white-space: nowrap; }
/* two equal segments; the thumb (::before) slides under the pressed one. js/views.js sets data-on. */
.viewseg { position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; flex: none; padding: 2px; gap: 2px; border: 1px solid var(--rule); border-radius: 7px; background: var(--panel); }
.viewseg::before { content: ""; position: absolute; top: 2px; bottom: 2px; left: 2px; width: calc(50% - 3px); border-radius: 5px; background: var(--ink); pointer-events: none; }
.viewseg[data-on="writeup"]::before { transform: translateX(calc(100% + 2px)); }
.viewseg__btn { position: relative; font: inherit; font-size: .875rem; font-weight: 500; line-height: 1; min-height: 32px; padding: 0 12px; border: 0; border-radius: 5px; background: transparent; color: var(--ink-2); cursor: pointer; transition: color .18s var(--ease); }
.viewseg__btn:hover { color: var(--ink); }
.viewseg__btn[aria-pressed="true"] { color: var(--paper); }
.viewseg__btn:focus-visible { outline-offset: 1px; border-radius: 5px; }
@media (prefers-reduced-motion: reduce) { .viewseg__btn { transition: none; } }
.bar__nav { display: flex; gap: var(--s5); margin-left: auto; overflow-x: auto; scrollbar-width: none; font-size: .9375rem; }
.bar__nav::-webkit-scrollbar { display: none; }
.bar__nav a { color: var(--ink-2); text-decoration: none; white-space: nowrap; padding: 14px 0; border-bottom: 2px solid transparent; }
.bar__nav a:hover, .bar__nav a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--ink); }
@media (max-width: 719px) {
  .viewseg { margin-left: auto; }
  body[data-view="writeup"] .bar__in { height: auto; flex-wrap: wrap; row-gap: 0; padding-top: 10px; }
  .bar__nav { width: 100%; margin-left: 0; gap: var(--s4); }
  .bar__nav a { padding: 8px 0 10px; }
  /* js/app.js marks the side with more links */
  .bar__nav.is-more-right { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
  .bar__nav.is-more-left { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); }
  .bar__nav.is-more-left.is-more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); }
  html { scroll-padding-top: 96px; }
}

/* ---- two views (js/views.js sets body[data-view]) ---- */
.view[hidden],
body[data-view="demo"] #view-writeup,
body[data-view="writeup"] #view-demo,
body[data-view="demo"] .bar__nav,
body[data-view="demo"] .skip--writeup,
body[data-view="writeup"] .skip--demo { display: none; }
#view-demo:focus { outline: none; }

/* ---- switching views (js/views.js): the lights come on, the lights go down ----
   html.is-switching lasts one switch; never on the first load or under reduced motion.
   View Transitions API: the header and each view get their own name, so the root holds only the
   ground, which cross-fades. The outgoing view fades and settles back (towards the middle of the
   screen, --hai-oy), the incoming one fades in and rises 8px. The header is shown live, not as a
   snapshot: its colours and the toggle's thumb move by the transitions below. The part links fade.
   Without the API (html.is-fading) the same moves run on the views with the swap in between. */
:root { --switch: 420ms; --switch-out: 200ms; --switch-ease: cubic-bezier(.33, 1, .68, 1); }
/* during a switch the header is fixed (its place kept by the body's padding, same layout): WebKit
   draws a sticky header's new snapshot without its content after the switch scrolls the page */
html.is-switching .bar { view-transition-name: hai-bar; position: fixed; top: 0; left: 0; right: 0; }
html.is-switching body { padding-top: var(--hai-bar-h, 0px); }
html.is-switching .bar__nav { view-transition-name: hai-nav; }
html.is-switching #view-demo { view-transition-name: hai-demo; }
html.is-switching #view-writeup { view-transition-name: hai-writeup; }
::view-transition { pointer-events: none; } /* WebKit: clicks and hover reach the page during a switch (Chromium: js/views.js) */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--switch); animation-timing-function: var(--switch-ease); }
::view-transition-group(hai-bar), ::view-transition-old(hai-bar), ::view-transition-new(hai-bar) { animation: none; }
::view-transition-group(hai-bar), ::view-transition-group(hai-nav) { z-index: 1; } /* WebKit paints groups in tree order */
::view-transition-old(hai-bar) { opacity: 0; }
::view-transition-group(hai-nav) { animation-duration: var(--switch-out); }
::view-transition-old(hai-nav), ::view-transition-new(hai-nav) { animation-duration: var(--switch-out); animation-timing-function: var(--switch-ease); }
::view-transition-old(hai-demo), ::view-transition-old(hai-writeup) { transform-origin: 50% var(--hai-oy, 50%); animation: hai-view-out var(--switch-out) var(--switch-ease) both; }
::view-transition-new(hai-demo), ::view-transition-new(hai-writeup) { animation: hai-view-in calc(var(--switch) - 80ms) var(--switch-ease) 80ms both; }
@keyframes hai-view-out { to { opacity: 0; transform: scale(.985); } }
@keyframes hai-view-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes hai-fade-out { to { opacity: 0; } }
@keyframes hai-fade-in { from { opacity: 0; } }
html.is-switching .bar,
html.is-switching .viewseg { transition: background-color var(--switch) var(--switch-ease), border-color var(--switch) var(--switch-ease); }
html.is-switching .bar__name,
html.is-switching .viewseg__btn,
html.is-switching .bar__nav a { transition: color var(--switch) var(--switch-ease), border-color var(--switch) var(--switch-ease); }
html.is-switching .viewseg::before { transition: transform var(--switch) var(--switch-ease), background-color var(--switch) var(--switch-ease); }
html.is-fading body { transition: background-color calc(var(--switch) - var(--switch-out)) var(--switch-ease); }
html.is-fading .view.is-leaving { transform-origin: 50% var(--hai-oy, 50%); animation: hai-view-out var(--switch-out) var(--switch-ease) both; }
html.is-fading .view.is-entering { animation: hai-view-in calc(var(--switch) - var(--switch-out)) var(--switch-ease) both; }
html.is-fading.is-switching-to-demo .bar__nav { animation: hai-fade-out var(--switch-out) var(--switch-ease) both; }
html.is-fading.is-switching-to-writeup .bar__nav { animation: hai-fade-in calc(var(--switch) - var(--switch-out)) var(--switch-ease) both; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---- write-up: one calm reading column; the top, then five numbered parts ---- */
#view-writeup { --col: 920px; counter-reset: part; }
.wu-top, .part, .credits { max-width: calc(var(--col) + 2 * var(--gut)); margin: 0 auto; padding-left: var(--gut); padding-right: var(--gut); }
.wu-top { padding-top: var(--s8); padding-bottom: var(--s7); }
.wu-top h1 { font-size: clamp(1.875rem, 1.3rem + 1.9vw, 2.75rem); line-height: 1.1; font-weight: 600; letter-spacing: -.028em; max-width: 22em; }
.lede { margin-top: var(--s5); font-size: 1.1875rem; line-height: 1.5; color: var(--ink-2); max-width: 38em; }
.lede b { color: var(--ink); }
.lede--result { color: var(--ink); }
.toc { margin-top: var(--s7); display: grid; grid-template-columns: 1fr; border-top: 1px solid var(--rule); }
@media (min-width: 720px) { .toc { grid-template-columns: repeat(5, minmax(0, 1fr)); column-gap: var(--s4); } }
.toc a { display: flex; align-items: baseline; gap: var(--s3); padding: var(--s3) var(--s4) var(--s3) 0; min-height: 44px; border-bottom: 1px solid var(--rule-soft); color: var(--ink); text-decoration: none; font-weight: 550; }
.toc a:hover { color: var(--model); }
.toc__n { font-family: var(--f-mono); font-size: .875rem; font-weight: 500; color: var(--ink-3); min-width: 1ch; }
.toc a:hover .toc__n { color: var(--model); }

/* the rule between parts spans the text column, not the gutters */
.part { counter-increment: part; padding-top: var(--s8); padding-bottom: var(--s7); background: linear-gradient(var(--rule), var(--rule)) no-repeat var(--gut) 0 / calc(100% - 2 * var(--gut)) 1px; }
.part__h { font-size: clamp(1.5rem, 1.15rem + 1.2vw, 2.125rem); line-height: 1.16; font-weight: 600; letter-spacing: -.024em; max-width: 30em; margin-bottom: var(--s6); }
.part__h::before { content: counter(part); display: block; margin-bottom: var(--s3); font-family: var(--f-mono); font-size: .9375rem; font-weight: 500; letter-spacing: 0; color: var(--ink-3); }
.part__sub { font-size: 1.375rem; line-height: 1.25; font-weight: 600; letter-spacing: -.016em; margin: var(--s8) 0 var(--s5); padding-top: var(--s5); border-top: 2px solid var(--ink); }
.part > * + * { margin-top: var(--s6); }
.part > .part__h + * { margin-top: 0; }
.part > .part__sub + * { margin-top: 0; }
.prose { max-width: 40em; display: grid; gap: var(--s4); }
.prose ul, .prose ol { margin: 0; padding-left: 1.2em; display: grid; gap: var(--s3); }
.prose li::marker { color: var(--ink-3); }
.findings li::marker { font-family: var(--f-mono); font-size: .9375rem; }
.part .fig { margin-top: var(--s7); margin-bottom: var(--s3); }

/* ---- tables in the copy: real tables, scrolling inside their own box when narrow ---- */
.dtab { overflow-x: auto; max-width: 100%; border-top: 2px solid var(--ink); -webkit-overflow-scrolling: touch; }
.dtab:focus-visible { outline-offset: 4px; }
.dtab table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: .9375rem; line-height: 1.4; }
.dtab th, .dtab td { text-align: left; vertical-align: top; padding: 10px 16px 10px 0; border-bottom: 1px solid var(--rule-soft); }
.dtab thead th { font-size: .8125rem; font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--rule); }
.dtab tbody th { font-weight: 600; min-width: 9.5em; }
.dtab--num tbody th { min-width: 13em; }
.dtab--num td, .dtab--num thead th + th { text-align: right; }
.dtab--num td { white-space: nowrap; }
.dtab--num td:last-child, .dtab--num thead th:last-child { padding-right: 0; }
.dtab--num td:last-child { font-weight: 650; }
.dtab tr.is-ours th { color: var(--model); }
.dtab tr.is-diff th, .dtab tr.is-diff td { border-top: 1px solid var(--ink); border-bottom: 0; font-weight: 650; }
/* Phones: no sideways scroll. Each row stacks: its name, then one line per column, the column's
   header (data-label, set by js/app.js) on the left and the value on the right. The header row
   stays for screen readers only. Without JavaScript (no labels) the table scrolls as above. */
@media (max-width: 599px) {
  .dtab.is-labelled { overflow-x: visible; }
  .dtab.is-labelled table { min-width: 0; }
  .dtab.is-labelled thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .dtab.is-labelled table, .dtab.is-labelled tbody, .dtab.is-labelled tr, .dtab.is-labelled tbody th, .dtab.is-labelled td { display: block; }
  .dtab.is-labelled tr { padding: 10px 0; border-bottom: 1px solid var(--rule-soft); }
  .dtab.is-labelled tbody th { min-width: 0; padding: 0 0 4px; border: 0; }
  .dtab.is-labelled td { padding: 2px 0; border: 0; text-align: right; white-space: normal; }
  .dtab.is-labelled td::after { content: ""; display: block; clear: both; }
  .dtab.is-labelled td::before { content: attr(data-label); float: left; max-width: 58%; margin-right: var(--s4); padding-top: .1em; text-align: left; font-size: .8125rem; font-weight: 500; color: var(--ink-3); }
  .dtab.is-labelled td.is-empty { display: none; }
  .dtab.is-labelled tr.is-diff { border-top: 1px solid var(--ink); border-bottom: 0; }
  .dtab.is-labelled tr.is-diff th, .dtab.is-labelled tr.is-diff td { border: 0; }
  /* a table of sentences (part 3's computed features): each column's header sits above its text */
  .dtab--text.is-labelled td { padding: 4px 0; text-align: left; }
  .dtab--text.is-labelled td::before { float: none; display: block; max-width: none; margin: 0 0 2px; padding-top: 0; }
}

/* ---- figures (chart-journalism grammar: heavy rule, sentence title, source line) ---- */
.fig { margin: 0; border-top: 4px solid var(--ink); padding-top: var(--s3); }
.fig__h { font-size: 1.1875rem; line-height: 1.3; font-weight: 600; letter-spacing: -.012em; max-width: 44em; }
.fig__src { margin-top: var(--s3); font-size: .8125rem; line-height: 1.45; color: var(--ink-3); }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--f); font-variant-numeric: tabular-nums; }

.flow { margin-top: var(--s4); display: grid; gap: var(--s5); }
@media (min-width: 860px) {
  .flow { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); column-gap: var(--s6); }
  .flow__step--chart { grid-row: span 2; }
}
.flow__label { font-size: .875rem; font-weight: 600; color: var(--ink-2); margin-bottom: var(--s2); }
.flow__step--out { padding-top: var(--s3); border-top: 1px solid var(--rule); }

.hints { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.hints li { font-size: .9375rem; line-height: 1.45; color: var(--ink-2); padding-left: var(--s3); border-left: 1px solid var(--rule); }
.hints li .hint__sig { color: var(--ink); font-weight: 600; }
.hints mark { background: var(--model-soft); color: var(--ink); padding: 0 .15em; border-radius: 2px; }
.answer { font-size: 1.0625rem; line-height: 1.45; }
.answer .verdict { font-weight: 650; }
.answer .verdict--attack { color: var(--attack); }
.answer .verdict--normal { color: var(--model); }
.answer q { quotes: "\201C" "\201D"; }

.voters__rule { margin-top: var(--s2); font-size: .8125rem; color: var(--ink-3); }

/* ---- the 64 runs (part 3) ---- */
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); margin: var(--s3) 0 var(--s2); font-size: .875rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend svg { width: 14px; height: 14px; overflow: visible; }
.tbl { margin-top: var(--s4); font-size: .875rem; }
.tbl summary { cursor: pointer; font-weight: 600; }
.tbl__wrap { margin-top: var(--s3); max-height: 420px; overflow: auto; border-top: 1px solid var(--rule); }
.tbl table { border-collapse: collapse; width: 100%; min-width: 560px; }
.tbl th, .tbl td { text-align: left; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--rule-soft); white-space: nowrap; }
.tbl th { position: sticky; top: 0; background: var(--band); font-weight: 600; }
.tbl td.n, .tbl th.n { text-align: right; }
.lessons { margin-top: var(--s7); display: grid; gap: var(--s6); }
@media (min-width: 860px) { .lessons { grid-template-columns: 1fr 1fr; gap: var(--s7); } }
.lessons h3 { font-size: 1.125rem; font-weight: 600; letter-spacing: -.01em; padding-bottom: var(--s2); border-bottom: 2px solid var(--ink); }
.lessons ul { margin: var(--s3) 0 0; padding-left: 1.1em; display: grid; gap: var(--s3); }
.lessons li::marker { color: var(--ink-3); }

/* ---- limits and credits (part 5, end of the write-up) ---- */
.prose .limits { list-style: none; padding: 0; gap: var(--s4); }
.limits li { padding-top: var(--s3); border-top: 1px solid var(--rule); }
.credits { padding-top: var(--s6); padding-bottom: var(--s8); display: grid; gap: var(--s3); color: var(--ink-2); font-size: .9375rem; }
.credits > * { max-width: 46em; }
.credits h3 { font-size: 1.125rem; color: var(--ink); padding-top: var(--s4); border-top: 4px solid var(--ink); }
.credits b { color: var(--ink); }

/* ---- tooltip ---- */
.tip { position: fixed; z-index: 40; pointer-events: none; background: var(--ink); color: var(--paper); font-size: .8125rem; line-height: 1.4; padding: 6px 10px; border-radius: 3px; max-width: 260px; box-shadow: 0 6px 18px rgba(17, 27, 39, .22); }
.tip b { font-weight: 600; }
.noscript { max-width: var(--max); margin: 0 auto; padding: var(--s5) var(--gut); }
