/* zero in the loop: system fonts only, no external resources. */

:root {
  color-scheme: light;
  --bg: #fbfbf9;
  --fg: #111111;
  --muted: #5c5c58;
  --accent: #a8360b;
  --code-bg: #f0f0eb;
  --rule: #dcdcd6;
  --rail: #c9c9c3;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0e0f;
  --fg: #ececea;
  --muted: #a3a3a0;
  --accent: #ff8a5c;
  --code-bg: #19191b;
  --rule: #2c2c2f;
  --rail: #3a3a3e;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0e0e0f;
    --fg: #ececea;
    --muted: #a3a3a0;
    --accent: #ff8a5c;
    --code-bg: #19191b;
    --rule: #2c2c2f;
    --rail: #3a3a3e;
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 1.0625rem/1.65 var(--sans);
  overflow-wrap: break-word;
}

a { color: inherit; text-decoration-color: var(--rail); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: currentColor; }

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

code, pre { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 3px; }

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--fg);
  color: var(--bg);
  z-index: 10;
}
.skip:focus { top: 1rem; }

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

/* Layout */

.top, main, .foot { max-width: 60rem; margin: 0 auto; padding-left: 1.25rem; padding-right: 1.25rem; }

.top {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
  font-size: 0.875rem;
}
.top nav { display: flex; gap: 1.25rem; margin-left: auto; }
.top nav a { text-decoration: none; }
.top nav a:hover { text-decoration: underline; }
.brand { font: 600 1rem var(--mono); text-decoration: none; letter-spacing: -0.02em; }

section { padding: 4.5rem 0; border-top: 1px solid var(--rule); }
section.hero { border-top: 0; padding-top: 3rem; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; font-weight: 600; }
h1 { font-size: clamp(2.5rem, 8vw, 4.5rem); margin: 0.5rem 0 1rem; }
h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 0.5rem 0 1.5rem; max-width: 40rem; }
h3 { font-size: 1.05rem; margin: 2.5rem 0 0.75rem; }
p { max-width: 42rem; }

.lede { font-size: clamp(1.15rem, 2.6vw, 1.4rem); color: var(--muted); max-width: 38rem; }

.label, .caption {
  font: 500 0.75rem/1.4 var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.marker { color: var(--accent); margin-right: 0.5rem; }
.note { color: var(--muted); font-size: 0.95rem; }

.soon {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0 0.4rem;
  border: 1px solid currentColor;
  border-radius: 3px;
  font: 500 0.7rem/1.6 var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  vertical-align: 0.1em;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 2rem 0 0; }
.button {
  display: inline-block;
  padding: 0.6rem 1rem;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  font-size: 0.9rem;
  text-decoration: none;
  border-radius: 4px;
}
.button.ghost { background: transparent; color: var(--fg); }

/* FIG. 1 */

.figure { margin: 3.5rem 0 0; }
.line-fig { display: block; width: 100%; height: auto; max-width: 48rem; overflow: visible; }
.line-fig .rail { stroke: var(--rail); stroke-width: 1.5; }
.line-fig .retry { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 5; }
.line-fig .owner-path { fill: none; stroke: var(--accent); stroke-width: 1.4; stroke-dasharray: 5 5; }
.line-fig .node circle { fill: var(--bg); stroke: var(--fg); stroke-width: 2; }
.line-fig text { fill: var(--muted); font: 12px var(--mono); text-anchor: middle; }
.line-fig .owner-label { fill: var(--accent); }
.line-fig .work { fill: var(--fg); animation: travel 9s linear infinite; }
.line-fig .owner { fill: var(--accent); animation: pulse 3s ease-in-out infinite; transform-origin: 360px 40px; }
.figure .caption { margin-top: 1rem; border-top: 1px solid var(--rule); padding-top: 0.5rem; max-width: 48rem; }

@keyframes travel {
  from { transform: translateX(0); }
  to { transform: translateX(600px); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.35); }
}

/* Lists */

.stations, .flow, .steps { list-style: none; padding: 0; margin: 2rem 0; counter-reset: step; }
.stations li, .flow li, .steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  column-gap: 0.75rem;
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}
.stations li::before, .flow li::before, .steps li::before {
  content: counter(step, decimal-leading-zero);
  grid-row: span 2;
  font: 500 0.75rem/2 var(--mono);
  color: var(--muted);
}
.stations code, .flow > li > code, .steps code { background: none; padding: 0; font-weight: 600; }
.stations p, .flow p, .steps p { margin: 0.25rem 0 0; color: var(--muted); }

.defs { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.75rem 1.5rem; margin: 1.5rem 0; }
.defs dt { padding-top: 0.15rem; }
.defs dd { margin: 0; max-width: 40rem; }

.points { padding-left: 1.1rem; }
.points li { margin: 0.4rem 0; max-width: 42rem; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; max-width: 46rem; font-size: 0.95rem; }
th, td { text-align: left; vertical-align: top; padding: 0.75rem 1rem 0.75rem 0; border-top: 1px solid var(--rule); }
thead th { font: 500 0.75rem var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border-top: 0; }
tbody th { font-weight: 600; white-space: nowrap; }

/* Grids */

.grid { list-style: none; padding: 0; margin: 1.5rem 0; display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); }
.grid > li { background: var(--bg); padding: 1.25rem; }
.cards { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.cards h3 { margin: 0 0 0.5rem; }
.cards p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.dense { grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); }
.dense > li { padding: 0.85rem 1rem; font-size: 0.9rem; }
.dense strong { display: block; font-weight: 600; }
.dense span { color: var(--muted); font-size: 0.85rem; }
.compat { display: grid; gap: 0 2rem; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); }
.compat h3 { margin: 1rem 0 0; }

/* Code */

.code { border: 1px solid var(--rule); background: var(--code-bg); border-radius: 6px; margin: 1.5rem 0; max-width: 46rem; }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0.5rem 0.4rem 1rem; border-bottom: 1px solid var(--rule); }
.code pre { margin: 0; padding: 1rem; overflow-x: auto; line-height: 1.6; }

button {
  font: 500 0.75rem var(--mono);
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
}
button:hover { border-color: var(--fg); }
button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.switch { display: inline-flex; gap: 0.25rem; }

/* Footer */

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 2.5rem;
  border-top: 1px solid var(--rule);
  font: 0.8rem var(--mono);
  color: var(--muted);
}
.foot .switch { margin-left: auto; }

@media (max-width: 40rem) {
  .top { gap: 0.75rem; flex-wrap: wrap; }
  section { padding: 3rem 0; }
  .defs { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
  .defs dd { margin-bottom: 0.75rem; }
  tbody th { white-space: normal; }
  .foot .switch { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
