/* ── Fonts ────────────────────────────────────────────────────────────────
   Matter is commercial (Displaay). Drop licensed files into public/fonts/
   and they are picked up automatically; until then Hanken Grotesk stands in. */
@font-face {
  font-family: "Matter";
  src: url("/fonts/Matter-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Matter";
  src: url("/fonts/Matter-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Matter";
  src: url("/fonts/Matter-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

/* ── Tokens ───────────────────────────────────────────────────────────── */
:root {
  --bordeaux: #5a0f23;
  --oxblood: #7a1530;
  --cellar: #2b0912;
  --rose: #e8b4be;
  /* White is the secondary colour: text, buttons and highlights on burgundy. */
  --white: #ffffff;
  --blush: rgb(255 255 255 / 0.64);
  --on-dark: rgb(255 255 255 / 0.86);
  --tint: #f8eef1;
  --ink: #24090f;
  --ink-soft: #5e3a42;
  --petal: #ffffff;
  --line: #ead7db;
  --amber: #f0b54a;
  --sand: #e9c79a;
  /* Light sections only; the burgundy bands look the same in both themes. */
  --accent: var(--bordeaux);
  --accent-soft: var(--oxblood);
  --on-accent: var(--white);
  --raised: #ffffff;
  --raised-edge: transparent;
  color-scheme: light;

  --sans: "Matter", "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mono: "Matter Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: clamp(1.875rem, 1.3rem + 2vw, 2.75rem);
  --step-3: clamp(2.6rem, 1.5rem + 3.4vw, 4.25rem);

  --wrap: 82rem;
  --gutter: clamp(1.25rem, 0.5rem + 2.5vw, 2.5rem);
  --section: clamp(5rem, 3.5rem + 5vw, 8rem);
  --radius-s: 6px;
  --radius-m: 12px;
}

/* Dark follows the system unless the visitor picked a theme (data-theme). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --petal: #140508;
    --ink: #f6e8eb;
    --ink-soft: #c7a6ae;
    --line: #3a1820;
    --tint: #2a0c14;
    --accent: #f0bcc6;
    --accent-soft: #e79aab;
    --on-accent: var(--cellar);
    --raised: #22090f;
    --raised-edge: rgb(232 180 190 / 0.2);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --petal: #140508;
  --ink: #f6e8eb;
  --ink-soft: #c7a6ae;
  --line: #3a1820;
  --tint: #2a0c14;
  --accent: #f0bcc6;
  --accent-soft: #e79aab;
  --on-accent: var(--cellar);
  --raised: #22090f;
  --raised-edge: rgb(232 180 190 / 0.2);
  color-scheme: dark;
}

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

html {
  scroll-padding-top: 5.5rem;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--petal);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dd,
ol,
figure {
  margin: 0;
}

h1,
h2,
h3 {
  font-weight: 500;
  text-wrap: balance;
}

h2 {
  font-size: var(--step-2);
  line-height: 1.08;
  letter-spacing: -0.025em;
}

h3 {
  font-size: var(--step-1);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

p {
  text-wrap: pretty;
}

a {
  color: inherit;
}

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

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

.site-header :focus-visible,
.hero :focus-visible,
.closing :focus-visible {
  outline-color: var(--rose);
}

.wrap {
  width: min(100% - 2 * var(--gutter), var(--wrap));
  margin-inline: auto;
}

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

.skip {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 10;
  padding: 0.5rem 0.875rem;
  background: var(--white);
  color: var(--bordeaux);
  border-radius: var(--radius-s);
}
.skip:focus {
  top: 1rem;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0 1.375rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: 500 var(--step-0) / 1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color 160ms ease,
    border-color 160ms ease;
}

.button-light {
  background: var(--white);
  color: var(--bordeaux);
}
.button-light:hover {
  background: #ffffff;
}

.button-ghost {
  border-color: rgb(255 255 255 / 0.35);
  color: var(--white);
}
.button-ghost:hover {
  border-color: var(--white);
}

/* ── Header (burgundy) ────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bordeaux);
  transition: box-shadow 240ms ease;
  color: var(--white);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
}

.mark {
  width: 2rem;
  height: 2rem;
}
.mark-tile {
  fill: var(--cellar);
}
.mark-shaft {
  fill: var(--white);
}
.mark-step {
  fill: var(--rose);
}

.wordmark {
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 2rem);
  font-size: var(--step--1);
}

.nav-link {
  color: var(--blush);
  text-decoration: none;
}
.nav-link:hover {
  color: var(--white);
}

.nav-cta {
  padding: 0.5rem 0.875rem;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 999px;
  color: var(--white);
  text-decoration: none;
}
.nav-cta:hover {
  border-color: var(--white);
}

/* Theme switch: shows the moon in light mode and the sun in dark mode. */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 50%;
  background: transparent;
  color: var(--white);
  cursor: pointer;
  transition: border-color 160ms ease;
}
.theme-toggle:hover {
  border-color: var(--white);
}
.theme-toggle svg {
  width: 1rem;
  height: 1rem;
}
.theme-toggle .icon-sun {
  display: none;
}
:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}
:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun {
    display: block;
  }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon {
    display: none;
  }
}

@media (max-width: 40rem) {
  .nav-link {
    display: none;
  }
}

/* ── Hero (burgundy) ──────────────────────────────────────────────────── */
.hero {
  background: var(--bordeaux);
  color: var(--white);
  /* bottom padding holds the second step of the plinth under .measure */
  padding-block: clamp(1rem, 0.25rem + 1.5vw, 1.25rem) 1.25rem;
  overflow: hidden;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: clamp(2rem, 1rem + 3vw, 3.5rem);
  align-items: center;
}

.kicker {
  margin-bottom: 1.5rem;
  color: var(--blush);
  font-size: var(--step--1);
}

/* Wide enough that every phrase fits on two lines under "Saves". */
.hero h1 {
  max-width: 22ch;
  font-size: clamp(2.4rem, 0.25rem + 3.7vw, 3.75rem);
  line-height: 1;
  letter-spacing: -0.045em;
}

/* Every phrase shares one grid cell, so the headline is always as tall as the
   longest one and nothing below it moves when the phrase changes. */
.rotator {
  display: grid;
}

.rotator > span {
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
}

.rotator > .is-current {
  opacity: 1;
  visibility: visible;
}

@media (prefers-reduced-motion: no-preference) {
  .rotator > span {
    transform: translateY(0.25em);
    transition:
      opacity 450ms cubic-bezier(0.2, 0.8, 0.2, 1),
      transform 450ms cubic-bezier(0.2, 0.8, 0.2, 1),
      visibility 0s 450ms;
  }
  .rotator > .is-current {
    transform: none;
    transition:
      opacity 450ms cubic-bezier(0.2, 0.8, 0.2, 1),
      transform 450ms cubic-bezier(0.2, 0.8, 0.2, 1),
      visibility 0s;
  }
}

.lede {
  max-width: 38rem;
  margin-top: 1.5rem;
  color: var(--on-dark);
  font-size: var(--step-1);
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

/* The demo turns toward the reader like a curved monitor: its far edge
   comes forward, and light falls off toward the sides of the screen. */
.hero-demo {
  transform: perspective(1600px) rotateY(-14deg) rotateX(3deg);
  transform-origin: 100% 50%;
}
.hero-demo .code {
  padding-top: 1rem;
  font-size: clamp(0.75rem, 0.5rem + 0.35vw, 0.8125rem);
  line-height: 1.6;
}
.hero-demo .hover-card {
  margin-top: 2.6rem;
  padding: 0.875rem 1rem;
  font-size: 0.8125rem;
}
.hero-demo .switches {
  margin-bottom: 0.625rem;
}
.hero-demo .editor {
  position: relative;
  box-shadow:
    -30px 40px 70px -30px rgb(20 2 8 / 0.75),
    inset 0 1px 0 rgb(232 180 190 / 0.12);
}
.hero-demo .editor::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(
      90deg,
      rgb(20 2 8 / 0.28),
      transparent 18%,
      transparent 70%,
      rgb(20 2 8 / 0.22)
    ),
    linear-gradient(115deg, rgb(255 255 255 / 0.05), transparent 40%);
}

/* Stack switches */
.switches {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.625rem;
  margin-bottom: 0.875rem;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: 999px;
  background: rgb(43 9 18 / 0.35);
}

.segmented button {
  min-height: 2.25rem;
  padding: 0 0.9375rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--blush);
  font: 500 var(--step--1) / 1 var(--sans);
  cursor: pointer;
  transition:
    background-color 160ms ease,
    color 160ms ease;
}
.segmented button:hover {
  color: var(--white);
}
.segmented button[aria-pressed="true"] {
  background: var(--white);
  color: var(--bordeaux);
}

/* The same switches on a light background */
.switches-light .segmented {
  border-color: var(--line);
  background: var(--raised);
}
.switches-light .segmented button {
  color: var(--ink-soft);
}
.switches-light .segmented button:hover {
  color: var(--accent);
}
.switches-light .segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

/* Editor */
.editor {
  background: var(--cellar);
  border: 1px solid rgb(232 180 190 / 0.18);
  border-radius: var(--radius-m);
  box-shadow: 0 30px 60px -30px rgb(20 2 8 / 0.7);
  padding-bottom: 1rem;
}

.editor-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgb(232 180 190 / 0.12);
  font-size: var(--step--1);
}

.dots {
  display: inline-flex;
  gap: 6px;
}
.dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgb(232 180 190 / 0.25);
}

.tab {
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-s);
  background: rgb(232 180 190 / 0.08);
  color: var(--white);
}

.code {
  margin: 0;
  padding: 1.25rem 1.25rem 0.25rem;
  overflow-x: auto;
  color: #e4cdd2;
  font-size: clamp(0.75rem, 0.68rem + 0.25vw, 0.875rem);
  line-height: 1.75;
}

.line {
  display: block;
  white-space: pre;
}

.ln {
  display: inline-block;
  width: 2.25ch;
  margin-right: 1.25ch;
  text-align: right;
  color: rgb(232 180 190 / 0.3);
  user-select: none;
}

.tok-k,
.tok-a {
  color: var(--rose);
}
.tok-f {
  color: #ffffff;
}
.tok-t {
  color: #d9b8ff;
}
.tok-s {
  color: var(--sand);
}
.tok-n {
  color: #f5a5a0;
}
.tok-c {
  color: rgb(232 180 190 / 0.45);
}

.squiggle {
  position: relative;
}
.squiggle::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 4px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='4' viewBox='0 0 6 4'%3E%3Cpath d='M0 3 Q1.5 0 3 3 T6 3' fill='none' stroke='%23F0B54A' stroke-width='1.1'/%3E%3C/svg%3E")
    0 0 / 6px 4px repeat-x;
  transform-origin: left center;
}

.hover-card {
  margin: 0.5rem 1rem 0 clamp(1rem, 3vw, 3.25rem);
  padding: 1rem 1.125rem;
  background: var(--raised);
  color: var(--ink);
  border: 1px solid var(--raised-edge);
  border-radius: 10px;
  box-shadow: 0 18px 40px -18px rgb(20 2 8 / 0.8);
  font-size: var(--step--1);
  line-height: 1.45;
}

.hover-title {
  font-weight: 500;
}
.hover-ratio {
  display: inline-block;
  margin-top: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--tint);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.75rem;
}
.hover-detail {
  margin-top: 0.375rem;
  color: var(--ink-soft);
}
.hover-fix {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  color: var(--accent-soft);
  font-weight: 500;
  overflow-wrap: break-word;
}
.bulb {
  flex: none;
  width: 0.625rem;
  height: 0.625rem;
  margin-top: 0.35em;
  border-radius: 50%;
  background: var(--amber);
}

/* The config that the warning quotes, floating over the code window's empty
   right side so it is seen with the warning, not hunted for. */
.config-card {
  position: absolute;
  z-index: 2;
  /* beside the short lines at the end of the query */
  top: 9.9rem;
  right: -1.25rem;
  width: min(20rem, 74%);
  border: 1px solid rgb(232 180 190 / 0.35);
  border-radius: 10px;
  background: #1c060b;
  box-shadow:
    0 0 0 4px rgb(232 180 190 / 0.08),
    0 22px 44px -16px rgb(10 1 4 / 0.85);
  font-size: clamp(0.72rem, 0.5rem + 0.3vw, 0.8rem);
}
.config-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgb(232 180 190 / 0.14);
  color: var(--white);
  font-size: 0.75rem;
  line-height: 1.2;
}
.config-file {
  font-family: var(--mono);
}
.config-tag {
  padding: 0.125rem 0.4375rem;
  border-radius: 999px;
  background: var(--rose);
  color: var(--cellar);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.config-code {
  margin: 0;
  padding: 0.625rem 0.75rem 0.75rem;
  color: #e4cdd2;
  line-height: 1.6;
  overflow-x: auto;
}
/* Drizzle's query is longer and its middle lines are wide: the config goes
   under the last line instead, and the warning makes room for it. */
.editor[data-orm="drizzle"] .config-card {
  top: 15.3rem;
}
.hero-demo .editor[data-orm="drizzle"] .hover-card {
  margin-top: 7rem;
}

/* The size the warning quotes reads brightest. */
.config-code .tok-n {
  color: var(--amber);
  font-weight: 500;
}

@media (prefers-reduced-motion: no-preference) {
  :root:not([data-settled]) .config-card {
    animation: rise 520ms 1500ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
}

/* Stacked layouts: the code window is narrow, so the config sits under it. */
@media (max-width: 62rem) {
  .hero-demo .hover-card,
  .hero-demo .editor[data-orm="drizzle"] .hover-card {
    margin-top: 0.5rem;
  }
  .config-card {
    position: relative;
    top: auto;
    right: auto;
    width: auto;
    margin: 0.75rem 1rem 0;
  }
}

/* Page-load moment: the squiggle draws, then the explanation appears. Once. */
@media (prefers-reduced-motion: no-preference) {
  :root:not([data-settled]) .squiggle::after {
    animation: draw 700ms 400ms cubic-bezier(0.3, 0.7, 0.2, 1) both;
  }
  :root:not([data-settled]) .hover-card {
    animation: rise 500ms 1000ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
}

@keyframes draw {
  from {
    transform: scaleX(0);
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* The measured result sits under the hero like the base under a column. */
.measure {
  position: relative;
  margin-top: clamp(1.25rem, 0.5rem + 1.5vw, 1.75rem);
  padding: 1.125rem clamp(1.25rem, 3vw, 2.25rem) 1.75rem;
  background: var(--oxblood);
  border-radius: var(--radius-m) var(--radius-m) 0 0;
}

.measure::after {
  /* the wider second step of the plinth */
  content: "";
  position: absolute;
  inset: auto -1.5rem -1.25rem;
  height: 1.25rem;
  border-radius: var(--radius-s) var(--radius-s) 0 0;
  background: var(--oxblood);
}

.measure-title {
  color: var(--rose);
  font-size: var(--step--1);
}

.measure-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: end;
  margin-top: 0.75rem;
}

.measure-row dt {
  line-height: 1.3;
  color: var(--blush);
  font-size: var(--step--1);
}

.measure-row dd {
  max-width: 26rem;
  margin-top: 0.25rem;
  color: var(--on-dark);
}

.measure-row strong {
  display: block;
  color: var(--white);
  font-size: clamp(2.25rem, 1.5rem + 2.4vw, 3.25rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.measure-step {
  align-self: center;
  width: 3rem;
  height: 2rem;
  background:
    linear-gradient(var(--rose), var(--rose)) 50% 0 / 0.75rem 0.875rem no-repeat,
    linear-gradient(var(--rose), var(--rose)) 50% 100% / 3rem 0.625rem no-repeat;
  opacity: 0.85;
}

.measure-cpu {
  max-width: 52ch;
  margin-top: 1.5rem;
  font-weight: 500;
}

.measure-note {
  margin-top: 0.5rem;
  color: var(--blush);
  font-size: var(--step--1);
}

/* Whichever section follows the hero starts the same distance below it. */
.hero + section:not(.saves) {
  padding-top: clamp(2.25rem, 6vh, 4rem);
}
/* Pinned "What it saves" carries that same gap inside its stage; after any
   other section, which already ends in its own padding, take it back. */
section:not(.hero) + .saves.is-stacking {
  margin-top: calc(-1 * clamp(2.25rem, 6vh, 4rem));
}

/* ── What it saves ────────────────────────────────────────────────────── */
.saves {
  padding-block: calc(var(--section) + 1rem) var(--section);
}

.saves h2,
.how h2,
.stack h2,
.rules h2 {
  color: var(--accent);
}

.saves-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem clamp(2rem, 5vw, 5rem);
  align-items: end;
}
.saves-head .section-lede {
  max-width: 34rem;
  margin-top: 0;
  justify-self: end;
}

.saves-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 3rem;
}

.saving {
  display: flex;
  flex-direction: column;
  padding: 1.75rem 1.5rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--raised);
  box-shadow: 0 1px 2px rgb(43 9 18 / 0.04);
}

.saving-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.saving-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  background: var(--tint);
  color: var(--accent);
}
.saving-icon svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.saving-tag {
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.saving h3 {
  color: var(--ink);
}

.saving p {
  margin-top: 0.625rem;
  color: var(--ink-soft);
  font-size: 0.975rem;
}

/* The one concrete fact behind each card, pinned to the bottom so the four
   line up whatever the length of the text above. */
.saving .saving-proof {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--accent);
  font-size: var(--step--1);
  font-weight: 500;
}
.saving .saving-proof::before {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
}
.saving {
  transition:
    border-color 200ms ease,
    box-shadow 200ms ease;
}
.saving:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  box-shadow: 0 18px 40px -24px rgb(43 9 18 / 0.35);
}

/* space above the proof line when the body text is the tallest in its row */
.saving p:not(.saving-proof) {
  margin-bottom: 1.5rem;
}

/* Stacking mode (motion.ts adds .is-stacking when motion is on and the screen
   is tall enough): the section pins while you scroll through it. One card is
   on screen at a time; as it hands over to the next, its disc drops onto the
   database, until all four are stacked. Without it, the grid above. */
.db {
  display: none;
}
.db-defs {
  position: absolute;
}

.saves.is-stacking {
  padding-block: 0;
}
.is-stacking .saves-track {
  /* scroll distance: four cards plus a short hold on the finished stack */
  height: 460vh;
}
/* Pinned under the sticky header. The title sits close to the hero's base,
   and the scene takes the rest of the screen. */
.is-stacking .saves-stage {
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 5rem);
  height: calc(100svh - 5rem);
  padding-block: clamp(2.25rem, 6vh, 4rem) clamp(1rem, 4vh, 2.5rem);
}
.is-stacking .saves-scene {
  flex: 1;
  display: grid;
  /* The card on the left, the database on the right: centred together, wide apart. */
  grid-template-columns: minmax(0, 25rem) auto;
  justify-content: center;
  gap: clamp(2rem, 5vw, 5rem) clamp(6rem, 14vw, 14rem);
  align-items: center;
  min-height: 0;
  margin-top: clamp(1rem, 3vh, 2rem);
}
.is-stacking .saves-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-top: 0;
}
/* The fold: --f runs 0 → 1 as a card becomes its disc. Per frame only
   opacity and transform change, which the browser composites without
   repainting: the card's surface (background, border, shadow) lives on
   ::before and fades out, the text fades first, and a disc face with the
   cylinder's fixed outline (half the width across, 30/118 of the height
   down, like the SVG disc's ellipse) fades in on ::after as the card lands. */
.is-stacking .saving {
  --f: 0;
  position: relative;
  isolation: isolate;
  grid-area: 1 / 1;
  opacity: 0;
  pointer-events: none;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.is-stacking .saving::before,
.is-stacking .saving::after {
  content: "";
  position: absolute;
  inset: -1px;
  z-index: -1;
  pointer-events: none;
  will-change: opacity;
}
.is-stacking .saving::before {
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--raised);
  box-shadow: 0 24px 60px -30px rgb(43 9 18 / 0.35);
  opacity: clamp(0, 1 - (var(--f) - 0.5) * 8, 1);
}
.is-stacking .saving > * {
  will-change: opacity;
  opacity: clamp(0, 1 - var(--f) * 4, 1);
}
.is-stacking .saving::after {
  z-index: 1;
  border-radius: 50% / 25.4%;
  background:
    radial-gradient(50% 25.4% at 50% 25.4%, var(--accent-soft) 99%, transparent 100%),
    linear-gradient(
      90deg,
      rgb(0 0 0 / 0.28),
      rgb(255 255 255 / 0.1) 35%,
      rgb(255 255 255 / 0) 60%,
      rgb(0 0 0 / 0.32)
    ),
    var(--accent);
  opacity: clamp(0, (var(--f) - 0.32) * 5, 1);
}
.is-stacking .saving:hover {
  border-color: transparent;
  box-shadow: none;
}
.is-stacking .saving.is-current {
  pointer-events: auto;
}

.saves-summary {
  display: none;
}
.is-stacking .saves-summary {
  display: block;
  grid-area: 1 / 1;
  align-self: center;
  opacity: 0;
}
.saves-summary-title {
  color: var(--accent);
  font-size: var(--step-1);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.saves-summary ul {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
}
.saves-summary li {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding-block: 0.875rem;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-weight: 500;
}
.saves-summary li span {
  color: var(--ink-soft);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.is-stacking .db {
  display: flex;
  justify-content: flex-start;
  order: 2;
}
.db-stack {
  --w: clamp(13rem, 8rem + 9vw, 17.5rem);
  --step: calc(var(--w) * 0.257);
  position: relative;
  width: var(--w);
  /* four discs, three steps between them, plus the top face */
  height: calc(var(--w) * 0.421 + var(--step) * 3);
  margin-right: clamp(9rem, 14vw, 14rem);
}
.db-layer {
  position: absolute;
  left: 0;
  bottom: calc(var(--i) * var(--step));
  width: 100%;
  opacity: 0;
  will-change: transform, opacity;
}
.db-layer svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.db-body {
  fill: var(--accent);
}
.db-shade {
  fill: url(#db-shade);
}
.db-top {
  fill: var(--accent-soft);
  stroke: rgb(255 255 255 / 0.22);
  stroke-width: 1;
}

.db-label {
  position: absolute;
  top: 50%;
  left: calc(100% + 1.25rem);
  display: flex;
  flex-direction: column;
  padding-left: 1rem;
  border-left: 1px solid var(--line);
  color: var(--ink);
  font-size: var(--step--1);
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
  transform: translateY(-15%);
}
.db-label span {
  color: var(--ink-soft);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
/* The disc of the card on screen reads strongest; the rest step back. */
.is-stacking .db-label {
  transition: opacity 240ms ease;
}
.is-stacking .db-stack:has(.db-layer.is-current) .db-layer:not(.is-current) .db-label {
  opacity: 0.45;
}

/* A disc that has just landed squashes a touch and settles. */
@keyframes disc-land {
  0% {
    transform: translateY(-4px) scale(1.02, 0.94);
  }
  45% {
    transform: translateY(1px) scale(0.99, 1.03);
  }
  100% {
    transform: none;
  }
}
.db-layer {
  transform-origin: 50% 100%;
}
.db-layer.is-landing {
  animation: disc-land 520ms cubic-bezier(0.3, 0.7, 0.3, 1) both;
}

/* ── plinth.config.json, field by field ──────────────────────────────── */
/* The file stands on an easel like a chalkboard: top leaning back, bottom
   toward the reader. The section pins (.is-touring, set by config-tour.ts)
   and each stretch of scroll slides the next field onto the board with a
   one-line comment above it. Without JS the board shows the finished file. */
.tour {
  padding-block: var(--section);
}
.tour h2 {
  color: var(--accent);
}
.tour-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 2rem;
}
.tour-head .section-lede {
  margin-top: 0;
}

.is-touring.tour {
  padding-block: 0;
}
.is-touring .tour-track {
  /* an empty board, then one stretch per field */
  height: 560vh;
}
.is-touring .tour-stage {
  position: sticky;
  top: 5rem;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 5rem);
  height: calc(100svh - 5rem);
  padding-block: clamp(1.5rem, 5vh, 3.5rem) clamp(1rem, 3vh, 2rem);
}

.tour-easel {
  display: flex;
  justify-content: center;
  margin-top: clamp(1.5rem, 4vh, 2.5rem);
  /* room below the board for the legs */
  padding-bottom: clamp(1.75rem, 4vh, 2.75rem);
  perspective: 1500px;
  perspective-origin: 50% 20%;
}
.is-touring .tour-easel {
  flex: 1;
  min-height: 0;
}
/* The board: a dark slate in a wooden frame, tilted back from the bottom edge. */
.tour-file {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 54rem);
  max-height: 100%;
  margin: 0;
  border: clamp(6px, 0.7vw, 10px) solid #5b2a33;
  border-radius: 14px;
  background: var(--cellar);
  color: #e4cdd2;
  box-shadow:
    inset 0 0 0 1px rgb(255 255 255 / 0.06),
    0 40px 60px -30px rgb(43 9 18 / 0.55);
  transform: rotateX(10deg);
  transform-origin: 50% 100%;
}
/* Easel legs, continuing the board's plane down to the floor. */
.tour-file::before,
.tour-file::after {
  content: "";
  position: absolute;
  top: 100%;
  width: clamp(6px, 0.6vw, 9px);
  height: clamp(1.75rem, 4vh, 2.75rem);
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, #4a1f28, #6b3540 60%, #4a1f28);
}
.tour-file::before {
  left: 14%;
  transform: skewX(12deg);
  transform-origin: top;
}
.tour-file::after {
  right: 14%;
  transform: skewX(-12deg);
  transform-origin: top;
}
.tour-file figcaption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.125rem;
  border-bottom: 1px solid rgb(232 180 190 / 0.12);
  color: var(--blush);
  font-family: var(--mono);
  font-size: 0.8125rem;
}
.tour-meta {
  display: flex;
  gap: 0.75rem;
  color: var(--rose);
}
.tour-count {
  color: var(--blush);
}
.tour-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.tour-scroll::-webkit-scrollbar {
  display: none;
}
.tour-file pre {
  margin: 0;
  padding: 1rem 0 1.25rem;
  font-family: var(--mono);
  font-size: clamp(0.8125rem, 0.72rem + 0.3vw, 0.975rem);
  line-height: 1.8;
}
.tour-line {
  --indent: 0ch;
  display: block;
  padding-inline: calc(1.125rem + var(--indent) + 2ch) 1.125rem;
  text-indent: calc(-1 * var(--indent) - 2ch);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  transition: background-color 360ms ease;
}
.tour-line.is-current {
  background: rgb(232 180 190 / 0.1);
}
.tour-comment {
  background: rgb(232 180 190 / 0.1);
  font-style: italic;
}
.tour-comment .tok-c {
  color: var(--sand);
}
/* A field enters the board from its right edge and settles into place;
   its comment leads by a beat. */
.tour-line.is-new {
  animation: tour-enter 620ms cubic-bezier(0.2, 0.75, 0.2, 1) 90ms both;
}
.tour-comment.is-new {
  animation-delay: 0ms;
}
@keyframes tour-enter {
  from {
    opacity: 0;
    transform: translate3d(3.5rem, 0, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.tour-fine {
  margin-top: 0.75rem;
  color: var(--ink-soft);
  font-size: var(--step--1);
  text-align: center;
}

@media (max-width: 44rem) {
  .is-touring .tour-stage {
    top: 4.5rem;
    height: calc(100vh - 4.5rem);
    height: calc(100svh - 4.5rem);
  }
  .tour-file {
    transform: rotateX(7deg);
  }
  .tour-file figcaption {
    flex-direction: column;
    gap: 0.25rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  .tour-line.is-new {
    animation: none;
  }
}

/* ── How it works ─────────────────────────────────────────────────────── */
.how {
  padding-bottom: var(--section);
}

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

.steps {
  margin-top: 2.25rem;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.25rem 1fr;
  column-gap: 1rem;
  padding-block: 1.375rem;
  border-top: 1px solid var(--line);
}

.steps li::before {
  content: counter(step);
  grid-row: span 2;
  color: var(--accent-soft);
  font-size: var(--step-1);
  font-weight: 500;
  line-height: 1.25;
}

.steps p {
  max-width: 60ch;
  margin-top: 0.375rem;
  color: var(--ink-soft);
}

.fix-panel {
  position: sticky;
  top: 6rem;
  display: grid;
  gap: 0.875rem;
}

.fix-panel .switches {
  margin-bottom: 0.25rem;
}

.snippet {
  overflow: hidden;
  background: var(--cellar);
  color: #e4cdd2;
  border-radius: var(--radius-m);
}

.snippet figcaption {
  padding: 0.75rem 1.125rem;
  border-bottom: 1px solid rgb(232 180 190 / 0.12);
  color: var(--blush);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.snippet pre {
  margin: 0;
  padding: 1rem 1.125rem;
  font-size: 0.8125rem;
  line-height: 1.7;
}

.snippet .line,
.snippet code[data-sql] {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.added {
  padding-inline: 0.25rem;
  border-radius: 4px;
  background: rgb(232 180 190 / 0.14);
  box-shadow: inset 2px 0 0 var(--rose);
}

.fix-follow-up {
  color: var(--ink-soft);
  font-size: var(--step--1);
}

/* ── Works with ───────────────────────────────────────────────────────── */
.stack {
  padding-bottom: var(--section);
}

.stack-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(2.5rem, 5vw, 5rem);
  align-items: center;
  padding-top: var(--section);
  border-top: 1px solid var(--line);
}

.section-lede {
  max-width: 30rem;
  margin-top: 1.25rem;
  color: var(--ink-soft);
}

.matrix {
  width: 100%;
  border-collapse: collapse;
}

.matrix th,
.matrix td {
  padding: 1.125rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-weight: 500;
}

.matrix thead th {
  padding-top: 0;
  color: var(--ink-soft);
  font-size: var(--step--1);
}

.matrix tbody th {
  padding-left: 0;
  text-align: left;
  color: var(--accent);
}

.matrix tbody th span {
  display: block;
  margin-top: 0.125rem;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-weight: 400;
}

.matrix tbody tr:last-child > * {
  border-bottom: 0;
}

.check {
  display: inline-block;
  width: 1.75rem;
  height: 1.75rem;
  position: relative;
  border-radius: 50%;
  background: var(--tint);
}
.check::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.6 2.5L12 5.5' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 1rem no-repeat;
}

/* Orbit: the supported ORMs and databases circle the Plinth mark on a
   tilted ring. Real CSS 3D, so chips pass behind the mark; each chip turns
   back to face the viewer and dims as it goes round the far side. */
@property --spin {
  syntax: "<angle>";
  inherits: true;
  initial-value: 0deg;
}

.orbit {
  --r: clamp(6.75rem, 5rem + 9vw, 12.5rem);
  --tilt: -22deg;
  position: relative;
  height: calc(var(--r) * 1.15 + 4rem);
  margin-top: 2.5rem;
  perspective: 1100px;
  perspective-origin: 50% 35%;
}

.orbit-stage {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(var(--tilt));
}

.orbit-ring,
.orbit-core,
.orbit-item {
  position: absolute;
  top: 50%;
  left: 50%;
}

.orbit-ring {
  width: calc(var(--r) * 2);
  height: calc(var(--r) * 2);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  border-radius: 50%;
  background: radial-gradient(
    closest-side,
    color-mix(in srgb, var(--accent) 7%, transparent),
    transparent
  );
  transform: translate(-50%, -50%) rotateX(90deg);
}

/* A soft shadow on the ring's floor, under the mark. */
.orbit-floor {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9rem;
  height: 9rem;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(43 9 18 / 0.28), transparent);
  transform: translate(-50%, -50%) translateY(3.25rem) rotateX(90deg);
}

.orbit-core {
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%) rotateX(calc(-1 * var(--tilt)));
}
.orbit-core .mark {
  display: block;
  width: 6.5rem;
  height: 6.5rem;
  border-radius: 1.42rem;
  box-shadow:
    0 0 0 1px var(--raised-edge),
    0 24px 40px -16px rgb(43 9 18 / 0.45);
}

.orbit-item {
  --at: calc(var(--a) + var(--spin));
  transform: translate(-50%, -50%) rotateY(var(--at)) translateZ(var(--r))
    rotateY(calc(-1 * var(--at))) rotateX(calc(-1 * var(--tilt)));
  opacity: calc(0.5 + 0.25 * (cos(var(--at)) + 1));
}

.orbit-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem 0.5rem 0.625rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--raised);
  box-shadow: 0 10px 24px -14px rgb(43 9 18 / 0.45);
  color: var(--accent);
  font-size: var(--step--1);
  font-weight: 500;
  white-space: nowrap;
}
.orbit-chip svg {
  width: 1.125rem;
  height: 1.125rem;
  fill: currentColor;
}

@media (prefers-reduced-motion: no-preference) {
  .orbit {
    animation: orbit-spin 28s linear infinite;
  }
  .orbit:hover {
    animation-play-state: paused;
  }
}

@media (max-width: 44rem) {
  .orbit {
    --r: 7.5rem;
    --tilt: -30deg;
  }
  .orbit-core .mark {
    width: 4rem;
    height: 4rem;
    border-radius: 0.875rem;
  }
  .orbit-chip {
    gap: 0.375rem;
    padding: 0.375rem 0.625rem 0.375rem 0.5rem;
    font-size: 0.8125rem;
  }
  .orbit-chip svg {
    width: 0.9375rem;
    height: 0.9375rem;
  }
}

/* Stacking on narrow screens: the database above, the card below it. */
@media (max-width: 62rem) {
  .is-stacking .saves-scene {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: clamp(1rem, 3vh, 2rem);
    align-items: start;
  }
  .is-stacking .saves-grid {
    max-width: 30rem;
    width: 100%;
    margin-inline: auto;
  }
  .is-stacking .db {
    order: 0;
    justify-content: center;
  }
  .is-stacking .db-stack {
    --w: clamp(7.5rem, 4rem + 12vw, 11rem);
    margin-right: clamp(8.5rem, 30vw, 12rem);
  }
}
@media (max-width: 44rem) {
  /* Room is tight: keep the title, the stack and one card on screen. */
  .is-stacking .saves-head .section-lede {
    display: none;
  }
  .is-stacking .saving {
    padding: 1.25rem 1.125rem 1.125rem;
  }
  .is-stacking .saving-top {
    margin-bottom: 0.875rem;
  }
  .is-stacking .saving p {
    font-size: 0.9rem;
    line-height: 1.5;
  }
  .is-stacking .saving p:not(.saving-proof) {
    margin-bottom: 1rem;
  }
  .is-stacking .saving .saving-proof {
    padding-top: 0.875rem;
  }
  .is-stacking .saves-summary-title {
    font-size: var(--step-0);
  }
  .is-stacking .saves-summary li {
    padding-block: 0.5rem;
    font-size: 0.9rem;
  }
  .db-label {
    left: calc(100% + 0.875rem);
    padding-left: 0.75rem;
    font-size: 0.8125rem;
    transform: translateY(0);
  }
  .db-label span {
    display: none;
  }
}

@keyframes orbit-spin {
  to {
    --spin: -360deg;
  }
}

/* ── Rules ────────────────────────────────────────────────────────────── */
.rules {
  padding-bottom: var(--section);
}

.rules-wrap {
  padding-top: var(--section);
  border-top: 1px solid var(--line);
}

.rules-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.5rem clamp(2rem, 5vw, 5rem);
  align-items: end;
}
.rules-head .section-lede {
  max-width: 34rem;
  margin-top: 0;
  justify-self: end;
}

/* Six cards, every one the same size. */
.rules-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 3rem;
}

.rule {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--raised);
  transition:
    border-color 200ms ease,
    box-shadow 200ms ease;
}
.rule:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  box-shadow: 0 18px 40px -24px rgb(43 9 18 / 0.35);
}

.rule-id {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.rule-id code {
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-s);
  background: var(--tint);
  color: var(--accent);
  font-size: 0.8125rem;
}
/* Six rules fill the grid; the habit that shapes every fix runs full width beneath them. */
.rule-habit {
  grid-column: 1 / -1;
}

.rule-new {
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rule h3 {
  color: var(--ink);
}
.rule-body {
  margin-block: 0.5rem 1.25rem;
  color: var(--ink-soft);
  font-size: 0.975rem;
}

.rule-foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 1.25rem;
  color: var(--ink-soft);
  font-size: var(--step--1);
  font-weight: 500;
}
.rule-foot::before {
  content: "";
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}
.rule-foot-fix {
  color: var(--accent);
}
.rule-foot-stats {
  color: var(--accent-soft);
}

/* Reads against writes: the evidence ladder, strongest first. */
/* A full-width burgundy band; its content lines up with the page. */
.weigh-band {
  margin-top: clamp(3rem, 6vw, 5rem);
  padding-block: clamp(3.5rem, 2rem + 5vw, 6.5rem);
  background: var(--bordeaux);
  color: var(--white);
}
.weigh {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 2rem clamp(2rem, 5vw, 5rem);
}
.weigh h3 {
  font-size: var(--step-2);
  line-height: 1.1;
  letter-spacing: -0.025em;
}
.weigh-intro > p {
  max-width: 34rem;
  margin-top: 1rem;
  color: var(--on-dark);
}

.weigh-samples {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.75rem;
}
.weigh-samples p {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  color: var(--blush);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.weigh-samples code {
  align-self: start;
  max-width: 100%;
  padding: 0.375rem 0.75rem;
  border: 1px solid rgb(232 180 190 / 0.25);
  border-radius: var(--radius-s);
  background: var(--cellar);
  color: var(--rose);
  font-size: 0.8125rem;
  letter-spacing: 0;
  text-transform: none;
  overflow-wrap: anywhere;
}

.weigh-ladder {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: rung;
}
.weigh-ladder li {
  position: relative;
  padding: 1rem 0 1rem 3.25rem;
  border-top: 1px solid rgb(255 255 255 / 0.14);
  counter-increment: rung;
}
.weigh-ladder li:first-child {
  border-top: 0;
  padding-top: 0;
}
.weigh-ladder li::before {
  content: counter(rung);
  position: absolute;
  left: 0;
  top: 1rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: rgb(255 255 255 / calc(0.06 * var(--strength) + 0.04));
  color: var(--white);
  font-size: var(--step--1);
  font-weight: 600;
}
.weigh-ladder li:first-child::before {
  top: 0;
}
/* Strength bars: how much each kind of evidence can move the confidence. */
.weigh-ladder h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0;
  font-size: var(--step-0);
  font-weight: 500;
}
.weigh-ladder h4::after {
  content: "";
  flex: none;
  width: 4.5rem;
  height: 0.375rem;
  border-radius: 999px;
  background:
    linear-gradient(var(--rose), var(--rose)) 0 0 / calc(var(--strength) * 25%) 100% no-repeat,
    rgb(255 255 255 / 0.14);
}
.weigh-ladder p {
  margin-top: 0.25rem;
  color: var(--on-dark);
  font-size: 0.95rem;
}

.weigh-note {
  grid-column: 1 / -1;
  padding-top: 1.25rem;
  border-top: 1px solid rgb(255 255 255 / 0.14);
  color: var(--blush);
  font-size: var(--step--1);
}

.rules-note {
  margin-top: clamp(2rem, 4vw, 3rem);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-s);
  background: var(--tint);
  color: var(--accent);
}

/* ── Plinth vs. AI review ─────────────────────────────────────────────── */
.why {
  padding-bottom: var(--section);
}
.why .wrap {
  padding-top: var(--section);
  border-top: 1px solid var(--line);
}
.why-head {
  max-width: 46rem;
}
.why-kicker {
  margin-bottom: 0.75rem;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.why h2 {
  color: var(--accent);
}
.why-head .section-lede {
  max-width: 44rem;
}

.why-table-wrap {
  margin-top: 3rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--raised);
}
.why-table {
  width: 100%;
  min-width: 40rem;
  border-collapse: collapse;
  text-align: left;
}
.why-table th,
.why-table td {
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.why-table tbody tr:last-child > * {
  border-bottom: 0;
}
.why-table thead th {
  padding-block: 1rem;
  color: var(--ink-soft);
  font-size: var(--step--1);
  font-weight: 500;
}
.why-table thead .why-us {
  color: var(--accent);
  font-weight: 600;
}
.why-table tbody th {
  width: 22%;
  color: var(--ink);
  font-weight: 500;
}
.why-table td {
  width: 39%;
  color: var(--ink-soft);
  font-size: 0.975rem;
}
/* The Plinth column reads strongest: tinted, with a check before each line. */
.why-table td:nth-of-type(1) {
  background: color-mix(in srgb, var(--tint) 60%, transparent);
  color: var(--ink);
}
.why-table td:nth-of-type(1)::before {
  content: "";
  display: inline-block;
  width: 0.875rem;
  height: 0.875rem;
  margin-right: 0.5rem;
  vertical-align: -0.1em;
  background: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* Phones: one block per row instead of a sideways-scrolling table. */
@media (max-width: 44rem) {
  .why-table,
  .why-table tbody,
  .why-table tr,
  .why-table th,
  .why-table td {
    display: block;
    width: auto;
    min-width: 0;
  }
  .why-table thead {
    display: none;
  }
  .why-table tbody th {
    width: auto;
  }
  .why-table tbody tr {
    padding: 1.25rem;
    border-bottom: 1px solid var(--line);
  }
  .why-table tbody tr:last-child {
    border-bottom: 0;
  }
  .why-table th,
  .why-table td {
    padding: 0;
    border: 0;
  }
  .why-table td {
    margin-top: 0.625rem;
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-s);
  }
  .why-table td:nth-of-type(2) {
    padding-block: 0;
  }
  .why-table td:nth-of-type(2)::before {
    content: "AI code review: ";
    color: var(--ink);
    font-weight: 500;
  }
}

/* ── Pricing ──────────────────────────────────────────────────────────── */
.pricing {
  padding-bottom: var(--section);
}

.pricing-head {
  padding-top: var(--section);
  border-top: 1px solid var(--line);
}

.pricing h2 {
  color: var(--accent);
}

.plans {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
  align-items: stretch;
  margin-top: 2.75rem;
}

.plan {
  display: flex;
  flex-direction: column;
  padding: clamp(1.5rem, 2.5vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
}

.plan-featured {
  border-color: var(--bordeaux);
  background: var(--bordeaux);
  color: var(--white);
}

.plan-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.plan h3 {
  color: var(--accent);
}
.plan-featured h3 {
  color: var(--white);
}

.plan-badge {
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: var(--rose);
  color: var(--cellar);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.plan-badge-light {
  background: var(--tint);
  color: var(--accent);
}

.plan-price {
  margin-top: 1.25rem;
  color: var(--ink-soft);
  font-size: var(--step--1);
}
.plan-price strong {
  display: block;
  color: var(--ink);
  font-size: var(--step-2);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.025em;
}
.plan-featured .plan-price {
  color: var(--on-dark);
}
.plan-featured .plan-price strong {
  color: var(--white);
}

.plan-for {
  margin-top: 0.5rem;
  color: var(--ink-soft);
  font-size: var(--step--1);
}
.plan-featured .plan-for {
  color: var(--blush);
}

.plan-list {
  flex: 1;
  margin: 1.5rem 0 2rem;
  padding: 1.25rem 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}
.plan-featured .plan-list {
  border-top-color: rgb(255 255 255 / 0.2);
}

.plan-list li {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.9375rem;
}
.plan-list li + li {
  margin-top: 0.625rem;
}
.plan-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 0.875rem;
  height: 0.875rem;
  background: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / contain no-repeat;
}
.plan-featured .plan-list li::before {
  background: var(--rose);
}

.plan .button {
  align-self: flex-start;
}

.button-outline {
  border-color: var(--accent);
  color: var(--accent);
}
.button-outline:hover {
  background: var(--tint);
}

.plan-featured :focus-visible {
  outline-color: var(--rose);
}

.pricing-note {
  max-width: 62ch;
  margin-top: 2rem;
  color: var(--ink-soft);
  font-size: var(--step--1);
}
.pricing-note strong {
  color: var(--accent);
  font-weight: 500;
}

/* ── Closing (burgundy) ───────────────────────────────────────────────── */
.closing {
  padding-block: clamp(4rem, 3rem + 4vw, 6.5rem);
  background: var(--bordeaux);
  color: var(--white);
}

.closing-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.closing h2 {
  max-width: 20ch;
}

.closing p {
  margin-top: 1rem;
  color: var(--on-dark);
}

/* ── Footer ───────────────────────────────────────────────────────────── */
.site-footer {
  padding-top: clamp(4rem, 3rem + 4vw, 6rem);
  overflow: hidden;
  background: var(--cellar);
  color: var(--blush);
  font-size: var(--step--1);
}

.site-footer :focus-visible {
  outline-color: var(--rose);
}

.footer-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: clamp(2.5rem, 6vw, 6rem);
}

.site-footer .brand {
  color: var(--white);
}
.site-footer .mark-tile {
  fill: var(--bordeaux);
}

.footer-tagline {
  max-width: 30ch;
  margin-top: 1.25rem;
  color: var(--on-dark);
  font-size: var(--step-1);
  line-height: 1.4;
}

.footer-cta {
  margin-top: 1.75rem;
}

.footer-free {
  margin-top: 0.875rem;
}

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

.footer-heading {
  color: var(--rose);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

.footer-cols ul {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}
.footer-cols li + li {
  margin-top: 0.625rem;
}

.footer-cols a,
.footer-top-link {
  color: var(--on-dark);
  text-decoration: none;
  transition: color 160ms ease;
}
.footer-cols a:hover,
.footer-top-link:hover {
  color: var(--white);
}

.footer-sign {
  margin-top: clamp(3rem, 6vw, 5rem);
  color: rgb(255 255 255 / 0.05);
  font-size: clamp(6rem, 22vw, 19rem);
  font-weight: 600;
  letter-spacing: -0.06em;
  line-height: 0.75;
  padding-bottom: 0.22em;
  user-select: none;
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: 1.5rem;
  border-top: 1px solid rgb(255 255 255 / 0.12);
}

/* ── Micro-interactions ───────────────────────────────────────────────────
   Static styles first (they work with or without JS), then everything that
   moves, which only applies under .motion (set by motion.ts) and never for
   reduced motion. */

.site-header.is-scrolled {
  box-shadow: 0 12px 30px -20px rgb(20 2 8 / 0.9);
}

.progress {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: var(--rose);
  transform: scaleX(var(--p, 0));
  transform-origin: left center;
}

/* Nav: an underline that grows in, and stays on the section you're reading. */
.nav-link {
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  padding-bottom: 2px;
  transition:
    color 160ms ease,
    background-size 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.nav-link:hover,
.nav-link.is-active {
  color: var(--white);
  background-size: 100% 1px;
}

.footer-cols a {
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition:
    color 160ms ease,
    background-size 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.footer-cols a:hover {
  background-size: 100% 1px;
}

/* Billing toggle */
.billing {
  justify-content: flex-start;
  margin: 1.75rem 0 0;
}
.billing button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.save {
  padding: 0.125rem 0.4rem;
  border-radius: 999px;
  background: var(--tint);
  color: var(--accent);
  font-size: 0.6875rem;
  line-height: 1.4;
  transition:
    background-color 160ms ease,
    color 160ms ease;
}
.billing button[aria-pressed="true"] .save {
  background: rgb(255 255 255 / 0.18);
  color: inherit;
}

.plan-price strong {
  will-change: transform;
}

/* Copy button on the migration */
.snippet-copyable {
  position: relative;
}
.snippet-copyable figcaption {
  padding-right: 5.5rem;
}
.copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 1.875rem;
  padding: 0 0.75rem;
  border: 1px solid rgb(232 180 190 / 0.25);
  border-radius: 999px;
  background: rgb(232 180 190 / 0.08);
  color: var(--on-dark);
  font: 500 0.75rem / 1 var(--sans);
  cursor: pointer;
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}
.copy::before {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6'%3E%3Crect x='5' y='5' width='9' height='9' rx='2'/%3E%3Cpath d='M11 5V3.5A1.5 1.5 0 0 0 9.5 2h-6A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5'/%3E%3C/svg%3E")
    center / contain no-repeat;
}
.copy:hover {
  border-color: var(--rose);
  color: var(--white);
}
.copy.is-done {
  border-color: var(--rose);
  background: var(--rose);
  color: var(--cellar);
}
.copy.is-done::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3.2 3L13 4.5' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* The bulb warms when you read the warning. */
.bulb {
  transition: box-shadow 260ms ease;
}
.hover-card:hover .bulb {
  box-shadow: 0 0 0 5px rgb(240 181 74 / 0.2);
}

@media (prefers-reduced-motion: no-preference) {
  /* Buttons lift on hover and press in on click. */
  .button,
  .nav-cta,
  .theme-toggle,
  .copy {
    transition-property: background-color, border-color, color, transform, box-shadow;
    transition-duration: 160ms, 160ms, 160ms, 220ms, 220ms;
    transition-timing-function:
      ease, ease, ease, cubic-bezier(0.2, 0.8, 0.2, 1), cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .button:hover,
  .nav-cta:hover {
    transform: translateY(-1px);
  }
  .button-light:hover {
    box-shadow: 0 10px 24px -12px rgb(20 2 8 / 0.65);
  }
  .button:active,
  .nav-cta:active,
  .theme-toggle:active,
  .copy:active,
  .segmented button:active {
    transform: scale(0.97);
    transition-duration: 80ms;
  }
  .segmented button {
    transition:
      background-color 160ms ease,
      color 160ms ease,
      transform 160ms ease;
  }

  /* Plan cards lift, with a soft light under the pointer. */
  .plan {
    position: relative;
    isolation: isolate;
    transition:
      transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1),
      box-shadow 300ms cubic-bezier(0.2, 0.8, 0.2, 1),
      border-color 200ms ease;
  }
  .plan::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: radial-gradient(
      22rem circle at var(--mx, 50%) var(--my, 0%),
      rgb(232 180 190 / 0.16),
      transparent 65%
    );
    opacity: 0;
    transition: opacity 300ms ease;
    pointer-events: none;
  }
  .plan:hover {
    transform: translateY(-4px);
    box-shadow: 0 24px 48px -28px rgb(43 9 18 / 0.45);
  }
  .plan:not(.plan-featured):hover {
    border-color: var(--rose);
  }
  .plan:hover::after {
    opacity: 1;
  }
  .plan-featured::after {
    background: radial-gradient(
      22rem circle at var(--mx, 50%) var(--my, 0%),
      rgb(255 255 255 / 0.12),
      transparent 65%
    );
  }

  /* Rules and steps nudge toward you on hover. */
  .steps > li {
    transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .steps > li:hover {
    transform: translateX(4px);
  }

  .matrix tbody tr .check {
    transition: transform 260ms cubic-bezier(0.3, 0.7, 0.2, 1.4);
  }
  .matrix tbody tr:hover .check {
    transform: scale(1.12);
  }

  .footer-sign {
    transition: color 600ms ease;
  }
  .footer-sign:hover {
    color: rgb(232 180 190 / 0.12);
  }

  /* Scroll reveals (motion.ts adds data-reveal and the stagger index --d). */
  .motion [data-reveal] {
    opacity: 0;
    transform: translateY(18px);
    transition:
      opacity 700ms cubic-bezier(0.2, 0.8, 0.2, 1),
      transform 700ms cubic-bezier(0.2, 0.8, 0.2, 1);
    transition-delay: calc(var(--d, 0) * 80ms);
  }
  .motion [data-reveal].is-in {
    opacity: 1;
    transform: none;
  }
  .motion .footer-sign[data-reveal] {
    transform: translateY(35%);
    transition-duration: 1100ms;
  }
  .motion .footer-sign[data-reveal].is-in {
    transform: none;
  }
  .motion .matrix tr[data-reveal] .check {
    transform: scale(0.3);
    opacity: 0;
    transition:
      transform 380ms cubic-bezier(0.3, 0.7, 0.2, 1.5),
      opacity 200ms ease;
    transition-delay: calc(var(--d, 0) * 80ms + 160ms);
  }
  .motion .matrix tr[data-reveal].is-in .check {
    transform: none;
    opacity: 1;
  }
  .motion .matrix tr[data-reveal] td + td .check {
    transition-delay: calc(var(--d, 0) * 80ms + 240ms);
  }

  /* Segmented switches: one pill that slides between options. */
  .motion .segmented.has-thumb {
    position: relative;
  }
  .motion .segmented.has-thumb button {
    position: relative;
    z-index: 1;
  }
  .motion .segmented.has-thumb button[aria-pressed="true"] {
    background: transparent;
  }
  .seg-thumb {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 0;
    width: var(--w, 0);
    border-radius: 999px;
    background: var(--white);
    transform: translateX(var(--x, 0));
  }
  .switches-light .seg-thumb {
    background: var(--accent);
  }
  .thumbs-ready .seg-thumb {
    transition:
      transform 380ms cubic-bezier(0.3, 0.75, 0.2, 1.08),
      width 380ms cubic-bezier(0.3, 0.75, 0.2, 1.08);
  }

  /* Switching stack replays the code, the warning and the fix. */
  .is-swapping .line {
    animation: line-in 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: calc(var(--i, 0) * 28ms);
  }
  .is-swapping .squiggle::after {
    animation: draw 600ms 260ms cubic-bezier(0.3, 0.7, 0.2, 1) both;
  }
  .editor.is-swapping .hover-card {
    animation: rise 420ms 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
  .editor.is-swapping .tab {
    animation: fade-in 300ms ease both;
  }
  .fix-panel.is-swapping .snippet {
    animation: rise 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
  .fix-panel.is-swapping .snippet + .snippet {
    animation-delay: 90ms;
  }
  .fix-panel.is-swapping .added {
    animation: flash 1200ms 300ms ease-out both;
  }

  /* The measure's "after" lands with a little weight. */
  .measure.is-counted .measure-row > div:last-child strong {
    animation: land 500ms 1950ms cubic-bezier(0.3, 0.7, 0.2, 1.5) both;
  }
  .measure.is-counted .measure-step {
    animation: nudge 900ms 600ms ease-in-out 2;
  }
}

@keyframes line-in {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes flash {
  from {
    background-color: rgb(232 180 190 / 0.5);
  }
}
@keyframes land {
  40% {
    transform: scale(1.06);
    color: var(--rose);
  }
}
@keyframes nudge {
  50% {
    transform: translateX(5px);
  }
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 62rem) {
  .hero-demo {
    transform: none;
  }
  .hero-grid,
  .how-grid,
  .stack-grid,
  .weigh {
    grid-template-columns: minmax(0, 1fr);
  }
  .rules-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .rules-head {
    grid-template-columns: minmax(0, 1fr);
  }
  .rules-head .section-lede {
    justify-self: start;
  }
  .fix-panel {
    position: static;
  }
  .footer-top {
    grid-template-columns: minmax(0, 1fr);
  }
  .plans {
    grid-template-columns: minmax(0, 1fr);
    max-width: 34rem;
  }
  .saves-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .saves-head {
    grid-template-columns: minmax(0, 1fr);
  }
  .saves-head .section-lede {
    justify-self: start;
  }
}

@media (max-width: 44rem) {
  .saves-grid,
  .rules-cards,
  .measure-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .measure-step {
    display: none;
  }
  .footer-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .segmented button {
    padding: 0 0.75rem;
  }
}
