/* =============================================================================
   Offprint — layout and components.

   Every colour, size and space here comes from tokens.css. Nothing in this file
   hard-codes a hex value, so a restyle is a token edit.

   Data drives geometry through custom properties (--w for a bar's width, --f for
   a segment's share), which the templates set and this file consumes. That way a
   template never carries an appearance decision.
   ============================================================================= */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--size-base);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
}

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

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius);
}

/* ---------- masthead ------------------------------------------------------ */
.masthead {
  position: sticky; top: 0; z-index: 20;
  background: var(--ground); border-bottom: 1px solid var(--rule);
}
.masthead-inner {
  max-width: var(--page-max); margin: 0 auto; padding: var(--space-3) var(--page-pad);
  display: flex; align-items: baseline; gap: var(--space-4); flex-wrap: wrap;
}
.wordmark {
  margin: 0; font-size: 15px; font-weight: 600;
  letter-spacing: var(--track-wordmark); text-transform: uppercase; white-space: nowrap;
}
.wordmark a { color: inherit; text-decoration: none; }
.wordmark a:hover { color: var(--accent); }
.crumb {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--muted);
  letter-spacing: .04em;
}
.masthead-right { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.theme-toggle {
  font-family: var(--font-mono); font-size: var(--size-micro); letter-spacing: .08em;
  text-transform: uppercase; background: none; cursor: pointer;
  border: 1px solid var(--rule); color: var(--muted);
  padding: 4px 9px; border-radius: var(--radius);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-2); }

/* ---------- masthead controls -------------------------------------------- */
.sitenav { display: flex; align-items: center; gap: var(--space-2); }
.sitenav-link {
  font-family: var(--font-mono); font-size: var(--size-micro); letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); text-decoration: none;
  padding: 4px 9px; border-radius: var(--radius); border: 1px solid transparent;
}
.sitenav-link:hover { color: var(--ink); border-color: var(--rule); }

/* ---------- page frame ---------------------------------------------------- */
/* One column, and everything in it spans the page. An experiment page is a
   sequence of titled sections — prose, a table, a chart, a run panel — and they
   all share one left edge and one right edge. */
main { max-width: var(--page-max); margin: 0 auto; padding: 0 var(--page-pad) 96px; }
.measure { max-width: var(--measure); }


/* ---------- headings ----------------------------------------------------- */
.title {
  font-size: var(--size-title); line-height: 1.14; font-weight: 400;
  letter-spacing: -.012em; margin: var(--space-6) 0 10px;
  text-wrap: balance;
}
.standfirst {
  font-size: var(--size-stand); line-height: 1.5; color: var(--ink-2);
  margin: 0 0 var(--space-4); font-style: italic;
}
/* The landing hero: a masthead rather than running prose, so its title is held
   narrower than the page on purpose, to read as a headline. */
.hero { margin-bottom: var(--space-6); }
.hero .title { max-width: 52rem; margin-bottom: var(--space-3); }
/* The subtitle reads as the collection's caption rather than a third line of the
   headline, so it gets its own band: centred, ruled above and below, spanning the page.
   Generous space above is what keeps the rules from looking like a table. */
.hero-band {
  max-width: none; text-align: center;
  margin: var(--space-6) 0 0; padding: var(--space-3) 0;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.bigq {
  font-size: var(--size-stand); line-height: 1.4; color: var(--ink);
  margin: 0 0 var(--space-2); max-width: 46rem; text-wrap: balance;
}

h2 {
  font-family: var(--font-mono);
  font-size: var(--size-label); letter-spacing: var(--track-label);
  text-transform: uppercase; font-weight: 600; color: var(--muted);
  margin: var(--space-6) 0 var(--space-1); padding-bottom: 7px;
  border-bottom: 1px solid var(--rule);
}
h3 { font-size: var(--size-h3); font-weight: 600; margin: var(--space-4) 0 var(--space-1); }
p { margin: 0 0 15px; }

.prose > :first-child { margin-top: 0; }
.prose h2 {
  /* Prose comes from Markdown, where ## is a subsection rather than a rail. */
  font-family: var(--font-body); font-size: var(--size-h3); text-transform: none;
  letter-spacing: 0; color: var(--ink); border-bottom: 0;
  margin: var(--space-4) 0 var(--space-1); padding: 0;
}
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 15px; }
.prose li { margin-bottom: 5px; }
.prose em { font-style: italic; }
.prose code { font-size: .92em; }

/* The stimulus itself, quoted on the page that describes it: the sketch a subject
   reads before it answers. Not a footnote — a footnote is a quiet aside, and this
   is the text the whole experiment turns on. Ruled rather than boxed, so it reads
   as a quotation and not as another table. */
.stimulus {
  margin: var(--space-4) 0; padding-left: var(--space-4);
  border-left: 2px solid var(--rule); color: var(--ink-2);
  max-width: var(--measure);
}


/* ---------- the about page ----------------------------------------------- */
/* The one page that is nothing but prose, so its `##` are the page's sections
   rather than subsections of one: the same rails every other page uses, spanning
   the page, with the text under them spanning it too. The doubled class beats
   `.prose h2` on specificity rather than on source order. */
.prose.about h2 {
  font-family: var(--font-mono);
  font-size: var(--size-label); letter-spacing: var(--track-label);
  text-transform: uppercase; font-weight: 600; color: var(--muted);
  margin: var(--space-6) 0 var(--space-1); padding-bottom: 7px;
  border-bottom: 1px solid var(--rule);
}
/* Full width, like every other page's prose: the rails span the page, and so does
   the text under them. */
.about h2 + p { margin-top: var(--space-3); }

/* ---------- the register (landing) --------------------------------------- */
.paradigm-head {
  display: flex; align-items: baseline; gap: var(--space-3);
  margin: 40px 0 0; padding-bottom: var(--space-2); border-bottom: 2px solid var(--ink);
}
.paradigm-head h3 { margin: 0; font-size: 21px; }

.entry {
  display: grid; grid-template-columns: 2.2rem 1fr 13rem; gap: 0 24px;
  width: 100%; text-align: left; align-items: start;
  padding: 20px 0; border: 0; border-bottom: 1px solid var(--rule-soft);
  background: none; font: inherit; color: inherit; cursor: pointer; text-decoration: none;
}
.entry:hover { background: var(--surface); }
.entry:hover .entry-name { color: var(--accent); }
.entry-idx { font-family: var(--font-mono); font-size: 12.5px; color: var(--faint); padding-top: 5px; }
.entry-name { display: block; font-size: 20px; font-weight: 600; margin-bottom: 3px; }
.entry-desc { margin: 0; font-size: 15px; color: var(--muted); max-width: 32rem; }
.entry-cite {
  text-align: right; font-family: var(--font-mono); font-size: 12.5px;
  color: var(--muted); line-height: 1.6; padding-top: 4px;
}
@media (max-width: 760px) {
  .entry { grid-template-columns: 1.8rem 1fr; }
  .entry-cite { grid-column: 2; text-align: left; margin-top: var(--space-2); padding-top: 0; }
}

/* ---------- tables ------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
caption {
  text-align: left; font-size: var(--size-label); color: var(--muted);
  padding-bottom: 9px; font-style: italic;
}
th {
  font-family: var(--font-mono); text-align: left; font-weight: 600;
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--ink); padding: 0 12px 6px 0; white-space: nowrap;
}
th.num, td.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
/* The row the design marks — the certain option, the conjunction. One name,
   because what is marked differs by paradigm but the mark does not. */
tr.is-marked td { background: var(--accent-soft); }
.tag {
  font-family: var(--font-mono); font-size: var(--size-micro); letter-spacing: .07em;
  text-transform: uppercase; color: var(--accent);
}

/* ---------- figures ------------------------------------------------------ */
figure { margin: var(--space-4) 0 0; }
figcaption {
  font-size: var(--size-fine); color: var(--muted); margin-top: var(--space-3);
  line-height: 1.5;
}
figcaption b { color: var(--ink-2); }

.chart { position: relative; }
/* Must span exactly the bar track — label gutter on the left, value column on the
   right — or the reference line lands somewhere that is not the value it claims. */
.chart-grid {
  position: absolute; inset: 0 var(--value-col) 22px var(--label-col);
  pointer-events: none;
}
.gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--rule-soft); left: var(--at); }
.baseline-rule {
  position: absolute; top: -4px; bottom: 0; width: 0; left: var(--at);
  border-left: 1px dashed var(--baseline);
}
.baseline-flag {
  position: absolute; top: -22px; left: 0; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: var(--size-micro); letter-spacing: .05em;
  color: var(--baseline); white-space: nowrap;
}

.bar-row, .stack-row {
  display: grid; grid-template-columns: var(--label-col) 1fr var(--value-col);
  align-items: center; height: var(--row-height); position: relative;
}
.stack-row { height: 32px; }
.bar-row:hover, .stack-row:hover { background: var(--surface); }
.bar-row:hover .bar-name, .stack-row:hover .bar-name { color: var(--accent); }
.bar-name {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2);
  padding-right: var(--space-3); text-align: right;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-track { position: relative; height: 100%; display: flex; align-items: center; }
.bar-fill {
  height: var(--bar-height); width: var(--w); min-width: 1px;
  background: var(--accent); border-radius: 0 var(--radius-bar) var(--radius-bar) 0;
}
/* A zero is not a very short bar — it is a tick, so it cannot be misread. */
.bar-fill.is-zero { width: 2px; background: var(--neutral-mark); border-radius: 0; }
.bar-val {
  font-family: var(--font-mono); font-size: 12.5px; text-align: right;
  color: var(--ink); font-variant-numeric: tabular-nums; padding-left: 10px;
}
.bar-axis {
  display: grid; grid-template-columns: var(--label-col) 1fr var(--value-col);
  height: 22px; margin-top: var(--space-1); border-top: 1px solid var(--ink);
}
.axis-ticks { position: relative; }
.axis-tick {
  position: absolute; top: 4px; left: var(--at); transform: translateX(-50%);
  font-family: var(--font-mono); font-size: var(--size-micro); color: var(--faint);
}


/* ---------- stacked distribution ----------------------------------------- */
.legend { display: flex; gap: var(--space-3) 16px; flex-wrap: wrap; margin: 0 0 var(--space-3); }
.legend span {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--muted);
}
/* The same key, carrying what each part means. One row per type: the name in the
   chart's own mono, the sentence in the page's reading face. */
.legend-defs { display: block; margin: 0 0 var(--space-4); }
.legend-defs > div {
  display: grid; grid-template-columns: 13rem 1fr; gap: 0 var(--space-3);
  align-items: baseline; padding: 5px 0;
}
.legend-defs dt {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--muted);
}
.legend-defs dd { margin: 0; font-size: var(--size-small); color: var(--ink-2); }
.legend-defs .swatch { position: relative; top: 1px; }

@media (max-width: 620px) {
  .legend-defs > div { grid-template-columns: 1fr; gap: 2px; }
}

.swatch { width: 11px; height: 11px; border-radius: 2px; flex: 0 0 auto; }
.swatch.s1 { background: var(--step-1); }
.swatch.s2 { background: var(--step-2); }
.swatch.s3 { background: var(--step-3); }
.swatch.s4 { background: var(--step-4); }
.swatch.s0, .seg.s0 {
  background: var(--step-0);
  background-image: repeating-linear-gradient(45deg, transparent 0 2px, var(--hatch) 2px 3.5px);
}
.stack { display: flex; height: 15px; gap: 2px; }
.seg { position: relative; min-width: 2px; flex: var(--f); }
.seg:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.seg:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.seg.s1 { background: var(--step-1); }
.seg.s2 { background: var(--step-2); }
.seg.s3 { background: var(--step-3); }
.seg.s4 { background: var(--step-4); }

/* ---------- tooltips ----------------------------------------------------- */
.tip {
  position: absolute; z-index: 9; bottom: 100%; left: 50%; transform: translateX(-50%);
  margin-bottom: var(--space-1);
  background: var(--ink); color: var(--ground);
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.45;
  padding: 6px 9px; border-radius: var(--radius); white-space: nowrap;
  opacity: 0; transition: opacity .12s; pointer-events: none;
}
.seg:hover .tip { opacity: 1; }
.bar-row .tip { left: var(--label-col); transform: none; }
.bar-row:hover .tip { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .tip { transition: none; } }

/* ---------- footnotes and references ------------------------------------- */
.footnote { font-size: var(--size-label); color: var(--faint); margin-top: var(--space-3); font-style: italic; }

.refs { font-size: var(--size-small); line-height: 1.55; margin: 0; padding-left: 0; list-style: none; }
.refs li { margin-bottom: 11px; }
.refs .authors { font-variant: small-caps; letter-spacing: .02em; color: var(--ink); }
.refs .note { display: block; color: var(--muted); font-size: var(--size-fine); }
.refs em { font-style: italic; }

/* ---------- prompt disclosure -------------------------------------------- */
.prompt {
  border: 1px solid var(--rule); border-radius: var(--radius);
  margin: var(--space-4) 0 0; background: var(--surface);
}
.prompt summary {
  cursor: pointer; padding: 11px 15px;
  font-family: var(--font-mono); font-size: var(--size-label);
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.prompt summary:hover { color: var(--ink); }
.prompt[open] summary { border-bottom: 1px solid var(--rule); }
.prompt-body { padding: var(--space-3) 15px; }
.prompt-label {
  font-family: var(--font-mono); font-size: var(--size-micro); letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); margin: 0 0 var(--space-1);
}
.prompt-body pre {
  margin: 0 0 var(--space-4); padding: 0; font-family: var(--font-mono);
  font-size: var(--size-label); line-height: 1.65; white-space: pre-wrap;
  overflow-x: auto; color: var(--ink-2);
}
.prompt-body > div:last-child pre { margin-bottom: 0; }

/* ---------- run panel ---------------------------------------------------- */
.runbox {
  border: 1px solid var(--ink); border-radius: var(--radius);
  margin-top: var(--space-4); background: var(--surface);
}
.runbox-head {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 15px 18px; flex-wrap: wrap; border-bottom: 1px solid var(--rule);
}
.btn {
  font-family: var(--font-mono); font-size: var(--size-label); letter-spacing: .07em;
  text-transform: uppercase; border: 0; cursor: pointer;
  background: var(--ink); color: var(--ground);
  padding: 10px 20px; border-radius: var(--radius);
}
.btn:hover { background: var(--accent); color: var(--on-accent); }
.btn[disabled] { opacity: .45; cursor: default; background: var(--ink); }
.btn.ghost {
  background: none; border: 1px solid var(--rule); color: var(--muted);
  padding: 9px 14px; font-size: 12px;
}
.btn.ghost:hover { background: none; color: var(--ink); border-color: var(--ink); }
/* Which LLM to watch. Set in the label voice, like every other control here. */
.picker { display: flex; align-items: center; gap: var(--space-2); }
.picker span {
  font-family: var(--font-mono); font-size: var(--size-micro); letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.picker select {
  font-family: var(--font-mono); font-size: 12.5px; color: var(--ink);
  background: var(--ground); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 8px 10px; cursor: pointer; max-width: 16rem;
}
.picker select:hover { border-color: var(--ink-2); }

.cost { font-size: var(--size-label); color: var(--muted); line-height: 1.45; }
.cost b { color: var(--ink-2); font-weight: 600; }

.runlog summary {
  cursor: pointer; padding: 11px 18px;
  font-family: var(--font-mono); font-size: var(--size-label);
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.runlog summary:hover { color: var(--ink); }
.runlog[open] summary { border-bottom: 1px solid var(--rule); }
.stream { padding: var(--space-1) 18px var(--space-3); min-height: 84px; }
.stream-idle {
  color: var(--faint); font-size: var(--size-small); font-style: italic;
  margin: 0; padding: 18px;
}
.ev {
  display: grid; grid-template-columns: 4.2rem 1fr; gap: 0 var(--space-3);
  padding: 9px 0; border-bottom: 1px solid var(--rule-soft); font-size: var(--size-small);
}
.ev:last-child { border-bottom: 0; }
.ev-k {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--faint);
  text-transform: uppercase; letter-spacing: .06em; padding-top: 3px;
}
.ev-body { min-width: 0; }
.ev-body .who {
  display: block; font-family: var(--font-mono); font-size: 11.5px;
  letter-spacing: .05em; text-transform: uppercase; color: var(--accent); margin-bottom: 1px;
}
.ev-body .pick { font-weight: 600; }
.ev-body .pick .lab { font-family: var(--font-mono); color: var(--accent); }
.ev-body .pick .tag { margin-left: var(--space-2); }
.ev-why { color: var(--muted); font-size: var(--size-small); font-style: italic; }
.ev.is-verdict .ev-body { font-family: var(--font-mono); font-size: var(--size-label); color: var(--baseline); }
.ev.is-final .ev-body { font-family: var(--font-mono); font-size: var(--size-label); color: var(--ink); }
.ev.is-error .ev-body { color: var(--baseline); }

.cursor {
  display: inline-block; width: 7px; height: 15px; vertical-align: -2px;
  background: var(--accent); animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .cursor { animation: none; } }

/* ---------- foot navigation ---------------------------------------------- */
.others { margin-top: var(--space-6); }
.others ul { list-style: none; padding: 0; margin: 0; }
.others li { border-bottom: 1px solid var(--rule-soft); }
.others a {
  display: flex; gap: var(--space-3); align-items: baseline; justify-content: space-between;
  padding: 12px 0; text-decoration: none; color: var(--ink);
}
.others a:hover .others-name { color: var(--accent); }
.others-name { font-weight: 600; }

/* ---------- design page -------------------------------------------------- */
.design-sec { margin-bottom: var(--space-6); }
.swatch-grid { display: flex; flex-wrap: wrap; gap: var(--space-3); margin: var(--space-3) 0; }
.swatch-chip { width: 96px; }
.swatch-chip i {
  display: block; height: 44px; border-radius: var(--radius); border: 1px solid var(--rule);
}
.swatch-chip span {
  display: block; font-family: var(--font-mono); font-size: 10.5px;
  color: var(--muted); margin-top: 5px; word-break: break-all;
}
