/* antra doc: the documentation site. Light by default (the colours of the
   Antra logo: slate blue on a warm white), dark on request; code blocks
   always use the dark theme of the VS Code extension, so Antra looks here
   as it does in the editor (token colours: src/highlight.zig). */

:root {
  --bg: #fbfaf7;
  --bg-soft: #f3f1ec;
  --panel: #ffffff;
  --text: #22303c;
  --muted: #66727f;
  --faint: #8d97a2;
  --border: #e4e1da;
  --accent: #4a78a6;
  --accent-strong: #2f5c88;
  --accent-soft: #e6eef6;
  --mark: #fdf1d9;
  --code-bg: #1c2430;
  --code-text: #d1d9e2;
  --code-border: #2a3442;
  --inline-code-bg: #eef1f4;
  --inline-code: #2f4a66;
  --shadow: 0 1px 2px rgba(30, 45, 60, .06), 0 4px 16px rgba(30, 45, 60, .06);
  --radius: 10px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", var(--sans);
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --top: 60px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #12171d;
  --bg-soft: #181f27;
  --panel: #1a222b;
  --text: #d8dee5;
  --muted: #9aa6b2;
  --faint: #76828e;
  --border: #29323d;
  --accent: #8db4dc;
  --accent-strong: #b3cfeb;
  --accent-soft: #1f2d3c;
  --mark: #3a3020;
  --code-bg: #0e1319;
  --code-text: #d1d9e2;
  --code-border: #242d38;
  --inline-code-bg: #1f2833;
  --inline-code: #b9cde2;
  --shadow: none;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12171d;
    --bg-soft: #181f27;
    --panel: #1a222b;
    --text: #d8dee5;
    --muted: #9aa6b2;
    --faint: #76828e;
    --border: #29323d;
    --accent: #8db4dc;
    --accent-strong: #b3cfeb;
    --accent-soft: #1f2d3c;
    --mark: #3a3020;
    --code-bg: #0e1319;
    --code-border: #242d38;
    --inline-code-bg: #1f2833;
    --inline-code: #b9cde2;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16.5px/1.7 var(--sans);
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------------- header */

header.top {
  position: sticky; top: 0; z-index: 20;
  height: var(--top);
  display: flex; align-items: center; gap: 22px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--accent); font: 700 22px/1 var(--round); letter-spacing: .02em; }
.brand:hover { text-decoration: none; color: var(--accent-strong); }
.brand img { width: 30px; height: 33px; }
.tabs { display: flex; gap: 4px; }
.tabs a { color: var(--muted); padding: 6px 12px; border-radius: 999px; font-weight: 550; font-size: 15px; }
.tabs a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.tabs a.on { color: var(--accent-strong); background: var(--accent-soft); }

.search { position: relative; margin-left: auto; width: min(340px, 40vw); }
.search input {
  width: 100%; height: 36px; padding: 0 34px 0 34px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238d97a2' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat 12px 50%;
  color: var(--text); font: inherit; font-size: 14.5px;
  outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  position: absolute; right: 10px; top: 8px;
  font: 12px/18px var(--mono); color: var(--faint);
  border: 1px solid var(--border); border-radius: 5px; padding: 0 6px; background: var(--bg-soft);
}
.search input:focus + kbd { display: none; }
.results {
  position: absolute; right: 0; top: 44px; width: min(560px, 92vw);
  max-height: 70vh; overflow: auto;
  margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 40px rgba(20, 30, 40, .18);
}
.results li a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); line-height: 1.35; }
.results li a:hover, .results li.sel a { background: var(--accent-soft); text-decoration: none; }
.results .t { font-weight: 600; }
.results .t code { font-size: .95em; }
.results .k {
  float: right; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--faint); margin-left: 10px; margin-top: 3px;
}
.results .c { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results .none { padding: 12px; color: var(--muted); }

.theme, .menu {
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.theme:hover, .menu:hover { color: var(--text); }
.menu { display: none; }

/* ---------------------------------------------------------------- frame */

.frame {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 230px;
  max-width: 1440px; margin: 0 auto;
}
body.home .frame { grid-template-columns: 260px minmax(0, 1fr); }

.side {
  position: sticky; top: var(--top); align-self: start;
  height: calc(100vh - var(--top)); overflow-y: auto;
  padding: 26px 14px 40px 22px;
  border-right: 1px solid var(--border);
  font-size: 14.5px;
  scrollbar-width: thin;
}
.side .group { margin-bottom: 22px; }
.side h4 {
  margin: 0 0 6px 10px;
  font: 700 11.5px/1.4 var(--sans); text-transform: uppercase; letter-spacing: .08em;
  color: var(--faint);
}
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a, .side-home {
  display: block; padding: 4px 10px; border-radius: 7px;
  color: var(--muted); line-height: 1.45;
}
.side-home { margin-bottom: 18px; font-weight: 600; }
.side li a:hover, .side-home:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.side li a.on, .side-home.on { color: var(--accent-strong); background: var(--accent-soft); font-weight: 600; }
.side code { font-size: .92em; background: none; padding: 0; color: inherit; }

.content { min-width: 0; padding: 40px 56px 80px; }
article { max-width: 46rem; margin: 0 auto; }
body.home article { max-width: 54rem; }

.toc {
  position: sticky; top: var(--top); align-self: start;
  max-height: calc(100vh - var(--top)); overflow-y: auto;
  padding: 34px 20px 40px 8px; font-size: 13.5px;
  scrollbar-width: thin;
}
.toc h4 { margin: 0 0 8px; font: 700 11.5px/1.4 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 3px 0 3px 12px; margin-left: -1px; color: var(--muted); border-left: 2px solid transparent; line-height: 1.4; }
.toc li.l3 a { padding-left: 24px; font-size: 13px; }
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.on { color: var(--accent-strong); border-left-color: var(--accent); }
.toc code { font-size: .92em; background: none; padding: 0; color: inherit; }

/* ---------------------------------------------------------------- text */

.eyebrow {
  margin: 0 0 6px; color: var(--accent); font: 700 13px/1.4 var(--sans);
  text-transform: uppercase; letter-spacing: .08em;
}
h1, h2, h3, h4, h5, h6 { color: var(--text); line-height: 1.25; position: relative; }
h1 { font: 750 2.35rem/1.15 var(--round); letter-spacing: -.01em; margin: 0 0 1.4rem; }
h2 { font: 700 1.55rem/1.25 var(--round); margin: 3rem 0 1rem; padding-top: .4rem; }
h3 { font-size: 1.2rem; font-weight: 650; margin: 2.2rem 0 .7rem; }
h4 { font-size: 1.02rem; font-weight: 650; margin: 1.8rem 0 .5rem; }
h5, h6 { font-size: .95rem; margin: 1.4rem 0 .4rem; }
h1 code, h2 code, h3 code, h4 code { font-size: .88em; }
.anchor {
  margin-left: .4em; color: var(--faint); opacity: 0; font-weight: 400;
  transition: opacity .15s;
}
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, h5:hover .anchor { opacity: 1; }
.anchor:hover { text-decoration: none; color: var(--accent); }

p, ul, ol, dl, blockquote, .table, .code { margin: 0 0 1.1rem; }
ul, ol { padding-left: 1.4rem; }
li { margin: .25rem 0; }
li > ul, li > ol { margin: .3rem 0 .3rem; }
li > p { margin: .4rem 0; }
strong { font-weight: 650; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }

blockquote {
  margin-left: 0; padding: .8rem 1.1rem;
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0; color: var(--text);
}
blockquote > :last-child { margin-bottom: 0; }

code {
  font: .875em/1.5 var(--mono);
  background: var(--inline-code-bg); color: var(--inline-code);
  padding: .12em .38em; border-radius: 5px;
  overflow-wrap: anywhere;
}
a code { color: var(--accent); }

.table { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; line-height: 1.5; }
th, td { text-align: left; padding: .5rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--bg-soft); font-weight: 650; font-size: .85rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.c, th.c { text-align: center; }
td.r, th.r { text-align: right; }
td code, th code { white-space: nowrap; }

/* ---------------------------------------------------------------- code */

.code { position: relative; }
.code pre {
  margin: 0; padding: 14px 18px;
  background: var(--code-bg); color: var(--code-text);
  border: 1px solid var(--code-border); border-radius: var(--radius);
  overflow-x: auto; scrollbar-width: thin;
  font: 13.8px/1.6 var(--mono); tab-size: 4;
}
.code pre code { background: none; color: inherit; padding: 0; font: inherit; border-radius: 0; overflow-wrap: normal; }
.code[data-lang]::before {
  content: attr(data-lang);
  position: absolute; top: 7px; right: 46px;
  font: 11px/1 var(--mono); color: #6f7d8c; text-transform: lowercase;
  pointer-events: none;
}
.code[data-lang="antra"]::before { content: ""; }
.copy {
  position: absolute; top: 6px; right: 6px;
  width: 30px; height: 26px; border-radius: 6px; cursor: pointer;
  border: 1px solid #334050; background: #253041; color: #9fb0c2;
  font-size: 13px; line-height: 1; opacity: 0; transition: opacity .15s;
}
.code:hover .copy, .copy:focus { opacity: 1; }
.copy:hover { color: #fff; }
.copy.done { color: #8ee0a6; }

/* token colours: the extension's theme (src/highlight.zig `sgr`) */
.t-keyword { color: #ff7b72; }
.t-type { color: #d8c8a0; }
.t-builtin_type { color: #c4b796; }
.t-namespace { color: #00d4e0; }
.t-tag { color: #b5eac2; }
.t-string { color: #70b8a0; }
.t-interp { color: #b5eac2; }
.t-number { color: #a5d6ff; }
.t-symbol { color: #45b8dc; }
.t-constant { color: #569cd6; }
.t-function { color: #c084fc; }
.t-property { color: #45b8dc; }
.t-variable { color: #79c0ff; }
.t-comment { color: #7d929c; }
.t-doc { color: #7d929c; font-style: italic; }
.t-attribute { color: #bfae9c; }
.t-arrow { color: #f97583; }
.t-type_op { color: #8b949e; }
.t-prompt, .t-dim { color: #8b949e; }
.t-err { color: #ff7b72; }
.t-warn { color: #e6c07b; }

/* ---------------------------------------------------------------- pager */

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 4rem; padding-top: 1.6rem; border-top: 1px solid var(--border); }
.pager a {
  display: flex; flex-direction: column; gap: 2px; max-width: 48%;
  padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-weight: 600; background: var(--panel);
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager small { font-weight: 500; color: var(--faint); font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; }
.pager .next { margin-left: auto; text-align: right; }
.edit { margin-top: 1.6rem; font-size: 13.5px; }
.edit a { color: var(--faint); }

/* ---------------------------------------------------------------- home */

.hero { display: flex; align-items: center; gap: 40px; margin: 10px 0 30px; }
.hero .mascot { width: 200px; height: 200px; flex: none; border-radius: 50%; box-shadow: var(--shadow); }
.hero h1 { font-size: 3.4rem; color: var(--accent); margin: 0; letter-spacing: .01em; }
.tagline { font: 700 1.35rem/1.3 var(--round); margin: .3rem 0 .8rem; color: var(--text); }
.lead { font-size: 1.1rem; color: var(--muted); margin-bottom: 1.3rem; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  padding: 9px 18px; border-radius: 999px; font-weight: 600; font-size: 15px;
  border: 1px solid var(--border); color: var(--text); background: var(--panel);
}
.btn:hover { text-decoration: none; border-color: var(--accent); color: var(--accent-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
:root[data-theme="dark"] .btn.primary { color: #10161c; }
.hero-code { margin-bottom: 2rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 2rem; }
.card { padding: 16px 18px 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); }
.card h3 { margin: 0 0 6px; font-size: 1.02rem; color: var(--accent-strong); }
.card ol { margin: 0 0 .6rem; padding-left: 1.6rem; font-size: 14.5px; }
.card li { margin: .15rem 0; }
.card li::marker { color: var(--faint); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- stdlib */

.import { margin-bottom: 1.4rem; }
.pkg-doc { font-size: 1.05rem; }
.pkg-doc h2 { font-size: 1.2rem; margin-top: 1.6rem; }
h2.api { border-top: 1px solid var(--border); padding-top: 2rem; }
.names { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0 0 1.8rem; }
.names li { margin: 0; }
.names a code { display: inline-block; padding: .2em .55em; }
.names a:hover { text-decoration: none; }
.names a:hover code { background: var(--accent-soft); }
.item { margin: 0 0 2.4rem; padding-top: .6rem; }
.item-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: .45rem; }
.item-name { font: 650 1.12rem/1.3 var(--mono); color: var(--text); }
.item-name:hover { color: var(--accent); text-decoration: none; }
.item:target .item-name { background: var(--mark); border-radius: 4px; padding: 0 4px; margin-left: -4px; }
.kind {
  font: 600 10.5px/1.6 var(--sans); text-transform: uppercase; letter-spacing: .07em;
  padding: 0 7px; border-radius: 999px; color: var(--muted); background: var(--bg-soft); border: 1px solid var(--border);
}
.kind.k-type { color: #8a6d2f; background: #faf1dd; border-color: #eedfbb; }
.kind.k-protocol { color: #6c4aa8; background: #f1eafb; border-color: #e0d3f4; }
:root[data-theme="dark"] .kind.k-type, :root[data-theme="dark"] .kind.k-protocol { background: var(--bg-soft); border-color: var(--border); }
.src { margin-left: auto; font: 12px var(--mono); color: var(--faint); }
.sig { margin-bottom: .8rem; }
.sig pre { padding: 10px 16px; font-size: 13.5px; }
.item-doc { padding-left: 2px; }
.item-doc h4, .item-doc h5 { margin-top: 1rem; }
.item-doc .code pre { background: var(--code-bg); }

dl.pkgs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 22px; margin-bottom: 2rem; }
dl.pkgs dt { margin: 0; }
dl.pkgs dd { margin: 0; color: var(--muted); }

/* ---------------------------------------------------------------- small */

@media (max-width: 1180px) {
  .frame { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
  .content { padding: 34px 40px 70px; }
}
@media (max-width: 860px) {
  .frame, body.home .frame { grid-template-columns: minmax(0, 1fr); }
  .menu { display: inline-block; }
  .tabs { display: none; }
  .side {
    position: fixed; z-index: 15; left: 0; top: var(--top); width: 290px;
    background: var(--bg); transform: translateX(-100%); transition: transform .2s;
    visibility: hidden;
  }
  body.nav-open .side { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  .content { padding: 26px 20px 60px; }
  .hero { flex-direction: column; text-align: center; gap: 18px; }
  .hero .mascot { width: 150px; height: 150px; }
  .cta { justify-content: center; }
  h1 { font-size: 1.9rem; }
  .search { width: auto; flex: 1; }
  .search kbd { display: none; }
  dl.pkgs { grid-template-columns: 1fr; }
  dl.pkgs dd { margin-bottom: 8px; }
}
