/* The hidden attribute always wins over a display set below. */
[hidden] { display: none !important; }
/* Layout: a fixed top bar; three columns on wide screens (contents, the page
   at reading width, on this page), one column with a drawer below 1000px. */
:root {
  --bg: #fcfcfd;
  --surface: #f3f4f7;
  --raised: #ffffff;
  --ink: #15171c;
  --muted: #5b606b;
  --faint: #8a909c;
  --rule: #e3e5ea;
  --accent: #2b4acb;
  --accent-soft: #e8ecfb;
  --code-bg: #f5f6f9;
  --syn-key: #3a4bc0;
  --syn-str: #1e7a55;
  --syn-num: #b5521b;
  --syn-color: #c2306f;
  --syn-bool: #8c4bc4;
  --note: #2b4acb;
  --tip: #1e7a55;
  --warn: #b5521b;
  --why: #8c4bc4;
  --display: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --body: "Public Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --top: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014; --surface: #161920; --raised: #1b1f27; --ink: #e7e9ee; --muted: #9aa1ae; --faint: #6f7684;
    --rule: #262a33; --accent: #8fa2ff; --accent-soft: #1d2340; --code-bg: #12151b;
    --syn-key: #9daeff; --syn-str: #6fd3a2; --syn-num: #f2a36b; --syn-color: #ff7ab0; --syn-bool: #c79bff;
    --note: #8fa2ff; --tip: #6fd3a2; --warn: #f2a36b; --why: #c79bff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1014; --surface: #161920; --raised: #1b1f27; --ink: #e7e9ee; --muted: #9aa1ae; --faint: #6f7684;
  --rule: #262a33; --accent: #8fa2ff; --accent-soft: #1d2340; --code-bg: #12151b;
  --syn-key: #9daeff; --syn-str: #6fd3a2; --syn-num: #f2a36b; --syn-color: #ff7ab0; --syn-bool: #c79bff;
  --note: #8fa2ff; --tip: #6fd3a2; --warn: #f2a36b; --why: #c79bff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--body); -webkit-font-smoothing: antialiased; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 8px; z-index: 50; background: var(--raised); padding: 8px 12px; }
kbd { font: 500 11px/1 var(--mono); padding: 3px 5px; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); background: var(--raised); }

/* Top bar */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--rule); }
.top-inner { height: var(--top); display: flex; align-items: center; gap: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); max-width: 1440px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 700 18px/1 var(--display); letter-spacing: -0.01em; }
.brand img { border-radius: 7px; }
.brand-sub { font-weight: 500; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--rule); }
.search-open { margin-left: 8px; display: flex; align-items: center; gap: 8px; min-width: 220px; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--rule); background: var(--surface); color: var(--muted); font: 14px var(--body); cursor: pointer; }
.search-open kbd { margin-left: auto; }
.top-links { margin-left: auto; display: flex; gap: 20px; }
.top-links a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.top-links a:hover { color: var(--ink); }
.theme, .menu { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.theme:hover, .menu:hover { color: var(--ink); background: var(--surface); }
.menu { display: none; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr) 210px; gap: 48px; max-width: 1440px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.nav { position: sticky; top: calc(var(--top) + env(safe-area-inset-top, 0px)); align-self: start; max-height: calc(100vh - var(--top)); overflow-y: auto; padding-block: 28px 40px; }
.nav-group + .nav-group { margin-top: 22px; }
.nav-head { margin: 0 0 6px; font: 700 11px/1.4 var(--display); letter-spacing: 0.09em; text-transform: uppercase; color: var(--faint); }
.nav ul { list-style: none; margin: 0; padding: 0; }
.nav a { display: block; padding: 5px 10px; margin-left: -10px; border-radius: 7px; color: var(--muted); text-decoration: none; font-size: 14.5px; }
.nav a:hover { color: var(--ink); background: var(--surface); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.page { min-width: 0; padding-block: 36px 80px; }
.toc { position: sticky; top: calc(var(--top) + env(safe-area-inset-top, 0px)); align-self: start; padding-block: 36px; font-size: 13px; }
.toc-head { margin: 0 0 8px; font: 700 11px/1.4 var(--display); letter-spacing: 0.09em; text-transform: uppercase; color: var(--faint); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc a { display: block; padding: 3px 12px; color: var(--muted); text-decoration: none; margin-left: -1px; border-left: 1px solid transparent; }
.toc .l3 a { padding-left: 24px; }
.toc a:hover, .toc a.on { color: var(--ink); border-left-color: var(--accent); }

/* Prose */
.prose { max-width: 760px; }
.prose h1 { font: 800 clamp(32px, 4.2vw, 44px)/1.08 var(--display); letter-spacing: -0.025em; margin: 0 0 18px; text-wrap: balance; }
.prose h2 { font: 700 26px/1.2 var(--display); letter-spacing: -0.015em; margin: 52px 0 12px; text-wrap: balance; }
.prose h3 { font: 700 19px/1.3 var(--display); margin: 34px 0 8px; }
.prose h4 { font: 700 15px/1.4 var(--display); margin: 26px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.prose h2, .prose h3, .prose h4 { position: relative; }
.anchor { position: absolute; left: -22px; color: var(--faint); text-decoration: none; opacity: 0; font-weight: 500; }
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }
.prose p, .prose li { color: var(--ink); }
.prose > p:first-of-type { font-size: 19px; line-height: 1.6; color: var(--muted); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li + li { margin-top: 4px; }
.prose code { font: 0.86em/1 var(--mono); background: var(--code-bg); border: 1px solid var(--rule); border-radius: 5px; padding: 2px 5px; white-space: nowrap; }
.prose strong { font-weight: 600; }

/* Code */
.code { position: relative; margin: 18px 0; }
pre { margin: 0; background: var(--code-bg); border: 1px solid var(--rule); border-radius: 12px; padding: 16px 18px; overflow-x: auto; font: 13.5px/1.6 var(--mono); }
/* Code in a block, not the inline style above: keeps its spaces and lines. */
pre code, .prose pre code { font: inherit; line-height: inherit; background: none; border: 0; border-radius: 0; padding: 0; white-space: pre-wrap; overflow-wrap: anywhere; display: block; }
/* One block per line: a wrapped line continues two columns under its own
   indent, so structure stays readable on a phone. */
.ln { display: block; padding-left: calc(var(--i, 0) * 1ch + 2ch); text-indent: calc(var(--i, 0) * -1ch - 2ch); }
.k { color: var(--syn-key); } .s { color: var(--syn-str); } .n { color: var(--syn-num); } .c { color: var(--syn-color); font-weight: 500; } .b { color: var(--syn-bool); }
.cmd { color: var(--accent); font-weight: 500; } .cm { color: var(--faint); }
.copy { position: absolute; top: 8px; right: 8px; font: 500 12px var(--body); color: var(--muted); background: var(--raised); border: 1px solid var(--rule); border-radius: 7px; padding: 4px 9px; cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.code:hover .copy, .copy:focus-visible { opacity: 1; }

/* Examples: the source beside what it builds. */
.example { margin: 28px 0 34px; border: 1px solid var(--rule); border-radius: 16px; overflow: hidden; background: var(--raised); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.ex-source { min-width: 0; border-right: 1px solid var(--rule); display: flex; flex-direction: column; }
.ex-source pre { border: 0; border-radius: 0; flex: 1; max-height: 560px; overflow-y: auto; font-size: 12.5px; }
.example.tall { grid-template-columns: minmax(0, 1fr); }
.example.tall .ex-source { border-right: 0; border-bottom: 1px solid var(--rule); }
.example.tall .ex-source pre { max-height: 640px; font-size: 13px; }
.ex-bar { display: flex; align-items: center; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--rule); background: var(--surface); font-size: 12.5px; }
.ex-name { font-family: var(--mono); color: var(--muted); }
.ex-tokens { margin-left: auto; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.ex-bar .copy { position: static; opacity: 1; }
.ex-render { min-width: 0; display: grid; place-items: center; padding: 24px; background:
  repeating-conic-gradient(var(--surface) 0 25%, transparent 0 50%) 0 0 / 18px 18px; }
.ex-render img { max-width: 100%; height: auto; border-radius: 4px; }
.example figcaption { grid-column: 1 / -1; border-top: 1px solid var(--rule); padding: 12px 16px; font-size: 14px; }
.ex-caption { margin: 0 0 4px; }
.ex-meta { margin: 0; color: var(--faint); font-size: 12.5px; }
.ex-warn { margin: 8px 0 0; color: var(--warn); font-size: 13px; }

/* Callouts */
.callout { margin: 22px 0; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--rule); background: var(--surface); border-left: 3px solid var(--note); }
.callout p { margin: 0; }
.callout strong:first-child { color: var(--note); margin-right: 4px; }
.callout.tip { border-left-color: var(--tip); } .callout.tip strong:first-child { color: var(--tip); }
.callout.warn { border-left-color: var(--warn); } .callout.warn strong:first-child { color: var(--warn); }
.callout.why { border-left-color: var(--why); } .callout.why strong:first-child { color: var(--why); }

/* Tables */
.table { overflow-x: auto; margin: 18px 0; border: 1px solid var(--rule); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font: 600 12.5px/1.4 var(--display); letter-spacing: 0.02em; color: var(--muted); background: var(--surface); }
th, td { padding: 9px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td code { white-space: normal; word-break: break-word; }

/* Cards on the home page */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 24px 0; }
.card { display: block; padding: 16px 18px; border: 1px solid var(--rule); border-radius: 14px; text-decoration: none; color: var(--ink); background: var(--raised); }
.card:hover { border-color: var(--accent); }
.card b { display: block; font: 700 16px/1.3 var(--display); margin-bottom: 4px; }
.card span { color: var(--muted); font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 24px 0; }
.stat { padding: 14px 16px; border-radius: 12px; background: var(--surface); }
.stat b { display: block; font: 800 28px/1.1 var(--display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13.5px; }

/* Pager */
.pager { display: flex; gap: 14px; margin-top: 56px; max-width: 760px; }
.pager a { flex: 1; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 12px; text-decoration: none; color: var(--ink); font: 600 16px var(--display); }
.pager a span { display: block; font: 500 12.5px var(--body); color: var(--muted); margin-bottom: 2px; }
.pager .next { text-align: right; }
.pager a:hover { border-color: var(--accent); }

/* Search */
.search { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--ink) 30%, transparent); display: grid; place-items: start center; padding: max(80px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); }
.search-box { width: min(640px, 100%); background: var(--raised); border: 1px solid var(--rule); border-radius: 16px; box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.35); overflow: hidden; }
#search-input { width: 100%; border: 0; border-bottom: 1px solid var(--rule); padding: 16px 18px; font: 17px var(--body); background: transparent; color: var(--ink); outline: none; }
.search-results { list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow-y: auto; }
.search-results a { display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--accent-soft); }
.search-results b { font: 600 15px var(--display); display: block; }
.search-results span { color: var(--muted); font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hint { margin: 0; padding: 10px 16px; border-top: 1px solid var(--rule); color: var(--faint); font-size: 12.5px; display: flex; gap: 6px; align-items: center; }

@media (max-width: 1240px) { .shell { grid-template-columns: 232px minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 1000px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .menu { display: grid; }
  .nav { display: none; position: fixed; inset: calc(var(--top) + env(safe-area-inset-top, 0px)) 0 0 0; max-height: none; z-index: 25; background: var(--bg); padding: 20px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
  body.nav-open .nav { display: block; }
  .top-links { display: none; }
  .search-open { min-width: 0; margin-left: auto; }
  .search-open span, .search-open kbd { display: none; }
  .example { grid-template-columns: minmax(0, 1fr); }
  .ex-source { border-right: 0; border-bottom: 1px solid var(--rule); }
  .anchor { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
.example.source-only { grid-template-columns: minmax(0, 1fr); }
.example.source-only .ex-source { border-right: 0; }
.terminal pre { background: color-mix(in srgb, var(--code-bg) 60%, var(--surface)); }
.prompt { color: var(--faint); user-select: none; }
.out { color: var(--muted); }
