/* Hotcode site. One stylesheet, system fonts, light and dark from the OS setting. */

:root {
  color-scheme: light dark;

  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, "Bitstream Charter", "Noto Serif", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;

  --bg: oklch(98.6% 0.005 85);
  --surface: oklch(96.2% 0.008 85);
  --code-bg: oklch(95.4% 0.009 85);
  --ink: oklch(23% 0.015 55);
  --ink-soft: oklch(38% 0.015 55);
  --muted: oklch(46% 0.015 60);
  --line: oklch(88% 0.01 80);
  --accent: oklch(54% 0.17 40);
  --accent-text: oklch(47% 0.16 38);
  --accent-soft: oklch(93.5% 0.04 60);
  --on-accent: oklch(99% 0.005 85);

  --c-kw: var(--accent-text);
  --c-str: oklch(42% 0.08 235);
  --c-num: oklch(45% 0.09 80);
  --c-com: var(--muted);

  --wrap: 80rem;
  --pad: clamp(1rem, 4vw, 2rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(19% 0.01 55);
    --surface: oklch(23% 0.012 55);
    --code-bg: oklch(22% 0.011 55);
    --ink: oklch(92% 0.008 80);
    --ink-soft: oklch(80% 0.01 70);
    --muted: oklch(72% 0.012 70);
    --line: oklch(32% 0.012 55);
    --accent: oklch(72% 0.15 48);
    --accent-text: oklch(78% 0.13 52);
    --accent-soft: oklch(30% 0.05 45);
    --on-accent: oklch(20% 0.02 50);

    --c-str: oklch(80% 0.07 230);
    --c-num: oklch(80% 0.09 90);
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--line) transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.65 var(--font-body);
  caret-color: var(--accent);
  overflow-wrap: break-word;
}

::selection { background: color-mix(in oklab, var(--accent) 28%, transparent); }

a {
  color: var(--accent-text);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: 6px;
}
.skip:focus { top: 1rem; }

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* header and footer */

.site-header { border-bottom: 1px solid var(--line); }
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-block: 1rem;
}
.brand {
  font: 700 1.375rem/1 var(--font-display);
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.top-nav { display: flex; gap: 1.5rem; font-size: 0.9375rem; }
.top-nav a { color: var(--ink-soft); text-decoration: none; padding-block: 0.25rem; }
.top-nav a:hover { color: var(--ink); text-decoration: underline; }
.top-nav a[aria-current] { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 0.35em; }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
  padding-block: 2rem;
}
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 2rem; }
.foot p { margin: 0; }

/* landing page */

.hero { padding-block: clamp(3rem, 9vw, 6.5rem) clamp(2.5rem, 6vw, 4.5rem); }
.hero h1 {
  margin: 0;
  max-width: 17ch;
  font: 600 clamp(2.25rem, 1.1rem + 4.6vw, 4rem)/1.08 var(--font-display);
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.lead {
  max-width: 36rem;
  margin: 1.5rem 0 0;
  font-size: clamp(1.1875rem, 1.05rem + 0.6vw, 1.375rem);
  line-height: 1.5;
  color: var(--ink-soft);
}
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 2rem 0 0; }
.btn {
  display: inline-block;
  padding: 0.7rem 1.25rem;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
}
.btn:hover { background: color-mix(in oklab, var(--accent) 88%, black); text-decoration: none; }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-quiet:hover { background: var(--surface); border-color: var(--ink-soft); }
.fine { margin: 1.25rem 0 0; font-size: 0.9375rem; color: var(--muted); }

.band { border-top: 1px solid var(--line); padding-block: clamp(2.5rem, 6vw, 4.5rem); }

.split { display: grid; gap: 1.25rem 4rem; }
.split > h2 {
  margin: 0;
  font: 600 1.625rem/1.2 var(--font-display);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
@media (min-width: 56rem) {
  .split { grid-template-columns: minmax(0, 17rem) minmax(0, 1fr); }
  .split > h2 { grid-column: 1; }
  .split > :not(h2) { grid-column: 2; }
  .split > figure { grid-column: 1 / -1; }
}

.copy { max-width: 40rem; }
.copy > :first-child { margin-top: 0; }
.copy p, .copy ul { margin: 0 0 1rem; }
.copy ul, .prose ul, .prose ol { padding-left: 1.3rem; }
.copy li { margin-bottom: 0.4rem; }
.copy h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.copy.two { display: grid; gap: 0 3rem; max-width: 46rem; }
@media (min-width: 40rem) {
  .copy.two { grid-template-columns: 1fr 1fr; }
  .copy.two .wide { grid-column: 1 / -1; }
}

.diagram {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem 3rem;
  max-width: 60rem;
  margin: 1rem 0 0.5rem;
}
@media (min-width: 46rem) {
  .diagram { grid-template-columns: 1fr 1fr; }
}
.diagram svg { display: block; width: 100%; height: auto; overflow: visible; }
.diagram figcaption { grid-column: 1 / -1; color: var(--muted); font-size: 0.875rem; }
.d-title { font: 600 17px var(--font-display); fill: var(--ink); }
.d-label { font: 14px var(--font-body); fill: var(--muted); }
.d-note { font: 14px var(--font-body); fill: var(--ink); }
.d-accent { fill: var(--accent-text); font-weight: 600; }
.d-lines line { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.d-gap { fill: var(--accent-soft); }
.d-mark { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.d-mem { fill: var(--ink-soft); }
.d-mem-empty { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }

.facts { margin: 0; }
.facts > div { padding-block: 1.1rem; border-top: 1px solid var(--line); }
.facts > div:first-child { border-top: 0; padding-top: 0; }
.facts dt { font-weight: 600; margin-bottom: 0.25rem; }
.facts dd { margin: 0; color: var(--ink-soft); max-width: 40rem; min-width: 0; }
.facts dd p { margin: 0 0 0.75rem; }
.facts dd > :last-child { margin-bottom: 0; }
.facts pre { margin-block: 0.75rem; }
.facts pre code { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (min-width: 44rem) {
  .facts > div { display: grid; grid-template-columns: 12.5rem minmax(0, 1fr); gap: 0 2rem; }
  .facts dt { margin: 0; }
}

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 2.75rem; }
.steps > li { counter-increment: step; position: relative; padding-left: 3rem; max-width: 44rem; }
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -0.15rem;
  font: 600 1.875rem/1.2 var(--font-display);
  color: var(--accent-text);
  font-variant-numeric: tabular-nums;
}
.steps h3 { margin: 0 0 0.25rem; font-size: 1.1875rem; }
.steps p { margin: 0 0 0.75rem; }
.steps pre { margin-block: 0.75rem 0; }
.steps pre code { white-space: pre-wrap; overflow-wrap: anywhere; }

.link-list { list-style: none; margin: 0; padding: 0; max-width: 44rem; }
.link-list li { padding-block: 0.7rem; border-top: 1px solid var(--line); }
.link-list li:first-child { border-top: 0; padding-top: 0; }
.link-list span { color: var(--muted); margin-left: 0.5rem; }

/* documentation layout */

.docs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; padding-block: 2rem 5rem; }
.side-nav, .toc { display: none; }
.menu {
  margin-bottom: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.menu > summary { padding: 0.7rem 1rem; cursor: pointer; font-weight: 600; }
.menu > nav { padding: 0 1rem 1rem; }

.nav-group { margin-bottom: 1.5rem; }
.nav-title { margin: 0 0 0.35rem; font-size: 0.8125rem; font-weight: 700; color: var(--muted); }
.nav-group ul { list-style: none; margin: 0; padding: 0; }
.nav-group a {
  display: block;
  padding: 0.3rem 0.6rem;
  margin-inline: -0.6rem;
  border-radius: 6px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9375rem;
  line-height: 1.4;
}
.nav-group a:hover { background: var(--surface); color: var(--ink); }
.nav-group a[aria-current] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }

@media (min-width: 60rem) {
  .docs { grid-template-columns: 14rem minmax(0, 1fr); gap: 3rem; }
  .side-nav {
    display: block;
    position: sticky;
    top: 1.5rem;
    align-self: start;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    padding-right: 0.5rem;
    overflow-x: hidden;
    scrollbar-width: thin;
  }
  .menu { display: none; }
}

@media (min-width: 76rem) {
  .docs { grid-template-columns: 14rem minmax(0, 1fr) 13rem; }
  .docs-index { grid-template-columns: 14rem minmax(0, 1fr); }
  .toc {
    display: block;
    position: sticky;
    top: 1.5rem;
    align-self: start;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    font-size: 0.8125rem;
    line-height: 1.4;
    scrollbar-width: thin;
  }
  .toc-inline { display: none; }
}

.toc-title { margin: 0 0 0.5rem; font-weight: 700; color: var(--muted); }
.toc ul, .toc-inline ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a { display: block; padding: 0.25rem 0; color: var(--ink-soft); text-decoration: none; }
.toc a:hover { color: var(--accent-text); text-decoration: underline; }
.toc .toc-3 a, .toc-inline .toc-3 a { padding-left: 0.9rem; }

.toc-inline {
  margin: 0 0 2rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.9375rem;
}
.toc-inline > summary { padding: 0.6rem 1rem; cursor: pointer; font-weight: 600; }
.toc-inline ul { padding: 0 1rem 0.9rem; }
.toc-inline a { display: block; padding: 0.2rem 0; }

/* prose */

.prose { max-width: 42rem; }
.prose > :first-child { margin-top: 0; }
.prose h1, .prose h2 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
.prose h1 { margin: 0 0 1.25rem; font-size: clamp(2rem, 1.4rem + 2vw, 2.75rem); line-height: 1.12; }
.prose h2 { margin: 3.25rem 0 0.9rem; padding-top: 0.5rem; font-size: 1.75rem; line-height: 1.2; }
.prose h3 { margin: 2.25rem 0 0.6rem; font-size: 1.25rem; line-height: 1.3; }
.prose h4, .prose h5 { margin: 1.75rem 0 0.5rem; font-size: 1.0625rem; line-height: 1.4; }
.prose h2, .prose h3, .prose h4 { scroll-margin-top: 1.5rem; }
.prose p { margin: 0 0 1.1rem; }
.prose ul, .prose ol { margin: 0 0 1.1rem; }
.prose li { margin-bottom: 0.35rem; }
.prose li > ul, .prose li > ol { margin: 0.35rem 0 0.5rem; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
.prose blockquote {
  margin: 1.4rem 0;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-radius: 8px;
}
.prose blockquote > :last-child { margin-bottom: 0; }
.prose img { max-width: 100%; height: auto; }
.prose strong { font-weight: 650; }

.anchor { margin-left: 0.4rem; text-decoration: none; color: var(--muted); opacity: 0; font-weight: 400; }
.anchor::after { content: "#"; }
:is(h1, h2, h3, h4, h5):hover > .anchor, .anchor:focus-visible { opacity: 1; }

code, pre, kbd { font-family: var(--font-mono); }
:not(pre) > code {
  font-size: 0.875em;
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--code-bg);
  overflow-wrap: anywhere;
}
pre {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--ink);
  font-size: 0.875rem;
  line-height: 1.6;
  overflow-x: auto;
  tab-size: 2;
  scrollbar-width: thin;
}
pre code { font-size: inherit; padding: 0; background: none; overflow-wrap: normal; white-space: pre; }

/* syntax highlighting: class names come from the build-time highlighter */
[class^="l-keyword"], [class^="l-conditional"], [class^="l-repeat"], [class^="l-include"], [class^="l-exception"] { color: var(--c-kw); }
[class^="l-string"], [class^="l-character"], [class^="l-symbol"] { color: var(--c-str); }
[class^="l-number"], [class^="l-boolean"], [class^="l-constant"] { color: var(--c-num); }
[class^="l-comment"] { color: var(--c-com); font-style: italic; }
[class^="l-punctuation"], [class^="l-operator"] { color: var(--muted); }
[class^="l-function"]:not([class^="l-function-call"]) { font-weight: 600; }
[class^="l-type"], [class^="l-module"] { color: var(--ink); }

.table-wrap { margin: 1.5rem 0; overflow-x: auto; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; line-height: 1.5; font-variant-numeric: tabular-nums; }
th, td { padding: 0.55rem 0.9rem 0.55rem 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-weight: 600; border-bottom-color: var(--ink-soft); white-space: nowrap; }
td { min-width: 6rem; }
td code { overflow-wrap: break-word; }
.prose h2 code, .prose h3 code { font-size: 0.8em; }
td:first-child code { white-space: nowrap; }
td:first-child { min-width: 0; }

.index-list { list-style: none; padding: 0 !important; }
.index-list li { padding-block: 0.6rem; border-top: 1px solid var(--line); }
.index-list li:first-child { border-top: 0; }
.index-list span { display: block; color: var(--muted); font-size: 0.9375rem; }
.index-list span code { font-size: 0.85em; }

.doc-foot { max-width: 42rem; margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.875rem; }
.doc-foot p { margin: 0 0 0.5rem; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.75rem; }
.pager a {
  display: block;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.pager a:hover { border-color: var(--accent); }
.pager span { display: block; margin-bottom: 0.1rem; font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.pager-next { grid-column: 2; text-align: right; }

.not-found { padding-block: 4rem; }

@media (max-width: 36rem) {
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; text-align: left; }
  .steps > li { padding-left: 2.25rem; }
}
