/* Tokens, base, buttons, header and footer mirror web/public/styles.css (approved identity). */
@font-face {
  font-family: "DejaVu Sans Mono";
  src: url("/fonts/DejaVuSansMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Ubuntu";
  src: url("/fonts/Ubuntu-var.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #29251F;
  --cream: #FFF8EA;
  --mango: #FFBA49;
  --mango-soft: #FFE2B0;
  --sand: #EFE6D5;
  --white: #FFFFFF;

  --bg: var(--cream);
  --text: var(--ink);
  --muted: #635A4C;
  --surface: var(--white);
  --surface-2: var(--sand);
  --line: #DCCFB8;
  --accent: var(--mango);
  --code-bg: #29251F;
  --code-text: #FFF8EA;
  --code-line: #4D4538;

  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem;
  --s6: 2rem; --s7: 3rem; --s8: 4rem;
  --r-sm: 8px; --r: 14px;
  --gutter: 16px;
  --max: 1180px;
  --mono: "DejaVu Sans Mono", ui-monospace, Menlo, Consolas, monospace;
  /* System monospace: the brand's DejaVu Sans Mono ships in bold only, too heavy for code. */
  --code: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: Ubuntu, Arial, sans-serif;
  --header-h: 64px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #29251F;
  --text: #FFF8EA;
  --muted: #CFC4B0;
  --surface: #373127;
  --surface-2: #322D24;
  --line: #4D4538;
  --code-bg: #1F1C17;
}
@media (min-width: 768px) { :root { --gutter: 32px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--mono); font-weight: 700; line-height: 1.2; letter-spacing: -.02em; margin: 0; text-wrap: balance; overflow-wrap: break-word; }
p { margin: 0; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: .18em; }
a:hover { text-decoration-color: var(--accent); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--mango); color: var(--ink); }
.only-dark { display: none; }
:root[data-theme="dark"] .only-dark { display: block; }
:root[data-theme="dark"] .only-light { display: none; }
.wrap { width: 100%; max-width: calc(var(--max) + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.skip { position: absolute; left: var(--gutter); top: -100px; z-index: 100; background: var(--ink); color: var(--cream); padding: var(--s2) var(--s4); border-radius: var(--r-sm); }
.skip:focus { top: var(--s2); }

/* ---------- Header and footer ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; gap: var(--s4); min-height: var(--header-h); }
.logo { flex: none; display: flex; align-items: center; gap: var(--s2); border-radius: 6px; text-decoration: none; }
.logo img { width: 140px; height: auto; }
.logo-tag { font: 700 .75rem/1 var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: .4em .55em; border-radius: 6px; background: var(--mango); color: var(--ink); }
.nav { display: none; gap: var(--s1); margin-left: auto; }
.nav-link { padding: .5rem .7rem; border-radius: 8px; text-decoration: none; font-weight: 500; font-size: .9375rem; }
.nav-link:hover { background: var(--surface-2); }
.header-tools { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.lang, .theme-toggle {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 10px; border: 1.5px solid var(--line); background: transparent; color: var(--text);
  font: 700 .8125rem/1 var(--mono); text-decoration: none; cursor: pointer;
}
.lang:hover, .theme-toggle:hover { border-color: var(--text); }
.theme-toggle svg { width: 20px; height: 20px; }
@media (min-width: 900px) { .nav { display: flex; } .header-tools { margin-left: var(--s4); } }

.site-footer { border-top: 1px solid var(--line); padding: var(--s7) 0; font-size: .9375rem; }
.footer-row { display: grid; gap: var(--s5); }
@media (min-width: 900px) { .footer-row { grid-template-columns: auto 1fr; align-items: center; } .footer-row nav { justify-self: end; } .footer-note { grid-column: 1 / -1; } }
.footer-brand img { width: 144px; height: auto; }
.footer-brand p { margin-top: var(--s2); color: var(--muted); font-family: var(--mono); font-weight: 700; font-size: .875rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.site-footer nav a { padding: .25rem 0; }
.footer-note { color: var(--muted); font-size: .8438rem; }

/* ---------- Docs layout ---------- */
.docs { display: grid; gap: var(--s5); padding-block: var(--s5) var(--s8); }
.sidebar { font-size: .9688rem; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: block; padding: .4rem .7rem; border-radius: 8px; text-decoration: none; }
.sidebar a:hover { background: var(--surface-2); }
.sidebar a[aria-current="page"] { background: var(--mango); color: var(--ink); font-weight: 700; }
.nav-group { font: 700 .75rem/1.2 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: var(--s5) 0 var(--s2); padding-inline: .7rem; }
.menu-toggle {
  display: none; width: 100%; min-height: 44px; padding: .5rem .9rem; text-align: left;
  font: 700 .9375rem/1.2 var(--sans); color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer;
}
.menu-toggle::after { content: "▾"; float: right; }
.menu-toggle[aria-expanded="true"]::after { content: "▴"; }
/* Without JavaScript the navigation stays visible above the article. */
@media (max-width: 959px) {
  .js .menu-toggle { display: block; }
  .js .menu-toggle[aria-expanded="false"] + nav { display: none; }
  .js .sidebar nav { padding-top: var(--s3); }
}
@media (min-width: 960px) {
  .docs { grid-template-columns: 240px minmax(0, 1fr); gap: var(--s7); padding-top: var(--s6); }
  .sidebar nav { position: sticky; top: calc(var(--header-h) + var(--s5)); max-height: calc(100vh - var(--header-h) - var(--s6)); overflow-y: auto; padding-bottom: var(--s5); }
}

/* ---------- Prose ---------- */
.prose { min-width: 0; max-width: 50rem; }
.prose > * + * { margin-top: var(--s4); }
.prose h1 { font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.6rem); }
.prose h1 + p { font-size: 1.1875rem; color: var(--muted); }
.prose h2 { font-size: 1.5rem; margin-top: var(--s7); padding-top: var(--s5); border-top: 1px solid var(--line); }
.prose h3 { font-size: 1.15rem; margin-top: var(--s6); }
.prose h4 { font-size: 1rem; margin-top: var(--s5); }
.anchor { text-decoration: none; }
.anchor:hover::after { content: " #"; color: var(--muted); }
.prose ul, .prose ol { margin-block: var(--s4) 0; padding-left: 1.4rem; }
.prose li + li { margin-top: var(--s2); }
.prose li > ul, .prose li > ol { margin-top: var(--s2); }
.prose code { font: 400 .875em/1.4 var(--code); background: var(--surface-2); padding: .12em .35em; border-radius: 5px; overflow-wrap: anywhere; }
.prose blockquote, .callout { margin-inline: 0; padding: var(--s3) var(--s4); background: var(--surface); border: 1.5px solid var(--line); border-left: 6px solid var(--mango); border-radius: var(--r-sm); }
.prose blockquote > * + * { margin-top: var(--s2); }
.table-wrap { overflow-x: auto; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: var(--surface); }
.prose table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.prose th, .prose td { padding: .6rem .8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose th { font-weight: 700; background: var(--surface-2); white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }
.prose td code { white-space: nowrap; overflow-wrap: normal; }

/* Code is always light-on-ink: 14.41:1, the brand's dark surface. */
.code { position: relative; margin-inline: 0; background: var(--code-bg); color: var(--code-text); border: 1.5px solid var(--code-line); border-radius: var(--r-sm); overflow: hidden; }
.code figcaption { display: flex; align-items: center; min-height: 40px; padding: 0 var(--s4); font: 700 .75rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: #CFC4B0; border-bottom: 1px solid var(--code-line); }
.code pre { margin: 0; padding: var(--s4); overflow-x: auto; }
.code pre:focus-visible { outline-offset: -3px; outline-color: var(--mango); }
.code code { font: 400 .875rem/1.6 var(--code); background: none; padding: 0; color: inherit; overflow-wrap: normal; white-space: pre; }
.copy { position: absolute; top: 5px; right: 6px; min-height: 30px; padding: 0 .7rem; font: 700 .75rem/1 var(--mono); color: var(--ink); background: var(--mango); border: 0; border-radius: 6px; cursor: pointer; }
.copy:focus-visible { outline-color: var(--cream); }
.tabs { position: relative; }
.tabs > .code + .code { margin-top: var(--s3); }
/* Room on the right for the copy button, which sits over the tab row instead of over the code. */
.tablist { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding: 6px 5.5rem 0 6px; background: var(--code-bg); border: 1.5px solid var(--code-line); border-bottom: 0; border-radius: var(--r-sm) var(--r-sm) 0 0; }
.tablist button { flex: none; min-height: 36px; padding: 0 .8rem; font: 700 .8125rem/1 var(--sans); color: #CFC4B0; background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 6px 6px 0 0; cursor: pointer; }
.tablist button[aria-selected="true"] { color: var(--code-text); border-bottom-color: var(--mango); }
.tablist button:focus-visible { outline-color: var(--mango); outline-offset: -3px; }
.tabs > .tablist ~ .code { position: static; margin-top: 0; border-radius: 0 0 var(--r-sm) var(--r-sm); }
.tablist ~ .code figcaption { display: none; }
.tablist ~ .code .copy { top: 7px; right: 8px; }
[hidden] { display: none !important; }

.cards { display: grid; gap: var(--s3); }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card { display: grid; gap: var(--s1); align-content: start; padding: var(--s4); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); text-decoration: none; }
.card:hover { border-color: var(--text); }
.card strong { font-family: var(--mono); }
.card span { color: var(--muted); font-size: .9375rem; line-height: 1.5; }

.page-tools { margin-top: var(--s7); font-size: .9375rem; color: var(--muted); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-top: var(--s4); }
.pager a { display: grid; gap: 2px; padding: var(--s3) var(--s4); border: 1.5px solid var(--line); border-radius: var(--r); text-decoration: none; background: var(--surface); }
.pager a:hover { border-color: var(--text); }
.pager span { font-size: .8125rem; color: var(--muted); }
.pager-next { text-align: right; }

/* ---------- API reference (Scalar) ---------- */
.reference-intro { padding-block: var(--s6) var(--s5); max-width: calc(var(--max) + 2 * var(--gutter)); }
#reference-app { border-top: 1px solid var(--line); }
#reference-fallback { padding-block: var(--s5) var(--s8); max-width: calc(50rem + 2 * var(--gutter)); margin-inline: 0; }
.is-reference .site-footer { position: relative; z-index: 1; background: var(--bg); }

@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
