/* The story page: a long read with wider figures, in the atlas's visual language. */
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body { font-size: 16px; line-height: 1.6; }
.mono { font-family: var(--mono); font-size: .92em; }
a { color: var(--accent); }
a:focus-visible, summary:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; padding: 10px max(16px, env(safe-area-inset-left, 0px)); background: var(--surface); border-bottom: 1px solid var(--line); font-size: 14px; }
.brand { font-weight: 600; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topbar-links { display: flex; gap: 16px; flex: 1; min-width: 0; }
.topbar-links a { color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.topbar-links a:hover { color: var(--ink); text-decoration: underline; }
.atlas-link { margin-left: auto; white-space: nowrap; color: var(--accent); font-weight: 500; text-decoration: none; }
.atlas-link:hover { text-decoration: underline; }
@media (max-width: 860px) { .topbar-links { display: none; } }

/* Layout */
main { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.prose { max-width: 68ch; }
.prose p { margin: 0 0 14px; }
.chapter { padding: 44px 0 36px; border-top: 1px solid var(--line); display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
.kicker, .eyebrow { display: block; margin: 0 0 8px; font: 500 12px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
h1, h2, h3 { text-wrap: balance; }
h2 { margin: 0 0 12px; font-size: clamp(24px, 3.4vw, 32px); line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
.subhead { margin: 10px 0 8px; font-size: 19px; font-weight: 600; }

/* Hero */
.hero { padding: 56px 0 44px; }
.hero h1 { margin: 0 0 16px; max-width: 22ch; font-size: clamp(32px, 5.4vw, 54px); line-height: 1.08; font-weight: 600; letter-spacing: -.02em; }
.lede { margin: 0 0 28px; max-width: 62ch; font-size: clamp(17px, 2vw, 19px); color: var(--ink-2); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.tile { display: grid; gap: 4px; align-content: start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.tile b { font: 500 26px/1.15 var(--mono); }
.tile span { color: var(--ink-2); font-size: 14px; line-height: 1.4; }
.fineprint { margin: 14px 0 0; color: var(--muted); font-size: 13.5px; }

/* Figures */
.figure { margin: 0; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.figure.bare { background: var(--surface); }
.fig-head { padding: 14px 16px 4px; }
.fig-head h3 { margin: 0 0 2px; font-size: 16px; font-weight: 600; }
.fig-head p { margin: 0; max-width: 78ch; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.fig-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 16px 0; }
.fig-note { margin: 0; padding: 4px 16px 12px; max-width: 86ch; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }
.fig-foot { margin: 0; padding: 6px 16px 12px; font-size: 13.5px; }
figcaption:not(.fig-head) { padding: 12px 16px 14px; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.plot { padding: 8px 16px 0; }
.plot svg, .atlas-frame { display: block; }
svg text { fill: var(--ink); }
.atlas-frame { width: 100%; border: 0; background: transparent; }
.scroll-x { overflow-x: auto; }

/* Legends and controls */
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 16px 12px; font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.key-box { display: inline-block; width: 11px; height: 11px; border-radius: 3px; flex: none; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.on { background: var(--seq); }
.dot.off { border: 1.5px solid var(--muted); }
.tick { display: inline-block; width: 2px; height: 14px; background: var(--ink); flex: none; }
.key-shape { display: inline-block; width: 12px; height: 12px; flex: none; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 13.5px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn { margin-left: auto; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 5px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.btn:hover { background: var(--raise); }
details.data { border-top: 1px solid var(--grid); padding: 8px 16px; font-size: 13.5px; }
details.data summary { cursor: pointer; color: var(--ink-2); }
details.data[open] summary { margin-bottom: 6px; }

/* Chart text */
.axis text, .axis-label { font: 12px var(--mono); fill: var(--ink-2); }
.axis line, .axis path { stroke: var(--line); }
.grid line { stroke: var(--grid); }
.row-name { font: 500 13.5px var(--sans); }
.row-val { font: 12px var(--mono); fill: var(--ink-2); }
.lane-name { font: 500 13px var(--sans); }
.host-label { font: 11.5px var(--mono); paint-order: stroke; stroke: var(--surface); stroke-width: 3.5px; stroke-linejoin: round; }
.met-label { font: 600 12px var(--sans); }
.hit { fill: transparent; cursor: pointer; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.4; }
.data-table th { padding: 10px 14px; text-align: left; font: 500 12px var(--sans); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 9px 14px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table td.num, .data-table th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table th.num { font-family: var(--sans); }
.data-table tr.hl td { background: var(--raise); font-weight: 500; }

/* Setup diagram */
.setup-grid { display: grid; grid-template-columns: 1fr 76px 1.25fr 76px 1fr; gap: 12px 6px; padding: 16px; align-items: stretch; }
.setup-grid h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.setup-grid ul { margin: 0; padding-left: 16px; font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.setup-grid p { margin: 0; font-size: 14px; color: var(--ink-2); line-height: 1.45; }
.setup-agent, .setup-web, .setup-harness { padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--bg); }
.setup-harness { grid-column: 1 / -1; border-style: dashed; }
.setup-sites { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 10px; font-size: 12px; }
.setup-sites span { padding: 1px 7px; border-radius: 999px; background: var(--raise); }
.setup-arrow { display: grid; align-content: center; justify-items: center; gap: 2px; font: 11px/1.2 var(--mono); color: var(--muted); text-align: center; }
.setup-arrow i { position: relative; display: block; width: 100%; height: 0; border-top: 2px solid var(--edge); }
.setup-arrow i::after { content: ""; position: absolute; right: -1px; top: -6px; border-left: 8px solid var(--edge); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.setup-arrow.reverse i::after { right: auto; left: -1px; border-left: 0; border-right: 8px solid var(--edge); }
@media (max-width: 760px) {
  .setup-grid { grid-template-columns: minmax(0, 1fr); }
  .setup-arrow { display: none; }
}

/* Site bars */
.sites-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px 32px; padding: 12px 16px 4px; }
.sites-grid h4 { margin: 0 0 8px; font-size: 14px; font-weight: 600; }
.sites-grid h4 span { font-weight: 400; color: var(--muted); }
.site-row { display: grid; grid-template-columns: minmax(0, 7.8em) 1fr 5.4em; gap: 8px; align-items: center; padding: 3px 0; font-size: 13px; line-height: 1.3; }
.site-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.site-row .track { position: relative; height: 10px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.site-row .track span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--seq); border-radius: 0 4px 4px 0; }
.site-row .track span.tried { opacity: .3; }
.site-row .val { text-align: right; font: 12px var(--mono); color: var(--ink-2); white-space: nowrap; }

/* Simulated-web rows */
.sim { padding: 8px 16px 2px; }
.sim-row { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 3.4em minmax(0, 6em); gap: 4px 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 14px; line-height: 1.35; }
.sim-row:last-child { border-bottom: 0; }
.sim-row small { display: block; color: var(--muted); font-size: 12.5px; }
.sim-dots { display: flex; flex-wrap: wrap; gap: 4px; }
.sim-rate { font: 13px var(--mono); text-align: right; }
.sim-ex { color: var(--muted); font-size: 12.5px; }
@media (max-width: 620px) {
  .sim-row { grid-template-columns: minmax(0, 1fr) 3.4em; }
  .sim-row > :first-child, .sim-ex { grid-column: 1 / -1; }
  .sim-rate { grid-column: 2; grid-row: 2; }
}

/* Race table */
.race td { min-width: 150px; }
.race td:first-child { min-width: 80px; font-weight: 500; }
.outcome { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.outcome + .arrow { margin: 0 2px; color: var(--muted); }
.outcome small { font: 12px var(--mono); color: var(--ink-2); }
.seq { display: flex; flex-wrap: wrap; gap: 3px 6px; align-items: center; }
.glyph { display: inline-block; width: 11px; height: 11px; flex: none; }
.glyph.seekers { background: var(--research); border-radius: 50%; }
.glyph.observer { background: var(--post); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.glyph.no_winner { border: 1.5px solid var(--muted); border-radius: 50%; }

/* Split-task bars */
.split { padding: 10px 16px 2px; display: grid; gap: 4px; }
.split h4 { margin: 10px 0 2px; font-size: 14px; font-weight: 600; }
.split h4:first-child { margin-top: 0; }
.split-row { display: grid; grid-template-columns: minmax(0, 12.5em) 1fr; gap: 3px 12px; align-items: center; padding: 4px 0; font-size: 13.5px; line-height: 1.3; }
.split-row small { display: block; color: var(--muted); font-size: 12px; }
.split-bars { display: grid; gap: 2px; }
.split-bar { display: grid; grid-template-columns: 1fr 3.4em; gap: 8px; align-items: center; }
.split-bar .track { height: 8px; background: var(--grid); border-radius: 4px; overflow: hidden; }
.split-bar .track span { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.split-bar .val { text-align: right; font: 12px var(--mono); color: var(--ink-2); }
@media (max-width: 560px) { .split-row { grid-template-columns: minmax(0, 1fr); } }

/* Quote */
.quote { margin: 0; padding: 4px 0 4px 18px; max-width: 64ch; border-left: 3px solid var(--post); }
.quote p { margin: 0 0 6px; font-size: 18px; line-height: 1.45; }
.quote cite { font-style: normal; font-size: 14px; color: var(--ink-2); }

/* Atlas card */
.atlas-card { display: grid; gap: 6px; padding: 26px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); text-decoration: none; }
.atlas-card:hover { border-color: var(--accent); }
.atlas-card .eyebrow { margin: 0; }
.atlas-card strong { font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.atlas-card > span:not(.eyebrow):not(.go) { max-width: 70ch; color: var(--ink-2); }
.atlas-card .go { color: var(--accent); font-weight: 500; }

/* Methods */
.limits { margin: 0 0 8px; padding-left: 18px; display: grid; gap: 9px; }
.site-foot { max-width: 1120px; margin: 36px auto 0; padding: 18px 16px 36px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }
.site-foot p { margin: 0; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
