/*
 * Mjolnir Knowledge Base — Forge Design, Phase A (tokens / shell / typography)
 *
 * This is the authored source for assets/docs.css (copied verbatim by
 * build-docs.mjs's writeAssets() — see that file for the copy step). Editing
 * this file and rerunning the build is now the supported workflow; the old
 * inline `css` template-literal constant has been removed.
 *
 * Theme contract (matches the pattern already established by Analytics'
 * design-system/tokens/color.css and website-v3/css/site.css): :root carries
 * the light defaults; a prefers-color-scheme media query guarded with
 * :not([data-theme="light"]) supplies dark values when the visitor has no
 * explicit preference; an explicit [data-theme="dark"] block repeats the
 * same dark values so a future persistent toggle (Phase B) can win either
 * direction without touching this token layer. No [data-theme="light"]
 * block is needed — :root already is the light case, exactly as in both
 * sibling systems.
 *
 * Accent: #52A8FF (V3's "Compute" blue) — the approved single Mjolnir-family
 * accent for this phase. --color-link is a separate, darker, AA-contrast
 * blue for body text on a light surface, reusing V3's own solution to the
 * identical problem (site.css: "the same signal as text on the light room,
 * AA, 5.5:1") rather than inventing a new one.
 */

:root {
  /* ---- surfaces & text ---- */
  --color-bg: #f5f7fb;
  --color-surface: #ffffff;
  --color-surface-2: #eef2f8;
  --color-surface-3: #e4e9f1;
  --color-text: #10151f;
  --color-text-secondary: #3b4457;
  --color-text-muted: #626c80;
  --color-border: rgba(16, 23, 42, 0.12);
  --color-border-strong: rgba(16, 23, 42, 0.22);

  /* ---- accent ----
     --color-accent is tuned for dark surfaces, where it carries plenty of
     contrast. On this theme's light surfaces it measures 2.50:1 against
     #ffffff, which is fine for a border, a focus ring or a connector line but
     fails WCAG AA (4.5:1) the moment it is used as text. --color-accent-ink is
     the accent *as text*: same role, same blue family, enough weight to be
     readable. In the dark theme below the two are deliberately the same value,
     because there the original accent already passes. */
  --color-accent: #52a8ff;
  --color-accent-ink: #1a62b8;
  --color-accent-text: #ffffff;
  --color-link: #1a62b8;

  /* ---- code ---- */
  --color-code-bg: var(--color-surface-2);
  --color-code-text: var(--color-text);
  --color-pre-bg: #10151f;
  --color-pre-text: #eef2f8;
  --color-pre-border: rgba(82, 168, 255, 0.28);

  /* ---- focus ---- */
  --color-focus: var(--color-accent);

  /* ---- admonitions (structural recipe unchanged; Phase C may redesign) ---- */
  --color-note: var(--color-link);
  --color-note-bg: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
  /* Each callout label paints its own colour on color-mix(currentColor 14%,
     transparent) over the callout's own 9% tint — so the contrast that
     actually matters is colour-against-its-own-wash, not colour-against-white.
     Measured on that real stack, the previous values came in at 3.90 (tip),
     4.49 (warning) and 4.24 (important) against a 4.5 requirement. These are
     the same three hues, darkened the minimum needed to clear AA with margin:
     4.93, 4.97 and 4.90 respectively. --color-note (4.53) and --color-verify
     already passed and are unchanged. */
  --color-tip: #0f6650;
  --color-tip-bg: color-mix(in srgb, #0f6650 9%, var(--color-surface));
  --color-warning: #a81f18;
  --color-warning-bg: color-mix(in srgb, #a81f18 9%, var(--color-surface));
  --color-important: #8a4a00;
  --color-important-bg: color-mix(in srgb, #8a4a00 9%, var(--color-surface));
  --color-verify: #5c6472;
  --color-verify-bg: color-mix(in srgb, #5c6472 10%, var(--color-surface));

  /* ---- elevation ---- */
  --shadow-sm: 0 1px 2px rgba(16, 23, 42, 0.07);
  --shadow-md: 0 10px 28px rgba(16, 23, 42, 0.10);

  /* ---- geometry ---- */
  --radius: 6px;
  --radius-sm: 4px;
  --radius-pill: 999px;

  /* ---- type ---- */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 0.75rem;      /* 12px — instrument labels */
  --text-sm: 0.875rem;     /* 14px */
  --text-base: 1rem;       /* 16px — UI text */
  --text-article: 1.0625rem; /* 17px — reading density unchanged from before */
  --text-lg: 1.25rem;      /* 20px */
  --text-xl: 1.5rem;       /* 24px */
  --text-2xl: 1.875rem;    /* 30px */
  --text-display: clamp(2rem, 5vw, 3.25rem); /* 32–52px, h1 */

  --tracking-tight: -0.025em;
  --tracking-label: 0.08em;

  /* ---- spacing (4px scale) ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0c0f15;
    --color-surface: #12161f;
    --color-surface-2: #171c27;
    --color-surface-3: #1d2330;
    --color-text: #eef2f8;
    --color-text-secondary: #c3ccdc;
    --color-text-muted: #8b96ac;
    --color-border: rgba(196, 209, 232, 0.14);
    --color-border-strong: rgba(196, 209, 232, 0.24);

    --color-accent: #52a8ff;
    /* Dark surfaces: the accent already clears AA as text, so ink == accent. */
    --color-accent-ink: #52a8ff;
    --color-link: #7fbcff;

    --color-code-bg: var(--color-surface-2);
    --color-pre-bg: #05070c;
    --color-pre-text: #e6ecf6;
    --color-pre-border: rgba(82, 168, 255, 0.30);

    --color-note: var(--color-accent);
    --color-note-bg: color-mix(in srgb, var(--color-accent) 14%, var(--color-surface));
    --color-tip: #4fd1a5;
    --color-tip-bg: color-mix(in srgb, #4fd1a5 14%, var(--color-surface));
    --color-warning: #ff8a80;
    --color-warning-bg: color-mix(in srgb, #ff8a80 14%, var(--color-surface));
    --color-important: #ffb84d;
    --color-important-bg: color-mix(in srgb, #ffb84d 14%, var(--color-surface));
    --color-verify: #9aa4b6;
    --color-verify-bg: color-mix(in srgb, #9aa4b6 14%, var(--color-surface));

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 20px 48px rgba(0, 0, 0, 0.45);
  }
}

:root[data-theme="dark"] {
  --color-bg: #0c0f15;
  --color-surface: #12161f;
  --color-surface-2: #171c27;
  --color-surface-3: #1d2330;
  --color-text: #eef2f8;
  --color-text-secondary: #c3ccdc;
  --color-text-muted: #8b96ac;
  --color-border: rgba(196, 209, 232, 0.14);
  --color-border-strong: rgba(196, 209, 232, 0.24);

  --color-accent: #52a8ff;
  --color-accent-ink: #52a8ff;
  --color-link: #7fbcff;

  --color-code-bg: var(--color-surface-2);
  --color-pre-bg: #05070c;
  --color-pre-text: #e6ecf6;
  --color-pre-border: rgba(82, 168, 255, 0.30);

  --color-note: var(--color-accent);
  --color-note-bg: color-mix(in srgb, var(--color-accent) 14%, var(--color-surface));
  --color-tip: #4fd1a5;
  --color-tip-bg: color-mix(in srgb, #4fd1a5 14%, var(--color-surface));
  --color-warning: #ff8a80;
  --color-warning-bg: color-mix(in srgb, #ff8a80 14%, var(--color-surface));
  --color-important: #ffb84d;
  --color-important-bg: color-mix(in srgb, #ffb84d 14%, var(--color-surface));
  --color-verify: #9aa4b6;
  --color-verify-bg: color-mix(in srgb, #9aa4b6 14%, var(--color-surface));

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 20px 48px rgba(0, 0, 0, 0.45);
}

/* ==========================================================================
   Base / reset
   ========================================================================== */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/inter/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/inter/inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/inter/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/inter/inter-700.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("fonts/inter/inter-800.woff2") format("woff2");
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Instrument voice — small, muted, mono, tracked-uppercase labels.
   Reserved for metadata/labels only, never body prose (Phase A §10).
   ========================================================================== */
.label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Shell
   ========================================================================== */
.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--color-surface); color: var(--color-text);
  padding: var(--space-2) var(--space-3); z-index: 50;
  border-radius: var(--radius-sm);
}
.skip-link:focus { left: var(--space-2); top: var(--space-2); }

.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}

/* flex:0 1 auto + min-width:0 (rather than flex:none) so the wordmark
   truncates gracefully on very narrow viewports instead of forcing the
   header row into page-level horizontal overflow — header-controls holds
   the operable buttons and stays non-shrinking; this is the element that
   can safely give up space. */
.brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; flex: 0 1 auto; min-width: 0; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px;
  background: var(--color-accent); border-radius: var(--radius-sm); flex: none;
}
.brand-mark-img {
  width: 20px; height: 20px;
  filter: brightness(0) invert(1);
}
.brand-mark + span { min-width: 0; overflow: hidden; }
.brand small {
  display: block; color: var(--color-text-muted);
  font-family: var(--font-mono); font-size: var(--text-xs);
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.brand strong { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm); width: 40px; height: 40px; font-size: 18px;
  flex: none;
}
.icon-button:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.search-toggle, .menu-toggle { display: none; }

/* ==========================================================================
   Header controls — theme control + (mobile-only) search/menu triggers.
   ========================================================================== */
.header-controls { display: flex; align-items: center; gap: var(--space-2); flex: none; }

.theme-control { position: relative; flex: none; }
.theme-trigger {
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 40px; padding: 0 var(--space-3);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text-secondary);
  font-family: var(--font-sans); font-size: var(--text-sm); white-space: nowrap;
}
.theme-trigger:hover { border-color: var(--color-border-strong); color: var(--color-text); }
.theme-trigger-caption { color: var(--color-text-muted); }
.theme-trigger-value { font-weight: 600; color: var(--color-text); }

/* Which of the trigger's three state icons is visible. build-docs.mjs emits
   all three and this is the only thing that chooses between them, keyed on
   the preference the pre-paint inline script (and then docs.js) writes to
   :root. The :not([data-theme-pref]) arm is the no-JS / storage-blocked
   case, where System is in fact what is in effect. */
.theme-icon { flex: none; display: none; }
:root[data-theme-pref="system"] .theme-icon-system,
:root[data-theme-pref="light"] .theme-icon-light,
:root[data-theme-pref="dark"] .theme-icon-dark,
:root:not([data-theme-pref]) .theme-icon-system { display: block; }

/* The only on-screen sign that this button opens a menu. */
.theme-caret {
  flex: none; color: var(--color-text-muted);
  transition: transform 0.15s ease;
}
.theme-trigger[aria-expanded="true"] .theme-caret { transform: rotate(180deg); }

.theme-menu {
  position: absolute; top: calc(100% + var(--space-2)); right: 0; min-width: 200px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); padding: var(--space-1);
  z-index: 30;
}
.theme-option {
  display: block; width: 100%; text-align: left;
  padding: var(--space-2) var(--space-3);
  border: none; border-radius: var(--radius-sm); background: none;
  font-family: var(--font-sans); font-size: var(--text-sm); color: var(--color-text);
}
.theme-option:hover { background: var(--color-surface-2); }
.theme-option-label { display: block; }
.theme-option-hint { display: block; font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 0.15em; }
.theme-option[aria-checked="true"] .theme-option-label { color: var(--color-accent); font-weight: 600; }
/* Was content: " \2713". The bundled Inter subsets have no U+2713, so that
   glyph only ever rendered out of a fallback family — or as tofu where the
   OS had none. An inline SVG on currentColor is self-contained. */
.theme-option-check { display: none; }
.theme-option[aria-checked="true"] .theme-option-check {
  display: inline-block; vertical-align: -0.1em; margin-left: 0.3em;
}

.global-search { position: relative; flex: 1 1 320px; max-width: 480px; }
.global-search input, .home-search input {
  width: 100%; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3); font-size: var(--text-sm);
  font-family: var(--font-sans); background: var(--color-surface-2); color: var(--color-text);
}
.global-search input:focus, .home-search input:focus {
  outline: none; border-color: var(--color-accent); background: var(--color-surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 22%, transparent);
}
.search-results {
  position: absolute; top: 48px; left: 0; right: 0; max-height: 70vh; overflow: auto;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-md); display: none;
}
.search-results.is-open { display: block; }
.search-result {
  display: block; padding: var(--space-3); text-decoration: none;
  border-bottom: 1px solid var(--color-border); color: var(--color-text);
}
.search-result:hover { background: var(--color-surface-2); }
.search-result span { display: block; color: var(--color-text-muted); font-size: var(--text-xs); }

.top-links { display: flex; gap: var(--space-4); align-items: center; font-size: var(--text-sm); flex: none; }
.top-links a:hover { color: var(--color-accent); }

.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 65px); }

.sidebar {
  border-right: 1px solid var(--color-border);
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  padding: var(--space-4) var(--space-3); overflow: auto;
  position: sticky; top: 65px; height: calc(100vh - 65px);
  backdrop-filter: blur(10px);
}
.side-home, .side-title, .side-items a { display: block; text-decoration: none; border-radius: var(--radius-sm); }
.side-home {
  padding: var(--space-2) var(--space-3); font-weight: 700;
  background: var(--color-surface-2); margin-bottom: var(--space-3);
  color: var(--color-text);
}
.side-section { margin-bottom: var(--space-2); border-left: 3px solid transparent; }
.side-title {
  padding: var(--space-2) var(--space-3); font-weight: 600;
  color: var(--color-text-secondary);
}
.side-section.is-active {
  border-left-color: var(--color-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--color-accent) 12%, transparent), color-mix(in srgb, var(--color-accent) 4%, transparent));
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.side-section.is-active .side-title { color: var(--color-text); }
.side-items { display: none; padding-left: var(--space-2); }
.side-section.is-active .side-items { display: block; }
.side-items a {
  position: relative;
  padding: var(--space-1) var(--space-3); color: var(--color-text-muted); font-size: var(--text-sm);
  transition: background 0.15s ease, color 0.15s ease;
}
.side-items a:hover { background: var(--color-surface-2); color: var(--color-text); }
.side-items a[aria-current="page"] {
  background: var(--color-surface-2); color: var(--color-text); font-weight: 600;
}
.side-items a[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; border-radius: var(--radius-pill);
  background: var(--color-accent);
}

/* container-type establishes .content as the sizing reference for `cqw`
   units below — lets a wide-table breakout (see .table-wrap.wide-table)
   measure against .content's actual width (padding excluded) rather than
   .doc-article's narrower 68ch prose column, without touching .content's
   own layout at all: it already has a definite width from the grid
   (max-width + width:100%), so establishing size containment here changes
   nothing about how .content itself renders. */
.content { max-width: 1180px; width: 100%; padding: var(--space-6) clamp(var(--space-4), 4vw, var(--space-7)); container-type: inline-size; }

/* Global documentation-accuracy notice — a quiet footnote, never a warning.
   Sits outside <main data-pagefind-body>, so it is not part of the search
   index (Pagefind only indexes within the data-pagefind-body element) and
   never appears once per page as a duplicate result. */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
}
.footer-notice {
  max-width: 68ch; margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  line-height: 1.6;
}
.footer-notice strong { color: var(--color-text-secondary); font-weight: 600; }
.footer-notice a { color: var(--color-link); text-underline-offset: 2px; }
.footer-notice a:hover { color: var(--color-accent); }

.breadcrumbs {
  font-family: var(--font-mono); font-size: var(--text-xs);
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--color-text-muted); margin-bottom: var(--space-5);
}
.breadcrumbs a { color: var(--color-text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--color-accent); }

/* ==========================================================================
   Hero / category surfaces — flat, restrained (no gradient hero, no glow).
   ========================================================================== */
.home-hero, .category-hero {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: clamp(var(--space-6), 5vw, var(--space-8));
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.home-hero h1, .category-hero h1, .doc-article h1 {
  font-size: var(--text-display); line-height: 1.06; letter-spacing: var(--tracking-tight);
  font-weight: 700; margin: 0 0 var(--space-3);
}
.home-hero p, .category-hero p { max-width: 62ch; color: var(--color-text-secondary); font-size: var(--text-lg); }
.home-search { max-width: 42rem; margin-top: var(--space-5); }

.eyebrow {
  font-family: var(--font-mono); text-transform: uppercase; letter-spacing: var(--tracking-label);
  font-size: var(--text-xs); color: var(--color-accent); font-weight: 600;
}

.doc-section { margin-top: var(--space-6); }
.doc-section h2, .doc-article h2 { font-size: var(--text-2xl); margin: 0 0 var(--space-4); color: var(--color-text); font-weight: 700; letter-spacing: var(--tracking-tight); }

/* ==========================================================================
   Cards
   ========================================================================== */
.card-grid, .category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--space-3); }
.card, .category-card {
  display: block; text-decoration: none; background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: var(--space-4); box-shadow: var(--shadow-sm); min-height: 140px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover, .card:focus-visible, .category-card:hover, .category-card:focus-visible {
  border-color: var(--color-accent); box-shadow: var(--shadow-md);
}
.card span {
  display: inline-block; color: var(--color-accent-ink); font-family: var(--font-mono);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: var(--tracking-label); text-transform: uppercase;
}
.card strong, .category-card strong { display: block; margin: var(--space-2) 0; font-size: var(--text-lg); color: var(--color-text); }
.card p, .category-card p { margin: 0; color: var(--color-text-muted); font-size: var(--text-sm); }
.compact { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* Category cards are the top-level IA index — a documentation destination,
   not a dashboard tile — so they get a touch more room and a directional
   affordance instead of the compact task-card treatment above. */
.category-card { padding: var(--space-5); }
.category-card strong {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  font-size: var(--text-xl);
}
/* Was content: "\2192" on ::after. The bundled Inter subsets have no U+2192,
   so that arrow only ever drew out of a fallback family at a mismatched
   weight. build-docs.mjs now emits .card-arrow as inline SVG in the same
   place; the hover colour and translate are unchanged. */
.category-card strong .card-arrow {
  flex: none; color: var(--color-text-muted);
  transition: transform 0.15s ease, color 0.15s ease;
}
.category-card:hover strong .card-arrow, .category-card:focus-visible strong .card-arrow {
  color: var(--color-accent); transform: translateX(3px);
}
.category-card p { font-size: var(--text-base); }

/* ==========================================================================
   Figures — authored inline SVG admitted by markdownToHtml's
   `<!-- figure: <id> -->` directive. Every colour inside a figure is one of
   the tokens above or currentColor, so Light/Dark/System all follow with no
   second asset and no JavaScript.
   ========================================================================== */
.doc-figure { margin: var(--space-6) 0; }
.doc-figure svg { display: block; width: 100%; height: auto; }
.doc-figure figcaption {
  margin-top: var(--space-3); color: var(--color-text-muted);
  font-size: var(--text-sm); line-height: 1.5;
}

/* Two authored layouts, not one scaled down. A figure drawn for ~700px of
   prose column reaches a phone at roughly half scale, which takes 15px
   labels below 8px — technically "responsive" and practically unreadable.
   The narrow layout is redrawn with the same content at full type size.
   Gated on @container rather than @media because .content already
   establishes an inline-size container (see its container-type above), so
   this measures the actual prose column and stays correct whether or not
   the sidebar is on screen. */
/* Selector depth matters here: `.doc-figure svg` above is (0,1,1), so a bare
   `.fig-narrow` (0,1,0) would lose to it and both layouts would paint. */
.doc-figure .fig-narrow { display: none; }
@container (max-width: 640px) {
  .doc-figure .fig-wide { display: none; }
  .doc-figure .fig-narrow { display: block; }
}

/* Related — visually lighter and subordinate to the article: no shadow, no
   card-grid weight, a quiet inline list of links rather than a second wall
   of tiles. Uses the same underlying .card markup/matching logic — only the
   ancestor scoping below changes how it's drawn. */
.related { margin-top: var(--space-7); padding-top: var(--space-5); border-top: 1px solid var(--color-border); }
.related h2 { font-size: var(--text-lg); font-weight: 600; color: var(--color-text-secondary); }
.related .card {
  padding: var(--space-3) var(--space-4); box-shadow: none; min-height: 0; border-color: var(--color-border);
}
.related .card:hover, .related .card:focus-visible {
  box-shadow: none; border-color: var(--color-border-strong); background: var(--color-surface-2);
}
.related .card span { font-size: 0.6875rem; }
.related .card strong { font-size: var(--text-base); margin: var(--space-1) 0; }
.related .card p { font-size: var(--text-xs); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.split > div, .split-single {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: var(--space-5);
}
.split-single { max-width: 32rem; }

.text-link { color: var(--color-link); font-weight: 600; }
.text-link:hover { color: var(--color-accent); }

/* ==========================================================================
   Article body
   ========================================================================== */
.doc-article { max-width: 68ch; }
.article-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.article-meta span {
  font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: var(--tracking-label);
  text-transform: uppercase; color: var(--color-text-muted);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2);
}
.doc-article h1 { margin-top: 0; }
.doc-article h3 { font-size: var(--text-xl); font-weight: 700; letter-spacing: var(--tracking-tight); margin: var(--space-5) 0 var(--space-3); }
.doc-article h4 { font-size: var(--text-lg); font-weight: 700; margin: var(--space-4) 0 var(--space-2); }
.doc-article p, .doc-article li { font-size: var(--text-article); }
.doc-article a { color: var(--color-link); text-underline-offset: 3px; }
.doc-article a:hover { color: var(--color-accent); }
.doc-article code {
  font-family: var(--font-mono); background: var(--color-code-bg); color: var(--color-code-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 0.1em 0.35em; font-size: 0.9em;
}
.doc-article p code, .doc-article li code, .callout code { overflow-wrap: anywhere; word-break: break-word; }

/* ==========================================================================
   Code blocks — a small instrument bar (language tag + copy control) above
   a plain <pre>, rather than a floating control layered over the code
   itself. The bar carries data-pagefind-ignore so "Copy"/"Copied" and the
   language tag never enter the search index — only the code is indexed.
   ========================================================================== */
.code-block {
  margin: var(--space-4) 0;
  border: 1px solid var(--color-pre-border);
  border-radius: var(--radius);
  background: var(--color-pre-bg);
  overflow: hidden;
}
.code-block-bar {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-1) var(--space-2) var(--space-1) var(--space-3);
  border-bottom: 1px solid color-mix(in srgb, var(--color-pre-text) 14%, transparent);
  background: color-mix(in srgb, var(--color-pre-text) 5%, transparent);
}
.code-block-lang {
  margin-right: auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-size: var(--text-xs);
  letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: color-mix(in srgb, var(--color-pre-text) 55%, transparent);
}
.copy-button {
  flex: none;
  border: none; background: none; cursor: pointer;
  color: color-mix(in srgb, var(--color-pre-text) 70%, transparent);
  font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 500;
  padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm);
  min-height: 36px;
}
.copy-button:hover { background: color-mix(in srgb, var(--color-pre-text) 12%, transparent); color: var(--color-pre-text); }
.copy-button[data-copy-state="copied"] { color: var(--color-pre-text); font-weight: 700; }

.doc-article pre {
  margin: 0;
  font-family: var(--font-mono); font-size: var(--text-sm);
  background: none; color: var(--color-pre-text);
  padding: var(--space-4); overflow: auto;
  border: none; border-radius: 0;
}
/* A long command line makes this <pre> a horizontally scrollable region, and a
   scrollable region that cannot be focused is unreachable without a pointer:
   keyboard-only users could not scroll to read the rest of the command. The
   markup therefore carries tabindex="0" (see codeBlockHtml in build-docs.mjs),
   which is only useful if the resulting focus is actually visible — and the
   global :focus-visible ring draws 2px OUTSIDE the element, where .code-block's
   own overflow:hidden would clip it. Inset the ring for this one case so it
   lands inside the block and stays visible against the dark code surface. */
.doc-article pre:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: -2px;
}
.doc-article pre code { background: none; border: none; padding: 0; color: inherit; white-space: pre; }

.doc-article h2, .doc-article h3, .doc-article h4 { scroll-margin-top: 80px; }
.anchor { margin-left: var(--space-2); color: var(--color-border-strong); text-decoration: none; font-weight: 600; opacity: 0; }
.doc-article h2:hover .anchor, .doc-article h3:hover .anchor, .doc-article h4:hover .anchor, .anchor:focus { opacity: 1; color: var(--color-accent); }

.table-wrap { overflow-x: auto; margin: var(--space-4) 0; border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); }
.doc-article table { border-collapse: collapse; width: 100%; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.doc-article th {
  text-align: left; padding: var(--space-3); background: var(--color-surface-2);
  color: var(--color-text-secondary); font-family: var(--font-mono); font-size: var(--text-xs);
  font-weight: 700; text-transform: uppercase; letter-spacing: var(--tracking-label);
  border-bottom: 1px solid var(--color-border-strong); white-space: nowrap;
}
.doc-article td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); vertical-align: top; }
.doc-article tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--color-surface-2) 45%, transparent); }
.doc-article tr:last-child td { border-bottom: none; }
.doc-article td code { white-space: nowrap; }

/* Horizontal first-column pinning — opt-in via `.table-wrap.pin-first-col`
   (see markdownToHtml's `<!-- pin-first-column -->` directive), not global:
   audited, only one of 33 authored tables is wide enough to ever actually
   scroll. Keeps the row-identifying first cell in view while later columns
   scroll underneath it. This is horizontal (`left: 0` within .table-wrap's
   own overflow-x:auto), unrelated to — and must never reintroduce — the
   vertical `position: sticky; top: ...` header pinning removed earlier for
   overlapping rows; .doc-article th here still carries no `top`/vertical
   stickiness of its own.
   The zebra stripe above is intentionally translucent (mixed with
   `transparent`) so it reads correctly over .table-wrap's own opaque
   background — a sticky cell needs its OWN opaque background instead, or
   the column scrolling underneath would show through. These rules restate
   the same header/body/zebra colors as fully opaque equivalents, scoped to
   just the pinned cell. */
.table-wrap.pin-first-col th:first-child,
.table-wrap.pin-first-col td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: 1px solid var(--color-border-strong);
}
.table-wrap.pin-first-col th:first-child { z-index: 2; background: var(--color-surface-2); }
.table-wrap.pin-first-col td:first-child { background: var(--color-surface); }
.table-wrap.pin-first-col tbody tr:nth-child(even) td:first-child {
  background: color-mix(in srgb, var(--color-surface-2) 45%, var(--color-surface));
}

/* Wide-table breakout — opt-in via `.table-wrap.wide-table` (see
   markdownToHtml's `<!-- wide-table -->` directive), scoped the same way
   as pin-first-col and for the same reason: only 1 of 33 authored tables
   is wide enough to need more room than .doc-article's 68ch prose column
   provides, so this doesn't touch ordinary prose or any other table.
   `cqw` measures against .content (see its container-type above),
   deliberately skipping past .doc-article's own max-width — that's the
   whole mechanism: no negative margins, no viewport-unit math that would
   have to separately replicate .content's own max-width/padding/sidebar
   logic, no JS. Capped at 56rem: comfortably fits this table's ~819px
   natural width without spanning anywhere near .content's full 1180px on
   very wide screens.
   No media-query gate: below the ~900px point where .content's own
   available width already exceeds .doc-article's 686px cap, .content's
   content-box is smaller than 686px too, so `100cqw` naturally resolves
   to what .doc-article was already rendering at — this rule is a no-op
   there, not a separate narrow-width behavior to maintain. Between there
   and roughly 1200px (measured; varies a little by rendering engine) it
   narrows the scroll gap without fully closing it; from there up all 7
   columns fit with no scroll at all. */
.table-wrap.wide-table { width: min(56rem, 100cqw); max-width: none; }

.callout {
  margin: var(--space-4) 0; padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm); border: 1px solid var(--color-border); border-left-width: 3px;
  background: var(--color-surface);
}
.callout p { margin: 0; }
.callout p + p { margin-top: var(--space-2); }
.callout-label {
  display: inline-flex; align-items: baseline;
  padding: 0.05em 0.5em; margin-right: var(--space-2);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, currentColor 14%, transparent);
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: var(--tracking-label); font-family: var(--font-mono);
}
.callout-note { border-left-color: var(--color-note); background: var(--color-note-bg); }
.callout-note .callout-label { color: var(--color-note); }
.callout-tip { border-left-color: var(--color-tip); background: var(--color-tip-bg); }
.callout-tip .callout-label { color: var(--color-tip); }
.callout-warning { border-left-color: var(--color-warning); background: var(--color-warning-bg); }
.callout-warning .callout-label { color: var(--color-warning); }
.callout-important { border-left-color: var(--color-important); background: var(--color-important-bg); }
.callout-important .callout-label { color: var(--color-important); }
.callout-verify { border-left-color: var(--color-verify); background: var(--color-verify-bg); }
.callout-verify .callout-label { color: var(--color-verify); }

.doc-article ol { padding-left: 1.375rem; }
.doc-article ol li { margin-bottom: var(--space-1); }
.doc-article blockquote { margin: var(--space-4) 0; padding: var(--space-2) var(--space-4); border-left: 3px solid var(--color-border); color: var(--color-text-muted); }

/* ==========================================================================
   Mobile — off-canvas nav (Phase A model, Phase B polish) + a compact
   search trigger replacing the permanent search bar, tokens only.
   ========================================================================== */
@media (max-width: 900px) {
  .site-header { gap: var(--space-2); }
  .global-search { display: none; }
  .top-links { display: none; }
  .theme-trigger-caption { display: none; }
  .theme-trigger { padding: 0 var(--space-2); }
  .search-toggle, .menu-toggle { display: inline-flex; }

  /* The same search element used on desktop becomes a full-panel overlay,
     rather than a second, duplicate search UI. */
  .global-search.is-open-panel {
    display: block; position: fixed; inset: 65px 0 0 0; z-index: 25;
    background: var(--color-surface); padding: var(--space-4); overflow: auto;
    max-width: none;
  }
  .global-search.is-open-panel input { font-size: var(--text-base); }
  .global-search.is-open-panel .search-results {
    position: static; display: block; margin-top: var(--space-3);
    border: none; box-shadow: none; max-height: none;
  }

  .layout { display: block; }
  .sidebar {
    position: fixed; inset: 65px auto 0 0; width: min(86vw, 320px);
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: var(--shadow-md); z-index: 19;
  }
  .sidebar.is-open { transform: translateX(0); }

  /* Dimmed backdrop behind the off-canvas nav so the page underneath reads
     as inactive rather than just partially obscured; also used to catch
     outside-clicks that should close the nav. */
  body.nav-open, body.search-open { overflow: hidden; }
  body.nav-open::after {
    content: ""; position: fixed; inset: 65px 0 0 0; z-index: 18;
    background: rgba(6, 9, 15, 0.45);
  }

  .content { padding: var(--space-5) var(--space-4); }
  .split { grid-template-columns: 1fr; }
  .home-hero h1, .category-hero h1, .doc-article h1 { font-size: 2rem; }
  .site-footer { padding: var(--space-4); }
}
