@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/archivo-latin.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --paper: #fbfbf9;
  --ink: #111111;
  --muted: #4b4b47;
  --rule: #d6d6d0;
  --blue: #0057e7;
  --violet: #7a3fb0;
  --amber: #b86f00;
  --ok: #0a7a3d;
  --bad: #c4321f;
  --sans: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --rail: clamp(3.25rem, 7vw, 6rem);
  --line: 14px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --stn: 1.4rem;
}

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

html {
  scroll-behavior: smooth;
  scrollbar-color: var(--ink) var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

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

a { color: inherit; text-underline-offset: 0.22em; text-decoration-thickness: 2px; }
a:hover { color: var(--blue); }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute; left: var(--gutter); top: -4rem;
  background: var(--ink); color: var(--paper);
  padding: 0.75rem 1rem; z-index: 10; font-weight: 700;
}
.skip:focus { top: 0.75rem; }
.skip:hover { color: var(--paper); }

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Header */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  padding: 1.25rem var(--gutter);
}
.mark {
  display: inline-flex; align-items: center; gap: 0.65rem;
  font-weight: 800; font-size: 1.2rem; letter-spacing: -0.01em;
  text-decoration: none; color: var(--ink);
}
.top nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; font-weight: 600; font-size: 0.95rem; }
.top nav a { text-decoration: none; padding: 0.35rem 0; border-bottom: 3px solid transparent; }
.top nav a:hover { border-bottom-color: var(--blue); color: var(--ink); }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.45fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center;
  padding: clamp(1rem, 3vw, 2.5rem) var(--gutter) clamp(3rem, 7vw, 6rem);
  min-height: min(46rem, calc(100svh - 5rem));
}
.hero-copy { max-width: 31rem; }
h1 {
  margin: 0;
  font-weight: 800;
  font-size: clamp(2.3rem, 5.4vw, 4.1rem);
  line-height: 1.02;
  letter-spacing: -0.028em;
  text-wrap: balance;
}
.lede { margin: 1.5rem 0 2rem; font-size: 1.2rem; line-height: 1.5; max-width: 28rem; text-wrap: pretty; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.75rem; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  background: var(--ink); color: var(--paper);
  font: 700 1.05rem/1 var(--sans);
  padding: 1.1rem 1.75rem; border-radius: 2px;
  transition: background-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.btn:hover { background: var(--blue); }
.btn:active { transform: translateY(1px); }
.btn[aria-disabled="true"] { background: var(--muted); cursor: progress; }
.quiet { font-weight: 700; }

/* Map */
.map { margin: 0; min-width: 0; }
.map-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem 1rem; margin-bottom: 0.5rem; }
.machine { font: 500 0.85rem var(--mono); color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-weight: 700; font-size: 0.92rem;
  border: 2px solid var(--ink); border-radius: 999px; padding: 0.2rem 0.75rem 0.2rem 0.5rem;
}
.chip[data-state="running"] { border-color: var(--blue); color: var(--blue); }
.chip[data-state="done"] { border-color: var(--ok); color: var(--ok); }
#map { display: block; width: 100%; height: auto; overflow: visible; }

.announce { min-height: 1.6em; margin: 0.25rem 0 0.5rem; font-weight: 600; font-size: 1.0625rem; }
figcaption { color: var(--muted); font-size: 0.92rem; max-width: 40rem; }

.events { margin-top: 0.75rem; font-size: 0.9rem; }
.events summary { cursor: pointer; font-weight: 700; width: max-content; }
#log { list-style: none; margin: 0.75rem 0 0; padding: 0; font: 400 0.84rem/1.5 var(--mono); font-variant-numeric: tabular-nums; border: 2px solid var(--ink); background: #fff; }
#log li { display: grid; grid-template-columns: 2.5rem 4.6rem 1fr; gap: 0.5rem; padding: 0.3rem 0.75rem; border-top: 1px solid var(--rule); color: var(--muted); }
#log li:first-child { border-top: 0; }
#log li[data-played] { color: var(--ink); }
#log li[data-failed] { color: var(--bad); font-weight: 700; }

/* map internals */
.seg { fill: none; stroke-width: var(--line); stroke-linecap: round; stroke-linejoin: round; }
.seg--blue { stroke: var(--blue); }
.seg--violet { stroke: var(--violet); }
.seg--amber { stroke: var(--amber); }
.seg--catch { stroke: var(--ink); stroke-dasharray: 0.1 22; stroke-dashoffset: -16; }
.station-ring { fill: #fff; stroke: var(--ink); stroke-width: 5; }
.station--hub .station-ring { stroke-width: 6; }
.station-core { fill: none; stroke: var(--ink); stroke-width: 3; }
.station-icon { fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.station[data-state="done"] .station-ring { fill: var(--ok); stroke: var(--ink); }
.station[data-state="failed"] .station-ring { fill: var(--bad); stroke: var(--ink); }
.station[data-state="active"] .station-ring { fill: var(--ink); }
.station[data-state="done"] .icon-check, .station[data-state="failed"] .icon-cross { opacity: 1; }
.station[data-state="active"] .station-core { stroke: #fff; }
.station-name { font: 800 20px var(--sans); fill: var(--ink); }
.station-kind { font: 500 16px var(--mono); fill: var(--muted); }
.marker-body { fill: var(--ink); stroke: var(--paper); stroke-width: 3; }
.marker--branch .marker-body { fill: var(--amber); }
.marker-pulse { fill: none; stroke: var(--ink); stroke-width: 2; opacity: 0.5; transform-box: fill-box; transform-origin: center; animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { from { transform: scale(0.6); opacity: 0.7; } to { transform: scale(1.8); opacity: 0; } }

/* Stops: the vertical line */
.stops {
  position: relative;
  padding: 0 var(--gutter) 2rem calc(var(--gutter) + var(--rail));
}
.stop { position: relative; max-width: 64rem; padding: 0 0 clamp(4rem, 8vw, 6.5rem); }
.stop h2 {
  position: relative;
  margin: 0 0 1rem; font-weight: 800; font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  line-height: 1.1; letter-spacing: -0.02em; text-wrap: balance;
}
.stop::before {
  content: ""; position: absolute; z-index: 0;
  left: calc(-1 * var(--rail) / 2 - var(--line) / 2);
  top: var(--stn); bottom: calc(-1 * var(--stn));
  width: var(--line); border-radius: var(--line); background: var(--seg, var(--blue));
}
#run { --seg: var(--blue); }
#evidence { --seg: var(--violet); }
#design { --seg: var(--amber); }
#limits::before { width: 0; background: none; border-left: var(--line) dotted var(--ink); border-radius: 0; }
.terminus::before { display: none; }
.stop h2::before {
  z-index: 1;
  content: ""; position: absolute;
  left: calc(-1 * var(--rail) / 2 - 15px); top: 0.18em;
  width: 30px; height: 30px; border-radius: 50%;
  background: #fff; border: 6px solid var(--ink);
}
.stop-head p { max-width: 34rem; text-wrap: pretty; }
.stop-body > :first-child { margin-top: 0; }
.fine { color: var(--muted); font-size: 0.95rem; max-width: 38rem; }

/* Tickets: code */
.ticket { margin: 1.5rem 0; border: 2px solid var(--ink); background: #fff; max-width: 46rem; }
.ticket-head { margin: 0; padding: 0.4rem 1rem; border-bottom: 2px solid var(--ink); background: var(--ink); color: var(--paper); font: 700 0.82rem var(--sans); letter-spacing: 0.04em; text-transform: uppercase; }
pre { margin: 0; padding: 1rem 1.1rem; overflow-x: auto; font: 400 0.9rem/1.6 var(--mono); tab-size: 4; }
code { font-family: var(--mono); font-size: 0.9em; }
.stop p code, td code { background: #efefea; padding: 0.1em 0.35em; border-radius: 2px; }
pre code { background: none; padding: 0; font-size: inherit; }

/* Evidence board */
.board { width: 100%; max-width: 64rem; border-collapse: collapse; margin-top: 1.5rem; border: 2px solid var(--ink); background: #fff; font-variant-numeric: tabular-nums; }
.board th, .board td { text-align: left; vertical-align: top; padding: 1rem 1.1rem; border-top: 2px solid var(--ink); }
.board thead th { border-top: 0; background: var(--ink); color: var(--paper); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.55rem 1.1rem; }
.board tbody th { font-weight: 800; white-space: nowrap; }
.board td:nth-child(2) { white-space: nowrap; }
.board td:nth-child(3) { color: var(--muted); font-size: 0.95rem; }
.board strong { font-weight: 800; }
.dot { display: inline-block; width: 0.8em; height: 0.8em; border-radius: 50%; background: var(--c); margin-right: 0.6em; border: 2px solid var(--ink); vertical-align: -0.05em; }

/* Throughput bars */
.bars { margin: 1.75rem 0 0; max-width: 64rem; border: 2px solid var(--ink); background: #fff; padding: 1rem 1.1rem 1.25rem; }
.bars figcaption { color: var(--muted); font-size: 0.95rem; }
.bars-grid { margin-top: 0.75rem; }
.bars-group { margin: 1rem 0 0.4rem; font-weight: 800; }
.bar { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) 3.5rem; align-items: center; gap: 0.75rem; margin: 0.35rem 0; font-variant-numeric: tabular-nums; }
.bar-label { color: var(--muted); font-size: 0.95rem; }
.bar-fill { display: block; height: 1.1rem; width: var(--w); background: var(--c); border: 2px solid var(--ink); }
.bar-value { font: 700 0.95rem var(--mono); }
@media (max-width: 560px) { .bar { grid-template-columns: 5rem minmax(0, 1fr) 2.75rem; gap: 0.5rem; } }

/* Design stations */
.stations { list-style: none; margin: 2rem 0 1.5rem; padding: 0 0 0 2rem; border-left: 6px solid var(--violet); max-width: 44rem; }
.stations li { position: relative; padding: 0 0 1.75rem; }
.stations li:last-child { padding-bottom: 0; }
.stations li::before { content: ""; position: absolute; left: calc(-2rem - 14px); top: 0.3em; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 5px solid var(--ink); }
.stations h3 { margin: 0 0 0.25rem; font-size: 1.2rem; font-weight: 800; letter-spacing: -0.01em; }
.stations p { margin: 0; max-width: 36rem; text-wrap: pretty; }
.links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; font-weight: 700; }

/* Notices */
.notices { list-style: none; margin: 1.5rem 0 0; padding: 0; max-width: 44rem; border: 2px solid var(--ink); background: #fff; }
.notices li { padding: 0.9rem 1.1rem; border-top: 2px solid var(--ink); }
.notices li:first-child { border-top: 0; }

.foot { border-top: 2px solid var(--ink); padding: 2rem var(--gutter) 3rem; }
.foot p { margin: 0 0 0.75rem; max-width: 46rem; }
.exit { display: inline-block; border: 2px solid var(--ink); padding: 1rem 1.6rem; font-weight: 800; text-decoration: none; background: var(--paper); transition: background-color 0.2s var(--ease), color 0.2s var(--ease); }
.exit:hover { background: var(--ink); color: var(--paper); }
.terminus { padding-bottom: clamp(2.5rem, 5vw, 4rem); }
.terminus h2::before { width: 40px; height: 40px; left: calc(-1 * var(--rail) / 2 - 20px); top: 0.08em; background: radial-gradient(circle, var(--ink) 0 7px, #fff 8px); border-width: 6px; }


/* Wide screens: heading and intro on the left, the content fills the rest of the width. */
@media (min-width: 1240px) {
  .stop {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(15rem, 0.7fr) minmax(0, 1.6fr);
    column-gap: clamp(2rem, 5vw, 5rem);
    align-items: start;
  }
  .stop-head { position: sticky; top: 1.5rem; }
  .terminus .stop-head { grid-column: 1 / -1; position: static; }
  .ticket, .board, .stations, .notices { max-width: none; }
  .ticket:first-child { margin-top: 0; }
  .stations { margin-top: 0; }
}

/* Narrow screens */
@media (max-width: 1000px) {
  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; padding-top: 0.5rem; }
  .hero-copy { max-width: none; }
  .map { max-width: 34rem; }
}
@media (max-width: 860px) {
  .board, .board tbody, .board tr, .board th, .board td { display: block; }
  .board thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .board tr { border-top: 2px solid var(--ink); padding: 0.75rem 1rem; }
  .board tr:first-child { border-top: 0; }
  .board th, .board td { border: 0; padding: 0.15rem 0; white-space: normal !important; }
}
@media (max-width: 560px) {
  .lede { margin: 0.9rem 0 1.25rem; font-size: 1.0625rem; }
  .hero { gap: 1.25rem; padding-bottom: 2.5rem; }
  .top { flex-direction: column; align-items: flex-start; gap: 0.35rem; padding-bottom: 0.5rem; }
  .top nav { gap: 0.25rem 1rem; }
  .stop h2::before { width: 24px; height: 24px; left: calc(-1 * var(--rail) / 2 - 12px); border-width: 5px; top: 0.12em; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn, .btn:active { transition: none; transform: none; }
  .marker-pulse { animation: none; opacity: 0.4; }
}

@media (forced-colors: active) {
  .stops::before { background: LinkText; }
  .seg { stroke: CanvasText; }
}

/* Studio screenshot in the "Run it locally" section */
.shot { margin: 1rem 0 0; border: 2px solid var(--ink); background: #fff; max-width: 46rem; }
.shot img { display: block; width: 100%; max-width: 100%; height: auto; border-bottom: 2px solid var(--ink); }
.shot figcaption { padding: 0.6rem 1rem; font-size: 0.9375rem; }

/* Crash replay: second figure in the hero, same chip and event list pattern as the first map */
.btn--outline { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.btn--outline:hover { background: transparent; color: var(--blue); box-shadow: inset 0 0 0 2px var(--blue); }
.btn--outline[aria-disabled="true"] { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 2px var(--muted); }
.readout { display: flex; flex-wrap: wrap; gap: 0.1rem 0.75rem; margin: 0 0 0.25rem; font-size: 0.95rem; }
.readout-label { color: var(--muted); font-weight: 700; min-width: 8.5rem; }
.readout output, .readout span:last-child { font: 500 0.9rem var(--mono); font-variant-numeric: tabular-nums; }
#crash-clock[data-compressed] { color: var(--amber); font-weight: 700; }
#crash-map { display: block; width: 100%; height: auto; overflow: visible; margin-top: 0.5rem; }
#crash-log { list-style: none; margin: 0.75rem 0 0; padding: 0; font: 400 0.84rem/1.5 var(--mono); font-variant-numeric: tabular-nums; border: 2px solid var(--ink); background: #fff; }
#crash-log li { display: grid; grid-template-columns: 4.6rem 8.5rem 1fr; gap: 0.5rem; padding: 0.3rem 0.75rem; border-top: 1px solid var(--rule); color: var(--muted); }
#crash-log li:first-child { border-top: 0; }
#crash-log li[data-played] { color: var(--ink); }
#crash-log li[data-failed] { color: var(--bad); font-weight: 700; }
.lane { fill: none; stroke-width: 10; stroke-linecap: round; opacity: 0.4; }
.lane--blue { stroke: var(--blue); }
.lane--violet { stroke: var(--violet); }
.lane--amber { stroke: var(--amber); }
.lane[data-state="dead"] { stroke: var(--muted); stroke-dasharray: 2 16; opacity: 0.8; }
.lane-name { font: 800 20px var(--sans); fill: var(--ink); }
.lane-kind { font: 500 15px var(--mono); fill: var(--muted); }
.lane-kind--bad { fill: var(--bad); font-weight: 700; }
.link { fill: none; stroke-width: var(--line); stroke-linecap: round; stroke-linejoin: round; }
.link--next { stroke: var(--blue); }
.link--retry { stroke: var(--ink); stroke-dasharray: 0.1 22; stroke-dashoffset: -16; }
.kill-mark { fill: none; stroke: var(--bad); stroke-width: 5; stroke-linecap: round; }
.station-text { paint-order: stroke; stroke: var(--paper); stroke-width: 6px; stroke-linejoin: round; }
@media (max-width: 1000px) { .map--crash { max-width: 46rem; } }
@media (max-width: 860px) { #crash-log li { grid-template-columns: 4.4rem 1fr; gap: 0 0.5rem; } #crash-log li > :nth-child(2) { font-size: 0.75rem; } #crash-log li > :nth-child(3) { grid-column: 1 / -1; } }
@media (forced-colors: active) { .lane, .link { stroke: CanvasText; } }
@media (min-width: 1240px) { .shot { max-width: none; } }
