/*
 * happbucket.com visual system. The thesis, palette ratios and class vocabulary
 * are documented in docs/site-brand-and-copy.md; change both together.
 *
 * Three rules carry the identity:
 *   1. One orange, Signal, for every fill. Small text never sits on it: orange frames small
 *      text instead (tape, tags, diagram accents). Only large bold text (19px/700 and up) sits
 *      on Signal, in white. Orange text on white is Rust.
 *   2. Ink outlines (2px) mean "you can press this". Hairlines (1px) mean structure.
 *   3. One hover effect per element, and it adds (lift, underline, bar, nudge). It never dims.
 *   4. Lines come from 3 weights (1, 2, 4px) and corners from 3 radii (0, 2, 4px).
 */

/* ---------- 0. Helix Mono (self-hosted, SIL OFL 1.1; licence in assets/fonts/OFL.txt) ---------- */

@font-face {
  font-family: "Helix Mono";
  src: url("/assets/fonts/HelixMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Helix Mono";
  src: url("/assets/fonts/HelixMono-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Helix Mono";
  src: url("/assets/fonts/HelixMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Helix Mono";
  src: url("/assets/fonts/HelixMono-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Helix Mono";
  src: url("/assets/fonts/HelixMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/*
 * Metric-matched fallback for Space Grotesk 700 while it loads: the local Arial Bold (Liberation Sans
 * Bold on Linux) scaled to Space Grotesk's measured width and box. Measured 27 Nov 2026 at 100px:
 * the 3 longest site headlines run 0.69-1.75% wider in Space Grotesk than in Arial Bold (mean 1.05%),
 * ascent 0.98em vs 0.91em, descent 0.29em vs 0.21em. Overrides are divided by size-adjust.
 */
@font-face {
  font-family: "Space Grotesk Fallback";
  src: local("Arial Bold"), local("Arial-BoldMT"), local("Liberation Sans Bold"), local("Helvetica Bold");
  font-weight: 700;
  size-adjust: 101%;
  ascent-override: 97%;
  descent-override: 28.7%;
  line-gap-override: 0%;
}

/* ---------- 1. Tokens ---------- */

:root {
  /* Orange */
  --hb-signal: #ff5b14;        /* graphics only: mark, chunks, bars, bullets, underlines. 3.11:1 on white */
  --hb-on-signal: #ffffff;     /* large bold text only (19px/700+): WCAG 3.11 (AA large), APCA Lc 62.3 */
  --hb-rust: #a83800;          /* orange text on light grounds. 6.50:1 on white */
  --hb-tint: #fff1e8;          /* orange wash behind callouts */
  --hb-tint-rule: #ffc9a8;

  /* Neutrals */
  --hb-ink: #15171c;           /* headings, UI ink, outlines. 17.93:1 on white */
  --hb-ink-prose: #2a2e35;     /* long-form reading */
  --hb-ink-2: #474c56;         /* body copy. 8.62:1 on white */
  --hb-ink-3: #5e6470;         /* meta and captions only. 5.94:1 on white */
  --hb-paper: #ffffff;
  --hb-paper-2: #f4f5f7;       /* recessed sections, footer */
  --hb-rule: #dde0e5;          /* hairline structure */
  --hb-rule-strong: #828995;   /* dashed "planned" outlines, chart bars. 3.52:1 on white, 3.23:1 on paper-2 */

  /* Code */
  --hb-code-bg: #16181d;
  --hb-code-ink: #e7e9ee;      /* 14.62:1 on code bg */
  --hb-code-signal: #ff9a5c;   /* 8.48:1 on code bg */
  --hb-code-muted: #9ba2ae;    /* 6.91:1 on code bg */

  /* Type */
  --hb-sans: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --hb-mono: "Helix Mono", ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --hb-display: "Space Grotesk", "Space Grotesk Fallback", ui-sans-serif, system-ui, sans-serif;

  /* Space */
  --hb-gutter: clamp(1.25rem, 4vw, 3rem);
  --hb-max: 76rem;
  --hb-measure: 68ch;
  --hb-header-h: 4.25rem;
  --hb-radius: 4px;             /* r4: frames (buttons, cards, figures, tables, code) */
  --hb-radius-chip: 2px;       /* r2: chips (tape, tags, tool chips, numbers, rail cells) */
  --hb-w1: 1px;                /* hairline: structure, dividers, label chips */
  --hb-w2: 2px;                /* ink line: anything you can press, emphasis rules, diagram strokes */
  --hb-w4: 4px;                /* accent bar: current nav, callouts, quotes, code, primary mode */
  --hb-inset-row: 1rem 1.25rem;               /* rows and small cards */
  --hb-inset-card: clamp(1rem, 2.5vw, 2rem);  /* cards and figure frames */
  --hb-lift: 4px 4px 0 var(--hb-ink);
  --hb-ease: 140ms cubic-bezier(0.2, 0.7, 0.3, 1);
  --hb-ease-out: cubic-bezier(0.2, 0.7, 0.3, 1);

  /* Vertical rhythm: eyebrow to heading, heading to lede, lede to the body below it. */
  --hb-gap-eyebrow: 1.25rem;
  --hb-gap-lede: 1.25rem;
  --hb-gap-body: clamp(2.25rem, 4vw, 3.25rem);

  color-scheme: light;
}

/* Whole-pixel gutters keep every column edge, frame and hairline on the pixel grid. */
@supports (width: round(1px, 1px)) {
  :root {
    --hb-gutter: round(clamp(1.25rem, 4vw, 3rem), 1px);
  }
}

/* ---------- 2. Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--hb-paper);
  color: var(--hb-ink-2);
  font-family: var(--hb-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

main {
  flex: 1 0 auto;
}

/* Every heading is Space Grotesk 700 (display); body is Archivo, labels and code Helix Mono. */
h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--hb-ink);
  font-family: var(--hb-display);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

p,
ul,
ol,
dl,
dd,
figure,
blockquote {
  margin: 0;
}

/* Text balance: short blocks balance their lines; running text avoids orphans. */
p,
li,
dd,
blockquote {
  text-wrap: pretty;
}

.eyebrow,
.hero-lede,
.page-lede,
.section-intro,
.article-standfirst,
.step-title,
.deploy-title,
.rail-name,
.stat-label,
.family-name,
.next-title,
.article-card-title,
.pager-title,
.figcaption,
figcaption,
.footer-about p,
.fine {
  text-wrap: balance;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--hb-rust);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--hb-signal);
}

/* Inline links: the single hover effect is the underline thickening 1px to 2px. */
a:hover {
  text-decoration-thickness: 2px;
}

strong {
  color: var(--hb-ink);
  font-weight: 650;
}

code,
kbd,
samp,
pre {
  font-family: var(--hb-mono);
}

::selection {
  background: var(--hb-tint-rule);
  color: var(--hb-ink);
}

:focus-visible {
  outline: var(--hb-w2) solid var(--hb-ink);
  outline-offset: 3px;
  border-radius: var(--hb-radius-chip);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--hb-ink);
  color: var(--hb-paper);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* Anchor targets clear the sticky header and its floating pill. Set on targets, not on the root, so
   focusing a link inside the sticky header never scrolls the page. */
[id] {
  scroll-margin-top: calc(var(--hb-header-h) + 1.5rem);
}

.wrap {
  width: 100%;
  max-width: var(--hb-max);
  margin-inline: auto;
  padding-inline: var(--hb-gutter);
}

/* ---------- 3. Header and brand ---------- */

/*
 * The header. At the top of a page it is a full-width white bar with no bottom rule. Once the page
 * scrolls 4rem it morphs, in one continuous motion, into a centred floating pill: 2px ink frame,
 * hard ink shadow, fully round ends (the one deliberate exception to the 0/2/4px radius scale).
 * The sticky header box never changes height, so page content never shifts; only the bar inside
 * it changes shape. Scroll-driven where supported; app.js adds .is-floating as the fallback and
 * for reduced motion (an instant change). Without JS or scroll timelines it stays a sticky bar.
 */
.site-header {
  --hb-pill-w: 40.5rem;
  --hb-pill-h: 3.25rem;
  --hb-pill-top: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--hb-header-h);
  pointer-events: none;
}

.site-header-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  height: var(--hb-header-h);
  margin-top: 0;
  padding-inline: calc(max(var(--hb-gutter), (100% - var(--hb-max)) / 2 + var(--hb-gutter)) - var(--hb-w2));
  border: var(--hb-w2) solid transparent;
  border-radius: 0;
  background: var(--hb-paper);
  box-shadow: 0 0 0 var(--hb-ink);
  pointer-events: auto;
}

@keyframes hb-nav-float {
  to {
    max-width: var(--hb-pill-w);
    height: var(--hb-pill-h);
    margin-top: var(--hb-pill-top);
    padding-inline: calc(1rem - var(--hb-w2));
    border-color: var(--hb-ink);
    border-radius: calc(var(--hb-pill-h) / 2);
    box-shadow: var(--hb-lift);
  }
}

/* Fallback and reduced-motion state, set by app.js. */
html.is-floating .site-header-inner {
  max-width: var(--hb-pill-w);
  height: var(--hb-pill-h);
  margin-top: var(--hb-pill-top);
  padding-inline: calc(1rem - var(--hb-w2));
  border-color: var(--hb-ink);
  border-radius: calc(var(--hb-pill-h) / 2);
  box-shadow: var(--hb-lift);
}

@media (prefers-reduced-motion: no-preference) {
  .site-header-inner {
    transition:
      max-width 220ms var(--hb-ease-out),
      height 220ms var(--hb-ease-out),
      margin-top 220ms var(--hb-ease-out),
      padding-inline 220ms var(--hb-ease-out),
      border-color 220ms var(--hb-ease-out),
      border-radius 220ms var(--hb-ease-out),
      box-shadow 220ms var(--hb-ease-out);
  }

  @supports (animation-timeline: scroll()) {
    .site-header-inner {
      transition: none;
      animation: hb-nav-float linear both;
      animation-timeline: scroll(root block);
      animation-range: 0 min(4rem, 100%);
    }
  }
}

/* Inside the bar the focus ring sits just inside each link, so the pill frame never crowds it. */
.site-header :is(.brand, .site-nav-link):focus-visible {
  outline-offset: -3px;
}

/*
 * "View on GitHub": GitHub's own pattern, an ink button with the GitHub mark and white text, at the
 * right end of the nav in both states. It links to the Granis-AI organisation and opens a new tab.
 * Its one hover effect is the lift every button shares. In the floating pill "View on" folds away.
 */
.gh-button {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.5rem;
  height: 2.5rem;
  margin-left: 0.25rem;
  padding: 0 0.875rem;
  border: var(--hb-w2) solid var(--hb-ink);
  border-radius: var(--hb-radius);
  background: var(--hb-ink);
  color: var(--hb-paper);
  font-family: var(--hb-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--hb-ease), box-shadow var(--hb-ease);
}

/* A 44px tall hit area around the 40px button. */
.gh-button::after,
.nav-menu-button::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--hb-w2) - 2px) calc(-1 * var(--hb-w2));
}

.gh-button:hover {
  color: var(--hb-paper);
  transform: translate(-2px, -2px);
  box-shadow: var(--hb-lift);
}

.gh-button:focus-visible,
.nav-menu-button:focus-visible {
  outline-offset: 2px;
}

.gh-mark {
  flex: none;
  display: block;
  fill: currentColor;
}

.gh-label {
  display: inline-flex;
}

.gh-view {
  overflow: hidden;
  max-width: 6.5rem;
  white-space: pre;
}

@keyframes hb-ghview-fold {
  60%,
  to {
    max-width: 0;
    opacity: 0;
  }
}

html.is-floating .gh-view {
  max-width: 0;
  opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .gh-view {
    transition: max-width 220ms var(--hb-ease-out), opacity 140ms var(--hb-ease-out);
  }

  @supports (animation-timeline: scroll()) {
    .gh-view {
      transition: none;
      animation: hb-ghview-fold linear both;
      animation-timeline: scroll(root block);
      animation-range: 0 min(4rem, 100%);
    }
  }
}

/* The compact menu (below 768px): a disclosure that works without JS; app.js closes it on outside
   clicks and Escape. Its button lifts on hover like every button; the open state fills it ink. */
.nav-menu {
  position: relative;
  display: none;
  flex: none;
}

.nav-menu-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 2.5rem;
  padding: 0 0.75rem;
  border: var(--hb-w2) solid var(--hb-ink);
  border-radius: var(--hb-radius);
  background: var(--hb-paper);
  color: var(--hb-ink);
  font-family: var(--hb-sans);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  list-style: none;
  cursor: pointer;
  user-select: none;
  transition: transform var(--hb-ease), box-shadow var(--hb-ease);
}

.nav-menu-button::-webkit-details-marker {
  display: none;
}

.nav-menu-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--hb-lift);
}

.nav-menu[open] > .nav-menu-button {
  background: var(--hb-ink);
  color: var(--hb-paper);
}

.nav-menu-icon {
  display: block;
  width: 0.875rem;
  height: 0.625rem;
  background:
    linear-gradient(currentColor, currentColor) top / 100% var(--hb-w2) no-repeat,
    linear-gradient(currentColor, currentColor) center / 100% var(--hb-w2) no-repeat,
    linear-gradient(currentColor, currentColor) bottom / 100% var(--hb-w2) no-repeat;
}

.nav-menu-panel {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  z-index: 1;
  display: grid;
  min-width: 13rem;
  padding: 0.5rem;
  border: var(--hb-w2) solid var(--hb-ink);
  border-radius: var(--hb-radius);
  background: var(--hb-paper);
  box-shadow: var(--hb-lift);
}

.nav-menu-link {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 0.75rem;
  color: var(--hb-ink);
  font-size: 1rem;
  font-weight: 600;
  text-decoration-line: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: var(--hb-w2);
  text-underline-offset: 0.3em;
}

/* Menu links: the single hover effect is a 2px ink underline. The current page has a Signal bar. */
.nav-menu-link:hover {
  text-decoration-color: var(--hb-ink);
}

.nav-menu-link[aria-current="page"] {
  box-shadow: inset var(--hb-w4) 0 0 var(--hb-signal);
}

/* Compact header (below 768px): mark, GitHub icon and the menu; the wordmark folds away as it floats. */
@keyframes hb-word-fold {
  60%,
  to {
    max-width: 0;
    margin-left: 0;
    opacity: 0;
  }
}

@media (max-width: 47.9375rem) {
  .site-header {
    --hb-pill-w: 14rem;
    --hb-pill-h: 3rem;
    --hb-pill-top: 0.5rem;
  }

  .site-header .site-nav {
    display: none;
  }

  .gh-button {
    width: 2.5rem;
    margin-left: auto;
    padding: 0;
    justify-content: center;
  }

  .gh-mark {
    width: 20px;
    height: 20px;
  }

  .gh-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .nav-menu {
    display: block;
  }

  .site-header .brand {
    min-width: 2.75rem;
    justify-content: center;
  }

  html.is-floating .site-header .brand-word {
    max-width: 0;
    margin-left: 0;
    opacity: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    .site-header .brand-word {
      transition: max-width 220ms var(--hb-ease-out), margin-left 220ms var(--hb-ease-out), opacity 140ms var(--hb-ease-out);
    }

    @supports (animation-timeline: scroll()) {
      .site-header .brand-word {
        transition: none;
        animation: hb-word-fold linear both;
        animation-timeline: scroll(root block);
        animation-range: 0 min(4rem, 100%);
      }
    }
  }
}

.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  min-height: 2.75rem;
  color: var(--hb-ink);
  text-decoration: none;
}

/* The lockup has no hover effect: the identity stays still. Focus still draws the ring. */
.brand:hover {
  color: var(--hb-ink);
}

.brand-mark {
  flex: none;
  display: block;
}

/* The mark: one Signal path on its own 32-unit grid, drawn at 32px so its edges land on whole pixels. */
.brand-mark-body {
  fill: var(--hb-signal);
}

.brand-word {
  overflow: hidden;
  max-width: 10rem;
  margin-left: 0.625rem;
  white-space: nowrap;
  font-family: var(--hb-mono);
  font-weight: 700;
  font-size: 1.375rem;
  letter-spacing: -0.03em;
  line-height: 1.5;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
}

.site-nav-link {
  position: relative;
  display: inline-flex;
  white-space: nowrap;
  align-items: center;
  min-height: 2.75rem;
  padding-inline: 0.75rem;
  color: var(--hb-ink-2);
  font-weight: 560;
  font-size: 1rem;
  text-decoration: none;
}

.site-nav-link::after {
  content: "";
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.5rem;
  height: var(--hb-w2);
  background: transparent;
}

/* Nav: the single hover effect is a 2px ink bar. The current page carries a 4px signal bar. */
.site-nav-link:hover::after {
  background: var(--hb-ink);
}

.site-nav-link[aria-current="page"] {
  color: var(--hb-ink);
  font-weight: 650;
}

.site-nav-link[aria-current="page"]::after {
  height: var(--hb-w4);
  background: var(--hb-signal);
}

/* ---------- 4. Shared pieces: tape, eyebrow, buttons, tags, links ---------- */

/*
 * Page tags (the row above a page title): separate chips with an even 8px gap. Each chip is a 1px ink
 * frame, 27px tall, ink mono caps on white, led by a 9px Signal square the height of the caps. The odd
 * height leaves equal whole-pixel space above and below the 9px caps at 1x and 2x, so text and marker
 * sit exactly centred and every edge is crisp.
 */
.tape {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1.75rem;
  padding: 0;
  list-style: none;
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.tape span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 1.6875rem;
  padding: 0 0.625rem;
  border: var(--hb-w1) solid var(--hb-ink);
  border-radius: var(--hb-radius-chip);
  background: var(--hb-paper);
  color: var(--hb-ink);
  white-space: nowrap;
}

.tape span::before {
  content: "";
  flex: none;
  width: 0.5625rem;
  height: 0.5625rem;
  background: var(--hb-signal);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: var(--hb-gap-eyebrow);
  color: var(--hb-ink-2);
  font-family: var(--hb-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow-num {
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  height: 1.5rem;
  padding-inline: 0.375rem;
  border: var(--hb-w1) solid var(--hb-ink);
  border-radius: var(--hb-radius-chip);
  color: var(--hb-ink);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3.125rem;
  padding: 0 1.25rem;
  border: var(--hb-w2) solid var(--hb-ink);
  border-radius: var(--hb-radius);
  color: var(--hb-ink);
  font-family: var(--hb-sans);
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  transition: transform var(--hb-ease), box-shadow var(--hb-ease);
}

/* White on Signal is large-text contrast (3.11:1), so the label is 19px/700: WCAG large text. */
.button-primary {
  background: var(--hb-signal);
  color: var(--hb-on-signal);
}

.button-secondary {
  background: var(--hb-paper);
}

/* Buttons: the single hover effect is the lift with a hard ink shadow. */
.button:hover {
  transform: translate(-2px, -2px);
  box-shadow: var(--hb-lift);
}

.button-primary:hover {
  color: var(--hb-on-signal);
}

.button-secondary:hover {
  color: var(--hb-ink);
}

.button:active {
  transform: none;
  box-shadow: none;
}

.button-arrow {
  display: inline-block;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
}

.tag {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border: var(--hb-w1) solid var(--hb-ink);
  border-radius: var(--hb-radius-chip);
  background: var(--hb-paper);
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag-measured {
  background: var(--hb-ink);
  color: var(--hb-paper);
}

/* Small text never sits on orange: the "built" tag is a 2px Signal frame around ink on white
   (a 1px border plus a 1px inset ring, so the text does not move). */
.tag-build {
  border-color: var(--hb-signal);
  box-shadow: inset 0 0 0 var(--hb-w1) var(--hb-signal);
  font-weight: 700;
}

.tag-planned {
  border-style: dashed;
}

.tag-target {
  border-style: dashed;
  border-color: var(--hb-rust);
  color: var(--hb-rust);
}

.tag-estimate {
  border-style: dotted;
  border-width: var(--hb-w2);
  padding: calc(0.25rem - 1px) calc(0.5rem - 1px);
}

.link-arrow {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--hb-ink);
  font-weight: 650;
  text-decoration-color: var(--hb-signal);
  text-decoration-thickness: var(--hb-w2);
}

.link-arrow::after {
  content: "→";
  display: inline-block;
  color: var(--hb-ink);
  transition: transform var(--hb-ease);
}

/* Arrow links: the single hover effect is the arrow nudging 4px; the underline stays put. */
.link-arrow:hover {
  text-decoration-thickness: var(--hb-w2);
}

.link-arrow:hover::after {
  transform: translateX(4px);
}

.nowrap {
  white-space: nowrap;
}

.fine {
  color: var(--hb-ink-3);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ---------- 5. Sections ---------- */

.section {
  padding-block: clamp(4rem, 8vw, 6.5rem);
  border-top: var(--hb-w1) solid var(--hb-rule);
}

.section-recessed {
  background: var(--hb-paper-2);
}

.section-head {
  max-width: 48rem;
  margin-bottom: var(--hb-gap-body);
}

.section-head-split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1.5rem 4rem;
  align-items: end;
  max-width: none;
}

.section-title {
  max-width: 15em;
  font-size: clamp(1.375rem, calc((100vw - 2.5rem) / 12.4), 2.625rem);
  line-height: 1.08;
  letter-spacing: -0.025em;
}

/*
 * Section titles hold their longest sentence ("Holochain keeps the rules.", 12.1em) on 1 line: on
 * phones the size is the column / 12.4; from 896px the title sits in a half-width split column.
 */
@media (min-width: 56rem) {
  .section-title {
    font-size: clamp(1.875rem, calc((100vw - 7rem) * 0.0335), 2.625rem);
  }
}

.section-intro {
  max-width: 34rem;
  color: var(--hb-ink-2);
  font-size: 1.125rem;
}

.section-more {
  margin-top: 2.25rem;
}

.body-lg {
  color: var(--hb-ink);
  font-size: 1.25rem;
  line-height: 1.55;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 2rem clamp(2.5rem, 6vw, 6rem);
}

.split-even {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}

.split-head .section-title {
  max-width: none;
}

/* A heading made of two sentences starts each one on a new line and wraps it in reading
   order (pretty, not balance: balance would strand a single long word on the first line). */
.section-title .line {
  display: block;
  text-wrap: balance;
}

.split-head > .section-title + * {
  margin-top: var(--hb-gap-lede);
}

.split-head > p + p {
  margin-top: 1rem;
}

.split-head > p,
.split-body > p {
  max-width: 34rem;
}

.split-body > * + * {
  margin-top: 1.25rem;
}

/* On wide screens the right column starts level with the heading, not the eyebrow. */
@media (min-width: 56.0625rem) {
  .split > :last-child {
    padding-top: calc(1.5rem + var(--hb-gap-eyebrow));
  }
}

/* ---------- 6. Home: hero ---------- */

.hero {
  padding-block: clamp(3rem, 7vw, 6rem) clamp(3.5rem, 7vw, 6rem);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 3rem clamp(2rem, 5vw, 5rem);
  align-items: center;
}

.hero-title {
  font-size: clamp(1.75rem, calc((100vw - 2.5rem) / 9.5), 3.75rem);
  line-height: 1.02;
  letter-spacing: -0.03em;
  max-width: 15em;
}

/*
 * Hero headline sizing. "run beside your own" is the longest line of the 3 ("An S3 endpoint you /
 * run beside your own / Holochain node.") and measures 9.29em at -0.03em tracking, so the size is the
 * column width / 9.5: 3 even lines at every width. Above 896px the copy shares the row with the
 * figure; its column measured 421px at 897, 481 at 1024, 555 at 1180 and 566-570 from 1280, and
 * 4.92vw tracks column / 9.5 across that range up to the 60px cap.
 */
@media (min-width: 56rem) {
  .hero-title {
    font-size: clamp(2.75rem, 4.92vw, 3.75rem);
  }
}

.hero-lede {
  max-width: 35rem;
  margin-top: var(--hb-gap-lede);
  color: var(--hb-ink-2);
  font-size: clamp(1.125rem, 1.6vw, 1.3125rem);
  line-height: 1.55;
}

.hero .cta-row {
  margin-top: 2.25rem;
}

.hero-status {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  max-width: 34rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: var(--hb-w1) solid var(--hb-rule);
  color: var(--hb-ink-2);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.status-dot {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  background: var(--hb-signal);
  box-shadow: 0 0 0 var(--hb-w1) var(--hb-ink);
}

.hero-figure {
  container: hero / inline-size;
  justify-self: end;
  width: 100%;
  max-width: 38rem;
  --hb-fig-inset: clamp(1rem, 1.5vw, 1.25rem);
  padding: var(--hb-fig-inset) var(--hb-fig-inset) 0;
  border: var(--hb-w1) solid var(--hb-rule);
  border-radius: var(--hb-radius);
  background: var(--hb-paper);
}

.hero-figure figcaption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: var(--hb-fig-inset) calc(-1 * var(--hb-fig-inset)) 0;
  padding: 0.75rem var(--hb-fig-inset);
  border-top: var(--hb-w1) solid var(--hb-rule);
  color: var(--hb-ink-2);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-figure svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.hero-figure .hero-svg-wide {
  display: none;
}

/* The figure picks its drawing by its own width: the wide one needs 440px for 12px+ labels. */
@container hero (min-width: 440px) {
  .hero-figure .hero-svg-wide {
    display: block;
  }

  .hero-figure .hero-svg-phone {
    display: none;
  }
}

.figp-label {
  fill: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.figp-sub {
  fill: var(--hb-ink-2);
  font-family: var(--hb-sans);
  font-size: 14px;
}

.figp-num {
  fill: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 14px;
  font-weight: 600;
}

/* Hero diagram: the data-bucket mark at 10x, cut into chunks, signed for by an ink key, on storage. */
.fig-body {
  fill: var(--hb-signal);
}

.fig-cuts rect {
  fill: var(--hb-paper);
}

.fig-seals rect {
  fill: var(--hb-ink);
}

.fig-key-solid,
.fig-arrow {
  fill: var(--hb-ink);
}

.fig-sign {
  fill: none;
  stroke: var(--hb-ink);
  stroke-width: var(--hb-w2);
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
  shape-rendering: crispEdges;
}

.fig-ground-line {
  fill: none;
  stroke: var(--hb-ink);
  stroke-width: var(--hb-w2);
  vector-effect: non-scaling-stroke;
  shape-rendering: crispEdges;
}

.fig-ground-hatch {
  fill: none;
  stroke: var(--hb-ink);
  stroke-width: var(--hb-w1);
  vector-effect: non-scaling-stroke;
}

.fig-leader {
  fill: none;
  stroke: var(--hb-ink);
  stroke-width: var(--hb-w1);
  vector-effect: non-scaling-stroke;
  shape-rendering: crispEdges;
}

.fig-balloon {
  fill: var(--hb-paper);
  stroke: var(--hb-ink);
  stroke-width: var(--hb-w1);
  vector-effect: non-scaling-stroke;
}

.fig-balloon-num {
  fill: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 17px;
  font-weight: 600;
}

.fig-label {
  fill: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.fig-sub {
  fill: var(--hb-ink-2);
  font-family: var(--hb-sans);
  font-size: 17px;
}

/* ---------- 7. Home: tools, steps, stats ---------- */

.tool-row {
  max-width: 34rem;
  margin-top: 2rem !important;
  padding-top: 1.5rem;
  border-top: var(--hb-w1) solid var(--hb-rule);
}

.tool-row-label {
  margin-bottom: 1rem;
  color: var(--hb-ink-2);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.tool-list li {
  padding: 0.375rem 0.75rem;
  border: var(--hb-w1) solid var(--hb-rule);
  border-radius: var(--hb-radius-chip);
  white-space: nowrap;
  background: var(--hb-paper-2);
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 0.875rem;
  font-weight: 500;
}

.tool-row .fine {
  margin-top: 1rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2.5rem clamp(2.5rem, 4vw, 4rem);
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step {
  position: relative;
  padding-top: 1.75rem;
  border-top: var(--hb-w2) solid var(--hb-ink);
}

.step-glyph {
  display: block;
  width: 96px;
  height: 64px;
  margin-bottom: 1.25rem;
}

.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 3.5rem;
  right: calc(-1 * clamp(2.5rem, 4vw, 4rem) / 2 - 0.75rem);
  width: 1.5rem;
  height: 0.875rem;
  background: var(--hb-ink);
  clip-path: polygon(0 40%, 62% 40%, 62% 0, 100% 50%, 62% 100%, 62% 60%, 0 60%);
}

.glyph-ink {
  fill: var(--hb-ink);
}

.glyph-signal {
  fill: var(--hb-signal);
}

.glyph-ink-dash {
  fill: none;
  stroke: var(--hb-ink);
  stroke-width: var(--hb-w2);
  stroke-dasharray: 4 3;
  shape-rendering: crispEdges;
}

.glyph-ink-thin {
  fill: none;
  stroke: var(--hb-ink);
  stroke-width: 1;
}

.step-num {
  margin-bottom: 0.5rem;
  color: var(--hb-rust);
  font-family: var(--hb-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.step-title {
  margin-bottom: 0.75rem;
  font-size: clamp(1.25rem, 1.7vw, 1.375rem);
  letter-spacing: -0.01em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: var(--hb-w1) solid var(--hb-rule);
  border-radius: var(--hb-radius);
  background: var(--hb-paper);
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  padding: var(--hb-inset-card);
}

.stat + .stat {
  border-left: var(--hb-w1) solid var(--hb-rule);
}

.stat-value {
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: clamp(1.75rem, 2.7vw, 2.375rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-label {
  flex: 1;
  color: var(--hb-ink-2);
  font-size: 1rem;
  line-height: 1.55;
}

/* ---------- 8. Home: deploy, build rail, family, next ---------- */

.deploy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 1.5rem;
}

/* Each card spans 6 shared rows (tag, title, text, 3 spec rows) so hairlines line up across cards. */
.deploy-card {
  display: grid;
  grid-row: span 6;
  grid-template-rows: subgrid;
  justify-items: start;
  row-gap: 0;
  padding: var(--hb-inset-card);
  border: var(--hb-w1) solid var(--hb-rule);
  border-radius: var(--hb-radius);
  background: var(--hb-paper);
}

.deploy-card > .deploy-title {
  margin-top: 1rem;
  font-size: clamp(1.5rem, 2.3vw, 1.75rem);
  letter-spacing: -0.02em;
}

.deploy-card > p:not(.tag) {
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.deploy-title {
  font-size: clamp(1.375rem, 2.2vw, 1.625rem);
}

.spec-list {
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  justify-self: stretch;
  row-gap: 0;
}

.spec-list > div {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 0.25rem 1rem;
  padding-block: 0.75rem;
  border-top: var(--hb-w1) solid var(--hb-rule);
}

.spec-list > div:last-child {
  padding-bottom: 0;
}

.spec-list dt {
  color: var(--hb-ink-2);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  line-height: 2;
  text-transform: uppercase;
}

.spec-list dd {
  color: var(--hb-ink);
  font-size: 1rem;
  line-height: 1.5;
}

.rail-block {
  margin-top: clamp(3rem, 6vw, 4.5rem);
}

.rail-title {
  margin-bottom: 1.25rem;
  font-size: 1.3125rem;
}

.rail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.rail-cell {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 7rem;
  padding: var(--hb-inset-row);
  border: var(--hb-w1) dashed var(--hb-rule-strong);
  border-radius: var(--hb-radius-chip);
  background: var(--hb-paper);
  color: var(--hb-ink);
}

.rail-id {
  font-family: var(--hb-mono);
  font-size: 0.875rem;
  font-weight: 600;
}

.rail-name {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.375;
}

.rail-state {
  white-space: nowrap;
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.rail-done {
  border: var(--hb-w1) solid var(--hb-ink);
  background: var(--hb-ink);
  color: var(--hb-paper);
}

.rail-built {
  border: var(--hb-w1) solid var(--hb-signal);
  box-shadow: inset 0 0 0 var(--hb-w1) var(--hb-signal);
}

.rail-built .rail-state {
  font-weight: 700;
}

.family {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.family-link,
.next-card {
  position: relative;
  display: grid;
  gap: 0.25rem;
  padding: var(--hb-inset-row);
  border: var(--hb-w2) solid var(--hb-ink);
  border-radius: var(--hb-radius);
  background: var(--hb-paper);
  color: var(--hb-ink-2);
  text-decoration: none;
  transition: transform var(--hb-ease), box-shadow var(--hb-ease);
}

.family-link::after,
.next-card::after {
  content: "→";
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  color: var(--hb-ink);
  font-size: 1.25rem;
  line-height: 1;
}

.family-link::after {
  content: "↗";
}

/* Cards: the single hover effect is the lift with a hard ink shadow. Titles and arrows stay still. */
.family-link:hover,
.next-card:hover {
  color: var(--hb-ink-2);
  transform: translate(-2px, -2px);
  box-shadow: var(--hb-lift);
}

.family-name {
  padding-right: 2rem;
  color: var(--hb-ink);
  font-size: 1.1875rem;
  font-weight: 700;
  font-family: var(--hb-display);
  letter-spacing: -0.01em;
}

.family-desc {
  font-size: 1rem;
  line-height: 1.5;
}

.family-host {
  margin-top: 0.25rem;
  color: var(--hb-rust);
  font-family: var(--hb-mono);
  font-size: 0.8125rem;
  font-weight: 500;
}

.section-next {
  background: var(--hb-paper);
}

.next-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.next-card {
  gap: 0.5rem;
  padding: var(--hb-inset-card);
  padding-right: calc(var(--hb-inset-card) + 2.5rem);
}

.next-card::after {
  top: var(--hb-inset-card);
  right: var(--hb-inset-card);
  font-size: 1.75rem;
}

.next-kicker {
  color: var(--hb-rust);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.next-title {
  color: var(--hb-ink);
  font-size: clamp(1.625rem, 2.8vw, 2.125rem);
  font-weight: 700;
  line-height: 1.1;
  font-family: var(--hb-display);
  letter-spacing: -0.025em;
}

.next-desc {
  max-width: 34rem;
  font-size: 1rem;
  line-height: 1.55;
}

/* ---------- 8b. Home: what you run, who it is for, start in 2 minutes ---------- */

.parts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.part {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: var(--hb-inset-card);
  border: var(--hb-w1) solid var(--hb-rule);
  border-radius: var(--hb-radius);
  background: var(--hb-paper);
}

.part-label {
  color: var(--hb-ink-2);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.part-name {
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: clamp(1.375rem, 2.4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.part-name code {
  font-family: inherit;
}

.part .fine {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: var(--hb-w1) solid var(--hb-rule);
}

/* A direct question and answer under the 2 parts: the question in mono, the answer in display type. */
.answer {
  display: grid;
  grid-template-columns: minmax(0, 18rem) minmax(0, 1fr);
  gap: 0.5rem 2rem;
  align-items: baseline;
  margin-top: 1.5rem;
  padding: var(--hb-inset-card);
  border: var(--hb-w2) solid var(--hb-ink);
  border-radius: var(--hb-radius);
}

.answer-q {
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 0.9375rem;
  font-weight: 700;
}

.answer-a {
  color: var(--hb-ink);
  font-family: var(--hb-display);
  font-size: clamp(1.25rem, 2.2vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.3;
  text-wrap: balance;
}

.audiences {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
}

.audience {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  padding: var(--hb-inset-card);
  border: var(--hb-w1) solid var(--hb-rule);
  border-top: var(--hb-w4) solid var(--hb-ink);
  border-radius: 0 0 var(--hb-radius) var(--hb-radius);
}

.audience-title {
  font-size: clamp(1.375rem, 2vw, 1.5rem);
  letter-spacing: -0.015em;
}

.audience .tag {
  margin-top: auto;
}

.parts-note {
  margin-top: 1.5rem;
  color: var(--hb-ink-2);
  font-size: 1rem;
  line-height: 1.5;
}

.parts-note .tag {
  margin-right: 0.5rem;
}

.try-body > * + * {
  margin-top: 1rem;
}

.try-body .callout {
  font-size: 0.9375rem;
}

.eval-note {
  color: var(--hb-ink-2);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.eval-note .tag {
  margin-right: 0.5rem;
}

.story > * + * {
  margin-top: 1.25rem;
}

.story .family {
  margin-top: 2rem;
}

.family-lead .family-link {
  border-width: var(--hb-w2);
  background: var(--hb-tint);
}

.family-lead .family-name {
  font-size: 1.375rem;
}

/* Command blocks: a copy button (added by app.js) sits in the top right corner of the dark block. */
.cmd-wrap {
  position: relative;
}

.prose .cmd-wrap > pre {
  margin: 0;
  padding-top: 3.25rem;
}

.copy-button {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  min-height: 2rem;
  padding: 0 0.625rem;
  border: var(--hb-w1) solid var(--hb-code-muted);
  border-radius: var(--hb-radius-chip);
  background: var(--hb-code-bg);
  color: var(--hb-code-ink);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}

/* Its one hover effect: the border brightens to the code text colour. */
.copy-button:hover {
  border-color: var(--hb-code-ink);
}

.copy-button:focus-visible {
  outline: var(--hb-w2) solid var(--hb-signal);
  outline-offset: 2px;
}

/* ---------- 8c. Get started page ---------- */

.start-main {
  max-width: 50rem;
  padding-bottom: clamp(3rem, 6vw, 5rem);
}

.doc-section > .run-steps {
  max-width: none;
}

.run-steps {
  margin: 1.75rem 0 0;
  padding: 0 !important;
  list-style: none;
  counter-reset: run;
}

.prose .run-steps > li {
  position: relative;
  margin: 0;
  padding: 1.5rem 0 1.5rem 3.5rem;
  border-top: var(--hb-w1) solid var(--hb-rule);
  counter-increment: run;
}

.prose .run-steps > li::before {
  content: counter(run);
  position: absolute;
  top: 1.5rem;
  left: 0;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: var(--hb-w2) solid var(--hb-ink);
  border-radius: var(--hb-radius-chip);
  background: var(--hb-paper);
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 1rem;
  font-weight: 700;
}

.prose .run-steps > li > * + * {
  margin-top: 0.875rem;
}

.prose .run-steps h3 {
  margin: 0.25rem 0 0;
  font-size: 1.3125rem;
}

/* ---------- 9. Page heads (how it works, articles, 404) ---------- */

.page-head {
  padding-block: clamp(3rem, 6vw, 5rem) clamp(2.5rem, 5vw, 3.75rem);
  border-bottom: var(--hb-w1) solid var(--hb-rule);
}

.page-title {
  max-width: 13em;
  font-size: clamp(2rem, calc((100vw - 2.5rem) / 8.1), 3.75rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
}

.page-lede {
  max-width: 38rem;
  margin-top: var(--hb-gap-lede);
  color: var(--hb-ink-2);
  font-size: clamp(1.125rem, 1.6vw, 1.25rem);
  line-height: 1.55;
}

/* ---------- 10. How it works: doc layout ---------- */

.doc {
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 0 clamp(2.5rem, 5vw, 5rem);
  align-items: start;
}

.toc {
  position: sticky;
  top: calc(var(--hb-header-h) + 2rem);
  padding-block: 3rem;
}

.toc-label {
  margin-bottom: 0.9rem;
  color: var(--hb-ink-2);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toc ol {
  display: grid;
  gap: 0.15rem;
  padding: 0;
  list-style: none;
  counter-reset: toc;
}

.toc a {
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  padding: 0.35rem 0;
  color: var(--hb-ink-2);
  font-size: 0.95rem;
  font-weight: 520;
  line-height: 1.35;
  text-decoration: none;
  counter-increment: toc;
}

.toc a::before {
  content: counter(toc, decimal-leading-zero);
  flex: none;
  width: 1.6rem;
  color: var(--hb-ink-3);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
}

/* On-page links: the single hover effect is a 2px ink underline. */
.toc a:hover {
  text-decoration: underline;
  text-decoration-color: var(--hb-ink);
  text-decoration-thickness: var(--hb-w2);
}

.toc a[aria-current="true"] {
  color: var(--hb-ink);
  font-weight: 650;
}

.toc a[aria-current="true"]::before {
  color: var(--hb-rust);
}

.doc-main {
  min-width: 0;
  max-width: 50rem;
}

.doc-section {
  padding-block: clamp(2.75rem, 5vw, 3.75rem);
}

.doc-section + .doc-section {
  border-top: var(--hb-w1) solid var(--hb-rule);
}

.doc-section > * + * {
  margin-top: 1.25em;
}

.doc-section > :is(p, ul, ol, h2, h3) {
  max-width: 66ch;
}

.doc-section > .eyebrow {
  margin-bottom: 0;
}

.prose .doc-section > h2 {
  margin-top: 1rem;
  font-size: clamp(1.5rem, calc((100vw - 2.5rem) / 11.4), 2.25rem);
  letter-spacing: -0.025em;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-block: 1.75rem;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  padding: var(--hb-inset-card);
  border: var(--hb-w1) solid var(--hb-rule);
  border-radius: var(--hb-radius);
}

/* The accent bar sits over the top border and shares the frame's outer radius, so corners meet. */
.mode-card-primary::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--hb-w1));
  right: calc(-1 * var(--hb-w1));
  left: calc(-1 * var(--hb-w1));
  height: var(--hb-w4);
  border-radius: var(--hb-radius) var(--hb-radius) 0 0;
  background: var(--hb-signal);
}

.prose .mode-card h3 {
  margin: 0;
  font-size: 1.3125rem;
}

.prose .mode-card p:not(.tag),
.prose .mode-card ul {
  margin: 0;
  font-size: 1rem;
}

.milestones {
  display: grid;
  gap: 0;
  margin-block: 1.75rem 0;
  padding: 0 !important;
  list-style: none;
}

.prose .milestones > li {
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr);
  gap: 1.25rem;
  margin: 0;
  padding: 1.5rem 0;
  border-top: var(--hb-w1) solid var(--hb-rule);
}

.prose .milestones > li::before {
  content: none;
}

.milestone-id {
  display: grid;
  place-items: center;
  width: 4.25rem;
  height: 4.25rem;
  border: var(--hb-w1) dashed var(--hb-rule-strong);
  border-radius: var(--hb-radius-chip);
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 1.125rem;
  font-weight: 600;
}

.milestone-done .milestone-id {
  border: var(--hb-w1) solid var(--hb-ink);
  background: var(--hb-ink);
  color: var(--hb-paper);
}

.milestone-built .milestone-id {
  border: var(--hb-w1) solid var(--hb-signal);
  background: var(--hb-signal);
  color: var(--hb-on-signal);
  font-size: 1.25rem;
  font-weight: 700;
}

.milestone-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.prose .milestone-head h3 {
  margin: 0;
  font-size: 1.25rem;
}

.prose .milestones p {
  margin: 0;
  font-size: 1rem;
}

.prose .milestones p + p {
  margin-top: 0.5rem;
}

.pin {
  margin-block: 1.75rem 0;
  border: var(--hb-w1) solid var(--hb-rule);
  border-radius: var(--hb-radius);
}

.pin > div {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  gap: 0.25rem 1.25rem;
  padding: 0.75rem 1.25rem;
}

.pin > div + div {
  border-top: var(--hb-w1) solid var(--hb-rule);
}

.pin dt {
  color: var(--hb-ink-2);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  line-height: 2;
  text-transform: uppercase;
}

.pin dd {
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.doc-end {
  padding-block: 3rem clamp(4rem, 8vw, 6rem);
  border-top: var(--hb-w1) solid var(--hb-rule);
}

.doc-end .next-kicker {
  display: block;
  margin-bottom: 1rem;
}

/* ---------- 11. Articles index ---------- */

.article-list {
  display: grid;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Article cards are framed like every other pressable card and share its single hover: the lift. */
.article-card {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr) auto;
  gap: 0.5rem clamp(1.25rem, 3vw, 2.5rem);
  align-items: start;
  padding: var(--hb-inset-card);
  border: var(--hb-w2) solid var(--hb-ink);
  border-radius: var(--hb-radius);
  background: var(--hb-paper);
  color: var(--hb-ink-2);
  text-decoration: none;
  transition: transform var(--hb-ease), box-shadow var(--hb-ease);
}

.article-card:hover {
  color: var(--hb-ink-2);
  transform: translate(-2px, -2px);
  box-shadow: var(--hb-lift);
}

.article-card-index {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--hb-radius-chip);
  background: var(--hb-signal);
  color: var(--hb-on-signal);
  font-family: var(--hb-mono);
  font-size: 1.25rem;
  font-weight: 700;
}

.article-card-body {
  display: grid;
  gap: 0.5rem;
  max-width: 46rem;
}

.article-card-title {
  font-size: clamp(1.3125rem, 2.5vw, 1.875rem);
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: wrap;
}

.article-card-desc {
  font-size: 1.0625rem;
  line-height: 1.55;
}

.article-card-meta {
  color: var(--hb-ink-3);
  font-family: var(--hb-mono);
  font-size: 0.8125rem;
  font-weight: 500;
}

.article-card-go {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--hb-ink);
  font-weight: 650;
}

.article-card-go::after {
  content: "→";
}

.articles-body {
  padding-block: clamp(1rem, 3vw, 2rem) clamp(4rem, 8vw, 6rem);
}

/* ---------- 12. Article page ---------- */

.article {
  padding-bottom: clamp(4rem, 8vw, 6rem);
}

/* Breakout grid: text sits in a 68ch column; figures, tables and stat rows may widen. */
.article-head,
.article-body,
.article-foot {
  display: grid;
  font-size: 1.125rem;
  grid-template-columns:
    [full-start] minmax(var(--hb-gutter), 1fr)
    [wide-start] minmax(0, 7rem)
    [text-start] min(var(--hb-measure), 100% - 2 * var(--hb-gutter))
    [text-end] minmax(0, 7rem)
    [wide-end] minmax(var(--hb-gutter), 1fr)
    [full-end];
}

.article-head {
  padding-block: clamp(3rem, 6vw, 4.5rem) clamp(2rem, 4vw, 3rem);
  border-bottom: var(--hb-w1) solid var(--hb-rule);
  margin-bottom: clamp(2rem, 4vw, 3rem);
}

.article-head-inner {
  grid-column: text;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin-bottom: 1.5rem;
  color: var(--hb-ink-3);
  font-family: var(--hb-mono);
  font-size: 0.8125rem;
  font-weight: 500;
}

.article-meta-back {
  color: var(--hb-rust);
  font-weight: 600;
}

.article-meta-sep {
  color: var(--hb-rule-strong);
}

.article-title {
  font-size: clamp(1.625rem, calc((100vw - 2.5rem) / 10.3), 3rem);
  line-height: 1.06;
  letter-spacing: -0.025em;
  text-wrap: wrap;
}

.article-standfirst {
  margin-top: 1.25rem;
  color: var(--hb-ink-2);
  font-size: clamp(1.125rem, 1.8vw, 1.3125rem);
  line-height: 1.5;
}

.article-body > * {
  grid-column: text;
}

.article-body > figure,
.article-body > .table-wrap,
.article-body > .stats,
.article-body > pre {
  grid-column: wide;
}

.article-foot {
  margin-top: clamp(3rem, 6vw, 4rem);
}

.article-foot > * {
  grid-column: text;
}

.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.pager:empty {
  display: none;
}

.pager-link {
  display: grid;
  gap: 0.25rem;
  padding: var(--hb-inset-row);
  border: var(--hb-w2) solid var(--hb-ink);
  border-radius: var(--hb-radius);
  color: var(--hb-ink);
  text-decoration: none;
  transition: transform var(--hb-ease), box-shadow var(--hb-ease);
}

.pager-link:hover {
  color: var(--hb-ink);
  transform: translate(-2px, -2px);
  box-shadow: var(--hb-lift);
}

.pager-next {
  grid-column: 2;
  text-align: right;
}

.pager-dir {
  color: var(--hb-ink-2);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pager-prev .pager-dir::before {
  content: "← ";
}

.pager-next .pager-dir::after {
  content: " →";
}

.pager-title {
  text-wrap: wrap;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.3;
  font-family: var(--hb-display);
  letter-spacing: -0.01em;
}

.article-about {
  margin-top: 2rem;
  padding: var(--hb-inset-card);
  border-radius: var(--hb-radius);
  background: var(--hb-paper-2);
  font-size: 1rem;
}

.article-about-label {
  margin-bottom: 0.5rem;
  color: var(--hb-ink-2);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.article-about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  margin-top: 1rem;
  padding: 0;
  list-style: none;
}

/* ---------- 13. Prose: articles and the how-it-works page ---------- */

.prose {
  color: var(--hb-ink-prose);
  line-height: 1.7;
  counter-reset: fig;
}

.prose > * + * {
  margin-top: 1.25em;
}

.prose h2 {
  margin-top: 2.5em;
  font-size: clamp(1.5rem, calc((100vw - 2.5rem) / 11.6), 2rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.prose h3 {
  margin-top: 2em;
  font-size: 1.3125rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.prose h2 + *,
.prose h3 + * {
  margin-top: 0.75em;
}

.prose a:not([class]) {
  color: var(--hb-rust);
}

.prose ul,
.prose ol {
  padding-left: 1.5em;
}

.prose li + li {
  margin-top: 0.45em;
}

.prose ul {
  list-style: none;
}

.prose ul > li {
  position: relative;
}

.prose ul > li::before {
  content: "";
  position: absolute;
  left: -1.15em;
  top: 0.62em;
  width: 0.45em;
  height: 0.45em;
  background: var(--hb-signal);
}

.prose ol > li::marker {
  color: var(--hb-rust);
  font-family: var(--hb-mono);
  font-size: 0.9em;
  font-weight: 600;
}

.prose li > ul,
.prose li > ol {
  margin-top: 0.45em;
}

.prose code {
  padding: 0.1em 0.35em;
  border: var(--hb-w1) solid var(--hb-rule);
  border-radius: var(--hb-radius-chip);
  background: var(--hb-paper-2);
  color: var(--hb-ink);
  font-size: 0.86em;
  white-space: nowrap;
}

/* Inline code stays on 1 line (a flag like --data never splits at its hyphen). Long literals that
   could overflow a phone column carry .code-wrap and may break anywhere. */
.prose code.code-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Program output: the same dark block as commands, with a grey top rule and no copy button. */
.prose pre.out {
  border-top-color: var(--hb-ink-3);
}

.prose pre {
  overflow-x: auto;
  padding: 1.25rem 1.5rem;
  border-top: var(--hb-w4) solid var(--hb-signal);
  border-radius: 0 0 var(--hb-radius) var(--hb-radius);
  background: var(--hb-code-bg);
  color: var(--hb-code-ink);
  font-size: 0.875rem;
  line-height: 1.65;
  tab-size: 2;
}

.prose pre:focus-visible {
  outline-color: var(--hb-signal);
}

.tok-k {
  color: var(--hb-code-signal);
}

.tok-s {
  color: #f2d0a9; /* 12.15:1 on code bg */
}

.tok-c {
  color: var(--hb-code-muted);
  font-style: italic;
}

.prose pre code {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  overflow-wrap: normal;
  /* Inline code is nowrap; a code block must keep its own line breaks, or Copy merges the lines. */
  white-space: inherit;
}

.prose blockquote {
  padding: 0.25em 0 0.25em 1.25em;
  border-left: var(--hb-w4) solid var(--hb-signal);
  color: var(--hb-ink);
  font-size: 1.1em;
  line-height: 1.55;
}

.prose blockquote > * + * {
  margin-top: 0.75em;
}

.prose hr {
  width: 7.5rem;
  height: 0.5rem;
  margin-block: 3em;
  border: 0;
  background: repeating-linear-gradient(90deg, var(--hb-signal) 0 1.5rem, transparent 1.5rem 2rem);
}

.prose img {
  height: auto;
  border-radius: var(--hb-radius);
}

.prose h3 .tag {
  margin-left: 0.5rem;
  vertical-align: 0.2em;
}

/* Phones: a status tag in a heading takes its own line, so the heading text wraps on its own. */
@media (max-width: 40rem) {
  .prose h3 .tag {
    display: table;
    margin: 0.5rem 0 0;
  }
}

.prose .article-about-links {
  padding-left: 0;
}

.prose .article-about-links li::before {
  content: none;
}

.prose .article-about-links li + li {
  margin-top: 0;
}

/* Tables arrive wrapped in .table-wrap so a phone scrolls the table, never the page. */
.table-wrap {
  overflow-x: auto;
  border: var(--hb-w1) solid var(--hb-rule);
  border-radius: var(--hb-radius);
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* Narrow tables fit a phone; wider ones keep a readable floor and scroll inside .table-wrap. */
.table-wrap table:has(tr > :nth-child(3)) {
  min-width: 32rem;
}

.table-wrap table:has(tr > :nth-child(4)) {
  min-width: 40rem;
}

.table-wrap th,
.table-wrap td {
  padding: 0.75rem 1rem;
  text-align: left;
  vertical-align: top;
}

.table-wrap thead th {
  border-bottom: var(--hb-w2) solid var(--hb-ink);
  background: var(--hb-paper-2);
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table-wrap tbody tr + tr td,
.table-wrap tbody tr + tr th {
  border-top: var(--hb-w1) solid var(--hb-rule);
}

.table-wrap td[align="right"],
.table-wrap th[align="right"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table-wrap td[align="right"] {
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 0.875rem;
  font-weight: 500;
}

.table-wrap td[align="center"],
.table-wrap th[align="center"] {
  text-align: center;
}

.table-wrap td:first-child {
  color: var(--hb-ink);
  font-weight: 600;
}

.table-wrap code {
  font-size: 0.85em;
  overflow-wrap: normal;
  white-space: nowrap;
}

/* .table-stack: under 40rem each row becomes a card; cells carry data-label for their heading. */
@media (max-width: 40rem) {
  .table-wrap.table-stack {
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: none;
  }

  .table-stack table,
  .table-stack tbody,
  .table-stack tr,
  .table-stack td {
    display: block;
    width: 100%;
    min-width: 0 !important;
  }

  .table-stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .table-stack tr {
    padding: var(--hb-inset-row);
    border: var(--hb-w1) solid var(--hb-rule);
    border-radius: var(--hb-radius);
  }

  .table-stack tbody tr + tr {
    margin-top: 0.75rem;
  }

  .table-wrap.table-stack td,
  .table-wrap.table-stack tbody tr + tr td {
    padding: 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }

  .table-stack td + td {
    margin-top: 0.5rem;
  }

  .table-stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.15rem;
    color: var(--hb-ink-2);
    font-family: var(--hb-mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
  }

  .table-stack code {
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* Callouts, from markdown via raw HTML: <aside class="callout"> or <aside class="callout callout-note">. */
.callout {
  padding: var(--hb-inset-row);
  border-left: var(--hb-w4) solid var(--hb-signal);
  border-radius: 0 var(--hb-radius) var(--hb-radius) 0;
  background: var(--hb-tint);
  color: var(--hb-ink);
  font-size: 1rem;
  line-height: 1.6;
}

.callout-note {
  border-left-color: var(--hb-ink);
  background: var(--hb-paper-2);
}

.callout > * + * {
  margin-top: 0.5rem;
}

.callout-label {
  color: var(--hb-rust);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.callout-note .callout-label {
  color: var(--hb-ink-2);
}

.prose .stats {
  margin-block: 2em;
}

.prose .stat > * {
  margin: 0;
}

.prose .stat-label {
  font-size: 0.975rem;
}

/* ---------- 14. Diagrams (inline SVG inside figure.diagram) ---------- */

.diagram {
  margin-block: 2.25em;
  counter-increment: fig;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.diagram-phone {
  display: none !important;
}

/* Compact figures (articles): the whole figure, drawing and caption, sits centred at 30rem. */
.diagram-compact {
  justify-self: center;
  width: 100%;
  max-width: 30rem;
  margin-inline: auto;
}

.diagram > svg {
  display: block;
  width: 100%;
  height: auto;
  padding: clamp(0.75rem, 2.5vw, 1.5rem);
  border: var(--hb-w1) solid var(--hb-rule);
  border-radius: var(--hb-radius);
  background: var(--hb-paper);
  font-family: var(--hb-sans);
  font-size: 14px;
  overflow: visible;
}

.diagram figcaption {
  position: sticky;
  left: 0;
  max-width: min(100%, 100vw - 2 * var(--hb-gutter));
  margin-top: 0.75rem;
  color: var(--hb-ink-3);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.diagram figcaption::before {
  content: "Fig. " counter(fig);
  margin-right: 0.5rem;
  color: var(--hb-ink);
  font-family: var(--hb-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/*
 * Diagram strokes are drawn in screen pixels at the 1/2px weights, whatever the drawing's scale
 * (non-scaling-stroke), and every box and straight connector snaps to the pixel grid (crispEdges).
 * Boxes are square-cornered for that reason: a crisp edge and a curve cannot share a pixel grid.
 */
.diagram svg :is(.d-box, .d-box-accent, .d-box-muted, .d-box-dashed, .d-chunk, .d-line, .d-line-accent, .d-line-dashed, .d-axis, .d-axis-base) {
  vector-effect: non-scaling-stroke;
  shape-rendering: crispEdges;
}

.diagram svg :is(.d-box, .d-box-accent, .d-box-muted, .d-box-dashed, .d-chunk) {
  rx: 0;
  ry: 0;
}

.d-box {
  fill: var(--hb-paper);
  stroke: var(--hb-ink);
  stroke-width: var(--hb-w2);
}

/* An accent box that carries text: a 4px Signal frame around ink on white. */
.d-box-accent {
  fill: var(--hb-paper);
  stroke: var(--hb-signal);
  stroke-width: var(--hb-w4);
}

/* A textless orange cell (a chunk, a byte): Signal fill. */
.d-chunk {
  fill: var(--hb-signal);
  stroke: var(--hb-ink);
  stroke-width: var(--hb-w1);
}

.d-box-muted {
  fill: var(--hb-paper-2);
  stroke: var(--hb-rule-strong);
  stroke-width: var(--hb-w1);
}

.d-box-dashed {
  fill: none;
  stroke: var(--hb-rule-strong);
  stroke-width: var(--hb-w1);
  stroke-dasharray: 5 4;
}

.d-line {
  fill: none;
  stroke: var(--hb-ink-2);
  stroke-width: var(--hb-w1);
}

.d-line-accent {
  fill: none;
  stroke: var(--hb-signal);
  stroke-width: var(--hb-w2);
}

.d-line-dashed {
  fill: none;
  stroke: var(--hb-ink-2);
  stroke-width: var(--hb-w1);
  stroke-dasharray: 5 4;
}

.d-arrow {
  fill: var(--hb-ink-2);
}

.d-arrow-accent {
  fill: var(--hb-signal);
}

.d-text {
  fill: var(--hb-ink);
  font-weight: 500;
}

.d-text-strong {
  fill: var(--hb-ink);
  font-weight: 700;
}

.d-text-muted {
  fill: var(--hb-ink-3);
}

.d-text-on-accent {
  fill: var(--hb-ink);
  font-weight: 600;
}

.d-mono {
  font-family: var(--hb-mono);
  letter-spacing: 0.02em;
}

.d-bar {
  fill: var(--hb-rule-strong);
}

.d-bar-accent {
  fill: var(--hb-signal);
}

.d-axis {
  fill: none;
  stroke: var(--hb-rule);
  stroke-width: var(--hb-w1);
}

.d-axis-base {
  fill: none;
  stroke: var(--hb-ink);
  stroke-width: var(--hb-w2);
}

/* ---------- 15. Footer ---------- */

.site-footer {
  flex: none;
  border-top: var(--hb-w1) solid var(--hb-rule);
  background: var(--hb-paper-2);
  color: var(--hb-ink-2);
  font-size: 0.975rem;
}

.site-footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 2.5rem 4rem;
  padding-block: 3.5rem 2.5rem;
}

.footer-about {
  display: grid;
  gap: 1rem;
  align-content: start;
  max-width: 28rem;
}

.brand-footer .brand-word {
  font-size: 1.1875rem;
}

.footer-credit {
  color: var(--hb-ink);
  font-weight: 600;
}

.footer-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2rem;
}

.footer-heading {
  margin-bottom: 1rem;
  color: var(--hb-ink-2);
  font-family: var(--hb-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.footer-nav ul {
  display: grid;
  gap: 0.25rem;
  padding: 0;
  list-style: none;
}

.footer-nav a {
  display: inline-block;
  padding-block: 0.25rem;
  color: var(--hb-ink);
  text-decoration-color: transparent;
}

/* Footer links: the single hover effect is a 2px Signal underline appearing. */
.footer-nav a:hover {
  text-decoration-color: var(--hb-signal);
  text-decoration-thickness: var(--hb-w2);
}

.footer-base {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-block: 1.25rem 2rem;
  border-top: var(--hb-w1) solid var(--hb-rule);
  color: var(--hb-ink-3);
  font-size: 0.875rem;
}

/* ---------- 16. 404 ---------- */

.lost {
  padding-block: clamp(4rem, 9vw, 7rem);
}

.lost-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2rem clamp(2.5rem, 6vw, 5rem);
  align-items: center;
}

.lost-mark {
  width: 8rem;
  height: auto;
}

/* The missing bottom row: a dashed ink outline where the chunk should be. */
.lost-chunk {
  fill: none;
  stroke: var(--hb-ink);
  stroke-width: var(--hb-w2);
  stroke-dasharray: 6 4;
  vector-effect: non-scaling-stroke;
}

.lost-code {
  margin-bottom: 1rem;
  color: var(--hb-rust);
  font-family: var(--hb-mono);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lost-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  margin-top: 2rem;
}

/* ---------- 17. Responsive ---------- */

@media (max-width: 72rem) {
  .doc {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc {
    position: static;
    padding-block: 2rem 0;
  }

  .toc ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1.5rem;
    max-width: 40rem;
  }
}

/* Below 47.5rem a figure swaps to its phone drawing, so labels stay at 12px or more. */
@media (max-width: 47.5rem) {
  .diagram-dual > .diagram-wide {
    display: none;
  }

  .diagram-dual > .diagram-phone {
    display: block !important;
    width: 100%;
    max-width: 28rem;
    min-width: 0 !important;
    margin-inline: auto;
  }
}

@media (max-width: 56rem) {
  .hero-grid,
  .split,
  .section-head-split,
  .site-footer-inner {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-figure {
    max-width: 32rem;
    justify-self: start;
  }

  .split-head .section-title {
    max-width: 22ch;
  }

  .steps {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.75rem;
  }

  .step:not(:last-child)::after {
    top: auto;
    bottom: -2.25rem;
    left: 0;
    right: auto;
    width: 0.875rem;
    height: 1.5rem;
    clip-path: polygon(40% 0, 60% 0, 60% 62%, 100% 62%, 50% 100%, 0 62%, 40% 62%);
  }

  .stats {
    grid-template-columns: minmax(0, 1fr);
  }

  .stat + .stat {
    border-left: 0;
    border-top: var(--hb-w1) solid var(--hb-rule);
  }

  .deploy-grid,
  .next-grid,
  .mode-grid,
  .parts,
  .audiences {
    grid-template-columns: minmax(0, 1fr);
  }

  .answer {
    grid-template-columns: minmax(0, 1fr);
  }

  .deploy-grid {
    row-gap: 1.5rem;
  }
}

@media (max-width: 40rem) {
  :root {
    --hb-header-h: 3.75rem;
  }

  body {
    font-size: 1rem;
  }

  .brand-word {
    font-size: 1.25rem;
  }

  .site-nav-link {
    padding-inline: 0.5rem;
    font-size: 0.9375rem;
  }

  .site-nav-link::after {
    left: 0.5rem;
    right: 0.5rem;
  }

  .button {
    width: 100%;
  }

  /* Phones: the 3 hero chips stay on 1 row at 390px; the square markers give way to the text. */
  .tape {
    gap: 0.375rem;
    font-size: 0.6875rem;
    letter-spacing: 0.04em;
  }

  .tape span {
    height: 1.625rem;
    padding: 0 0.5rem;
  }

  .tape span::before {
    content: none;
  }

  .tool-list {
    display: flex;
    flex-wrap: wrap;
  }

  .diagram > svg {
    min-width: 36rem;
    background: transparent;
  }

  .diagram-fluid > svg,
  .diagram-compact > svg {
    min-width: 0;
  }

  /* Scroll shadows: a soft edge appears on whichever side has more to see. */
  .diagram,
  .table-wrap {
    background:
      linear-gradient(to right, var(--hb-paper) 30%, rgb(255 255 255 / 0)) left / 2.5rem 100% no-repeat local,
      linear-gradient(to left, var(--hb-paper) 30%, rgb(255 255 255 / 0)) right / 2.5rem 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, rgb(21 23 28 / 0.2), rgb(21 23 28 / 0)) left / 0.9rem 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, rgb(21 23 28 / 0.2), rgb(21 23 28 / 0)) right / 0.9rem 100% no-repeat scroll,
      var(--hb-paper);
  }

  .rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .rail-cell {
    display: grid;
    grid-template-columns: 2.75rem minmax(0, 1fr);
    grid-template-areas: "id name" "id state";
    gap: 0.25rem 0.5rem;
    min-height: 0;
  }

  .rail-id {
    grid-area: id;
  }

  .rail-name {
    grid-area: name;
  }

  .rail-state {
    grid-area: state;
  }

  .spec-list > div,
  .pin > div {
    grid-template-columns: minmax(0, 1fr);
  }

  .toc ol {
    grid-template-columns: minmax(0, 1fr);
  }

  .article-card {
    grid-template-columns: 2.75rem minmax(0, 1fr);
  }

  .article-card-index {
    width: 2.75rem;
    height: 2.75rem;
  }

  .article-card-go {
    display: none;
  }

  /* Phones: the number sits above the title, so title, description and date use the full width. */
  .article-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 1rem;
  }

  .pager {
    grid-template-columns: minmax(0, 1fr);
  }

  .pager-next {
    grid-column: 1;
  }

  .prose .milestones > li {
    grid-template-columns: 3.25rem minmax(0, 1fr);
    gap: 1rem;
  }

  .milestone-id {
    width: 3.25rem;
    height: 3.25rem;
    font-size: 1.125rem;
  }

  .footer-nav {
    grid-template-columns: minmax(0, 1fr);
  }

  .lost-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .button:hover,
  .family-link:hover,
  .next-card:hover,
  .pager-link:hover,
  .article-card:hover {
    transform: none;
  }
}


/* ---------- 18. Narrow phones, below 390px ----------
 * The wordmark never shrinks (the brand is flex: none); the 2 links give up padding, gap and 1px of
 * type so the full lockup fits at 375 and 360, and at 320 the wordmark and links step down once more.
 * The hero chips lose their tracking and some padding to stay on 1 row down to 352px; below that a
 * 3-chip row stacks into a left-aligned column rather than leaving 1 chip alone on a second row.
 */
@media (max-width: 24.3125rem) {
  .site-header-inner {
    gap: 0.5rem;
  }

  .site-nav {
    gap: 0;
  }

  .site-nav-link {
    padding-inline: 0.375rem;
    font-size: 0.875rem;
  }

  .site-nav-link::after {
    left: 0.375rem;
    right: 0.375rem;
  }

  .tape {
    letter-spacing: 0;
  }

  .tape span {
    padding: 0 0.375rem;
  }
}

@media (max-width: 22.4375rem) {
  .brand-word {
    margin-left: 0.5rem;
    font-size: 1rem;
  }

  .site-nav-link {
    padding-inline: 0.3125rem;
    font-size: 0.8125rem;
  }

  .site-nav-link::after {
    left: 0.3125rem;
    right: 0.3125rem;
  }
}

@media (max-width: 21.9375rem) {
  .tape:has(> span:nth-child(3)) {
    flex-direction: column;
    align-items: flex-start;
  }
}
