/* =========================================================================
   Docs page — palette + page-specific components
   Light (default) and dark themes, switched via data-theme="light|dark" on
   <html>. Code blocks are always dark. Only the docs page loads this file, so
   its token vocabulary and component classes never clash with the home page.
   ========================================================================= */

/* ============================== Palette =========================== */
/* AUD-259: the docs use the site theme. marketing.css (loaded before this
   file) holds the site tokens; the docs tokens below are mapped onto them, so
   both follow the same light / dark switch (data-theme on <html>). */
:root {
  color-scheme: light;

  /* Fonts: system font for text and titles, JetBrains Mono for code (AUD-236) */
  --font-title: var(--font-sans);
  --font-body: var(--font-sans);
  --font-code: var(--font-mono);

  /* Structure tokens */
  --radius-sm: .375rem;
  --radius-md: .5rem;
  --radius-lg: .75rem;
  --shadow-lg: 0 18px 50px rgba(42,37,28,.12);

  /* Code window (github-dark, always dark) */
  --code-bg:#0d1117; --code-border:#1f2630; --code-fg:#c9d1d9;
  --tok-c:#8b949e; --tok-k:#ff7b72; --tok-s:#a5d6ff; --tok-f:#d2a8ff; --tok-v:#79c0ff; --tok-n:#ffa657;

  /* Site colours (marketing.css tokens) */
  --bg:var(--bg-page); --surface:#FFFFFF; --surface-2:var(--bg-deep); --border:var(--bd-12);
  --text:var(--tx-4); --muted:var(--tx-7); --heading:var(--tx-1);
  --primary:var(--ac-text); --primary-strong:#4338CA; --primary-soft:rgba(var(--ac-rgb),.10); --on-primary:#ffffff;
  --accent:var(--ac-text); --accent-strong:#4338CA; --accent-soft:rgba(var(--ac-rgb),.06); --on-accent:#ffffff;
  --card-bg:var(--surface);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface:#0E1014;
  --primary-strong:#B9B5F5; --primary-soft:rgba(149,144,239,.16); --on-primary:#08090C;
  --accent-strong:#B9B5F5; --accent-soft:rgba(149,144,239,.08); --on-accent:#08090C;
  --shadow-lg:0 24px 70px rgba(0,0,0,.55);
}

/* ============================ Element base ======================== */
body { background: var(--bg); color: var(--text); font-family: var(--font-body); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; transition: background .25s, color .25s; }
h1, h2, h3, h4 { font-family: var(--font-title); font-weight: 600; color: var(--heading); line-height: 1.15; }
h1, h2 { letter-spacing: -0.02em; }
a { color: var(--primary); }
a:hover { color: var(--primary-strong); }

/* ============================ Code window (always dark) =========== */
.window { background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); overflow: hidden; }
.window-bar { display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid var(--code-border); background: #0b0f16; }
.window-bar i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.window-bar i:nth-child(1) { background: #ff5f56; }
.window-bar i:nth-child(2) { background: #ffbd2e; }
.window-bar i:nth-child(3) { background: #27c93f; }
.window-bar .file { margin-left: .6rem; color: #8b949e; font-family: var(--font-code); font-size: .78rem; }
pre { margin: 0; padding: 1.1rem 1.2rem; overflow: auto; }
code, pre { font-family: var(--font-code); font-size: .86rem; line-height: 1.7; color: var(--code-fg); }
.tok-c { color: var(--tok-c); font-style: italic; }
.tok-k { color: var(--tok-k); }
.tok-s { color: var(--tok-s); }
.tok-f { color: var(--tok-f); }
.tok-v { color: var(--tok-v); }
.tok-n { color: var(--tok-n); }
.cli .ok { color: #3fb950; }
.cli .dim { color: #8b949e; }
.cli .pr { color: #58a6ff; }
.cli .err { color: #f85149; }

/* ============================ Layout ============================== */
.docs { display: grid; grid-template-columns: 260px minmax(0,1fr) 220px; gap: 2.5rem; max-width: 1340px; margin-inline: auto; padding: 2rem 24px 5rem; }
/* sidebar */
.side { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow: auto; padding-right: .5rem; }
.side .grp { margin-bottom: 1.4rem; }
.side .grp h6 { font-family: var(--font-code); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 .6rem; padding-left: .6rem; }
.side a { display: block; color: var(--muted); font-size: .92rem; padding: .34rem .6rem; border-radius: 7px; border-left: 2px solid transparent; }
.side a:hover { color: var(--text); background: var(--surface); }
.side a.active { color: var(--primary); background: var(--primary-soft); border-left-color: var(--primary); font-weight: 600; }
.side a.soon { color: var(--muted); opacity: .45; cursor: default; pointer-events: none; }
.side a.later { opacity: .6; }
.side a.later small { font-family: var(--font-code); font-size: .7rem; opacity: .8; }
/* content */
.content { min-width: 0; }
.docs-meta { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.crumb { color: var(--muted); font-size: .85rem; }
.crumb b { color: var(--text); }
.content h1 { font-size: 2.4rem; font-weight: 600; letter-spacing: -.02em; margin-bottom: .6rem; }
.content h2 { font-size: 1.5rem; font-weight: 600; margin: 2.4rem 0 .8rem; scroll-margin-top: 84px; }
.content p { color: var(--text); margin: .9rem 0; line-height: 1.7; }
.content .lead { color: var(--muted); font-size: 1.12rem; }
.content ul { color: var(--text); line-height: 1.8; }
.content code:not(pre code) { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: .1rem .4rem; font-family: var(--font-code); font-size: .86em; color: var(--primary-strong); }
.content .window { margin: 1.2rem 0; box-shadow: none; }
.content h3 { font-size: 1.15rem; font-weight: 600; margin: 1.8rem 0 .6rem; scroll-margin-top: 84px; }
.table-wrap { overflow-x: auto; margin: 1.2rem 0; }
.content table { width: 100%; border-collapse: collapse; font-size: .92rem; line-height: 1.55; }
.content th, .content td { text-align: left; vertical-align: top; padding: .55rem .7rem; border-bottom: 1px solid var(--border); }
.content th { font-family: var(--font-title); color: var(--heading); background: var(--surface); }
.figure { margin: 1.4rem 0; }
.figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: var(--radius-md); }
.figure .img-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .figure .img-light { display: none; }
  :root:not([data-theme="light"]) .figure .img-dark { display: block; }
}
:root[data-theme="dark"] .figure .img-light { display: none; }
:root[data-theme="dark"] .figure .img-dark { display: block; }
.callout { display: flex; gap: .8rem; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: var(--radius-md); padding: 1rem 1.1rem; margin: 1.4rem 0; }
.callout svg { flex: none; width: 22px; height: 22px; color: var(--accent); margin-top: 2px; }
.callout b { color: var(--heading); font-family: var(--font-title); }
.pager { display: flex; justify-content: space-between; margin-top: 3rem; gap: 1rem; }
.pager a { flex: 1; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem; background: var(--card-bg); }
.pager small { color: var(--muted); }
.pager b { display: block; color: var(--primary); font-family: var(--font-title); }
/* toc */
.toc { position: sticky; top: 84px; align-self: start; font-size: .88rem; }
.toc h6 { font-family: var(--font-code); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 .7rem; }
.toc a { display: block; color: var(--muted); padding: .25rem 0; border-left: 2px solid var(--border); padding-left: .8rem; }
.toc a.active, .toc a:hover { color: var(--primary); border-left-color: var(--primary); }
/* version menu (next to the breadcrumb, AUD-259) */
.ver { flex: none; border: 1px solid var(--border); border-radius: 8px; padding: .35rem .6rem; background: var(--surface); color: var(--text); font-size: .85rem; font-family: var(--font-code); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ============================ A11y =============================== */
/* Skip link — first focusable element, reveals on focus */
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 200; background: var(--primary); color: var(--on-primary); padding: .6rem 1rem; border-radius: var(--radius-sm); font-family: var(--font-title); font-weight: 700; transition: top .15s; }
.skip-link:focus { top: 8px; }

/* ============================ Responsive ========================= */
@media (max-width: 1100px) { .docs { grid-template-columns: 240px 1fr; } .toc { display: none; } }
@media (max-width: 820px) { .docs { grid-template-columns: 1fr; } .side { display: none; } }
/* sticky site nav is 66px high: keep anchors and sticky columns below it */
