/* docs.scmjs.dev — the editor's own dark palette (src/styles/tokens.css), the same one
   scm-js/site uses, laid out as a three-column documentation shell: sections on the left,
   the page in the middle, its headings on the right. Plain CSS, no build step. */

:root {
  --bg-0: #0a0c10;
  --bg-1: #12151b;
  --bg-2: #191d25;
  --bg-3: #222732;
  --bg-4: #2b313e;
  --border: #2c3341;
  --border-strong: #3b4453;
  --text: #dde2ea;
  --text-dim: #99a2b3;
  --text-faint: #5d6675;
  --gold: #e6b95c;
  --gold-hi: #f4d08a;
  --teal: #4fd1c5;
  --violet: #a06cf0;
  --pink: #ff5fa2;
  --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Cascadia Mono", "JetBrains Mono", ui-monospace, Consolas, Menlo, monospace;
  --radius: 3px;
  --side: 250px;
  --toc: 210px;
  --top: 52px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg-1);
  color: var(--text);
  font: 15.5px/1.65 var(--font-ui);
  -webkit-text-size-adjust: 100%;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 8px; top: 8px; z-index: 20;
  padding: 8px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

/* ── top bar ────────────────────────────────────────────── */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--top);
  padding: 0 20px;
  background: rgba(10, 12, 16, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { display: block; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.04em; color: var(--pink); }
.brand-name b { color: var(--text); font-weight: 700; }
.brand-sub {
  padding: 2px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.top-links { margin-left: auto; display: flex; gap: 18px; font-size: 14px; }
.top-links a { color: var(--text-dim); }
.top-links a:hover { color: var(--teal); }

.menu-button { display: none; }

/* ── shell ──────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr) var(--toc);
  gap: 0;
  max-width: 1420px;
  margin: 0 auto;
}

.side {
  position: sticky;
  top: var(--top);
  align-self: start;
  max-height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 26px 18px 60px 20px;
  border-right: 1px solid var(--border);
  font-size: 14px;
}

.nav-group { margin-bottom: 4px; }
.nav-head {
  display: block;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.nav-head:hover { background: var(--bg-2); text-decoration: none; }
.nav-head.here { color: var(--gold); }
.nav-group ul { margin: 2px 0 10px; padding: 0 0 0 8px; list-style: none; border-left: 1px solid var(--border); }
.nav-group li a {
  display: block;
  padding: 4px 8px;
  border-radius: var(--radius);
  color: var(--text-dim);
}
.nav-group li a:hover { background: var(--bg-2); color: var(--text); text-decoration: none; }
.nav-group li a.here { color: var(--gold); background: var(--bg-2); }
/* Only the section you are in is expanded: the whole tree is 60-odd pages and all of it
   at once is a wall rather than a map. */
.nav-group:not(.open) ul { display: none; }

main {
  min-width: 0;
  padding: 30px 42px 80px;
}

.toc {
  position: sticky;
  top: var(--top);
  align-self: start;
  max-height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 32px 20px 60px 0;
  font-size: 13px;
}
.toc-title {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.toc ul { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--border); }
.toc li a { display: block; padding: 3px 0 3px 12px; color: var(--text-dim); }
.toc li a:hover { color: var(--teal); text-decoration: none; }

/* ── prose ──────────────────────────────────────────────── */

main h1 {
  margin: 0 0 6px;
  font-size: 31px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}
main h2 {
  margin: 44px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-size: 21px;
  font-weight: 650;
}
main h3 { margin: 30px 0 8px; font-size: 17px; font-weight: 650; color: var(--gold-hi); }
main h4 { margin: 22px 0 6px; font-size: 15px; font-weight: 650; color: var(--text); }

.anchor {
  margin-left: 9px;
  color: var(--text-faint);
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.12s;
}
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }
.anchor:hover { text-decoration: none; color: var(--teal); }

main p { margin: 0 0 14px; }
main ul, main ol { margin: 0 0 14px; padding-left: 22px; }
main li { margin: 3px 0; }
main li > p { margin: 0 0 6px; }

main :not(pre) > code {
  padding: 1px 4px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--gold);
  overflow-wrap: break-word;
}
main a code { color: var(--teal); }

pre {
  margin: 0 0 16px;
  padding: 12px 14px;
  overflow-x: auto;
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
}
pre code { color: var(--text); }

blockquote {
  margin: 0 0 16px;
  padding: 2px 0 2px 16px;
  border-left: 2px solid var(--border-strong);
  color: var(--text-dim);
}

hr { margin: 34px 0; border: 0; border-top: 1px solid var(--border); }

table {
  width: 100%;
  margin: 0 0 18px;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 7px 12px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
thead th { background: var(--bg-2); font-weight: 650; }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.014); }

img { max-width: 100%; }

/* ── code colouring ─────────────────────────────────────── */

pre .k { color: var(--violet); }
pre .s { color: #8fd694; }
pre .n { color: #d79b6a; }
pre .c { color: var(--text-faint); font-style: italic; }
pre .t { color: var(--teal); }
pre .t:hover { text-decoration: underline; }

/* ── the API reference ──────────────────────────────────── */

.lede {
  margin: 0 0 26px;
  font-size: 17px;
  color: var(--text-dim);
}

.member, .type {
  margin: 0 0 10px;
  padding: 16px 18px 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scroll-margin-top: calc(var(--top) + 12px);
}
.member > h3, .type > h3 { margin: 0 0 10px; font-size: 16px; color: var(--text); }
.anchor-name { color: var(--gold-hi); font-family: var(--font-mono); font-size: 15px; }
.member .code, .type .code { margin-bottom: 12px; background: var(--bg-0); }

.opt, .kind {
  margin-left: 9px;
  padding: 1px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  vertical-align: 2px;
}

.tag { font-size: 13.5px; color: var(--text-dim); }
.tag span { color: var(--gold); font-family: var(--font-mono); }

.fields { margin-top: 12px; }
.fields th {
  width: 40%;
  background: transparent;
  font-weight: 400;
  vertical-align: top;
}
.fields th code { font-family: var(--font-mono); font-size: 12.5px; }
.fields td { color: var(--text-dim); font-size: 13.5px; }
.fields td p:last-child { margin-bottom: 0; }

/* ── cards, on the index and the section fronts ─────────── */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  margin: 22px 0 34px;
  padding: 0;
  list-style: none;
}
.cards li { margin: 0; }
.card {
  display: block;
  height: 100%;
  padding: 15px 17px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.card:hover { border-color: var(--border-strong); background: var(--bg-3); text-decoration: none; }
.card b { display: block; margin-bottom: 4px; font-size: 15px; font-weight: 650; color: var(--gold-hi); }
.card span { font-size: 13.5px; color: var(--text-dim); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 26px; padding: 0; list-style: none; }
.chips li { margin: 0; }
.chips a {
  display: block;
  padding: 4px 11px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
}
.chips a:hover { border-color: var(--border-strong); color: var(--gold); text-decoration: none; }

.page-foot {
  margin-top: 60px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-faint);
}
.page-foot p { margin: 0; }

/* ── narrow ─────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--side) minmax(0, 1fr); }
  .toc { display: none; }
  main { padding: 30px 30px 80px; }
}

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .menu-button {
    display: block;
    margin-left: auto;
    padding: 5px 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--text-dim);
    cursor: pointer;
  }
  .top-links { margin-left: 0; }
  .side {
    display: none;
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  /* The sidebar is a checkbox away rather than a script: the whole site is static and
     this is the only interactive thing on it. */
  .menu-toggle:checked ~ .shell .side { display: block; }
  .nav-group:not(.open) ul { display: block; }
  main { padding: 24px 20px 70px; }
  main h1 { font-size: 26px; }
}

/* ── search ─────────────────────────────────────────────── */

.search { position: relative; margin-left: auto; }
#q {
  width: 240px;
  padding: 5px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: 13.5px var(--font-ui);
}
#q::placeholder { color: var(--text-faint); }
#q:focus { outline: none; border-color: var(--teal); background: var(--bg-3); }

#results {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: min(520px, 78vw);
  max-height: 68vh;
  overflow-y: auto;
  padding: 5px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
}
#results a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text);
}
#results a:hover, #results a.on { background: var(--bg-3); text-decoration: none; }
#results b { font-size: 14px; font-weight: 600; color: var(--gold-hi); }
#results .where { margin-left: 8px; font-size: 11.5px; color: var(--text-faint); }
#results .snip { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.5; color: var(--text-dim); }
#results mark { background: rgba(230, 185, 92, 0.22); color: var(--gold-hi); border-radius: 2px; }
.no-hits { margin: 0; padding: 10px; font-size: 13px; color: var(--text-dim); }

@media (max-width: 820px) {
  .search { order: 3; width: 100%; margin: 0 0 10px; }
  #q { width: 100%; }
  .top { flex-wrap: wrap; height: auto; padding: 10px 16px; }
}
