/* JustOnAir docs. Light first (docs are read for long stretches), dark on
   request or by system setting. Brand: navy, the Plancode blue for links in
   light, lime in dark, the logo gradient only on the dot. Code is always on
   navy, in both themes, like the dashboard. */
@font-face { font-family: 'Hanken Grotesk'; src: url('/assets/hanken-grotesk-latin-wght-normal.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/assets/jetbrains-mono-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('/assets/jetbrains-mono-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #0e1626;
  --ink-2: #3b475c;
  --muted: #5b6880;
  --line: #e2e6ee;
  --line-2: #d3d9e4;
  --link: #3149d6;
  --accent: #405be8;
  --accent-soft: #eaeefe;
  --code-bg: #0e1626;
  --code-bar: #172236;
  --code-ink: #e4e9f2;
  --inline-bg: #eef1f6;
  --note-bg: #eef2fd;
  --note-line: #c9d3fb;
  --warn-bg: #fdf4e6;
  --warn-line: #f2d3a0;
  --warn-ink: #7a4b06;
  --live: #afd136;
  --logo: linear-gradient(135deg, #00ff9d, #e6ff00);
  --sans: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0e1626; --surface: #121c30; --ink: #e4e9f2; --ink-2: #c3cddd; --muted: #9aa8c0; --line: #22304d; --line-2: #2a3a5c;
    --link: #c8e86a; --accent: #afd136; --accent-soft: #1f2d1a; --code-bg: #0a1120; --code-bar: #121c30; --code-ink: #e4e9f2;
    --inline-bg: #1a2640; --note-bg: #152036; --note-line: #2a3a5c; --warn-bg: #241f14; --warn-line: #4a3c1e; --warn-ink: #e8d3a8;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0e1626; --surface: #121c30; --ink: #e4e9f2; --ink-2: #c3cddd; --muted: #9aa8c0; --line: #22304d; --line-2: #2a3a5c;
  --link: #c8e86a; --accent: #afd136; --accent-soft: #1f2d1a; --code-bg: #0a1120; --code-bar: #121c30; --code-ink: #e4e9f2;
  --inline-bg: #1a2640; --note-bg: #152036; --note-line: #2a3a5c; --warn-bg: #241f14; --warn-line: #4a3c1e; --warn-ink: #e8d3a8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- header */
.top {
  position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 16px;
  padding: 0 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 750; font-size: 17px; letter-spacing: -0.015em; }
.brand:hover { text-decoration: none; }
.brand i { width: 11px; height: 11px; border-radius: 50%; background: var(--logo); box-shadow: 0 0 12px rgba(0, 255, 157, 0.35); }
.brand span { color: var(--muted); font-weight: 500; }
.top-links { margin-left: auto; display: flex; align-items: center; gap: 18px; font-size: 14px; }
.top-links a { color: var(--ink-2); }
.top-links a.pill { color: var(--ink); font-weight: 600; padding: 5px 11px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface); }
.top-links a.pill::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--live); margin-right: 7px; vertical-align: 1px; }
.top-links a.dash { color: var(--accent); font-weight: 600; }
.theme { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; position: relative; }
.theme::after { content: ''; position: absolute; inset: 9px; border-radius: 50%; background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); border: 1.5px solid var(--ink); }
.menu { display: none; width: 36px; height: 36px; border: 0; background: none; padding: 9px 7px; cursor: pointer; flex-direction: column; justify-content: space-around; }
.menu span { display: block; height: 2px; background: var(--ink); border-radius: 2px; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); max-width: 1400px; margin: 0 auto; }
.side {
  position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; padding: 26px 16px 40px 20px;
  border-right: 1px solid var(--line); font-size: 14.5px;
}
.nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 22px; }
.nav-h { font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.side a { color: var(--ink-2); padding: 6px 10px; border-radius: 7px; }
.side a:hover { background: var(--inline-bg); color: var(--ink); text-decoration: none; }
.side a[aria-current='page'] { background: var(--accent-soft); color: var(--ink); font-weight: 650; }

main { display: grid; grid-template-columns: minmax(0, 1fr) 210px; gap: 48px; padding: 36px 40px 80px; }
article { min-width: 0; max-width: 780px; }

/* ---------- toc */
.toc { position: sticky; top: 92px; align-self: start; font-size: 13.5px; display: flex; flex-direction: column; gap: 2px; max-height: calc(100vh - 120px); overflow-y: auto; }
.toc-h { font-size: 11.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.toc a { color: var(--muted); padding: 3px 0 3px 12px; border-left: 2px solid var(--line); }
.toc a.d3 { padding-left: 24px; font-size: 13px; }
.toc a:hover, .toc a.on { color: var(--ink); border-left-color: var(--accent); text-decoration: none; }

/* ---------- prose */
.page-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-bottom: -6px; }
.act { font: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line-2); border-radius: 7px; padding: 4px 10px; cursor: pointer; }
.act:hover { color: var(--ink); text-decoration: none; border-color: var(--muted); }
h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.1; letter-spacing: -0.03em; font-weight: 780; margin: 10px 0 12px; text-wrap: balance; }
.lede { font-size: 18.5px; color: var(--ink-2); margin: 0 0 28px; max-width: 64ch; }
h2 { font-size: 24px; letter-spacing: -0.02em; font-weight: 720; margin: 46px 0 12px; padding-top: 22px; border-top: 1px solid var(--line); text-wrap: balance; }
h3 { font-size: 18px; letter-spacing: -0.01em; font-weight: 680; margin: 32px 0 8px; }
h4 { font-size: 15px; font-weight: 700; margin: 22px 0 6px; }
h1 .anchor { display: none; }
.anchor { color: var(--line-2); margin-left: -0.9em; padding-right: 0.25em; opacity: 0; font-weight: 500; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; text-decoration: none; }
p, ul, ol { margin: 0 0 16px; }
ul, ol { padding-left: 1.3em; }
li { margin: 4px 0; }
li > p { margin: 0; }
strong { font-weight: 680; }
hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }
:not(pre) > code { font-family: var(--mono); font-size: 0.86em; background: var(--inline-bg); padding: 1.5px 5px; border-radius: 5px; overflow-wrap: anywhere; }
a code { color: inherit; }

.code { margin: 16px 0 22px; border-radius: 10px; overflow: hidden; background: var(--code-bg); border: 1px solid color-mix(in srgb, var(--code-bg) 80%, var(--line)); }
.code-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; background: var(--code-bar); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: #9aa8c0; }
.copy { font: inherit; font-size: 12px; color: #c3cddd; background: transparent; border: 1px solid #2a3a5c; border-radius: 6px; padding: 2px 9px; cursor: pointer; }
.copy:hover { color: #fff; border-color: #9aa8c0; }
.code pre { margin: 0; padding: 14px 16px 16px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; color: var(--code-ink); tab-size: 2; }
.code code { font-family: inherit; }

.table { overflow-x: auto; margin: 14px 0 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th { text-align: left; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: bottom; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

.callout { margin: 18px 0 22px; padding: 12px 16px; border-radius: 10px; background: var(--note-bg); border: 1px solid var(--note-line); }
.callout.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.callout.warn, .callout.warn strong { color: var(--warn-ink); }
.callout p:last-child { margin-bottom: 0; }

/* Cards on the overview page (raw HTML in index.md). */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 22px 0 28px; }
.cards a { display: block; padding: 16px 16px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); }
.cards a:hover { border-color: var(--accent); text-decoration: none; }
.cards b { display: block; font-size: 15.5px; margin-bottom: 4px; }
.cards span { display: block; font-size: 14px; color: var(--muted); line-height: 1.5; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; }
.pager a { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; color: var(--ink); font-weight: 650; background: var(--surface); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.pager .next { text-align: right; grid-column: 2; }

/* ---------- highlight.js, tuned to the navy code background */
.hljs-comment, .hljs-quote { color: #7c8aa5; }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-meta .hljs-keyword { color: #9dbbef; }
.hljs-string, .hljs-attr + .hljs-string, .hljs-regexp { color: #c8e86a; }
.hljs-number, .hljs-literal { color: #f9ad3e; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-property { color: #7ff0c4; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #e6ff9a; }
.hljs-meta { color: #9aa8c0; }

/* ---------- smaller screens */
@media (max-width: 1180px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .menu { display: flex; }
  .side { position: fixed; inset: 60px 0 0 0; height: auto; background: var(--bg); z-index: 15; transform: translateX(-100%); transition: transform 0.2s; border-right: 0; }
  body.nav-open .side { transform: none; }
  main { padding: 24px 16px 60px; }
  .top { padding: 0 12px; gap: 8px; }
  .top-links a:not(.pill):not(.dash) { display: none; }
  .top-links { gap: 10px; }
}
@media (max-width: 480px) {
  .top-links a.dash { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
