/* wayu docs: styles for every page under docs/docs/ (build/docs_shell.html). */

/* ── Fonts (same as index.html: self-hosted, metric-matched fallbacks) ── */
@font-face { font-family: 'Bricolage Grotesque'; src: url(/fonts/bricolage-grotesque.woff2) format('woff2'); font-weight: 700 800; font-style: normal; font-display: swap; }
@font-face { font-family: 'Geist'; src: url(/fonts/geist.woff2) format('woff2'); font-weight: 400 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Geist Mono'; src: url(/fonts/geist-mono.woff2) format('woff2'); font-weight: 400 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Bricolage Fallback'; src: local('Arial Bold'), local('Arial-BoldMT'), local('Liberation Sans Bold'), local('Arial'); font-weight: 700 800; size-adjust: 92.6%; ascent-override: 100.43%; descent-override: 29.16%; line-gap-override: 0%; }
@font-face { font-family: 'Geist Fallback'; src: local('Arial'), local('ArialMT'), local('Liberation Sans'); size-adjust: 103.87%; ascent-override: 96.76%; descent-override: 28.4%; line-gap-override: 0%; }
@font-face { font-family: 'Geist Mono Fallback'; src: local('Menlo'), local('Menlo-Regular'), local('DejaVu Sans Mono'); size-adjust: 99.66%; ascent-override: 100.84%; descent-override: 29.6%; line-gap-override: 0%; }

/* ── Tokens (same as index.html) ─────────────────────────────────────── */
:root {
  --bg:        #f5f1ec;
  --bg-2:      #ece6df;
  --surface:   #fbf9f6;
  --ink:       #1d1519;
  --ink-2:     #564a50;
  --ink-3:     #6f6268;
  --line:      rgba(29, 21, 25, 0.12);
  --line-2:    rgba(29, 21, 25, 0.2);
  --accent:    #c0003f;
  --accent-fill: #e40050;
  --accent-soft: rgba(228, 0, 80, 0.09);
  --on-accent: #fff8fa;
  --shadow:    0 1px 2px rgba(29, 21, 25, 0.06), 0 8px 24px -12px rgba(29, 21, 25, 0.18);
  --code-bg:   rgba(29, 21, 25, 0.065);
  --halo-1:    rgba(228, 0, 80, 0.18);
  --halo-2:    rgba(228, 0, 80, 0.10);
  --mark:      rgba(228, 0, 80, 0.16);

  --term-bg:   #1e1e2e;
  --term-bar:  #181825;
  --term-fg:   #cdd6f4;
  --term-dim:  #8b90a8;
  --term-ok:   #74c7ec;
  --term-dir:  #94e2d5;
  --term-git:  #f5c2e7;
  --term-arrow:#a6e3a1;
  --term-key:  #f9e2af;
  --term-pink: #f38ba8;

  --font-display: 'Bricolage Grotesque', 'Bricolage Fallback', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Geist', 'Geist Fallback', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Geist Mono', 'Geist Mono Fallback', ui-monospace, 'SF Mono', Menlo, monospace;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-swap: cubic-bezier(0.2, 0, 0, 1);
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --gutter: clamp(16px, 4vw, 40px);
  --header: 64px;
  --side: 264px;
  --toc: 220px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #141016;
    --bg-2:      #1b161d;
    --surface:   #1f1a21;
    --ink:       #f2ecef;
    --ink-2:     #b9adb3;
    --ink-3:     #8f8389;
    --line:      rgba(242, 236, 239, 0.1);
    --line-2:    rgba(242, 236, 239, 0.18);
    --accent:    #ff5b8f;
    --accent-soft: rgba(255, 91, 143, 0.12);
    --shadow:    0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
    --code-bg:   rgba(242, 236, 239, 0.08);
    --halo-1:    rgba(228, 0, 80, 0.32);
    --halo-2:    rgba(228, 0, 80, 0.16);
    --mark:      rgba(255, 91, 143, 0.26);
  }
}
:root[data-theme="dark"] {
  --bg:        #141016;
  --bg-2:      #1b161d;
  --surface:   #1f1a21;
  --ink:       #f2ecef;
  --ink-2:     #b9adb3;
  --ink-3:     #8f8389;
  --line:      rgba(242, 236, 239, 0.1);
  --line-2:    rgba(242, 236, 239, 0.18);
  --accent:    #ff5b8f;
  --accent-soft: rgba(255, 91, 143, 0.12);
  --shadow:    0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
  --code-bg:   rgba(242, 236, 239, 0.08);
  --halo-1:    rgba(228, 0, 80, 0.32);
  --halo-2:    rgba(228, 0, 80, 0.16);
  --mark:      rgba(255, 91, 143, 0.26);
}

/* ── Base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header) + 20px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.65 var(--font-body); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: clip; }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; letter-spacing: -0.02em; text-wrap: balance; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code, pre, kbd { font-family: var(--font-mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-fill); color: var(--on-accent); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r-sm); text-decoration: none; transition: transform 0.2s var(--ease-out); }
.skip:focus { transform: translateY(72px); }
kbd { display: inline-grid; place-items: center; min-width: 1.6em; height: 1.6em; padding: 0 0.35em; border-radius: 4px; font-size: 0.72rem; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line-2), 0 1px 0 var(--line-2); }

/* ── Header (same as the landing nav) ──────────────────────────────── */
.nav { position: sticky; top: 0; z-index: 50; height: var(--header); background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); box-shadow: 0 1px 0 var(--line); }
.nav-inner { display: flex; align-items: center; gap: 16px; height: 100%; padding: 0 var(--gutter); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font: 800 1.35rem/1 var(--font-display); letter-spacing: -0.03em; }
.brand-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent-fill); box-shadow: 0 0 0 2.5px var(--halo-1), 0 0 0 5px var(--halo-2); transition: box-shadow 0.3s var(--ease-out); }
.brand:hover .brand-dot { box-shadow: 0 0 0 3.5px var(--halo-1), 0 0 0 7px var(--halo-2); }
.brand-sub { font: 500 0.8rem/1 var(--font-mono); color: var(--ink-3); padding-left: 10px; margin-left: 2px; box-shadow: inset 1px 0 0 var(--line-2); }
.nav-inner > nav { margin-left: auto; }
.nav-links { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; align-items: center; }
.nav-links a:not(.icon-btn) { display: inline-flex; align-items: center; min-height: 40px; padding: 0 10px; color: var(--ink-2); text-decoration: none; font-size: 0.93rem; border-radius: var(--r-sm); transition: color 0.15s ease, background-color 0.15s ease; }
.nav-links a:not(.icon-btn):hover { color: var(--ink); background: var(--bg-2); }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink-2); cursor: pointer; transition: color 0.15s ease, background-color 0.15s ease, transform 0.15s var(--ease-out); }
.icon-btn:hover { color: var(--ink); background: var(--bg-2); }
.icon-btn:active { transform: scale(0.96); }
.icon-btn svg { width: 20px; height: 20px; }
.theme-btn .sun, .theme-btn .moon, .copy-btn .cp, .copy-btn .ok { grid-area: 1 / 1; transition: opacity 0.3s var(--ease-swap), transform 0.3s var(--ease-swap), filter 0.3s var(--ease-swap); }
.theme-btn .moon { opacity: 0; transform: scale(0.25); filter: blur(4px); }
:root[data-theme="dark"] .theme-btn .sun { opacity: 0; transform: scale(0.25); filter: blur(4px); }
:root[data-theme="dark"] .theme-btn .moon { opacity: 1; transform: none; filter: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { opacity: 0; transform: scale(0.25); filter: blur(4px); }
  :root:not([data-theme="light"]) .theme-btn .moon { opacity: 1; transform: none; filter: none; }
}
.menu-btn { display: none; margin-left: -8px; }
@media (max-width: 899px) { .menu-btn { display: inline-grid; } .nav-links .hide-sm { display: none; } .brand-sub { display: none; } }

/* ── Layout: sidebar · article · on-this-page ──────────────────────── */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); max-width: 1440px; margin: 0 auto; }
@media (min-width: 900px) { .layout { grid-template-columns: var(--side) minmax(0, 1fr); } }
@media (min-width: 1240px) { .layout { grid-template-columns: var(--side) minmax(0, 1fr) var(--toc); } }

.side { position: sticky; top: var(--header); align-self: start; height: calc(100dvh - var(--header)); overflow-y: auto; overscroll-behavior: contain; padding: 24px 16px 40px var(--gutter); box-shadow: inset -1px 0 0 var(--line); scrollbar-width: thin; }
@media (max-width: 899px) {
  .side { position: fixed; z-index: 60; top: var(--header); left: 0; width: min(320px, 86vw); height: calc(100dvh - var(--header)); padding: 20px 16px 40px; background: var(--bg); box-shadow: var(--shadow), inset -1px 0 0 var(--line); transform: translateX(-102%); visibility: hidden; transition: transform 0.3s var(--ease-out), visibility 0s linear 0.3s; }
  .nav-open .side { transform: none; visibility: visible; transition: transform 0.3s var(--ease-out), visibility 0s; }
  .scrim { position: fixed; inset: var(--header) 0 0 0; z-index: 55; background: rgba(20, 8, 16, 0.4); opacity: 0; pointer-events: none; transition: opacity 0.3s ease; }
  .nav-open .scrim { opacity: 1; pointer-events: auto; }
}
@media (min-width: 900px) { .scrim { display: none; } }

.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; height: 40px; padding: 0 40px 0 34px; border: 0; border-radius: var(--r); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); font: 400 0.92rem var(--font-body); transition: box-shadow 0.15s ease; }
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--accent); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd { position: absolute; right: 9px; top: 50%; margin-top: -0.8em; pointer-events: none; }
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { display: none; }

.side-label { margin: 24px 0 8px 10px; font: 500 0.72rem/1 var(--font-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
.pages { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.pages > li > a { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 6px 10px; border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 0.94rem; transition: color 0.15s ease, background-color 0.15s ease; }
.pages > li > a:hover { color: var(--ink); background: var(--bg-2); }
.pages > li > a[aria-current="page"] { color: var(--ink); background: var(--bg-2); }
.pages > li > a::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); transition: background-color 0.15s ease, box-shadow 0.15s ease; }
.pages > li > a[aria-current="page"]::before { background: var(--accent-fill); box-shadow: 0 0 0 2px var(--halo-1), 0 0 0 4px var(--halo-2); }

/* On-this-page lists: in the right rail on wide screens, nested in the sidebar otherwise */
.toc-list { margin: 0; padding: 0; list-style: none; }
.toc-list a { display: block; padding: 4px 10px 4px 12px; color: var(--ink-3); text-decoration: none; font-size: 0.85rem; line-height: 1.4; box-shadow: inset 1.5px 0 0 var(--line); transition: color 0.15s ease, box-shadow 0.15s ease; overflow-wrap: anywhere; }
.toc-list a:hover { color: var(--ink); }
.toc-list a.l3 { padding-left: 24px; font-size: 0.82rem; }
.toc-list a.active { color: var(--ink); box-shadow: inset 1.5px 0 0 var(--accent-fill); }
.side-toc { margin: 6px 0 8px 14px; }
@media (min-width: 1240px) { .side-toc { display: none; } }
.rail { display: none; }
@media (min-width: 1240px) { .rail { display: block; position: sticky; top: var(--header); align-self: start; max-height: calc(100dvh - var(--header)); overflow-y: auto; padding: 40px var(--gutter) 40px 8px; scrollbar-width: thin; } }
.rail .side-label { margin-top: 0; }

.results { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 2px; }
.results a { display: block; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; font-size: 0.85rem; line-height: 1.45; }
.results a:hover, .results a:focus-visible { background: var(--bg-2); color: var(--ink); outline-offset: -2px; }
.results .r-where { display: block; font: 500 0.7rem/1.3 var(--font-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.results .r-title { display: block; margin-top: 2px; color: var(--ink); font-weight: 600; }
.results .r-snip { display: block; margin-top: 2px; color: var(--ink-3); }
.results mark, .doc mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.results-empty { margin: 14px 10px 0; color: var(--ink-3); font-size: 0.88rem; }
[hidden] { display: none !important; }

/* ── Article ───────────────────────────────────────────────────────── */
.main { min-width: 0; padding: 40px var(--gutter) 96px; }
@media (min-width: 900px) { .main { padding-left: clamp(32px, 4vw, 64px); padding-right: clamp(32px, 4vw, 64px); } }
.doc { max-width: 48rem; }
.doc-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 14px; font: 500 0.78rem/1.2 var(--font-mono); color: var(--ink-3); }
.doc-meta .crumb { color: var(--accent); }
.doc-meta a { color: var(--ink-3); }
.doc-meta a:hover { color: var(--ink); }
.md { overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md h1 { margin: 0 0 20px; font-size: clamp(2.1rem, 4vw, 2.9rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.02; }
.md h2 { margin: 56px 0 14px; padding-top: 28px; font-size: clamp(1.5rem, 2.6vw, 1.85rem); font-weight: 700; box-shadow: 0 -1px 0 var(--line); }
.md h3 { margin: 36px 0 10px; font-size: 1.22rem; font-weight: 700; }
.md h4 { margin: 28px 0 8px; font-size: 1.02rem; font-weight: 700; }
.md p, .md ul, .md ol, .md blockquote, .md .table-wrap, .md .code { margin: 0 0 16px; }
.md p, .md li { color: var(--ink-2); text-wrap: pretty; }
.md strong { color: var(--ink); font-weight: 600; }
.md ul, .md ol { padding-left: 1.4em; }
.md li + li { margin-top: 4px; }
.md li > ul, .md li > ol { margin: 4px 0 0; }
.md li::marker { color: var(--ink-3); }
.md hr { border: 0; height: 1px; background: var(--line); margin: 40px 0; }
.md blockquote { padding: 2px 0 2px 16px; box-shadow: inset 2px 0 0 var(--line-2); color: var(--ink-2); }
.md :not(pre) > code { font-size: 0.86em; background: var(--code-bg); color: var(--ink); padding: 0.12em 0.36em; border-radius: 4px; -webkit-box-decoration-break: clone; box-decoration-break: clone; overflow-wrap: break-word; }
.md :is(h1, h2, h3, h4) > code { font-size: 0.86em; background: none; padding: 0; letter-spacing: -0.01em; }
.md p.pseudo-h { margin-top: 32px; }
.md p.pseudo-h strong { font: 700 1.08rem/1.35 var(--font-display); letter-spacing: -0.01em; }

/* Heading anchors */
.md .anchor { margin-left: 8px; color: var(--ink-3); text-decoration: none; font-weight: 500; opacity: 0; transition: opacity 0.15s ease, color 0.15s ease; }
.md :is(h2, h3, h4, .pseudo-h):hover .anchor, .md .anchor:focus-visible { opacity: 1; }
.md .anchor:hover { color: var(--accent); }
@media (hover: none) { .md .anchor { opacity: 0.6; } }
@media (prefers-reduced-motion: no-preference) { .md .flash { animation: flash 1.6s var(--ease-out); } }
@keyframes flash { 0%, 30% { background: var(--mark); } 100% { background: transparent; } }
.md .flash { border-radius: 4px; }

/* Tables scroll on their own, never the page */
.table-wrap { overflow-x: auto; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line); }
.md table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.md th, .md td { padding: 9px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.md th { font-weight: 600; color: var(--ink); background: var(--bg-2); white-space: nowrap; }
.md td { color: var(--ink-2); }
.md tr:last-child td { border-bottom: 0; }
.md table { min-width: 34rem; }
.md code.nw { white-space: nowrap; }
@media (max-width: 359px) { .md li code.nw { white-space: normal; } }  /* deep lists leave too little room */

/* Code blocks: the same dark terminal as the landing page, in both themes */
.code { position: relative; border-radius: var(--r); background: var(--term-bg); color: var(--term-fg); box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset; min-width: 0; }
.code pre { margin: 0; padding: 14px 48px 14px 18px; overflow-x: auto; font: 400 0.82rem/1.65 var(--font-mono); tab-size: 4; scrollbar-width: thin; scrollbar-color: #45475a transparent; }
.code pre code { background: none; padding: 0; font: inherit; color: inherit; }
.code .copy-btn { position: absolute; top: 3px; right: 3px; width: 36px; height: 36px; color: var(--term-dim); background: var(--term-bg); }
.code .copy-btn:hover { color: var(--term-fg); background: #2a2a3c; }
.code .copy-btn svg { width: 16px; height: 16px; }
.copy-btn .ok { opacity: 0; transform: scale(0.25); filter: blur(4px); color: var(--term-arrow); }
.copy-btn.copied .cp { opacity: 0; transform: scale(0.25); filter: blur(4px); }
.copy-btn.copied .ok { opacity: 1; transform: none; filter: none; }
.hljs-comment, .hljs-quote { color: var(--term-dim); font-style: italic; }
.hljs-keyword, .hljs-built_in, .hljs-selector-tag, .hljs-section { color: var(--term-pink); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--term-arrow); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-property { color: var(--term-ok); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: var(--term-key); }
.hljs-title, .hljs-name, .hljs-type, .hljs-meta { color: var(--term-dir); }
.hljs-subst, .hljs-params { color: var(--term-fg); }
.hljs-deletion { color: var(--term-pink); }

/* Pager + states */
.pager { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 64px; padding-top: 28px; box-shadow: 0 -1px 0 var(--line); }
.pager a { display: block; padding: 14px 16px; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--line-2); text-decoration: none; color: var(--ink); font-weight: 600; transition: box-shadow 0.15s ease, background-color 0.15s ease; }
.pager a:hover { background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent); }
.pager span { display: block; font: 500 0.72rem/1.4 var(--font-mono); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.pager .next { grid-column: 2; text-align: right; }
.state { padding: 8px 0; }
.state h1 { margin: 0 0 14px; font-size: clamp(2.1rem, 4vw, 2.9rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.02; }
.state p { color: var(--ink-2); max-width: 36em; }
.cards { margin-top: 32px; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cards a { display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow); color: var(--ink-2); text-decoration: none; font-size: 0.9rem; transition: transform 0.2s var(--ease-out), box-shadow 0.2s ease; }
.cards a strong { color: var(--ink); font: 700 1.1rem/1.2 var(--font-display); letter-spacing: -0.015em; }
.cards a:hover { transform: translateY(-2px); box-shadow: var(--shadow), inset 0 0 0 1.5px var(--accent-fill); }
.cards a:active { transform: scale(0.98); }
.foot { margin-top: 48px; color: var(--ink-3); font-size: 0.85rem; }
.foot a { color: var(--ink-2); }

/* Without JavaScript: no search, copy or theme buttons, and the sidebar sits above the page on phones */
html:not(.js) .search, html:not(.js) .copy-btn, html:not(.js) .menu-btn, html:not(.js) .theme-btn { display: none; }
@media (max-width: 899px) {
  html:not(.js) .side { position: static; width: auto; height: auto; transform: none; visibility: visible; box-shadow: inset 0 -1px 0 var(--line); padding: 16px var(--gutter); }
  html:not(.js) .side-toc { display: none; }
}
