/* Documentation site. Diagrams are measured with Inter, kerning and ligatures off (see src/text.ts):
   the same settings are required here, or labels overflow their boxes. */
@font-face { font-family: Inter; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: Inter; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/inter-latin-600-normal.woff2") format("woff2"); }

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --ink: #2d3142;
  --muted: #5a6580;
  --rule: #e2e4e8;
  --accent: #3c6a9b;
  --accent-soft: #dfeaf8;
  --code-bg: #f3f4f7;
  --k: #3c6a9b; --s: #2f7d4f; --n: #a35c00; --l: #8a3ffc;
  --diagram-paper: #f5f5f5;
  --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --bg-soft: #1c1f26;
    --ink: #e4e6eb;
    --muted: #a2a9b8;
    --rule: #2c3039;
    --accent: #8db5e3;
    --accent-soft: #233246;
    --code-bg: #1e2129;
    --k: #8db5e3; --s: #8fd1a5; --n: #f0b46a; --l: #c5a3ff;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--font); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; height: 56px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; gap: 10px; align-items: center; font-weight: 600; color: var(--ink); text-decoration: none; }
.toplinks { display: flex; gap: 20px; font-size: 15px; }
.toplinks a { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); text-decoration: none; }
.toplinks .icon { width: 16px; height: 16px; flex: none; }
.toplinks a:hover { color: var(--ink); }

/* Sidebar + content */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); max-width: 1320px; margin: 0 auto; }
.sidebar { position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); overflow-y: auto; padding: 24px 16px 32px 24px; font-size: 15px; }
.sidebar ul { list-style: none; margin: 0 0 20px; padding: 0; }
.sidebar li a { display: block; padding: 4px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.sidebar li a:hover { color: var(--ink); background: var(--bg-soft); }
.sidebar li a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.nav-section { margin: 0 0 6px 10px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.menu-toggle, .menu-button { display: none; }

.content { min-width: 0; max-width: 860px; padding: 32px 48px 48px; }
.content.wide { max-width: 1060px; }

/* Typography */
h1, h2, h3, h4 { line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 34px; margin: 8px 0 16px; }
h2 { font-size: 24px; margin: 48px 0 12px; padding-top: 16px; border-top: 1px solid var(--rule); }
h3 { font-size: 19px; margin: 32px 0 8px; }
h4 { font-size: 16px; margin: 24px 0 4px; }
h2 code, h3 code { font-size: .9em; }
p, ul, ol { margin: 0 0 16px; }
li { margin: 4px 0; }
.lead { font-size: 19px; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 32px 0; }

code { font: .88em/1.5 var(--mono); background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre { margin: 0 0 20px; padding: 14px 18px; overflow-x: auto; background: var(--code-bg); border-radius: 8px; font-size: 14px; line-height: 1.55; }
pre code { background: none; padding: 0; font-size: inherit; }
pre .k { color: var(--k); } pre .s { color: var(--s); } pre .n { color: var(--n); } pre .l { color: var(--l); }

.source { margin: 0 0 20px; }
.source .file { display: inline-block; font: 13px var(--mono); color: var(--muted); margin: 0 0 6px; }
.source pre { max-height: 560px; }
details.source { border: 1px solid var(--rule); border-radius: 8px; padding: 8px 14px; }
details.source summary { cursor: pointer; font-size: 15px; color: var(--muted); }
details.source[open] summary { margin-bottom: 10px; }
details.source .file { margin: 0; }

table { width: 100%; border-collapse: collapse; margin: 0 0 24px; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border-bottom: 1px solid var(--rule); }
th { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td code { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

blockquote, .note {
  margin: 0 0 20px; padding: 12px 16px; border-left: 3px solid var(--accent); background: var(--bg-soft); border-radius: 0 8px 8px 0;
}
blockquote p:last-child, .note p:last-child { margin-bottom: 0; }

/* Diagrams: always on their own light paper, whatever the page theme. */
figure.diagram { margin: 8px 0 28px; padding: 16px; background: var(--diagram-paper); border-radius: 10px; overflow-x: auto; }
figure.diagram svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
figure.diagram svg text { font-family: Inter, system-ui, sans-serif; font-kerning: none; font-variant-ligatures: none; font-feature-settings: "kern" 0, "liga" 0, "calt" 0; }
figure.diagram svg a { cursor: pointer; }
figure.diagram figcaption { margin-top: 10px; text-align: center; font-size: 14px; color: #4f5d75; }

/* Home page */
.hero { padding: 24px 0 8px; }
.hero h1 { font-size: 44px; margin: 0 0 12px; letter-spacing: -.02em; }
.hero .lead { max-width: 640px; }
.hero .subtitle { font-size: 22px; font-weight: 600; margin: -4px 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 8px; }
.button { display: inline-block; padding: 9px 18px; border-radius: 8px; font-weight: 600; text-decoration: none; border: 1px solid var(--rule); color: var(--ink); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 0 0 24px; }
.card { padding: 16px 18px; border: 1px solid var(--rule); border-radius: 10px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0; font-size: 15px; color: var(--muted); }

/* Schema reference */
.req { font-size: 12px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.prop-name code { font-weight: 600; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; vertical-align: middle; }

.pagefoot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 64px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 14px; color: var(--muted); }

/* Small screens: the sidebar becomes a toggled panel (checkbox hack, no script). */
@media (max-width: 860px) {
  .shell { display: block; }
  .menu-button { display: block; margin: 12px 20px 0; font-size: 15px; font-weight: 600; color: var(--accent); cursor: pointer; }
  .sidebar { display: none; position: static; height: auto; padding: 8px 20px; border-bottom: 1px solid var(--rule); }
  .menu-toggle:checked ~ .sidebar { display: block; }
  .content { padding: 16px 20px 40px; }
  .toplinks a:not(:last-child) { display: none; }
  .hero h1 { font-size: 34px; }
}

/* Shape gallery: one small diagram per shape. */
.shape-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 1.25rem 0; }
.shape-grid figure.diagram { margin: 0; padding: 8px; }
.shape-grid figure.diagram svg { width: 100%; height: auto; }
