/*
 * Wizz.js documentation — global design system.
 *
 * Spatial glassmorphism over an animated aurora substrate. Component-scoped
 * rules live in each .wizz file's <wizz:style>; this sheet owns tokens, the
 * substrate, the reset, the shared document shell, prose typography, glass
 * primitives, motion utilities, and the cross-document view transitions.
 *
 * Blur budget: backdrop-filter is applied only to sibling chrome (top dock,
 * sidebar, article pane, TOC) and the search dialog — never nested. Inner
 * surfaces (code, callouts, sandboxes) are tier-2 wells with zero blur.
 */

/* ------------------------------------------------------------------ */
/* 1. Tokens                                                           */
/* ------------------------------------------------------------------ */

:root {
  color-scheme: dark;

  /* Substrate & aurora orbs (Cosmic Aurora with a Wizz amber spark) */
  --canvas: light-dark(oklch(0.97 0.012 255), oklch(0.14 0.03 268));
  --orb-1: light-dark(oklch(0.86 0.09 215), oklch(0.62 0.17 215));
  --orb-2: light-dark(oklch(0.84 0.1 295), oklch(0.45 0.22 292));
  --orb-3: light-dark(oklch(0.9 0.1 85), oklch(0.62 0.16 70));
  --orb-4: light-dark(oklch(0.88 0.08 350), oklch(0.5 0.2 350));
  --orb-opacity: 0.55;
  --grid-dot: light-dark(oklch(0.3 0.03 260 / 0.07), oklch(1 0 0 / 0.045));

  /* Optical ink */
  --ink: light-dark(oklch(0.2 0.035 262), oklch(0.97 0.006 250));
  --ink-2: light-dark(oklch(0.36 0.035 262), oklch(0.86 0.018 255));
  --ink-3: light-dark(oklch(0.5 0.03 262), oklch(0.72 0.025 255));
  --ink-shadow: 0 1px 10px oklch(0 0 0 / 0.28);

  /* Brand & semantic accents */
  --accent: light-dark(oklch(0.55 0.2 292), oklch(0.78 0.14 292));
  --accent-strong: light-dark(oklch(0.47 0.22 292), oklch(0.86 0.11 292));
  --amber: light-dark(oklch(0.62 0.15 70), oklch(0.86 0.16 88));
  --cyan: light-dark(oklch(0.55 0.12 215), oklch(0.84 0.12 210));
  --mint: light-dark(oklch(0.55 0.13 160), oklch(0.84 0.14 160));
  --rose: light-dark(oklch(0.55 0.2 15), oklch(0.78 0.15 15));
  --focus-ring: light-dark(oklch(0.55 0.2 292), oklch(0.86 0.13 210));

  /* Surfaces: tier 1 pane, tier 2 well, tier 3 lens */
  --pane-top: light-dark(oklch(1 0 0 / 0.72), oklch(0.24 0.035 268 / 0.62));
  --pane-bottom: light-dark(oklch(1 0 0 / 0.58), oklch(0.17 0.03 268 / 0.5));
  --lens-top: light-dark(oklch(1 0 0 / 0.84), oklch(0.27 0.04 268 / 0.72));
  --lens-bottom: light-dark(oklch(1 0 0 / 0.68), oklch(0.19 0.035 268 / 0.6));
  --well: light-dark(oklch(0.96 0.01 260 / 0.75), oklch(0.09 0.02 268 / 0.62));
  --well-border: light-dark(oklch(0.3 0.03 260 / 0.1), oklch(1 0 0 / 0.08));
  --hairline: light-dark(oklch(0.3 0.03 260 / 0.12), oklch(1 0 0 / 0.1));
  --hover-fill: light-dark(oklch(0.3 0.05 270 / 0.06), oklch(1 0 0 / 0.07));
  --active-fill: light-dark(oklch(0.55 0.2 292 / 0.12), oklch(0.78 0.14 292 / 0.16));

  --rim-hi: light-dark(oklch(1 0 0 / 0.95), oklch(1 0 0 / 0.42));
  --rim-mid: light-dark(oklch(1 0 0 / 0.4), oklch(1 0 0 / 0.12));
  --rim-lo: light-dark(oklch(0.3 0.03 260 / 0.14), oklch(1 0 0 / 0.04));
  --glint: light-dark(oklch(1 0 0 / 0.9), oklch(1 0 0 / 0.26));
  --shadow-color: light-dark(oklch(0.35 0.06 270 / 0.16), oklch(0 0 0 / 0.5));

  --specular-rim: linear-gradient(135deg, var(--rim-hi) 0%, var(--rim-mid) 45%, var(--rim-lo) 100%);
  --pane-fill: linear-gradient(135deg, var(--pane-top), var(--pane-bottom));
  --lens-fill: linear-gradient(135deg, var(--lens-top), var(--lens-bottom));

  --shadow-pane:
    0 1px 2px var(--shadow-color),
    0 18px 40px -18px var(--shadow-color),
    inset 0 1px 0 0 var(--glint);
  --shadow-lens:
    0 2px 6px var(--shadow-color),
    0 28px 60px -20px var(--shadow-color),
    inset 0 1px 0 0 var(--glint);

  --blur-sm: blur(12px) saturate(160%);
  --blur-md: blur(20px) saturate(175%);
  --blur-lg: blur(28px) saturate(185%);

  /* Concentric radius scale */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-pill: 9999px;

  /* Syntax palette (legible on the well in both themes) */
  --code-ink: light-dark(oklch(0.25 0.03 262), oklch(0.92 0.012 255));
  --tok-kw: light-dark(oklch(0.5 0.2 300), oklch(0.8 0.13 300));
  --tok-str: light-dark(oklch(0.5 0.13 150), oklch(0.84 0.13 150));
  --tok-num: light-dark(oklch(0.55 0.15 50), oklch(0.84 0.13 60));
  --tok-com: light-dark(oklch(0.55 0.02 260), oklch(0.62 0.03 260));
  --tok-tag: light-dark(oklch(0.5 0.15 230), oklch(0.8 0.12 220));
  --tok-attr: light-dark(oklch(0.55 0.13 70), oklch(0.86 0.12 85));
  --tok-dir: light-dark(oklch(0.55 0.2 350), oklch(0.8 0.15 350));
  --tok-fn: light-dark(oklch(0.48 0.13 255), oklch(0.82 0.1 250));
  --tok-pun: light-dark(oklch(0.45 0.03 260), oklch(0.72 0.03 260));

  /* Type */
  --font-sans: "Inter Variable", "Inter", "SF Pro Text", system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "SF Pro Display", "Inter Variable", "Inter", system-ui, -apple-system,
    "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo,
    Consolas, monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: linear(0, 0.06, 0.25 18%, 0.81 36%, 1.05 45%, 1.09 50%, 1.02 62%, 1 100%);
  --dur-fast: 160ms;
  --dur: 260ms;
  --dur-slow: 700ms;
  --stagger: 70ms;

  /* Layout */
  --nav-h: 4rem;
  --nav-gap: 0.75rem;
  --sidebar-w: 16.5rem;
  --toc-w: 14rem;
  --content-max: 50rem;
  --chrome-top: calc(var(--nav-h) + var(--nav-gap) * 2);
}

:root[data-theme="light"] {
  color-scheme: light;
  --orb-opacity: 0.8;
  --ink-shadow: none;
}

/* ------------------------------------------------------------------ */
/* 2. Reset & base                                                     */
/* ------------------------------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-block-start: calc(var(--chrome-top) + 1rem);
  /* The canvas lives on html only: a body background would paint above the
     negative-z-index aurora layers and hide them. */
  background-color: var(--canvas);
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 22px 22px;
}

body {
  margin: 0;
  min-block-size: 100dvh;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 450;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

/* Aurora substrate: two fixed layers of blurred orbs, drifting on the
   compositor (transform only). Glass panes refract these. */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: -20vmax;
  z-index: -1;
  pointer-events: none;
  opacity: var(--orb-opacity);
  will-change: transform;
}

body::before {
  background:
    radial-gradient(28vmax 28vmax at 18% 22%, var(--orb-2), transparent 70%),
    radial-gradient(24vmax 24vmax at 82% 18%, var(--orb-1), transparent 70%);
  animation: aurora-drift-a 26s var(--ease-in-out) infinite alternate;
}

body::after {
  background:
    radial-gradient(22vmax 22vmax at 70% 78%, var(--orb-4), transparent 70%),
    radial-gradient(18vmax 18vmax at 28% 82%, var(--orb-3), transparent 72%);
  animation: aurora-drift-b 32s var(--ease-in-out) infinite alternate;
}

@keyframes aurora-drift-a {
  from { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  to { transform: translate3d(6vmax, 4vmax, 0) rotate(12deg) scale(1.08); }
}

@keyframes aurora-drift-b {
  from { transform: translate3d(0, 0, 0) rotate(0deg) scale(1.05); }
  to { transform: translate3d(-5vmax, -6vmax, 0) rotate(-10deg) scale(0.96); }
}

#app {
  isolation: isolate;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p, li {
  text-wrap: pretty;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--accent-strong);
}

code, kbd, pre, samp {
  font-family: var(--font-mono);
}

img, video {
  max-inline-size: 100%;
  block-size: auto;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background-color: color-mix(in oklch, var(--accent) 35%, transparent);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* 3. Glass primitives                                                 */
/* ------------------------------------------------------------------ */

.glass {
  background-image: var(--pane-fill), var(--specular-rim);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  box-shadow: var(--shadow-pane);
}

.glass-lens {
  background-image: var(--lens-fill), var(--specular-rim);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  border: 1px solid transparent;
  backdrop-filter: var(--blur-lg);
  -webkit-backdrop-filter: var(--blur-lg);
  box-shadow: var(--shadow-lens);
}

.well {
  background-color: var(--well);
  border: 1px solid var(--well-border);
  border-radius: var(--r-md);
  box-shadow: inset 0 2px 8px light-dark(oklch(0.3 0.05 270 / 0.06), oklch(0 0 0 / 0.35));
}

/* Pointer-tracked light sheen. Set --mx / --my on the element (see the
   delegated pointermove handlers) and add .sheen. */
.sheen {
  position: relative;
  isolation: isolate;
}

.sheen::after {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(22rem circle at var(--mx, 50%) var(--my, 0%),
      color-mix(in oklch, var(--accent) 22%, transparent), transparent 60%);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
  pointer-events: none;
}

.sheen::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background:
    radial-gradient(16rem circle at var(--mx, 50%) var(--my, 0%),
      color-mix(in oklch, var(--cyan) 80%, transparent), transparent 65%);
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
  pointer-events: none;
}

.sheen:hover::after,
.sheen:hover::before,
.sheen:focus-within::before {
  opacity: 1;
}

/* ------------------------------------------------------------------ */
/* 4. Buttons, badges, kbd, icons                                      */
/* ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-block-size: 2.75rem;
  padding-inline: 1.25rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--hairline);
  background-color: var(--hover-fill);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--glint);
  transition:
    transform var(--dur-fast) var(--ease-out),
    background-color var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}

.btn:hover {
  color: var(--ink);
  background-color: color-mix(in oklch, var(--hover-fill), var(--ink) 6%);
  border-color: color-mix(in oklch, var(--accent) 45%, transparent);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0) scale(0.97);
}

.btn-primary {
  border-color: transparent;
  color: oklch(0.16 0.03 270);
  background-image: linear-gradient(120deg, oklch(0.88 0.12 210), oklch(0.8 0.14 292) 50%, oklch(0.88 0.14 80));
  background-size: 200% 100%;
  background-position: 0% 50%;
  box-shadow:
    0 10px 30px -10px color-mix(in oklch, var(--accent) 70%, transparent),
    inset 0 1px 0 oklch(1 0 0 / 0.6);
  transition:
    transform var(--dur-fast) var(--ease-out),
    background-position var(--dur-slow) var(--ease-out),
    box-shadow var(--dur) var(--ease-out);
}

.btn-primary:hover {
  color: oklch(0.16 0.03 270);
  background-position: 100% 50%;
  box-shadow:
    0 14px 36px -10px color-mix(in oklch, var(--accent) 85%, transparent),
    inset 0 1px 0 oklch(1 0 0 / 0.6);
}

.btn-sm {
  min-block-size: 2.25rem;
  padding-inline: 0.9rem;
  font-size: 0.85rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--r-pill);
  border: 1px solid color-mix(in oklch, var(--accent) 40%, transparent);
  background-color: color-mix(in oklch, var(--accent) 14%, transparent);
  color: var(--accent-strong);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 var(--glint);
}

.badge-mint {
  border-color: color-mix(in oklch, var(--mint) 45%, transparent);
  background-color: color-mix(in oklch, var(--mint) 14%, transparent);
  color: var(--mint);
}

.badge-amber {
  border-color: color-mix(in oklch, var(--amber) 45%, transparent);
  background-color: color-mix(in oklch, var(--amber) 14%, transparent);
  color: var(--amber);
}

kbd {
  display: inline-block;
  min-inline-size: 1.5em;
  padding: 0.05em 0.4em;
  border-radius: 6px;
  border: 1px solid var(--hairline);
  border-block-end-width: 2px;
  background-color: var(--hover-fill);
  color: var(--ink-2);
  font-size: 0.78em;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}

/* Icons are CSS masks over currentColor: the generator creates elements in
   the HTML namespace, so inline <svg> would not render on client mounts. */
.icon {
  display: inline-block;
  inline-size: 1.1em;
  block-size: 1.1em;
  flex: none;
  background-color: currentColor;
  mask: var(--icon) center / contain no-repeat;
  -webkit-mask: var(--icon) center / contain no-repeat;
}

.icon-github { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z'/></svg>"); }
.icon-search { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'><circle cx='10.5' cy='10.5' r='6.5'/><path d='m20 20-4.6-4.6'/></svg>"); }
.icon-sun { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><circle cx='12' cy='12' r='4.5'/><path d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/></svg>"); }
.icon-moon { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M20.5 14.6A8.5 8.5 0 0 1 9.4 3.5a8.5 8.5 0 1 0 11.1 11.1z'/></svg>"); }
.icon-menu { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><rect x='3' y='4' width='18' height='16' rx='3'/><path d='M9 4v16'/></svg>"); }
.icon-copy { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'><rect x='8' y='8' width='12' height='12' rx='2.5'/><path d='M16 8V6.5A2.5 2.5 0 0 0 13.5 4h-7A2.5 2.5 0 0 0 4 6.5v7A2.5 2.5 0 0 0 6.5 16H8'/></svg>"); }
.icon-check { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'><path d='m5 12.5 4.5 4.5L19 7.5'/></svg>"); }
.icon-arrow { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12h14M13 6l6 6-6 6'/></svg>"); }
.icon-arrow-left { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M19 12H5M11 6l-6 6 6 6'/></svg>"); }
.icon-chevron { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='m9 6 6 6-6 6'/></svg>"); }
.icon-bolt { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M13.5 2 4 14h7l-1 8 9.5-12h-7z'/></svg>"); }
.icon-doc { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'><path d='M6 3h8l4 4v14H6z'/><path d='M14 3v4h4M9 12h6M9 16h6'/></svg>"); }
.icon-hash { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><path d='M5 9h15M4 15h15M10 3 8 21M16 3l-2 18'/></svg>"); }
.icon-return { --icon: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M20 5v6a3 3 0 0 1-3 3H5M9 10l-4 4 4 4'/></svg>"); }

/* ------------------------------------------------------------------ */
/* 5. Document shell                                                   */
/* ------------------------------------------------------------------ */

.site {
  min-block-size: 100dvh;
  display: flex;
  flex-direction: column;
}

.doc-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 1.25rem;
  inline-size: 100%;
  max-inline-size: 92rem;
  margin-inline: auto;
  padding-inline: clamp(0.75rem, 2vw, 1.5rem);
  padding-block: var(--nav-gap) 3rem;
  align-items: start;
}

:root[data-sidebar="collapsed"] .doc-shell {
  grid-template-columns: 0 minmax(0, 1fr) var(--toc-w);
  column-gap: 0;
}

:root[data-sidebar="collapsed"] .doc-shell > .doc-main {
  margin-inline-end: 1.25rem;
}

.doc-main {
  min-inline-size: 0;
  padding: clamp(1.25rem, 3.5vw, 3rem);
  view-transition-name: doc-main;
}

.doc-main.glass {
  /* The article pane carries body copy: raise the opacity floor. */
  --pane-top: light-dark(oklch(1 0 0 / 0.8), oklch(0.2 0.03 268 / 0.74));
  --pane-bottom: light-dark(oklch(1 0 0 / 0.7), oklch(0.16 0.03 268 / 0.66));
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
}

@media (max-width: 75rem) {
  .doc-shell,
  :root[data-sidebar="collapsed"] .doc-shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  :root[data-sidebar="collapsed"] .doc-shell {
    grid-template-columns: 0 minmax(0, 1fr);
  }
}

@media (max-width: 56rem) {
  .doc-shell,
  :root[data-sidebar="collapsed"] .doc-shell {
    grid-template-columns: minmax(0, 1fr);
    column-gap: 0;
  }

  :root[data-sidebar="collapsed"] .doc-shell > .doc-main {
    margin-inline-end: 0;
  }

  .doc-main {
    border-radius: var(--r-md);
  }

  /* Scrim behind the off-canvas sidebar drawer. */
  .doc-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 35;
    background-color: oklch(0.08 0.02 268 / 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease-out);
  }

  :root[data-drawer="open"] .doc-shell::before {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ------------------------------------------------------------------ */
/* 6. Prose                                                            */
/* ------------------------------------------------------------------ */

.prose {
  max-inline-size: var(--content-max);
  margin-inline: auto;
  color: var(--ink-2);
}

.prose > * + * {
  margin-block-start: 1.1rem;
}

.prose h1 {
  margin: 0;
  font-size: clamp(2rem, 1.4rem + 2.4vw, 2.85rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  text-shadow: var(--ink-shadow);
}

.prose h2 {
  margin-block: 3rem 0;
  padding-block-start: 1.25rem;
  border-block-start: 1px solid var(--hairline);
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.75rem);
  font-weight: 750;
}

.prose h3 {
  margin-block: 2rem 0;
  font-size: 1.2rem;
  font-weight: 700;
}

.prose h2 + *,
.prose h3 + * {
  margin-block-start: 0.75rem;
}

.prose p,
.prose li {
  font-size: 1.02rem;
  line-height: 1.75;
}

.prose strong {
  color: var(--ink);
  font-weight: 650;
}

.prose ul,
.prose ol {
  padding-inline-start: 1.35rem;
}

.prose li + li {
  margin-block-start: 0.4rem;
}

.prose li::marker {
  color: var(--accent);
}

.prose :not(pre) > code {
  padding: 0.12em 0.38em;
  border-radius: 6px;
  border: 1px solid var(--well-border);
  background-color: var(--well);
  color: var(--ink);
  font-size: 0.86em;
  font-weight: 500;
  white-space: break-spaces;
}

.prose .lead {
  margin-block-start: 1rem;
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--ink-2);
}

.prose .eyebrow {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.85rem;
  color: var(--ink-3);
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.prose table {
  inline-size: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--well-border);
  border-radius: var(--r-md);
  overflow: hidden;
  background-color: var(--well);
  font-size: 0.92rem;
}

.table-scroll {
  overflow-x: auto;
  border-radius: var(--r-md);
}

.prose th,
.prose td {
  padding: 0.65rem 0.9rem;
  text-align: start;
  vertical-align: top;
  border-block-end: 1px solid var(--well-border);
}

.prose tr:last-child td {
  border-block-end: 0;
}

.prose th {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background-color: var(--hover-fill);
}

.prose td code {
  white-space: nowrap;
}

.prose hr {
  border: 0;
  border-block-start: 1px solid var(--hairline);
  margin-block: 2.5rem;
}

/* Heading anchors */
.prose .anchor {
  margin-inline-start: 0.4rem;
  color: var(--ink-3);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.prose h2:hover .anchor,
.prose h3:hover .anchor,
.prose .anchor:focus-visible {
  opacity: 1;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 1rem;
}

.mini-card {
  padding: 1.1rem 1.2rem;
  border-radius: var(--r-md);
  border: 1px solid var(--well-border);
  background-color: var(--hover-fill);
  box-shadow: inset 0 1px 0 var(--glint);
}

.mini-card h3,
.mini-card h4 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.mini-card p {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.6;
}

.sandbox {
  padding: clamp(1rem, 3vw, 1.5rem);
  border-radius: var(--r-lg);
  border: 1px dashed color-mix(in oklch, var(--accent) 40%, transparent);
  background:
    radial-gradient(120% 120% at 0% 0%, color-mix(in oklch, var(--accent) 10%, transparent), transparent 60%),
    var(--well);
}

.sandbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
  color: var(--ink-3);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sandbox-label::before {
  content: "";
  inline-size: 0.5rem;
  block-size: 0.5rem;
  border-radius: 50%;
  background-color: var(--mint);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--mint) 22%, transparent);
  animation: live-pulse 2.4s var(--ease-in-out) infinite;
}

@keyframes live-pulse {
  50% { box-shadow: 0 0 0 7px color-mix(in oklch, var(--mint) 0%, transparent); }
}

/* ------------------------------------------------------------------ */
/* 7. Motion utilities                                                 */
/* ------------------------------------------------------------------ */

/* Staggered entrance: set style="--i: n" for the step index. */
.rise {
  animation: rise var(--dur-slow) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * var(--stagger));
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* Scroll-driven reveal for long-form sections; static where unsupported. */
@supports (animation-timeline: view()) {
  .reveal {
    animation: reveal linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 35%;
  }

  @keyframes reveal {
    from {
      opacity: 0;
      transform: translateY(24px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* Reading-progress hairline driven by the root scroller. */
@supports (animation-timeline: scroll()) {
  .scroll-progress {
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    z-index: 60;
    block-size: 2px;
    background: linear-gradient(90deg, var(--cyan), var(--accent), var(--amber));
    transform-origin: 0 50%;
    animation: scroll-progress linear both;
    animation-timeline: scroll(root block);
    pointer-events: none;
  }

  @keyframes scroll-progress {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
  }
}

/* ------------------------------------------------------------------ */
/* 8. Cross-document page transitions                                  */
/* ------------------------------------------------------------------ */

/* Every docs link is a document navigation: the server renders the next
   page and the browser morphs between the two snapshots. Chrome stays put,
   the article slides, and the sidebar's active pill glides to its new row. */
@view-transition {
  navigation: auto;
}

::view-transition-old(doc-main) {
  animation: page-out 200ms var(--ease-in-out) both;
}

::view-transition-new(doc-main) {
  animation: page-in 420ms var(--ease-out) both;
}

::view-transition-group(nav-pill),
::view-transition-group(toc) {
  animation-duration: 420ms;
  animation-timing-function: var(--ease-spring);
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 260ms;
}

@keyframes page-out {
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.99);
  }
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.99);
  }
}

/* ------------------------------------------------------------------ */
/* 9. Accessibility safeguards                                         */
/* ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }

  body::before,
  body::after {
    animation: none !important;
  }

  @view-transition {
    navigation: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --pane-top: light-dark(oklch(0.99 0.004 255), oklch(0.2 0.03 268));
    --pane-bottom: var(--pane-top);
    --lens-top: light-dark(oklch(1 0 0), oklch(0.22 0.03 268));
    --lens-bottom: var(--lens-top);
  }

  .glass,
  .glass-lens,
  .doc-main.glass {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  body::before,
  body::after {
    opacity: 0.2;
  }
}

@media (forced-colors: active) {
  .glass,
  .glass-lens,
  .well,
  .btn {
    border: 1px solid CanvasText;
    background: Canvas;
  }

  .icon {
    background-color: CanvasText;
  }
}
