/* ============================================================
   Showcase system layer — "The Instrument Panel"

   The shared half of every showcase page: tokens, base, chrome,
   and the primitives DESIGN.md names (eyebrow, region, panel,
   badge, button). A showcase links this file and then adds only
   the machinery unique to its own story.

   Tokens are the same values as src/styles/site.css and
   public/index.html. Change one, change all three.
   ============================================================ */

:root,
:root[data-theme='dark'] {
  --bg: #0c0e11;
  --surface: #12161b;
  --surface-2: #1a1f27;
  --border: #232a33;
  --border-strong: #33404c;
  --text: #e8eaed;
  --muted: #9aa1ab;
  --faint: #7d8794;
  --orange: #ff7a2f;
  --pink: #ff3d67;
  --cyan: #2fd4c4;
  --violet: #9b87ff;
  --green: #58d68d;
  --amber: #ffb14d;
  --accent: var(--orange);
  --grad: linear-gradient(120deg, var(--orange), var(--pink));
  /* CTAs carry 13px bold text on the gradient and must clear 4.5:1 at BOTH
     stops, so they get their own gradient and ink. On the dark canvas the
     display gradient already clears it for near-black (7.4:1 / 5.7:1). */
  --grad-cta: var(--grad);
  --cta-ink: #16090b;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset, 0 24px 60px -30px rgba(0, 0, 0, 0.8);
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --maxw: 1180px;
  --step--1: clamp(0.78rem, 0.76rem + 0.1vw, 0.84rem);
  --step-0: clamp(0.95rem, 0.92rem + 0.18vw, 1.05rem);
  --step-1: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  --step-2: clamp(1.5rem, 1.2rem + 1.4vw, 2.3rem);
  --step-3: clamp(2.1rem, 1.5rem + 3vw, 4rem);
  /* Sub-body scale. Four steps, not twelve — anything smaller than
     --step--1 must land on one of these. */
  --micro: 0.58rem;  /* chips, legends, cites, units, stamps */
  --label: 0.66rem;  /* mono controls: tabs, buttons, field labels, readouts */
  --meta: 0.78rem;   /* small prose: notes, captions, code */
  --copy: 0.88rem;   /* prose inside a panel */
  /* Every region sets its own --hue; orange is the page default. */
  --hue: var(--orange);
}

:root[data-theme='light'] {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f2ef;
  --border: #e3e4df;
  --border-strong: #cfd1ca;
  --text: #16191c;
  --muted: #55606a;
  --faint: #666f78;
  --orange: #e0641c;
  --pink: #e02a54;
  /* Deepened from #0e9e90, which sat at 3.1:1 on the light canvas. */
  --cyan: #0b7d72;
  --violet: #6d4ae0;
  --green: #1f9d57;
  --amber: #c07d16;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 20px 50px -30px rgba(20, 30, 45, 0.28);
  /* Neither ink clears the floor on the light display gradient: near-black is
     4.3:1 at the pink stop, white is 3.5:1 at the orange stop. CTAs deepen
     their own gradient and go white — 4.8:1 and 6.0:1. */
  --grad-cta: linear-gradient(120deg, #c2500f, #c01f45);
  --cta-ink: #fff;
}

/* Hue-as-text, light theme only.

   The signal hues are tuned to sit on the dark chassis, where every one of
   them clears 6:1 on a panel. Dropped straight onto white they land at
   3.3-3.5:1 — under the 4.5:1 floor for the micro labels that carry the
   actual meaning here. Compositing the hue toward the ink keeps the hue
   identity and lifts every one of them past 5.2:1.

   Dark theme deliberately does not inherit this: there the bright hue is
   the point. Use .hue-ink on any small text that takes its color from
   --hue or --ch. */
.hue-ink { color: var(--ch, var(--hue)); }
:root[data-theme='light'] .hue-ink,
:root[data-theme='light'] .eyebrow,
/* Small text that takes its color from --hue in showcase-page.css. Same
   treatment, same reason: on paper the raw hue lands at 3.0-3.5:1. */
:root[data-theme='light'] .slot .lab,
:root[data-theme='light'] .kcard-h .tag,
:root[data-theme='light'] .ev .meta .src,
:root[data-theme='light'] .dstep .lvl,
:root[data-theme='light'] .trow .bind,
:root[data-theme='light'] .flow .n,
:root[data-theme='light'] .maprow .to b,
:root[data-theme='light'] .code-tabs .tab[aria-selected='true'],
:root[data-theme='light'] .split .col li::before,
:root[data-theme='light'] .case .kick,
:root[data-theme='light'] .mini .kick,
:root[data-theme='light'] .case-number,
:root[data-theme='light'] .case-kicker,
:root[data-theme='light'] .case-marker,
:root[data-theme='light'] .yaml-note code,
:root[data-theme='light'] .case-write > span,
:root[data-theme='light'] .case-next {
  color: color-mix(in srgb, var(--ch, var(--hue)) 72%, var(--text));
}

:root[data-theme='light'] .case-chapter .case-kicker,
:root[data-theme='light'] .case-chapter .case-marker,
:root[data-theme='light'] .case-chapter .yaml-note code,
:root[data-theme='light'] .case-chapter .case-write > span,
:root[data-theme='light'] .case-chapter .case-next,
:root[data-theme='light'] .case-chapter .effect-label,
:root[data-theme='light'] .case-chapter .effect-arrow,
:root[data-theme='light'] .case-chapter .effect-summary strong {
  color: color-mix(in srgb, var(--chapter-hue) 72%, var(--text));
}
:root[data-theme='light'] .badge {
  color: color-mix(in srgb, var(--bh, var(--hue)) 72%, var(--text));
}

/* ============ base ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 4vw, 2.5rem);
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 3px; border-radius: 2px; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }

h1, h2, h3 {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-wrap: balance;
}

/* Inline code in prose, tinted by the region hue. */
:not(pre) > code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.1em 0.38em;
  border-radius: 5px;
  white-space: nowrap;
  color: var(--text);
  background: color-mix(in srgb, var(--hue) 11%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--hue) 24%, var(--border));
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--surface-2);
  color: var(--text);
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border-strong);
  font-family: var(--mono);
  font-size: var(--step--1);
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* ============ eyebrow — the hue-carrying section mark ============ */
.eyebrow {
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--hue);
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
}
.eyebrow::before {
  content: '';
  width: 2.4em;
  height: 2px;
  background: var(--hue);
  opacity: 0.7;
}

/* The one gradient. Reserved for the primary action and rare headline emphasis. */
/* Headline emphasis is the solid filament, not a third gradient in the viewport;
   the gradient stays with the two actions (nav CTA and primary button). */
.grad { color: var(--orange); }
:root[data-theme='light'] .grad { color: color-mix(in srgb, var(--orange) 85%, var(--text)); }
/* ============ nav ============ */
header.nav {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 1rem;
}
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.1rem;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .caret { color: var(--orange); animation: blink 1.2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.nav-right { display: flex; align-items: center; gap: 1.1rem; }
.nav-right a.navlink {
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--step--1);
}
.nav-right a.navlink:hover { color: var(--text); text-decoration: none; }
.nav-right a.navlink[aria-current='page'] { color: var(--text); }
/* The repo link survives the narrow-screen collapse that hides .navlink, since
   a showcase page is exactly where a reader decides to go read the code. */
.nav-right a.nav-gh { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); }
.nav-right a.nav-gh:hover { color: var(--text); text-decoration: none; }
.nav-gh svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
@media (max-width: 700px) { .nav-gh .lbl { display: none; } }
.nav-cta {
  font-family: var(--mono);
  font-weight: 700;
  font-size: var(--step--1);
  color: var(--cta-ink);
  background: var(--grad-cta);
  padding: 0.5rem 1rem;
  border-radius: 8px;
}
.nav-cta:hover { text-decoration: none; filter: brightness(1.07); }

/* Standalone showcase pages use the same compact, section-based header as the
   rest of the marketing site. */
.site-nav .nav-inner { height: 64px; gap: 1.4rem; }
.site-nav .brand {
  align-items: center;
  gap: .6rem;
  font-size: 1.15rem;
}
.site-nav .brand .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--grad);
  flex: none;
}
.site-nav .nav-links { display: flex; align-items: center; gap: 1.25rem; }
.site-nav .nav-links a,
.site-nav .nav-cta { white-space: nowrap; }
.site-nav .nav-links a {
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--step--1);
}
.site-nav .nav-links a:hover { color: var(--text); text-decoration: none; }
.site-nav .nav-links a[aria-current='page'] { color: var(--text); }
.site-nav .nav-links .nav-cta,
.site-nav .nav-links .nav-cta:hover { color: var(--cta-ink); }
.site-nav .nav-menu { position: relative; }
.site-nav .nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--step--1);
  white-space: nowrap;
  padding: 0;
}
.site-nav .nav-trigger::after {
  content: '▾';
  font-size: .95em;
  line-height: 1;
  opacity: .7;
  transition: transform .15s;
}
.site-nav .nav-trigger:hover,
.site-nav .nav-trigger[data-current],
.site-nav .nav-menu.open .nav-trigger { color: var(--text); }
.site-nav .nav-menu.open .nav-trigger::after { transform: rotate(180deg); }
.site-nav .nav-panel {
  display: none;
  position: absolute;
  top: calc(100% + .7rem);
  left: -.7rem;
  min-width: 13.5rem;
  padding: .4rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  box-shadow: var(--shadow);
}
.site-nav .nav-menu.open .nav-panel { display: block; }
.site-nav .nav-panel a {
  display: block;
  padding: .5rem .65rem;
  border-radius: 7px;
  line-height: 1.35;
}
.site-nav .nav-panel a:hover { color: var(--text); background: var(--surface-2); }
.site-nav .nav-panel .narrow-only { display: none; }
.site-nav .theme-toggle {
  display: inline-flex;
  align-items: center;
  width: auto;
  height: auto;
  padding: .35rem .55rem;
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .05em;
}
.site-nav .theme-toggle:hover { color: var(--orange); border-color: var(--orange); }
.site-nav .nav-cta { padding: .55rem 1rem; }
.site-nav .nav-burger { display: none; }
.site-nav .nav-burger .nav-trigger { color: var(--text); padding-inline: .1rem; }
.site-nav .nav-burger .nav-trigger::after { content: none; }
.site-nav .nav-burger .bars { position: relative; }
.site-nav .nav-burger .bars,
.site-nav .nav-burger .bars::before,
.site-nav .nav-burger .bars::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform .18s ease, top .18s ease, background-color .18s ease;
}
.site-nav .nav-burger .bars::before { content: ''; position: absolute; top: -6px; }
.site-nav .nav-burger .bars::after { content: ''; position: absolute; top: 6px; }
.site-nav .nav-burger.open .bars { background: transparent; }
.site-nav .nav-burger.open .bars::before { top: 0; transform: rotate(45deg); }
.site-nav .nav-burger.open .bars::after { top: 0; transform: rotate(-45deg); }
.site-nav .nav-burger .nav-panel {
  left: auto;
  right: -.6rem;
  width: min(15.5rem, calc(100vw - 2rem));
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
}
.site-nav .nav-burger .nav-group {
  padding: .5rem .65rem .25rem;
  color: var(--faint);
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.site-nav .nav-burger .nav-group:not(:first-child) {
  border-top: 1px solid var(--border);
  margin-top: .35rem;
  padding-top: .6rem;
}
.site-nav .nav-cta .cta-narrow { display: none; }

@media (max-width: 820px) {
  .site-nav .nav-links { gap: .95rem; }
  .site-nav .nav-bench { display: none; }
  .site-nav .nav-panel .narrow-only { display: block; }
}

@media (max-width: 620px) {
  .site-nav .nav-inner { gap: .8rem; }
  .site-nav .nav-links { gap: .85rem; }
  .site-nav .nav-links > a:not(.nav-cta),
  .site-nav .nav-menu:not(.nav-burger) { display: none; }
  .site-nav .nav-burger { display: block; }
  .site-nav .nav-cta .cta-wide { display: none; }
  .site-nav .nav-cta .cta-narrow { display: inline; }
  .site-nav .nav-cta { padding-inline: .75rem; }
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--muted);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--hue); }
/* Compact for a mouse; a real target on touch. */
@media (pointer: coarse) {
  .theme-toggle { width: 44px; height: 44px; }
  .nav-cta, .nav-right a.navlink { min-height: 44px; display: inline-flex; align-items: center; }
  .site-nav .theme-toggle,
  .site-nav .nav-cta,
  .site-nav .nav-trigger { min-height: 44px; display: inline-flex; align-items: center; }
  .site-nav .nav-links a { padding-block: .6rem; }
  .site-nav .nav-panel a { padding-block: .7rem; }
}
.theme-toggle svg { width: 15px; height: 15px; }
:root[data-theme='dark'] .theme-toggle .sun { display: none; }
:root[data-theme='light'] .theme-toggle .moon { display: none; }

/* ============ regions ============ */
.region {
  padding-block: clamp(3.2rem, 7vw, 5.5rem);
  border-bottom: 1px solid var(--border);
}
.region-head { max-width: 62ch; }
.region-head h2 { font-size: var(--step-2); margin-top: 1.1rem; max-width: 24ch; }
.region-head p { margin-top: 1.1rem; color: var(--muted); max-width: 68ch; }
.region-head p strong { color: var(--text); font-weight: 600; }
.lede { font-size: var(--step-1); line-height: 1.5; color: var(--text); }

/* ============ hero ============ */
.hero {
  position: relative;
  overflow: hidden;
  padding-top: clamp(2.6rem, 5vw, 4.6rem);
  padding-bottom: clamp(2.4rem, 4vw, 3.4rem);
  border-bottom: 1px solid var(--border);
}
/* Atmospheric lighting, not elevation. */
.hero::before {
  content: '';
  position: absolute;
  inset: -40% -10% auto;
  height: 620px;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(38% 60% at 14% 32%, color-mix(in srgb, var(--orange) 26%, transparent), transparent 70%),
    radial-gradient(34% 55% at 74% 18%, color-mix(in srgb, var(--pink) 16%, transparent), transparent 72%);
  opacity: 0.5;
}
.hero .wrap { position: relative; z-index: 1; }
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 0.92fr;
  gap: clamp(2rem, 4vw, 3.4rem);
  align-items: center;
}
.hero h1 { font-size: var(--step-3); margin-top: 1.2rem; max-width: 19ch; }
.hero h1 .dim { color: var(--faint); }
.hero p.sell {
  margin-top: 1.4rem;
  max-width: 54ch;
  color: var(--muted);
  font-size: var(--step-1);
  line-height: 1.55;
}
.hero p.sell strong { color: var(--text); font-weight: 600; }
.simulation-note {
  max-width: 64ch;
  margin-top: 1.15rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--hue) 28%, var(--border));
  border-left: 3px solid var(--hue);
  border-radius: 8px;
  background: color-mix(in srgb, var(--hue) 6%, var(--surface));
  color: var(--muted);
  font-size: var(--meta);
  line-height: 1.55;
}
.simulation-note strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--label);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.hero-cta { display: flex; flex-wrap: wrap; gap: 0.85rem; align-items: center; margin-top: 2rem; }

/* ============ scrolling case file ============
   Keep the problem in view while each scroll chapter explains the event, the
   YAML contract that handles it, and the record that contract writes. */
.case-study {
  padding-block: clamp(3.2rem, 7vw, 6rem);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, color-mix(in srgb, var(--hue) 5%, transparent), transparent 38%), var(--surface);
}
.case-layout {
  display: grid;
  grid-template-columns: minmax(15rem, 0.7fr) minmax(0, 1.3fr);
  gap: clamp(2rem, 6vw, 6rem);
  align-items: start;
}
.case-brief { position: sticky; top: 5.5rem; min-width: 0; }
.case-number {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--hue);
  font-family: var(--mono);
  font-size: var(--micro);
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
.case-number::before { content: ''; width: 1.8rem; height: 1px; background: currentColor; }
.case-brief h2 { max-width: 16ch; margin-top: 1rem; font-size: var(--step-2); line-height: 1.08; }
.case-brief > p { max-width: 44ch; margin-top: 1rem; color: var(--muted); line-height: 1.65; }
.case-contract {
  display: grid;
  gap: 0;
  margin-top: 1.5rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.case-contract div { display: grid; grid-template-columns: 5.4rem 1fr; gap: 0.7rem; padding: 0.72rem 0.8rem; border-top: 1px solid var(--border); }
.case-contract div:first-child { border-top: 0; }
.case-contract dt { color: var(--faint); font-family: var(--mono); font-size: var(--micro); letter-spacing: 0.08em; text-transform: uppercase; }
.case-contract dd { color: var(--text); font-size: var(--meta); line-height: 1.45; }
.case-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1rem;
  color: var(--faint);
  font-family: var(--mono);
  font-size: var(--micro);
}
.case-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--status-hue, var(--green));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--status-hue, var(--green)) 12%, transparent);
}
.case-scroll { position: relative; min-width: 0; }
.case-scroll::before {
  content: '';
  position: absolute;
  top: 1rem;
  bottom: 1rem;
  left: 1.05rem;
  width: 1px;
  background: linear-gradient(var(--hue), color-mix(in srgb, var(--hue) 12%, var(--border)));
}
.case-chapter {
  --chapter-hue: var(--hue);
  position: relative;
  display: grid;
  grid-template-columns: 2.15rem minmax(0, 1fr);
  gap: 1.2rem;
  padding-bottom: clamp(3.6rem, 8vw, 7rem);
}
.case-chapter:last-child { padding-bottom: 0; }
.case-marker {
  position: sticky;
  top: 6rem;
  z-index: 1;
  display: grid;
  width: 2.15rem;
  height: 2.15rem;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--chapter-hue) 55%, var(--border));
  border-radius: 50%;
  background: var(--surface);
  color: var(--chapter-hue);
  font-family: var(--mono);
  font-size: var(--micro);
  font-weight: 700;
}
.case-body { min-width: 0; }
.case-kicker { color: var(--chapter-hue); font-family: var(--mono); font-size: var(--micro); font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; }
.case-body h3 { max-width: 26ch; margin-top: 0.55rem; font-size: clamp(1.28rem, 2.3vw, 1.75rem); line-height: 1.18; }
.case-body > p { max-width: 61ch; margin-top: 0.8rem; color: var(--muted); line-height: 1.65; }
.case-event {
  margin-top: 1.2rem;
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--chapter-hue);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--chapter-hue) 7%, var(--bg));
  color: var(--text);
  font-size: var(--copy);
  line-height: 1.55;
}
.case-event b { display: block; margin-bottom: 0.25rem; color: var(--chapter-hue); font-family: var(--mono); font-size: var(--micro); letter-spacing: 0.08em; text-transform: uppercase; }
.effect-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem minmax(0, 1fr);
  gap: 0.8rem;
  align-items: stretch;
  margin-top: 1.2rem;
}
.effect-stack { display: grid; gap: 0.55rem; min-width: 0; }
.effect-card {
  --effect-hue: var(--chapter-hue);
  min-width: 0;
  padding: 0.85rem 0.9rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--effect-hue);
  border-radius: 8px;
  background: var(--bg);
}
.effect-card.is-output { background: color-mix(in srgb, var(--effect-hue) 6%, var(--bg)); }
.effect-card.is-muted { --effect-hue: var(--faint); opacity: 0.76; }
.effect-card.is-zero { border-style: dashed; }
.effect-label {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  color: var(--effect-hue);
  font-family: var(--mono);
  font-size: var(--micro);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.effect-label small { color: var(--faint); font-size: inherit; font-weight: 500; letter-spacing: 0; text-transform: none; }
.effect-card blockquote,
.effect-card > p {
  margin-top: 0.45rem;
  color: var(--text);
  font-size: var(--meta);
  line-height: 1.52;
}
.effect-card blockquote { padding: 0; border: 0; }
.effect-card code { color: inherit; font-size: 0.92em; white-space: normal; }
.effect-fields {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.18rem 0.55rem;
  margin-top: 0.5rem;
  font-family: var(--mono);
  font-size: var(--micro);
  line-height: 1.5;
}
.effect-fields dt { color: var(--faint); }
.effect-fields dd { min-width: 0; color: var(--text); overflow-wrap: anywhere; }
.effect-arrow {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  color: var(--chapter-hue);
  text-align: center;
}
.effect-arrow span {
  padding: 0.28rem 0.4rem;
  border: 1px solid color-mix(in srgb, var(--chapter-hue) 35%, var(--border));
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.52rem;
  font-weight: 700;
  line-height: 1.25;
  text-transform: uppercase;
}
.effect-arrow i { position: relative; display: block; width: 100%; height: 1px; background: color-mix(in srgb, var(--chapter-hue) 50%, var(--border)); }
.effect-arrow i::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 0;
  width: 0.45rem;
  height: 0.45rem;
  border-top: 1px solid currentColor;
  border-right: 1px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
}
.effect-summary {
  margin-top: 0.7rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--micro);
  line-height: 1.5;
}
.effect-summary strong { color: var(--chapter-hue); }
.yaml-explainer {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(13rem, 0.88fr);
  margin-top: 1.2rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg);
}
.yaml-file { min-width: 0; background: #0b0f14; }
.yaml-file header { display: flex; justify-content: space-between; gap: 1rem; padding: 0.65rem 0.8rem; border-bottom: 1px solid #252c35; color: #9aa8b8; font-family: var(--mono); font-size: var(--micro); }
.yaml-file header span:last-child { color: var(--chapter-hue); }
.yaml-file pre { max-width: 100%; margin: 0; padding: 1rem; overflow-x: auto; background: transparent; color: #d7e0ea; font-family: var(--mono); font-size: clamp(0.65rem, 1.15vw, 0.75rem); line-height: 1.65; tab-size: 2; }
.yaml-file code { color: inherit; white-space: pre; }
.yaml-notes { min-width: 0; }
.yaml-note { padding: 0.8rem 0.9rem; border-top: 1px solid var(--border); }
.yaml-note:first-child { border-top: 0; }
.yaml-note code { display: block; margin-bottom: 0.25rem; color: var(--chapter-hue); font-size: var(--micro); font-weight: 700; }
.yaml-note p { color: var(--muted); font-size: var(--meta); line-height: 1.48; }
.case-write {
  display: grid;
  grid-template-columns: 5.7rem 1fr;
  gap: 0.8rem;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid color-mix(in srgb, var(--chapter-hue) 30%, var(--border));
  border-radius: 9px;
  background: color-mix(in srgb, var(--chapter-hue) 5%, var(--surface));
}
.case-write > span { color: var(--chapter-hue); font-family: var(--mono); font-size: var(--micro); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.case-write p { color: var(--text); font-size: var(--meta); line-height: 1.5; }
.case-next { display: inline-flex; margin-top: 1rem; color: var(--chapter-hue); font-family: var(--mono); font-size: var(--label); font-weight: 700; }

/* ============ buttons ============ */
.btn {
  font-family: var(--mono);
  font-weight: 700;
  font-size: var(--step--1);
  padding: 0.85rem 1.4rem;
  border-radius: 9px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease, filter 0.15s ease;
}
.btn-primary { background: var(--grad-cta); color: var(--cta-ink); }
.btn-primary:hover { text-decoration: none; filter: brightness(1.07); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { text-decoration: none; border-color: var(--violet); color: var(--violet); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; filter: none; transform: none; }
.cta-note { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }

/* ============ panels ============ */
.panel {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.panel-head .t {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-body { display: flex; flex-direction: column; flex: 1; padding: 1.2rem; }
.panel-foot { margin-top: auto; padding-top: 1rem; font-size: 0.78rem; color: var(--muted); line-height: 1.55; }

/* Micro-label chip. --bh overrides the inherited region hue when a badge
   carries its own meaning (added / changed / removed). */
.badge {
  font-family: var(--mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  color: var(--bh, var(--hue));
  background: color-mix(in srgb, var(--bh, var(--hue)) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--bh, var(--hue)) 38%, var(--border));
  white-space: nowrap;
}

/* The recurring micro-shape: a 7px square status mark tinted by hue. */
.mark {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--bh, var(--hue));
  flex: none;
}

/* ============ close + footer ============ */
.close { padding-block: clamp(3.4rem, 8vw, 6rem); }
.close-grid {
  display: grid;
  grid-template-columns: 1fr 1.02fr;
  gap: clamp(2rem, 4vw, 3.2rem);
  align-items: center;
}
.close h2 { font-size: var(--step-2); margin-top: 1.1rem; max-width: 18ch; }
.close p { margin-top: 1.1rem; color: var(--muted); max-width: 52ch; }

footer { border-top: 1px solid var(--border); padding-block: 2rem 2.6rem; }
.foot {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--faint);
}
.foot-links { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.foot-links a { color: var(--muted); }
.foot-links a:hover { color: var(--text); }
.foot-links a.gh { display: inline-flex; align-items: center; gap: .4rem; color: var(--text); }
.foot-links a.gh svg { width: 15px; height: 15px; fill: currentColor; }

.disclosure {
  margin-top: 1.6rem;
  font-size: 0.74rem;
  color: var(--muted);
  max-width: 74ch;
  line-height: 1.6;
  padding-left: 0.9rem;
  border-left: 1px solid var(--border);
}

/* ============ reveal ============ */
/* Content is visible by default; only a JS-capable page hides it to reveal. */
.rv { transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
.js .rv { opacity: 0; transform: translateY(14px); }
.js .rv.in { opacity: 1; transform: none; }

@media (max-width: 900px) {
  .hero-grid, .close-grid { grid-template-columns: 1fr; }
  .case-layout { grid-template-columns: 1fr; gap: 3rem; }
  .case-brief { position: static; }
}
@media (max-width: 720px) {
  .nav-right a.navlink { display: none; }
  .case-scroll::before { left: 0.85rem; }
  .case-chapter { grid-template-columns: 1.7rem minmax(0, 1fr); gap: 0.8rem; }
  .case-marker { width: 1.7rem; height: 1.7rem; top: 5rem; }
  .yaml-explainer { grid-template-columns: 1fr; }
  .yaml-notes { border-top: 1px solid var(--border); }
  .case-contract div, .case-write { grid-template-columns: 1fr; gap: 0.3rem; }
  .effect-flow { grid-template-columns: 1fr; }
  .effect-arrow { min-height: 3.2rem; }
  .effect-arrow i { width: 1px; height: 2rem; }
  .effect-arrow i::after { top: auto; right: 50%; bottom: 0; transform: translateX(50%) rotate(135deg); }
}
@media (max-width: 520px) {
  .panel-body { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .js .rv { opacity: 1 !important; transform: none !important; }
  .brand .caret { animation: none !important; }
}

/* ============================================================
   Problem primer — "00 · the problem"

   Every showcase opens the same way for a reader who has never
   heard of Memseek: one question, one plain answer, the two
   outcomes side by side, and the page's own vocabulary
   translated. It is deliberately jargon-free; the YAML and the
   record shapes start after it.

   Self-contained on purpose — the primer appears on pages that
   link showcase-page.css and on pages that do not.
   ============================================================ */
.why-lead {
  margin-top: 1.1rem;
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--text);
  max-width: 60ch;
}
.why-lead strong { color: var(--text); font-weight: 650; }

.why-grid {
  margin-top: clamp(1.6rem, 3.5vw, 2.4rem);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.why-card {
  --ch: var(--hue);
  position: relative;
  border: 1px solid var(--border);
  border-top: 2px solid var(--ch);
  border-radius: 12px;
  padding: 1.15rem 1.15rem 1.25rem;
  background: var(--surface);
}
.why-card.is-without { --ch: var(--border-strong); }
.why-card.is-with { background: color-mix(in srgb, var(--hue) 5%, var(--surface)); }
.why-tag {
  display: block;
  font-family: var(--mono);
  font-size: var(--micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.why-card.is-with .why-tag { color: var(--hue); }
:root[data-theme='light'] .why-card.is-with .why-tag { color: color-mix(in srgb, var(--hue) 78%, var(--text)); }
.why-card h3 {
  margin-top: 0.5rem;
  font-size: var(--step-1);
  line-height: 1.3;
  color: var(--text);
}
.why-card > p {
  margin-top: 0.6rem;
  font-size: var(--copy);
  line-height: 1.6;
  color: var(--muted);
}
.why-card ul {
  margin-top: 0.9rem;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.why-card li {
  position: relative;
  padding-left: 1.05rem;
  font-size: var(--meta);
  line-height: 1.55;
  color: var(--muted);
}
/* Absolute, not a grid column: each bullet is one flowing sentence whose lead
   clause is bold, so the marker must not become a sibling grid item. */
.why-card li::before {
  content: '›';
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--mono);
  color: var(--ch);
}
.why-card.is-without li::before { content: '×'; color: var(--faint); }
.why-card li b { color: var(--text); font-weight: 600; }

/* The payoff, stated as plainly as the question. */
.why-out {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--border);
  overflow: hidden;
}
.why-out > div { padding: 1rem 1.1rem; background: var(--surface); }
.why-out b {
  display: block;
  font-size: var(--copy);
  line-height: 1.4;
  color: var(--text);
}
.why-out b em {
  font-style: normal;
  font-family: var(--mono);
  color: var(--hue);
}
:root[data-theme='light'] .why-out b em { color: color-mix(in srgb, var(--hue) 78%, var(--text)); }
.why-out span {
  display: block;
  margin-top: 0.35rem;
  font-size: var(--meta);
  line-height: 1.55;
  color: var(--muted);
}

/* The vocabulary the rest of the page uses, in everyday words. */
.why-words {
  margin-top: clamp(1.6rem, 3.5vw, 2.4rem);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.why-words > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: var(--micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.why-words dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.why-words dl > div {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: 0.7rem;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--border);
}
.why-words dl > div:nth-child(-n + 2) { border-top: 0; }
.why-words dl > div:nth-child(odd) { border-right: 1px solid var(--border); }
.why-words dt {
  font-family: var(--mono);
  font-size: var(--meta);
  color: var(--text);
}
.why-words dd {
  margin: 0;
  font-size: var(--meta);
  line-height: 1.55;
  color: var(--muted);
}

@media (max-width: 860px) {
  .why-grid { grid-template-columns: 1fr; }
  .why-words dl { grid-template-columns: 1fr; }
  .why-words dl > div { border-top: 1px solid var(--border); }
  .why-words dl > div:first-child { border-top: 0; }
  .why-words dl > div:nth-child(odd) { border-right: 0; }
}
@media (max-width: 520px) {
  .why-words dl > div { grid-template-columns: 1fr; gap: 0.25rem; }
}

/* One shared orientation line, identical on every showcase: a reader who
   arrived here from a link has no idea what Memseek is, and the walkthrough
   below assumes they do. */
.why-note {
  margin-top: 1rem;
  padding: 0.9rem 1.05rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--hue);
  border-radius: 10px;
  background: var(--surface);
  font-size: var(--meta);
  line-height: 1.65;
  color: var(--muted);
}
.why-note b {
  font-family: var(--mono);
  font-size: var(--micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

/* ============================================================
   Specimens — "what it actually writes"

   Naming an output ("a reflection is produced") tells a new
   reader nothing. Every primer therefore shows the literal
   input and the literal record that comes out of it, before the
   page starts talking about contracts.
   ============================================================ */
.why-spec {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}
.why-spec > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: var(--micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.spec-row {
  display: grid;
  grid-template-columns: 1fr 2.2rem 1fr;
  align-items: stretch;
  border-top: 1px solid var(--border);
}
.spec-row:first-of-type { border-top: 0; }
.spec-in, .spec-out { padding: 0.95rem 1.1rem; }
.spec-out { background: color-mix(in srgb, var(--hue) 4%, transparent); }
.spec-in > span, .spec-out > span {
  display: block;
  font-family: var(--mono);
  font-size: var(--micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}
.spec-out > span { color: var(--hue); }
:root[data-theme='light'] .spec-out > span { color: color-mix(in srgb, var(--hue) 78%, var(--text)); }
.spec-in p, .spec-out p {
  margin-top: 0.45rem;
  font-size: var(--copy);
  line-height: 1.55;
  color: var(--text);
}
.spec-in p.quote, .spec-out p.quote { color: var(--text); }
.spec-in code, .spec-out code { font-size: 0.9em; }
.spec-in small, .spec-out small {
  display: block;
  margin-top: 0.45rem;
  font-family: var(--mono);
  font-size: var(--micro);
  line-height: 1.6;
  color: var(--muted);
}
.spec-arrow {
  display: grid;
  place-items: center;
  border-inline: 1px solid var(--border);
  font-family: var(--mono);
  font-size: var(--meta);
  color: var(--hue);
}
.why-spec > footer {
  padding: 0.7rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--meta);
  line-height: 1.6;
  color: var(--muted);
}

@media (max-width: 860px) {
  .spec-row { grid-template-columns: 1fr; }
  .spec-arrow {
    border-inline: 0;
    border-top: 1px solid var(--border);
    padding: 0.15rem 0;
    transform: rotate(90deg);
  }
  .spec-out { border-top: 1px solid var(--border); }
}

/* A named output is not an explanation. `.eg` carries the literal thing that
   was written, wherever the prose above it names a kind of record. */
.eg {
  margin-top: 0.35rem;
  padding: 0.55rem 0.7rem;
  border-left: 2px solid color-mix(in srgb, var(--hue) 45%, var(--border));
  border-radius: 0 7px 7px 0;
  background: color-mix(in srgb, var(--hue) 5%, var(--surface-2));
  font-size: var(--meta);
  line-height: 1.55;
  color: var(--text);
}
.eg .eg-l {
  display: block;
  margin-bottom: 0.25rem;
  font-family: var(--mono);
  font-size: var(--micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 400;
  color: var(--faint);
}
.eg .eg-m { color: var(--faint); }

/* ============================================================
   The story — "how it goes"

   Replaces the earlier input/output table. A reader who has
   never heard of Memseek should be able to follow the case as a
   short narrative: a few beats, one quoted line each, and the
   two or three lines of code the application actually writes.
   Airy on purpose — density is what made the table hard.
   ============================================================ */
.story { margin-top: clamp(1.6rem, 3.5vw, 2.4rem); }
.story > ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(1.5rem, 3vw, 2.2rem);
}
.story > ol > li {
  position: relative;
  padding-left: 2.6rem;
}
/* One continuous rail with a dot per beat, so the eye reads it as a sequence. */
.story > ol > li::before {
  content: '';
  position: absolute;
  left: 0.55rem;
  top: 1.5rem;
  bottom: -2.2rem;
  width: 1px;
  background: var(--border);
}
.story > ol > li:last-child::before { display: none; }
.story > ol > li::after {
  content: '';
  position: absolute;
  left: 0.2rem;
  top: 0.55rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 2px solid var(--hue);
  background: var(--bg);
}
.story .when {
  display: block;
  font-family: var(--mono);
  font-size: var(--micro);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--hue);
}
:root[data-theme='light'] .story .when { color: color-mix(in srgb, var(--hue) 78%, var(--text)); }
.story .beat {
  margin-top: 0.45rem;
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--text);
  max-width: 58ch;
}
/* The literal thing: a sentence someone said, or a record that got written. */
.story q {
  display: block;
  margin-top: 0.7rem;
  padding: 0.75rem 0.95rem;
  border-left: 2px solid color-mix(in srgb, var(--hue) 55%, var(--border));
  border-radius: 0 9px 9px 0;
  background: color-mix(in srgb, var(--hue) 5%, var(--surface));
  quotes: none;
  font-size: var(--copy);
  line-height: 1.6;
  color: var(--text);
  max-width: 62ch;
}
.story q b { font-weight: 600; }
.story .aside {
  display: block;
  margin-top: 0.5rem;
  font-size: var(--meta);
  line-height: 1.6;
  color: var(--muted);
  max-width: 60ch;
}
.story pre {
  margin-top: 0.7rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: var(--meta);
  line-height: 1.85;
  color: var(--text);
  max-width: 74ch;
}
.story pre .c { color: var(--faint); font-style: italic; }
.story pre .s { color: var(--hue); }
