/*
 * Delorean documentation site. The tokens are the web app's own: brushed
 * steel and time-circuit amber, Barlow for text. Series hues (code, models,
 * traces) follow the validated categorical order: blue, orange, aqua.
 */
:root {
  color-scheme: light;
  --page: #eceef0;
  --surface: #fafbfb;
  --sunken: #e3e6e9;
  --line: #cdd2d7;
  --line-strong: #7a828a;
  --ink: #16191c;
  --ink-muted: #545b63;
  --amber: #f2a516;
  --amber-ink: #7d5200;
  --on-amber: #1c1305;
  --up: #1b7f4b;
  --down: #a33a2c;
  --s-code: #2a78d6;
  --s-model: #eb6834;
  --s-obs: #1baf7a;
  --font-text: "Barlow", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Barlow Semi Condensed", "Barlow", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #101214;
    --surface: #181b1e;
    --sunken: #0c0e10;
    --line: #2d3338;
    --line-strong: #6b737b;
    --ink: #e8eaec;
    --ink-muted: #a3aab1;
    --amber: #f5b03a;
    --amber-ink: #f5b03a;
    --up: #4cc38a;
    --down: #ff8f80;
    --s-code: #3987e5;
    --s-model: #d95926;
    --s-obs: #199e70;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #101214;
  --surface: #181b1e;
  --sunken: #0c0e10;
  --line: #2d3338;
  --line-strong: #6b737b;
  --ink: #e8eaec;
  --ink-muted: #a3aab1;
  --amber: #f5b03a;
  --amber-ink: #f5b03a;
  --up: #4cc38a;
  --down: #ff8f80;
  --s-code: #3987e5;
  --s-model: #d95926;
  --s-obs: #199e70;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 16px/1.6 var(--font-text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--amber); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
code, pre, kbd { font-family: var(--font-mono); }

/* Header */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px 28px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
}
.brand svg { width: 22px; height: 22px; color: var(--amber); }
.brand small {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.nav a {
  display: block;
  padding: 6px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink-muted);
  font-weight: 500;
}
.nav a:hover { color: var(--ink); background: var(--sunken); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }

/* Page layout: the document, and a rail with the services and the outline. */
.layout {
  max-width: 1240px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 32px 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 40px;
  align-items: start;
}
.rail {
  position: sticky;
  top: 76px;
  display: grid;
  gap: 24px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding-bottom: 8px;
}
/* Full-width content above the layout, for figures that need the room. */
.wide { max-width: 1240px; margin: 0 auto; padding-inline: 16px; padding-block: 32px 0; }
.wide + .layout { padding-top: 8px; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; max-height: none; order: -1; }
  .rail .toc { display: none; }
}

.rail h2 {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Services: one row per service, with a live status and an Open button. */
.services { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.service {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.service .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line-strong);
}
.service[data-state="up"] .dot { background: var(--up); }
.service[data-state="down"] .dot { background: transparent; box-shadow: inset 0 0 0 2px var(--line-strong); }
.service[data-state="checking"] .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .service[data-state="checking"] .dot { animation: none; } }
.service .name { font-weight: 600; line-height: 1.25; }
.service .meta {
  grid-column: 2;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-muted);
  overflow-wrap: anywhere;
}
.service .state { font-family: var(--font-text); }
.service[data-state="up"] .state { color: var(--up); }
.service .open { grid-row: 1 / span 2; grid-column: 3; }

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: 600 0.88rem/1.2 var(--font-text);
  text-decoration: none;
  white-space: nowrap;
}
.button:hover { background: var(--sunken); }
.button.primary { background: var(--amber); border-color: var(--amber); color: var(--on-amber); }
.button.primary:hover { filter: brightness(1.05); }
.button svg { width: 14px; height: 14px; }

.links { display: grid; gap: 8px; }
.links .button { justify-content: space-between; }

.toc ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; border-left: 1px solid var(--line); }
.toc a {
  display: block;
  padding: 3px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  text-decoration: none;
  color: var(--ink-muted);
  font-size: 0.92rem;
  line-height: 1.35;
}
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--ink); border-left-color: var(--amber); }

/* Document typography */
.doc { min-width: 0; }
.doc > :first-child { margin-top: 0; }
.doc h1, .doc h2, .doc h3, .doc h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}
.doc h1 { font-size: clamp(2.2rem, 4.5vw, 3rem); margin: 0 0 12px; letter-spacing: -0.01em; }
.doc h2 { font-size: 1.65rem; margin: 2.4em 0 0.6em; padding-top: 0.6em; border-top: 1px solid var(--line); }
.doc h3 { font-size: 1.25rem; margin: 1.8em 0 0.5em; }
.doc h4 { font-size: 1.05rem; margin: 1.4em 0 0.4em; }
.doc p, .doc li { max-width: 74ch; }
.doc p { margin: 0 0 1em; }
.doc ul, .doc ol { padding-left: 1.3em; margin: 0 0 1em; }
.doc li { margin: 0.3em 0; }
.doc li::marker { color: var(--ink-muted); }
.doc strong { font-weight: 600; }
.doc .lead { font-size: 1.18rem; color: var(--ink); }
.doc .eyebrow, .eyebrow {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber-ink);
}
.doc :not(pre) > code {
  font-size: 0.86em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--sunken);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.doc pre {
  margin: 0 0 1.2em;
  padding: 14px 16px;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.55;
}
.doc blockquote {
  margin: 0 0 1em;
  padding: 2px 16px;
  border-left: 3px solid var(--amber);
  color: var(--ink-muted);
}
.doc hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.2em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.doc table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.doc th, .doc td { text-align: left; vertical-align: top; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.doc tr:last-child td { border-bottom: 0; }
.doc thead th {
  background: var(--sunken);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.doc td code { white-space: nowrap; }
.repo-path {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px dashed var(--line-strong);
}
.anchor { margin-left: 8px; color: var(--line-strong); text-decoration: none; opacity: 0; font-weight: 400; }
.doc :is(h2, h3):hover .anchor { opacity: 1; }

.notice {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-muted);
}
.notice code { color: var(--ink); }

/* Figures (architecture) */
figure { margin: 0 0 1.6em; display: grid; gap: 10px; }
.frame {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
}
.frame svg { display: block; width: 100%; height: auto; min-width: 920px; }
figcaption { color: var(--ink-muted); font-size: 0.95rem; max-width: 74ch; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0 0 12px; padding: 0; list-style: none; font-size: 0.92rem; }
.legend li { display: flex; align-items: center; gap: 8px; max-width: none; margin: 0; }
.swatch { width: 22px; height: 14px; border-radius: 4px; border: 2px solid var(--line-strong); background: var(--surface); flex: none; }
.swatch.code { border-color: var(--s-code); }
.swatch.model { border-color: var(--s-model); }
.swatch.obs { border-color: var(--s-obs); }
.swatch.tool { border-color: var(--ink-muted); }
.swatch.future { border-style: dashed; border-color: var(--s-code); }
.diamond { color: var(--amber-ink); width: 22px; text-align: center; flex: none; }

svg text { font-family: var(--font-text); fill: var(--ink); }
svg .t-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
svg .t-sub { font-size: 12px; fill: var(--ink-muted); }
svg .t-body { font-size: 12.5px; }
svg .t-mono { font-family: var(--font-mono); font-size: 11.5px; }
svg .t-mono.muted, svg .t-port { fill: var(--ink-muted); }
svg .t-port { font-family: var(--font-mono); font-size: 11.5px; }
svg .t-arrow { font-size: 11.5px; fill: var(--ink-muted); }
svg .t-arrow.mono { font-family: var(--font-mono); font-size: 11px; fill: var(--ink); }
svg .t-tier { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; fill: var(--ink-muted); text-transform: uppercase; }
svg .t-strong { font-weight: 600; }
svg .t-contract { fill: var(--amber-ink); }
svg .t-inline-mono { font-family: var(--font-mono); font-size: 11px; fill: var(--ink); }
svg .box { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
svg .box.code { stroke: var(--s-code); stroke-width: 2; }
svg .box.model { stroke: var(--s-model); stroke-width: 2; }
svg .box.obs { stroke: var(--s-obs); stroke-width: 2; }
svg .box.tool { stroke: var(--ink-muted); stroke-width: 1.5; }
svg .box.future { stroke: var(--s-code); stroke-width: 1.5; stroke-dasharray: 6 5; fill: none; }
svg .box.ok { stroke: var(--amber); stroke-width: 2; }
svg .group { fill: var(--sunken); stroke: var(--s-model); stroke-width: 1.5; }
svg .chip { fill: var(--sunken); stroke: var(--line); stroke-width: 1; }
svg .dot.code { fill: var(--s-code); }
svg .dot.model { fill: var(--s-model); }
svg .rule { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 5; }
svg .flow { fill: none; stroke: var(--ink-muted); stroke-width: 1.6; }
svg .flow.back { stroke-dasharray: 2 4; }
svg .flow.opt { stroke-dasharray: 6 5; }
svg .flow.reject { stroke: var(--line-strong); stroke-dasharray: 4 4; }
svg .flow.bracket { stroke: var(--line-strong); }
svg .ah { fill: var(--ink-muted); }

/* API reference */
.op {
  margin: 0 0 1.6em;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.op-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.op-head h3 { margin: 0; font-family: var(--font-mono); font-size: 1rem; font-weight: 500; }
.op-head .summary { color: var(--ink-muted); }
.op-body { padding: 4px 16px 14px; }
.op-body h4 { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); margin: 1.2em 0 0.5em; }
.method {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid currentColor;
}
.method.get { color: var(--s-code); }
.method.post { color: var(--amber-ink); }
.status { font-family: var(--font-mono); font-weight: 500; }
.status.s2 { color: var(--up); }
.status.s4 { color: var(--amber-ink); }
.status.s5 { color: var(--down); }
.schema-type { font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink-muted); }
.schema-type a { color: var(--ink); }
.req { font-family: var(--font-mono); font-size: 0.72rem; color: var(--amber-ink); margin-left: 6px; }
.schema { margin: 0 0 1.4em; }
.schema h3 { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 500; }

.footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  color: var(--ink-muted);
  font-size: 0.88rem;
  border-top: 1px solid var(--line);
}

/* Quoters: the side-by-side tables, the trees and the key functions. */
.doc .services.inline { max-width: 560px; margin: 0 0 1.2em; }
.doc .services.inline li { max-width: none; margin: 0; }
.doc table.compare { min-width: 860px; table-layout: fixed; }
.doc table.compare col.label { width: 150px; }
.doc table.compare th[scope="row"] { font-weight: 600; background: var(--sunken); }
.doc table.compare td code { white-space: normal; overflow-wrap: anywhere; }
.doc table.compare tr.diverge th[scope="row"] { box-shadow: inset 3px 0 0 var(--amber); }
.doc table.compare .why { display: block; margin-top: 4px; color: var(--ink-muted); font-size: 0.86rem; }
.doc pre.tree { line-height: 1.6; }
.tree .role { color: var(--ink-muted); }
.tree .dir { color: var(--amber-ink); }
.fns { display: grid; gap: 10px; margin: 0 0 1.4em; padding: 0; list-style: none; counter-reset: fn; }
.doc .fns > li { max-width: none; margin: 0; }
.fn {
  counter-increment: fn;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.fn-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.fn-step {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber-ink);
}
.fn-step::before { content: counter(fn, decimal-leading-zero) " · "; color: var(--ink-muted); }
.fn-src { font-family: var(--font-mono); font-size: 0.8rem; overflow-wrap: anywhere; }
.doc .fn pre.sig {
  margin: 8px 0;
  padding: 8px 10px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.doc .fn p { margin: 0; font-size: 0.95rem; }
