/* Documentation pages (front/docs/, generated by scripts/build-docs.mjs).
   Static content only — the app bundle is never loaded here. */
:root {
  --bg: #1e1e2e;
  --surface: #181825;
  --surface-2: #313244;
  /* Two reading colours only: --text for headings and emphasis, --muted for
     every line of prose (body default). --dim is for ornaments — counters,
     list markers, borders — never for text meant to be read: it is 3.4:1 on
     --bg, under WCAG AA. */
  --text: #cdd6f4;
  --muted: #a6adc8;
  --dim: #6c7086;
  --accent: #89b4fa;
  --border: #313244;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--muted);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }

#docs {
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  gap: 3rem;
  max-width: 76rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
}

/* Sidebar ---------------------------------------------------------------- */
#docs aside {
  position: sticky;
  top: 2rem;
  align-self: start;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  font-size: 0.9rem;
}
#docs .brand {
  display: inline-block;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--text);
}
#docs .languages { margin: 0.6rem 0 1.4rem; font-size: 0.78rem; }
#docs .languages a { margin-right: 0.7rem; line-height: 1.9; color: var(--muted); text-decoration: none; }
#docs .languages a:hover { color: var(--accent); }
#docs .languages a[aria-current] { color: var(--text); font-weight: 600; }
#docs .toc-title {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
#docs .toc ol { margin: 0; padding: 0; list-style: none; counter-reset: toc; }
#docs .toc li { counter-increment: toc; }
#docs .toc a {
  display: block;
  padding: 0.22rem 0.6rem 0.22rem 0.7rem;
  border-left: 2px solid var(--border);
  color: var(--muted);
  text-decoration: none;
}
#docs .toc a::before { content: counter(toc) ". "; color: var(--dim); }
#docs .toc a:hover { color: var(--text); border-left-color: var(--accent); background: var(--surface); }
#docs .cta {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.5rem 0.95rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
}

/* Article ---------------------------------------------------------------- */
#docs main { min-width: 0; max-width: 48rem; }
#docs h1 { font-size: 2.1rem; line-height: 1.15; margin: 0 0 0.6rem; color: var(--text); }
#docs .tagline { font-size: 1.05rem; margin: 0 0 2.5rem; }
#docs section { scroll-margin-top: 1.5rem; }
#docs h2 {
  font-size: 1.5rem;
  margin: 3rem 0 1rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--border);
  color: var(--text);
}
#docs section:first-of-type h2 { border-top: none; padding-top: 0; margin-top: 1rem; }
#docs h3 { font-size: 1.05rem; margin: 1.8rem 0 0.5rem; color: var(--text); }
#docs p { margin: 0 0 1rem; }
#docs ul, #docs ol { padding-left: 1.3rem; margin: 0 0 1rem; }
#docs li { margin: 0.35rem 0; }
#docs li > ul { margin: 0.35rem 0 0.5rem; }
#docs strong { color: var(--text); }
#docs code {
  background: var(--surface-2);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
#docs pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  margin: 0 0 1.2rem;
}
#docs pre code { background: none; padding: 0; font-size: 0.85rem; line-height: 1.55; }
#docs kbd {
  background: var(--surface-2);
  border: 1px solid #45475a;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.05em 0.45em;
  font-size: 0.82em;
  font-family: inherit;
  white-space: nowrap;
}

/* Screenshots ------------------------------------------------------------ */
#docs figure { margin: 1.4rem 0 1.6rem; }
#docs figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
#docs figcaption { margin-top: 0.5rem; font-size: 0.85rem; }

/* Shortcut table --------------------------------------------------------- */
#docs .table-wrap { overflow-x: auto; }
#docs table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
#docs th, #docs td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
#docs th { font-weight: 600; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }
#docs td:first-child { white-space: nowrap; }

#docs footer { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: 0.85rem; }

@media (max-width: 900px) {
  #docs { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding-top: 1.5rem; }
  #docs aside { position: static; max-height: none; overflow: visible; padding-bottom: 1rem; border-bottom: 1px solid var(--border); }
  #docs .toc ol { columns: 2; column-gap: 1.5rem; }
  #docs h1 { font-size: 1.7rem; }
  #docs h2 { font-size: 1.3rem; margin-top: 2.2rem; }
}

/* Code blocks that name their file (gateway.json) or context (Terminal). */
#docs .code-block { margin: 0 0 1.2rem; }
#docs .code-block .code-label {
  margin: 0;
  padding: 0.35rem 1rem;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--surface-2);
  color: var(--muted);
  font: 600 0.75rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}
#docs .code-block pre { margin: 0; border-radius: 0 0 8px 8px; }

/* Lessons (/learn, generated by scripts/build-learn.mjs) --------------------
   Same shell as the docs page (#docs) plus what only lessons have: a grouped
   lesson rail, runnable examples and prev/next navigation. */
#docs.learn .lessons-home { margin: 0 0 1.2rem; font-size: 0.85rem; }
#docs.learn .lessons-home a { color: var(--muted); text-decoration: none; }
#docs.learn .lessons-home a:hover,
#docs.learn .lessons-home a[aria-current] { color: var(--text); }
/* Not a lesson, so it takes no number from the docs TOC counter. */
#docs.learn .lessons-home a::before { content: none; }
#docs.learn .toc .toc-title { margin-top: 1.3rem; }
#docs.learn .toc .toc-title:first-of-type { margin-top: 0; }
/* Only the core path is a sequence, so only the <ol> gets numbers. */
#docs.learn .toc ul { margin: 0; padding: 0; list-style: none; }
#docs.learn .toc ul a::before { content: none; }
#docs.learn .toc a[aria-current] { color: var(--text); border-left-color: var(--accent); background: var(--surface); }

/* Runnable example: code block + the button that opens it in the app. */
#docs.learn .step { margin: 1.4rem 0 1.8rem; }
#docs.learn .step .code-block { margin-bottom: 0.75rem; }
#docs.learn .step .code-label { font-variant-numeric: tabular-nums; }
#docs.learn .run {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
}
#docs.learn .run:hover { filter: brightness(1.08); }
#docs.learn .run::after { content: " \2192"; }
#docs.learn .run-note { margin: 0.6rem 0 0; font-size: 0.82rem; }

/* Index: the lesson list, with what each one teaches. */
#docs.learn .tagline p:last-child { margin-bottom: 0; }
#docs.learn .lesson-list { padding-left: 1.4rem; }
#docs.learn .lesson-list li { margin: 0.7rem 0; }
#docs.learn .lesson-list li::marker { color: var(--dim); }
#docs.learn .lesson-list a { font-weight: 600; text-decoration: none; }
#docs.learn .lesson-list a:hover { text-decoration: underline; }
#docs.learn .lesson-list span { display: block; font-size: 0.88rem; }

/* Previous / next lesson. */
#docs.learn .lesson-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
#docs.learn .lesson-nav a {
  flex: 1 1 14rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.92rem;
  text-decoration: none;
}
#docs.learn .lesson-nav a:hover { border-color: var(--accent); }
#docs.learn .lesson-nav .next { text-align: right; }
#docs.learn .lesson-nav span {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

/* Cross-link between the documentation and the lessons. */
#docs .section-link { margin: 0.9rem 0 0; font-size: 0.85rem; }
#docs .section-link a { color: var(--muted); text-decoration: none; }
#docs .section-link a:hover { color: var(--accent); }

/* A lesson-level notice (e.g. "this one changes data"), distinct from the
   quiet grey note under a run button. */
#docs.learn .callout {
  margin: 0 0 1.5rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--surface);
  font-size: 0.94rem;
}

/* Schema reference (/learn/schema/): one block per table. */
#docs.learn .legend { margin-bottom: 2.5rem; }
#docs.learn .legend ul { margin-top: 0.6rem; }
#docs.learn .schema-table { margin: 1.5rem 0 2rem; }
#docs.learn .schema-table h3 {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  margin: 0 0 0.6rem;
  scroll-margin-top: 1.5rem;
}
#docs.learn .schema-table h3 code {
  background: none;
  padding: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
}
#docs.learn .schema-table h3 span {
  font-size: 0.78rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
#docs.learn .schema-table table { font-size: 0.86rem; }
#docs.learn .schema-table td:first-child { white-space: nowrap; }
#docs.learn .schema-table td:nth-child(2) {
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}
#docs.learn .schema-table em { font-style: normal; color: var(--text); font-weight: 600; }

/* What an example returns, shown under it. Quieter than the code block above
   it: this is something to glance at and compare, not to read closely. */
#docs.learn .result {
  margin: 0.9rem 0 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}
#docs.learn .result-label {
  margin: 0;
  padding: 0.4rem 0.85rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font: 500 0.74rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}
#docs.learn .result:has(.result-label:only-child) .result-label { border-bottom: 0; }
#docs.learn .result table { font-size: 0.8rem; }
#docs.learn .result th,
#docs.learn .result td { padding: 0.35rem 0.85rem; white-space: nowrap; }
#docs.learn .result th {
  font-size: 0.7rem;
  border-bottom-color: var(--surface-2);
}
#docs.learn .result tbody tr:last-child td { border-bottom: 0; }
#docs.learn .result td { font-variant-numeric: tabular-nums; }
#docs.learn .result td.null { color: var(--dim); font-style: italic; }
#docs.learn .result.error { border-color: #6d3b4a; }
#docs.learn .result.error .result-label { color: #f38ba8; border-bottom-color: #6d3b4a; }
#docs.learn .result-message {
  margin: 0;
  padding: 0.55rem 0.85rem;
  font: 0.82rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Exercises: the answer is folded away so scrolling past does not spoil it. */
#docs.learn .exercises { margin-top: 3rem; }
#docs.learn .exercises ol { padding-left: 1.4rem; }
#docs.learn .exercises > ol > li { margin: 1.6rem 0; }
#docs.learn .exercises > ol > li::marker { color: var(--dim); }
#docs.learn .exercises .question { margin: 0 0 0.7rem; }
#docs.learn .exercises details {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 50%, transparent);
}
#docs.learn .exercises summary {
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
#docs.learn .exercises summary::-webkit-details-marker { display: none; }
#docs.learn .exercises summary::before { content: "▸ "; color: var(--dim); }
#docs.learn .exercises details[open] summary::before { content: "▾ "; }
#docs.learn .exercises details[open] summary { border-bottom: 1px solid var(--border); }
#docs.learn .exercises details > *:not(summary) { margin-left: 0.9rem; margin-right: 0.9rem; }
#docs.learn .exercises details > .code-block { margin-top: 0.9rem; }
#docs.learn .exercises details > p:last-child { margin-bottom: 0.9rem; }
#docs.learn .exercises .result { margin-bottom: 0.9rem; }
#docs.learn .exercises .code-block .code-label { display: none; }

/* Asides: a warning, or a note about another engine. Set apart so a first
   reader can skip them and come back. */
#docs.learn aside[class^="note-"] {
  margin: 1.3rem 0;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--dim);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  font-size: 0.94rem;
}
#docs.learn aside[class^="note-"] > *:last-child { margin-bottom: 0; }
#docs.learn .note-label {
  margin: 0 0 0.4rem;
  font: 600 0.68rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
/* `aside.note-*`, not a bare `.note-*`: the base rule above is an attribute
   plus a type selector, so a bare class loses the cascade and the colour
   silently never applies. */
#docs.learn aside.note-warn { border-left-color: #fab387; }
#docs.learn aside.note-warn .note-label { color: #fab387; }
#docs.learn aside.note-portable { border-left-color: #cba6f7; }
#docs.learn aside.note-portable .note-label { color: #cba6f7; }
