/* Fira Code, self-hosted: a CDN would break the wiki offline and on a VPN
   with no DNS. local() first, so a machine that already has the font skips
   the download entirely. The woff2 is a subset built by tools/build_font.py
   and keeps the variable weight axis, which is why one file covers 300-700. */
@font-face {
  font-family: "Fira Code";
  src: local("Fira Code"), local("FiraCode-Regular"),
       url("FiraCode.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

/* Shared chrome for every wiki page. Edit here, restyle the whole wiki. */

:root {
  --bg: #fdfcfa; --panel: #f4f1ec; --fg: #1b1a18; --muted: #6a655e;
  --rule: #e2ddd5; --accent: #9a4b1f; --code-bg: #f1eee8; --quote-bg: #f3f0ff;
  --quote-rule: #6f5bd1;
  --tok-com: #6f685c; --tok-key: #7d4e8c; --tok-str: #4a6b3d; --tok-num: #8a5a2b;
  --tok-def: #2f5d7c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15161a; --panel: #1c1e23; --fg: #e4e2dd; --muted: #9a968e;
    --rule: #2c2f36; --accent: #e9a06a; --code-bg: #1f2228; --quote-bg: #1e1d2b;
    --quote-rule: #8f7ce8;
    --tok-com: #7e8591; --tok-key: #cfa0dd; --tok-str: #a3c585; --tok-num: #e0ab76;
    --tok-def: #8fbcd9;
  }
}
:root[data-theme="dark"] {
  --bg: #15161a; --panel: #1c1e23; --fg: #e4e2dd; --muted: #9a968e;
  --rule: #2c2f36; --accent: #e9a06a; --code-bg: #1f2228; --quote-bg: #1e1d2b;
  --quote-rule: #8f7ce8;
  --tok-com: #7e8591; --tok-key: #cfa0dd; --tok-str: #a3c585; --tok-num: #e0ab76;
  --tok-def: #8fbcd9;
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 17px/1.65 ui-serif, Georgia, "Times New Roman", serif;
  overflow-wrap: break-word;
}
.layout { display: flex; gap: 3rem; max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }
main { flex: 1 1 auto; min-width: 0; max-width: 46rem; padding: 2.5rem 0 6rem; }

nav.toc {
  flex: 0 0 15rem; align-self: flex-start; position: sticky; top: 0;
  max-height: 100vh; overflow-y: auto; padding: 2.75rem 0 3rem;
  font: 13.5px/1.5 ui-sans-serif, system-ui, sans-serif;
}
nav.toc h2 {
  margin: 0 0 .75rem; font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); font-weight: 600; border: 0; padding: 0;
}
nav.toc ol { list-style: none; margin: 0; padding: 0; }
nav.toc > ol > li { margin-bottom: .45rem; }
nav.toc ol ol { margin: .2rem 0 .5rem .85rem; }
nav.toc ol ol a { color: var(--muted); font-size: 12.5px; }
nav.toc a { display: block; padding: .12rem 0; color: var(--fg); text-decoration: none; }
nav.toc a:hover { color: var(--accent); }

h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.6rem); line-height: 1.15;
  margin: 0 0 1.5rem; letter-spacing: -.015em;
}
h2 {
  font-size: 1.5rem; margin: 3.25rem 0 1rem; padding-bottom: .35rem;
  border-bottom: 1px solid var(--rule); letter-spacing: -.01em; scroll-margin-top: 1.5rem;
}
h3 { font-size: 1.12rem; margin: 2.25rem 0 .75rem; scroll-margin-top: 1.5rem; }
h4 { font-size: 1rem; margin: 1.75rem 0 .6rem; color: var(--muted); scroll-margin-top: 1.5rem; }
a.anchor { color: inherit; text-decoration: none; }
a.anchor:hover { color: var(--accent); }

p, li { margin: 0 0 1rem; }
li { margin-bottom: .4rem; }
ul, ol { padding-left: 1.4rem; margin: 0 0 1.25rem; }
li > ul, li > ol { margin: .4rem 0 .2rem; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.75rem 0; }
strong { font-weight: 650; }
main a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
img { max-width: 100%; height: auto; border-radius: 6px; }

code, pre, .table-scroll code {
  font-family: "Fira Code", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  /* Fira Code keeps its programming ligatures (-> != === |>) in `calt`,
     not `liga`. Set `none` here if they ever get in the way. */
  font-variant-ligatures: contextual;
}
code {
  background: var(--code-bg); border-radius: 4px; padding: .1em .32em;
  font-size: .86em; border: 1px solid var(--rule);
}
pre {
  background: var(--code-bg); border: 1px solid var(--rule); border-radius: 8px;
  padding: .9rem 1rem; margin: 0 0 1.4rem; overflow-x: auto;
  font-size: 13.5px; line-height: 1.55; -webkit-overflow-scrolling: touch;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; }

/* Pygments token classes, mapped onto five colours and scoped to code blocks
   so these one-letter names cannot collide with layout classes. Everything
   not listed -- builtins, operators, punctuation, plain names, and the Error
   tokens Pygments emits on a fragment -- keeps the body colour on purpose:
   in typing-heavy notes, `int` and `str` are the subject matter, and colouring
   them turns every example into confetti. */
pre .c, pre .ch, pre .cm, pre .cp, pre .cpf, pre .c1, pre .cs {
  color: var(--tok-com); font-style: italic;
}
pre .k, pre .kc, pre .kd, pre .kn, pre .kp, pre .kr, pre .kt { color: var(--tok-key); }
pre .s, pre .sa, pre .sb, pre .sc, pre .dl, pre .sd, pre .s2, pre .se, pre .sh,
pre .si, pre .sx, pre .sr, pre .s1, pre .ss { color: var(--tok-str); }
pre .m, pre .mb, pre .mf, pre .mh, pre .mi, pre .mo, pre .il { color: var(--tok-num); }
pre .nf, pre .fm, pre .nc, pre .nd { color: var(--tok-def); }

blockquote {
  margin: 1.5rem 0; padding: .9rem 1.1rem; background: var(--quote-bg);
  border-left: 3px solid var(--quote-rule); border-radius: 0 6px 6px 0;
}
blockquote p { margin: 0; font-size: .95rem; }

.table-scroll { overflow-x: auto; margin: 0 0 1.5rem; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th {
  font: 600 11.5px/1.4 ui-sans-serif, system-ui, sans-serif;
  text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}

#theme {
  position: fixed; top: .75rem; right: .75rem; z-index: 10;
  background: var(--panel); color: var(--muted); border: 1px solid var(--rule);
  border-radius: 999px; width: 2.25rem; height: 2.25rem; font-size: 1rem;
  cursor: pointer; line-height: 1;
}

/* --- page chrome --- */

.home {
  display: inline-block; margin: 0 0 1.5rem; color: var(--muted);
  font: 13px/1 ui-sans-serif, system-ui, sans-serif; text-decoration: none;
}
.home:hover { color: var(--accent); }
.page-meta {
  margin: -1rem 0 1.5rem; color: var(--muted);
  font: 12.5px/1.5 ui-sans-serif, system-ui, sans-serif;
}
h1 + p, .page-meta + p { color: var(--muted); font-size: 1.05rem; }

/* --- index --- */

.index h1 { margin-bottom: .5rem; }
.index .count {
  margin: 0 0 2.5rem; color: var(--muted);
  font: 13px/1.5 ui-sans-serif, system-ui, sans-serif;
}
.cards { list-style: none; margin: 0; padding: 0; }
.cards li { margin: 0 0 .9rem; }
.cards a {
  display: block; padding: 1.1rem 1.25rem; background: var(--panel);
  border: 1px solid var(--rule); border-radius: 10px; text-decoration: none; color: inherit;
}
.cards a:hover { border-color: var(--accent); }
.card-title { display: block; font-size: 1.16rem; letter-spacing: -.01em; margin-bottom: .3rem; }
.cards a:hover .card-title { color: var(--accent); }
.card-desc { display: block; color: var(--muted); font-size: .95rem; margin-bottom: .55rem; }
.card-meta {
  display: block; color: var(--muted);
  font: 11.5px/1.5 ui-sans-serif, system-ui, sans-serif;
  text-transform: uppercase; letter-spacing: .07em;
}
.tag {
  display: inline-block; margin-left: .45rem; padding: .1em .5em;
  border: 1px solid var(--rule); border-radius: 999px; background: var(--bg);
  text-transform: none; letter-spacing: 0;
}
.empty { color: var(--muted); font-style: italic; }

@media (max-width: 950px) {
  .layout { display: block; padding: 0 1.1rem; }
  main { max-width: none; padding: 1.75rem 0 4rem; }
  nav.toc {
    position: static; max-height: none; width: auto; padding: 0;
    margin: 1.5rem 0 0; border-top: 1px solid var(--rule); padding-top: 1.25rem;
  }
  nav.toc.top { margin: 0 0 2rem; border: 0; border-bottom: 1px solid var(--rule); padding: 0 0 1.25rem; }
  body { font-size: 16.5px; }
  pre { font-size: 12.5px; }
}
