@font-face {
  font-family: "EB Garamond";
  src: url("fonts/eb-garamond-latin.woff2") format("woff2");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}

:root {
  /* What the fixed header takes from the top of the window. */
  --head-space: 96px;
  --black: #050506;
  --bg: var(--black);
  --ink: var(--white);
  --muted: var(--smoke);
  --metadata: #999097;
  --panel: #100e10;
  --inset: #080708;
  --overlay: #242024;
  --chrome: #191519;
  --menu: #242024;
  --focus: #ef6a81;
  --action: #ef6a81;
  --selected: #351820;
  --active: #ffffff;
  --success: #68cf8f;
  --danger: #ff718c;
  --warning: #e9ba78;
  --peer: #b3a4dc;
  --muted-dark: #82777e;
  --selected-strong: #61303e;
  --quiet: #242024;
  --edge-focus: #f7f4f5;
  --site-gutter: clamp(24px, 4vw, 58px);
  --white: #f7f4f5;
  --smoke: #aaa3a7;
  --line: #2b282a;
  --red: #e42d4f;
  --green: #68cf8f;
  /* Document pages: body text and section labels. A chosen theme derives
     its own, below. */
  --prose: #c4bcc1;
  --label: var(--red);
  /* Page titles: cherry red here and in Terminal Mono and Ember; other themes use their ink. */
  --title: var(--red);
  /* The header in the site's own palette; a chosen theme sets its own, below. */
  --head-bg: #050506;
  --head-open-from: #060607;
  --head-open-mid: #151516;
  --head-open-to: #323235;
  --head-edge: #49494d;
  --head-ink: #f7f4f5;
  --head-hover: #ff6b80;
  --head-focus: #ffffff;
  --head-press: #2a1a20;
  --head-count: #82777e;
  --head-cta-edge: #b6425a;
  --head-cta-bg: #6d1529;
  --head-cta-count: #f4b7c3;
  --head-current: #ed4962;
  --head-sheet-edge: #3a3438;
  --head-sheet-from: #1b1418;
  --head-sheet-to: #0a090a;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "EB Garamond", Georgia, serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
:root[data-theme] {
  --prose: color-mix(in srgb, var(--ink) 74%, var(--muted));
  --label: var(--focus);
  --title: var(--ink);
  /* The header follows the theme: its bar, labels and the mark's colours. */
  --head-bg: var(--bg);
  --head-open-from: var(--panel);
  --head-open-mid: var(--chrome);
  --head-open-to: var(--menu);
  --head-edge: var(--line);
  --head-ink: var(--ink);
  --head-hover: var(--focus);
  --head-focus: var(--edge-focus);
  --head-press: var(--selected);
  --head-count: var(--metadata);
  --head-cta-edge: var(--edge-focus);
  --head-cta-bg: var(--selected);
  --head-cta-count: var(--ink);
  --head-current: var(--focus);
  --head-sheet-edge: var(--line);
  --head-sheet-from: var(--chrome);
  --head-sheet-to: var(--panel);
  --mark-fruit: var(--focus);
  --mark-stem: var(--muted);
  --mark-crown: var(--action);
}
:root:is([data-theme="terminal-mono"], [data-theme="rednode-ember"]) { --title: var(--red); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 var(--sans);
}
a { color: inherit; text-decoration: none; }
button { color: inherit; font: inherit; }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 5px;
}
.skip {
  position: fixed;
  left: 20px;
  top: -80px;
  z-index: 5;
  background: var(--white);
  color: var(--black);
  padding: 9px 12px;
}
.skip:focus { top: 20px; }

html { scroll-padding-top: var(--head-space); }
/* The header stays on screen: the logo, and the menu it opens. */
.site-head {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  padding: 20px clamp(18px, 4vw, 58px);
  pointer-events: none;
}
.header-bar {
  --menu-width: 500px;
  display: inline-flex;
  align-items: center;
  position: relative;
  max-width: 100%;
  height: 58px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--head-bg);
  pointer-events: auto;
  isolation: isolate;
  transition: border-color 320ms ease, box-shadow 320ms ease;
}
.header-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(105deg, var(--head-open-from) 0%, var(--head-open-mid) 42%, var(--head-open-to) 100%);
  opacity: 0;
  transition: opacity 320ms ease;
}
.header-bar[data-open="true"] { border-color: var(--head-edge); box-shadow: 0 8px 28px #0005; }
.header-bar[data-open="true"]::before { opacity: 1; }
.header-home {
  display: grid;
  place-items: center;
  flex: 0 0 60px;
  width: 60px;
  height: 56px;
  padding: 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}
.header-home :is(img, svg) { display: block; width: 40px; height: 40px; object-fit: contain; }
.header-home:focus-visible { outline: 2px solid var(--head-focus); outline-offset: 3px; }
/* The candied mark is the site's own palette; a theme draws the flat mark in its colours. */
.header-home .header-mark-flat { display: none; }
:root[data-theme] .header-home .header-mark-candy { display: none; }
:root[data-theme] .header-home .header-mark-flat { display: block; }
.mark-fruit { fill: var(--mark-fruit, #d51f38); }
.mark-stem { fill: var(--mark-stem, #a96c24); }
.mark-crown { fill: var(--mark-crown, #68aa49); }
.header-menu {
  width: 0;
  overflow: hidden;
  visibility: hidden;
  transition: width 420ms cubic-bezier(.22,1,.36,1), visibility 0s 420ms;
}
/* Its open width is measured (site-shell.js), so any label set fits exactly. */
.header-menu-items {
  display: flex;
  align-items: center;
  gap: 2px;
  width: max-content;
  padding: 5px 7px 5px 5px;
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity 160ms ease, transform 320ms ease;
}
.header-bar[data-open="true"] .header-menu { width: var(--menu-width); visibility: visible; transition-delay: 0s; }
.header-bar[data-open="true"] .header-menu-items { opacity: 1; transform: translateX(0); transition-delay: 90ms; }
.header-menu :is(a, button) {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--head-ink);
  font: 13px/1.4 var(--sans);
  white-space: nowrap;
  background: transparent;
  cursor: pointer;
  transition: color 220ms ease;
}
.header-menu :is(a, button):hover { color: var(--head-hover); }
.header-menu :is(a, button):focus-visible { outline: 2px solid var(--head-focus); outline-offset: -3px; color: var(--head-hover); }
.label-short { display: none; }
.header-toggle { display: none; }
.header-scrim { display: none; }

/* Mid widths: the short words, divided like a list. */
@media (max-width: 1099px) and (min-width: 721px) and (hover: hover) {
  .label-long { display: none; }
  .label-short { display: inline; }
  .header-menu-items > * + * { position: relative; }
  .header-menu-items > * + *::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 30%;
    bottom: 30%;
    border-left: 1px solid var(--head-edge);
  }
}

/* Phones, and any screen without hover: the logo is home, the button beside it
   opens a sheet of the short words, sized to the screen and its safe areas. */
@media (max-width: 720px), (hover: none) {
  :root { --head-space: calc(max(12px, env(safe-area-inset-top)) + 64px); }
  .site-head {
    padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  }
  .header-bar {
    z-index: 2;
    height: 52px;
    border-color: #2b282a;
    background: #0a090a;
  }
  .header-bar::before { display: none; }
  .header-bar[data-open="true"] { height: 52px; align-items: center; border-color: var(--head-edge); }
  .header-home { flex-basis: 50px; width: 50px; height: 50px; }
  .header-home :is(img, svg) { width: 34px; height: 34px; }
  .header-toggle {
    display: grid;
    place-content: center;
    gap: 7px;
    width: 46px;
    height: 46px;
    margin-right: 2px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .header-toggle span {
    display: block;
    width: 20px;
    height: 1.5px;
    border-radius: 1px;
    background: var(--head-ink);
    transition: transform 260ms cubic-bezier(.22,1,.36,1), background-color 200ms ease;
  }
  .header-bar[data-open="true"] .header-toggle span { background: var(--head-hover); }
  .header-bar[data-open="true"] .header-toggle span:first-child { transform: translateY(4.25px) rotate(45deg); }
  .header-bar[data-open="true"] .header-toggle span:last-child { transform: translateY(-4.25px) rotate(-45deg); }
  .header-toggle:focus-visible { outline: 2px solid var(--head-focus); outline-offset: -2px; }

  .header-menu {
    --sheet-top: calc(max(12px, env(safe-area-inset-top)) + 62px);
    position: fixed;
    z-index: 3;
    top: var(--sheet-top);
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    width: auto;
    max-width: 460px;
    max-height: calc(100svh - var(--sheet-top) - max(12px, env(safe-area-inset-bottom)));
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--head-sheet-edge);
    border-radius: 16px;
    background: linear-gradient(160deg, var(--head-sheet-from), var(--head-sheet-to) 72%);
    box-shadow: 0 28px 90px #000d;
    opacity: 0;
    transform: translateY(-10px) scale(.98);
    transform-origin: top left;
    transition: opacity 180ms ease, transform 280ms cubic-bezier(.22,1,.36,1), visibility 0s 280ms;
  }
  .header-bar[data-open="true"] .header-menu { width: auto; opacity: 1; transform: none; }
  .header-menu-items {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    width: auto;
    padding: 8px;
    opacity: 1;
    transform: none;
    counter-reset: item;
  }
  .label-long { display: none; }
  .label-short { display: inline; }
  .header-menu :is(a, button) {
    justify-content: space-between;
    min-height: 56px;
    padding: 0 18px;
    border-radius: 11px;
    font: 400 27px/1 var(--serif);
    letter-spacing: .01em;
    -webkit-tap-highlight-color: transparent;
  }
  .header-menu :is(a, button)::after {
    counter-increment: item;
    content: "0" counter(item);
    color: var(--head-count);
    font: 11px/1 var(--mono);
    letter-spacing: .08em;
  }
  .header-menu :is(a, button):active { background: var(--head-press); }
  .header-menu :is(a, button):hover { color: var(--head-ink); }
  .header-menu #early-access-link {
    margin-top: 6px;
    border-color: var(--head-cta-edge);
    background: var(--head-cta-bg);
  }
  .header-menu #early-access-link::after { color: var(--head-cta-count); }
  .header-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1;
    background: #000a;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 200ms ease;
  }
  .header-scrim[hidden] { display: none; }
  .header-scrim.is-open { opacity: 1; }
  html.menu-open { overflow: hidden; }
}
/* Short screens (a phone on its side): rows that still fit. */
@media (max-width: 720px) and (max-height: 500px), (hover: none) and (max-height: 500px) {
  .header-menu :is(a, button) { min-height: 44px; font-size: 21px; }
}
/* A folding or dual-screen phone: the sheet stays on the first screen, clear of the hinge. */
@media (horizontal-viewport-segments: 2) {
  .header-menu { right: auto; width: calc(env(viewport-segment-width 0 0) - 20px) !important; }
}
@media (vertical-viewport-segments: 2) {
  .header-menu { max-height: calc(env(viewport-segment-height 0 0) - var(--sheet-top, 74px) - 12px); }
}
@media (prefers-reduced-motion: reduce) {
  .header-bar, .header-bar::before, .header-menu, .header-menu-items, .header-menu :is(a, button),
  .header-toggle span, .header-scrim { transition: none; }
}

.site-footer { padding: 0 24px 20px; color: #82777e; font: 10px/1.6 var(--sans); letter-spacing: .025em; text-align: center; }


/* The frame stays identical across home, reference pages, and the blog. Every
   page but the home page is one container and opens with one header. */
.site-page { min-height: 100svh; display: flex; flex-direction: column; }
.site-page > main { flex: 1; }
.site-page:not(.home-page) > main { width: min(1360px, calc(100% - 2 * var(--site-gutter))); margin: calc(var(--head-space) + 14px) auto 56px; }
.doc-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "title theme" "lede lede" "meta meta";
  align-items: center;
  gap: 6px 24px;
  margin-bottom: 30px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.doc-head h1 { grid-area: title; margin: 0; color: var(--title); font: 700 clamp(28px, 3vw, 36px)/1.15 var(--serif); letter-spacing: -.015em; }
.doc-lede { grid-area: lede; max-width: 80ch; margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
/* Its links are divided by dots that sit in the gap; one that would start a line
   falls outside the row and is clipped. */
.doc-meta { grid-area: meta; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 19px; margin: 6px 0 0; overflow: hidden; color: var(--metadata); font-size: 12px; line-height: 1.8; }
.doc-meta > * { position: relative; }
.doc-meta > *::before { content: "·"; position: absolute; left: -12px; color: var(--metadata); pointer-events: none; }
.doc-meta a { color: var(--muted); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.doc-meta a:hover { color: var(--ink); text-decoration-color: currentColor; }
.doc-meta a[aria-current] { color: var(--ink); text-decoration: none; }
.doc-meta sup { margin-left: 3px; color: var(--metadata); font-size: 9px; }
.doc-head .theme-switch { grid-area: theme; }
@media (max-width: 720px) {
  .doc-head { grid-template-columns: minmax(0, 1fr); grid-template-areas: "title" "lede" "meta" "theme"; }
  .doc-head .theme-switch { margin-top: 8px; }
}

/* The theme switcher, the diagrams' one: a swatch per theme, then its name. */
.theme-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 8px; color: var(--metadata); font: 12px/1.5 var(--sans); }
.theme-switch > span:first-child { margin-right: 4px; }
.theme-swatch { flex-shrink: 0; width: 16px; height: 16px; padding: 0; border: 1px solid var(--quiet); border-radius: 50%; background: radial-gradient(circle, var(--swatch-fill) 0 3.5px, var(--swatch-ground) 4px); cursor: pointer; transition: border-color .15s, transform .15s; }
.theme-swatch:hover { border-color: var(--metadata); transform: scale(1.15); }
.theme-swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--ink); }
.theme-swatch:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.theme-switch-name { min-width: 118px; margin-left: 6px; color: var(--ink); }
/* A phone drops the word "Theme" so the swatches and the name share a line. */
@media (max-width: 460px) { .theme-switch > span:first-child { display: none; } .theme-switch-name { min-width: 0; } }
@media (prefers-reduced-motion: reduce) { .theme-swatch { transition: none; } }
.site-page:not(.home-page) .site-footer { border-top: 1px solid var(--line); margin: 0 var(--site-gutter); padding: 24px 0; }
.site-footer a { text-decoration: underline; text-underline-offset: 3px; }
.site-footer nav { display: flex; justify-content: center; gap: 20px; margin-bottom: 10px; }
.header-menu [aria-current="page"] { text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--head-current); }
::selection { background: #681c30; color: #fff; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
@media print {
  .site-head, .site-footer, .skip { display: none !important; }
  .site-page:not(.home-page) > main { width: 100%; margin: 0; }
  .theme-switch { display: none !important; }
}
