/* krasikralev.com, round 6 "The Run" (DESIGN-R6): tokens, type, the seven colour-blocked bands and
   every static component. The run builder styles states in run.css; the diagram builder owns
   everything inside .diagram (diagrams.css); swarm.css styles only what swarm.js injects. */

/* ---------- Fonts (self-hosted; an English visit never requests a Cyrillic file) ---------- */
@font-face {
  font-family: 'Sofia Sans Extra Condensed';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/assets/fonts/sofia-xc-800-latin-v1.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Sofia Sans Extra Condensed';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('/assets/fonts/sofia-xc-800-cyrillic-v1.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Sofia Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/fonts/sofia-sans-latin-v1.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Sofia Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/assets/fonts/sofia-sans-cyrillic-v1.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/assets/fonts/jetbrains-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/assets/fonts/jetbrains-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* ---------- Tokens (DESIGN-R6 §2: no black, no grey; the dark is navy, the light is paper) ---------- */
:root {
  --deep: #0b1035;
  --deep-2: #141b52;
  --deep-3: #232c78;
  --line: rgba(246, 242, 232, 0.16);
  --foam: #f6f2e8;
  --foam-2: #c7cbea;
  --foam-3: #9ca3d6;
  --coral: #ff5a3d;
  --coral-ink: #c53014;
  --sea: #2fe0c2;
  --lamp: #ffc531;
  --violet: #8d7bff;
  --paper: #f6f2e8;
  --paper-2: #ebe5d6;
  /* deep at 80 % over a bright band: 4.7:1 on coral, more on lamp, sea and paper */
  --deep-80: rgba(11, 16, 53, 0.8);
  --deep-line: rgba(11, 16, 53, 0.2);
  --deep-outline: rgba(11, 16, 53, 0.14);
  /* legacy names, literal values: swarm.js and the sprites read them through getComputedStyle */
  --ink: #0b1035;
  --ink-3: #232c78;
  --sand: #0b1035;
  --shale: #232c78;
  --kelp: #9ca3d6;
  --pebble: #c7cbea;
  --line-paper: #d9d1bf;
  --shell: #ff5a3d;
  --shell-text: #c53014;
  --shell-dark: #ff5a3d;
  --lob-live: #ff5a3d;
  --lob-live-hi: #ff9a80;
  --lob-live-lo: #b3200d;
  --lob-classic: #ff5a3d;
  --lob-classic-hi: #ff9a80;
  --lob-blue: #4f7bd9;
  --lob-blue-hi: #8fb0ff;
  /* per-band aliases: rules use THESE; a band class sets them */
  --bg: var(--deep);
  --fg: var(--foam);
  --fg-2: var(--foam-2);
  --fg-3: var(--foam-3);
  --link: var(--coral);
  --hairline: var(--line);
  --focus: var(--sea);
  --panel: var(--deep-2);

  /* type */
  --font-display: 'Sofia Sans Extra Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --font-body: 'Sofia Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --fs-name: clamp(3.75rem, 1.8rem + 8.6vw, 8rem);
  --fs-title: clamp(2.75rem, 1.4rem + 5.8vw, 6.5rem);
  --fs-sub: clamp(1.625rem, 1.2rem + 1.7vw, 2.5rem);
  --fs-body: 1.0625rem;
  --fs-small: 0.875rem;
  --fs-mono: 0.8125rem;
  --measure: 62ch;
  --measure-lead: 54ch;

  /* shape, depth, space */
  --r-code: 6px;
  --r-slip: 14px;
  --r-panel: 20px;
  --r-pill: 999px;
  --lift: 0 28px 56px -28px rgba(11, 16, 53, 0.55);
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;
  --sp-9: 96px;
  --gutter: clamp(16px, 4vw, 40px);
  --container: 1200px;
  --band-pad: clamp(56px, 7vw, 104px);
  --header-h: 56px;

  /* motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-state: 150ms;
}

@media (min-width: 721px) {
  :root { --header-h: 64px; }
}

/* ---------- Bands: each sets the aliases, the components read them ---------- */
.band-deep {
  --bg: var(--deep);
  --fg: var(--foam);
  --fg-2: var(--foam-2);
  --fg-3: var(--foam-3);
  --link: var(--coral);
  --hairline: var(--line);
  --focus: var(--sea);
  --panel: var(--deep-2);
}

.band-coral,
.band-paper,
.band-lamp,
.band-sea {
  --fg: var(--deep);
  --fg-2: var(--deep-80);
  --fg-3: var(--deep-80);
  --link: var(--deep);
  --hairline: var(--deep-line);
  --focus: var(--deep);
  --panel: var(--deep);
}

.band-coral { --bg: var(--coral); }
.band-lamp { --bg: var(--lamp); }
.band-sea { --bg: var(--sea); }
.band-paper { --bg: var(--paper); --link: var(--coral-ink); }

.band-deep,
.band-coral,
.band-paper,
.band-lamp,
.band-sea {
  background-color: var(--bg);
  color: var(--fg);
}

/* ---------- Language siblings ---------- */
html[data-lang='en'] [data-lang='bg'],
html[data-lang='bg'] [data-lang='en'] {
  display: none !important;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* The header, plus room for a focus ring, so a focused element is never under the sticky rail. */
  scroll-padding-top: calc(var(--header-h) + 10px);
}

body {
  margin: 0;
  background: var(--deep);
  color: var(--foam);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: break-word;
  font-variant-numeric: lining-nums;
}

/* The one texture (DESIGN-R6 §2.3): a fixed grain at 4 %. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2147483647;
  opacity: 0.04;
  background: url('/assets/art/grain-v1.png');
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure,
pre,
blockquote {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0;
  text-wrap: balance;
}

h2 {
  font-size: var(--fs-title);
  line-height: 0.9;
  margin-bottom: var(--sp-5);
}

h3 {
  font-size: var(--fs-sub);
  line-height: 0.95;
}

h4 {
  font-size: 1.625rem;
  line-height: 1;
}

p {
  text-wrap: pretty;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

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

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

::selection {
  background: var(--lamp);
  color: var(--deep);
}

code {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  /* Anchored, so the 1px box never sits past the end of a line and widens the page. */
  inset: 0 auto auto 0;
}

.nobr {
  white-space: nowrap;
}

/* Icons (DESIGN-R7 §2): one external sprite; stroke and fill come from the symbol, colour from the
   context. An icon always labels something. */
.ico {
  flex: none;
  width: 1.25em;
  height: 1.25em;
  vertical-align: -0.25em;
  overflow: visible;
}

/* The icon tile: 40px, the owner's role colour, the icon in navy. */
.ico-tile {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--role);
  color: var(--deep);
}

.ico-tile .ico {
  width: 24px;
  height: 24px;
}

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

.band {
  padding-block: var(--band-pad);
}

.intro {
  max-width: var(--measure);
  color: var(--fg-2);
  font-size: 1.125rem;
}

.skip-link {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-4);
  z-index: 60;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-code);
  background: var(--lamp);
  color: var(--deep);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-200%);
}

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

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-pill);
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1.2;
  text-decoration: none;
}

/* On a bright band: a navy pill with foam text (16:1). */
.btn-deep {
  background: var(--deep);
  color: var(--foam);
}

.btn-deep:hover {
  background: var(--deep-3);
}

.btn-deep:focus-visible {
  outline-color: var(--deep);
}

/* ---------- The step marker: "2/7 The box", the nav's own words ---------- */
.step {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  padding: 3px 14px 3px 3px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  color: var(--fg);
  font-size: var(--fs-small);
  font-weight: 700;
  line-height: 1.4;
}

.step-n {
  padding: 2px 10px;
  border-radius: var(--r-pill);
  background: var(--fg);
  color: var(--bg);
  font-variant-numeric: tabular-nums;
}

/* ---------- Header: the run rail (states are run.css's) ---------- */
.site-header {
  --bg: var(--deep);
  --fg: var(--foam);
  --fg-2: var(--foam-2);
  --fg-3: var(--foam-3);
  --link: var(--coral);
  --hairline: var(--line);
  --focus: var(--sea);
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--deep);
  color: var(--foam);
  border-bottom: 1px solid var(--line);
}

.run {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  flex: none;
  color: var(--foam);
  text-decoration: none;
}

.brand-mark {
  display: inline-block;
  flex: none;
  width: 28px;
  height: 28px;
  color: var(--coral);
}

.brand-mark svg {
  display: block;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.625rem;
  font-weight: 800;
  line-height: 1;
}

/* Without run.js the pill has nothing to open: run.css shows it (under .js, below 1100px) and
   turns the list into its panel. */
.run-pill {
  display: none;
}

.run-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px var(--sp-1);
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
  counter-reset: none;
}

.run-steps a {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--r-pill);
  color: var(--foam-2);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.run-steps a:hover {
  color: var(--foam);
  background: var(--deep-2);
}

/* The state glyph: every step is "todo" (a hollow ring) until run.js says otherwise. */
.run-state {
  flex: none;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.lang-toggle {
  flex: none;
  min-width: 44px;
  min-height: 40px;
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--foam);
  font: 700 0.875rem / 1 var(--font-body);
  cursor: pointer;
}

.lang-toggle:hover {
  background: var(--deep-2);
}

/* Without JavaScript the language button cannot work, so it is not offered. */
html:not(.js) .lang-toggle {
  display: none;
}

/* The scroll progress bar along the header's bottom edge; run.js sets --p (0 to 1). */
.run-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--sea);
  transform: scaleX(var(--p, 0));
  transform-origin: 0 50%;
  pointer-events: none;
}

/* Narrow screens without the panel: the steps wrap as a row under the brand. */
@media (max-width: 1099px) {
  .run {
    flex-wrap: wrap;
    row-gap: 0;
    padding-block: var(--sp-1);
  }

  .run-steps {
    order: 3;
    width: 100%;
    margin: 0;
    padding-bottom: var(--sp-1);
  }

  .run-steps a {
    min-height: 36px;
    padding-inline: var(--sp-2);
    font-size: 0.875rem;
  }

  .lang-toggle {
    margin-left: auto;
  }

  /* A wrapped rail is tall: it scrolls away rather than covering the page. */
  html:not(.js) .site-header {
    position: relative;
  }
}

@media (min-width: 1100px) {
  .run-steps {
    flex-wrap: nowrap;
  }
}

/* ---------- 1 · #task, the hero ---------- */
.hero {
  position: relative;
  /* The stage's glow reaches past the stage; it never widens the page. */
  overflow-x: clip;
  padding-block: var(--sp-6) var(--sp-5);
}

.hero-wrap {
  --floor-min: 232px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(var(--floor-min), auto) auto;
}

/* Hook box: the swarm fills the whole band, behind the copy; the floor is what the copy and the
   foot leave free (swarm.js reads the two data-swarm-avoid rects). */
.swarm {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.hero .step,
.hero-grid,
.hero-foot {
  position: relative;
  z-index: 1;
}

.hero .step {
  justify-self: start;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-6);
  align-items: start;
}

@media (min-width: 1024px) {
  .hero-grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: var(--sp-7);
  }
}

.hero h1 {
  color: var(--fg);
}

.hero-name {
  display: flex;
  align-items: center;
  gap: 0.14em;
  font-size: var(--fs-name);
  line-height: 0.84;
}

/* A face, early: the portrait's head in a circle beside the name (CSS crop of the 1:2 file). */
.hero-avatar {
  flex: none;
  align-self: center;
  width: 0.78em;
  height: 0.78em;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 2%;
  background: var(--deep-3);
  outline: 2px solid var(--coral);
  outline-offset: 3px;
}

.hero-line {
  display: block;
  margin-top: var(--sp-4);
  max-width: 22ch;
  font-size: var(--fs-sub);
  line-height: 1;
  color: var(--coral);
}

/* The proof: three links, one per line; run.css draws each ring and its tick. */
.proof {
  display: grid;
  gap: var(--sp-1);
  margin-top: var(--sp-5);
  padding: 0;
  list-style: none;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
}

.proof li {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.proof a {
  color: var(--fg);
  text-decoration-color: var(--fg-3);
}

.proof a:hover {
  color: var(--sea);
}

.hero-lead {
  max-width: var(--measure-lead);
  margin-top: var(--sp-5);
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--fg-2);
}

/* Desktop (DESIGN-R6 review 1, P3): the crew and both machines on the first screen at 1440x900, so
   the copy column closes up: less air around the hook, the proof and the lead, and a hook wide enough
   to set on two lines in Bulgarian too. Phones keep their rhythm. */
@media (min-width: 1024px) {
  .hero { padding-top: var(--sp-5); }
  .hero .step { margin-bottom: var(--sp-3); }
  .hero-name { line-height: 0.82; }
  .hero-line { margin-top: var(--sp-3); max-width: 30ch; line-height: 0.96; }
  /* P3b: the three ticked links in one row (Bulgarian may wrap to two). */
  .proof {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1) var(--sp-5);
    margin-top: var(--sp-4);
    font-size: 1rem;
  }
  .proof li { gap: var(--sp-2); }
  .hero-lead { margin-top: var(--sp-3); font-size: 1.125rem; line-height: 1.5; }
}

/* ---------- The crew console: box and static look (run.js and run.css bring it to life) ---------- */
.console {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--deep-2);
  color: var(--foam);
}

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--line);
}

.console-head h2 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
}

.console-state {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--foam-2);
  font-size: 0.8125rem;
  font-weight: 600;
}

.console-state::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--foam-3);
}

.console-state[data-state='done']::before { background: var(--sea); }
.console-state[data-state='running']::before { background: var(--lamp); }

/* The trace: one machine line per step. tr-k colours by kind (§5): task foam, plan lamp, tool
   coral, check violet, done sea. */
.trace {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  line-height: 1.55;
}

.tr {
  display: grid;
  grid-template-columns: 4.5ch minmax(0, 1fr) auto;
  column-gap: var(--sp-3);
  align-items: baseline;
}

.tr-k {
  font-weight: 700;
  color: var(--foam);
}

.tr[data-kind='plan'] .tr-k { color: var(--lamp); }
.tr[data-kind='tool'] .tr-k { color: var(--coral); }
.tr[data-kind='check'] .tr-k { color: var(--violet); }
.tr[data-kind='done'] .tr-k { color: var(--sea); }

.tr-t {
  grid-column: 2;
  color: var(--foam-2);
}

.tr-v {
  grid-column: 3;
  color: var(--foam);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tr[data-kind='done'] .tr-t { color: var(--foam); }

.tr time { white-space: nowrap; }

@media (min-width: 1024px) {
  .trace { font-size: 0.875rem; }
}

/* Phones: the last four lines of the trace. */
@media (max-width: 720px) {
  .trace > .tr:nth-last-child(n + 5) { display: none; }
}

.console-result:empty {
  display: none;
}

.console-ask {
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
  color: var(--foam);
  font-weight: 700;
  font-size: 0.9375rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.chip {
  min-height: 40px;
  padding: var(--sp-2) 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--foam);
  font: 600 0.875rem / 1.2 var(--font-body);
  text-align: left;
  cursor: pointer;
}

/* Hover only where there is one: after a tap on a phone a chip must not stay coral. */
@media (hover: hover) {
  .chip:hover {
    border-color: var(--coral);
    background: var(--coral);
    color: var(--deep);
  }
}

.console-note {
  color: var(--foam-3);
  font-size: 0.8125rem;
  line-height: 1.45;
}

/* No JavaScript, no agent: the task chips and their prompt are not offered. */
html:not(.js) .console-ask,
html:not(.js) .chips {
  display: none;
}

/* ---------- The stage on its dock (DESIGN-R7 §3a): the boxes are ours, the machines' placement is
   swarm.css's ---------- */
/* The machines' sizes live on the wrap, so the dock can be drawn from them. --cb-over is how far
   swarm.css steps the small box left of the stage (a share of --stage-w). */
.hero-wrap {
  --stage-w: 150px;
  --cb-over: 0.48;
  --dock-gap: var(--sp-4);
  /* The Workstation's lid starts 8 % down the stage, so a small top pad reads the same as the bottom one. */
  --dock-pt: var(--sp-1);
  --dock-pb: var(--sp-5);
  --dock-w: calc(var(--stage-w) * (1 + var(--cb-over)) + 2 * var(--sp-4));
}

@media (min-width: 721px) {
  .hero-wrap { --stage-w: 220px; --cb-over: 0.24; }
}

/* From 1024px the dock is the console's column (the hero grid's 5fr), so the right column reads
   console, gap, dock: one edge, one width, one radius. */
@media (min-width: 1024px) {
  .hero-wrap { --dock-gap: var(--sp-5); --dock-w: calc((100% - var(--sp-7)) * 5 / 12); }
}

@media (min-width: 1280px) {
  .hero-wrap { --stage-w: 280px; --cb-over: 0.12; }
}

/* The dock: a lamp floor under both machines. It is an in-flow grid item in the floor row, so it
   paints under the swarm (the crew walks onto it to deliver) and under the stage. */
.hero-wrap::before {
  content: '';
  grid-row: 3;
  grid-column: 1;
  justify-self: end;
  align-self: end;
  width: var(--dock-w);
  height: calc(var(--stage-w) * 0.95 + var(--dock-pt) + var(--dock-pb));
  border-radius: var(--r-panel);
  background: var(--lamp);
}

/* The stage sits on the dock, the machine pair centred across it; ink and focus turn navy. */
.stage {
  grid-row: 3;
  grid-column: 1;
  justify-self: end;
  align-self: end;
  position: relative;
  z-index: 1;
  pointer-events: none;
  width: var(--stage-w);
  aspect-ratio: 20 / 19;
  margin: calc(var(--dock-gap) + var(--dock-pt)) calc((var(--dock-w) - var(--stage-w) * (1 + var(--cb-over))) / 2) var(--dock-pb) 0;
  --focus: var(--deep);
}

.hw {
  pointer-events: auto;
  position: absolute;
  display: block;
  color: var(--deep);
  text-decoration: none;
}

.hw img {
  display: block;
  width: 100%;
  height: auto;
}

/* Ink on lamp: the name 11.7:1, the platform line at 80 % 7.6:1. */
.hw-name {
  display: block;
  color: var(--deep);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
}

.hw-name small {
  display: block;
  color: var(--deep-80);
  font-size: 0.8125rem;
  font-weight: 500;
}

.hw-workstation .hw-name {
  text-align: right;
}

.hw:hover .hw-name,
.hw:focus-visible .hw-name {
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.hw:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
  border-radius: 10px;
}

/* Review finding 8: the small box stands in front of the Workstation and hid part of its ring, and the
   Workstation's label sits outside the link's box. So its ring is drawn by a pseudo-element raised over
   the small box (the link itself stays behind it: raising the link would put the big box in front),
   and its label gets the same ring. */
.hw-workstation:focus-visible {
  outline: none;
}

.hw-workstation:focus-visible::after,
.hw-workstation:focus-visible .hw-name {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
  border-radius: 10px;
}

.hw-workstation:focus-visible::after {
  content: '';
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
}

@media (max-width: 720px) {
  .hw-name small { display: none; }
}

/* Contact shadows on the dock: a tight navy core where the case meets the floor, a soft penumbra
   around it (seat: 16 % of the image tall). */
.hw::before {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0 auto auto 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(11, 16, 53, 0.5), rgba(11, 16, 53, 0.24) 55%, rgba(11, 16, 53, 0));
  pointer-events: none;
}

/* The crab's own contact shadow on the lid, under its feet (the image's feet line is 86 % down); it
   stays put while the crab jumps. */
.crab-perch {
  isolation: isolate;
}

/* Only once swarm.js has put the crab there: no crab without JavaScript, so no shadow either. */
.crab-perch:not(:empty)::before {
  content: '';
  position: absolute;
  left: 14%;
  right: 14%;
  top: 77%;
  height: 17%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(3, 5, 20, 0.8), rgba(3, 5, 20, 0));
}

.hw-workstation::before {
  width: 88%;
  margin: 47.2% 0 0 6%;
  aspect-ratio: 88 / 8.68;
}

.hw-clawbox::before {
  width: 92%;
  margin: 51.7% 0 0 4%;
  aspect-ratio: 92 / 9.5;
}

/* The intake: the fan in the ClawBox lid, lit on each delivery (swarm.js places, swarm.css plays). */
.stage .fx,
.fx > * {
  position: absolute;
  pointer-events: none;
}

.stage .fx { inset: 0; }

.fx > *,
.swarm .ring { opacity: 0; }

.fx svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.fx .fan {
  border-radius: 50%;
  mix-blend-mode: screen;
  background: radial-gradient(closest-side, #d6fff6, var(--sea) 30%, rgba(47, 224, 194, 0.3) 70%, rgba(47, 224, 194, 0));
}

/* R7: a release flashes foam, not lamp (the lobster artist's value): where the flash overfills the lid
   it lands on the lamp dock. The gold of a release is the slip itself, flying in. */
.fx .fan.is-release {
  background: radial-gradient(closest-side, #ffffff, var(--foam) 35%, rgba(246, 242, 232, 0.35) 70%, rgba(246, 242, 232, 0));
}

/* The check rises off the small box: over its dark lid, the Workstation's face or (below 1280px,
   where the box steps clear of the Workstation) the lamp dock. A navy disc keeps it readable on all. */
.fx .tick {
  box-sizing: content-box;
  margin: -3px;
  padding: 3px;
  border-radius: 50%;
  background: var(--deep);
  color: var(--sea);
}

.fx .is-release ~ .tick { color: var(--foam); }

.fx .tick path {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Coral sparks (the lobster artist's value) with a navy rim: they fly off the dark box and over the lamp
   dock, readable on both. */
.fx .spark {
  border-radius: 50%;
  outline: 1px solid var(--deep);
  background: var(--coral);
}

.fx .spark:nth-child(4) { --dx: calc(var(--bw) * -0.26); --dy: calc(var(--bw) * -0.08); }
.fx .spark:nth-child(5) { --dx: calc(var(--bw) * -0.26); --dy: calc(var(--bw) * -0.24); }
.fx .spark:nth-child(6) { --dx: calc(var(--bw) * -0.07); --dy: calc(var(--bw) * -0.22); }
.fx .spark:nth-child(7) { --dx: calc(var(--bw) * 0.1); --dy: calc(var(--bw) * -0.31); }
.fx .spark:nth-child(8) { --dx: calc(var(--bw) * 0.18); --dy: calc(var(--bw) * -0.17); }
.fx .spark:nth-child(9) { --dx: calc(var(--bw) * 0.37); --dy: calc(var(--bw) * -0.12); }

/* The release ring runs on the floor round the small box, which is the lamp dock now: navy ink, as
   on every other mark on the dock (lamp on lamp vanishes). */
.swarm .ring {
  z-index: 1;
  border: 2px solid var(--deep);
  border-radius: 50%;
}

/* The foot: the caption and the live line. */
.hero-foot {
  grid-row: 4;
  grid-column: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: start;
  gap: var(--sp-1);
  min-width: 0;
  margin-top: var(--sp-3);
}

/* From 1280px the foot sits in the copy column, its last line on the dock's bottom edge (so the caption
   stays on the first screen at 1440x900). Not below that: swarm.js lifts the delivery lane above any
   keep-out left of the small box, and there the foot would sit beside the box and push the lane up to
   its top edge. */
@media (min-width: 1280px) {
  .hero-foot {
    grid-row: 3;
    align-self: end;
    width: calc((100% - var(--sp-7)) * 7 / 12);
  }
}

.hero-caption,
.hero-live {
  font-size: var(--fs-small);
  line-height: 1.5;
}

.hero-caption {
  max-width: 72ch;
  color: var(--fg-3);
}

/* No JavaScript, no lobsters: the caption that explains them is not shown (review finding 14). */
html:not(.js) .hero-caption {
  display: none;
}

.hero-live {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--fg-2);
}

.hero-live li {
  display: none;
}

.hero-live li.is-in {
  display: flex;
  align-items: baseline;
  column-gap: var(--sp-2);
  max-width: 80ch;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.hero-live li.is-in > a {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-dot,
.live-k,
.live-meta {
  flex: none;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sea);
  vertical-align: 1px;
}

.hero-live.is-shipped .live-dot {
  background: var(--lamp);
}

.live-k,
.live-meta {
  color: var(--fg-3);
}

/* Phones: "Latest in: repo · date" on line 1, the title under it, two lines held open. */
@media (max-width: 720px) {
  .hero-live li.is-in {
    display: grid;
    grid-template-columns: 8px auto minmax(0, 1fr);
    grid-template-areas: 'dot k meta' '. title title';
    white-space: normal;
  }

  .live-dot { grid-area: dot; }
  .live-k { grid-area: k; }
  .live-meta { grid-area: meta; }

  .hero-live li.is-in > a {
    grid-area: title;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    min-height: 3em;
  }
}

@media (max-width: 360px) {
  .hero-wrap { --floor-min: 200px; }
}

/* ---------- 2 · #box, coral ---------- */
.box-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-6);
  align-items: start;
}

@media (min-width: 1024px) {
  .box-grid {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: var(--sp-8);
  }
}

.box-text p {
  max-width: var(--measure);
}

.box-text p + p {
  margin-top: var(--sp-4);
}

.box-lead {
  font-size: 1.1875rem;
  line-height: 1.5;
  font-weight: 600;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3) var(--sp-5);
  margin-top: var(--sp-6);
  padding: 0;
  list-style: none;
  font-weight: 700;
}

/* The screenshot in a navy bezel, lifted off the coral. */
.box-figure {
  min-width: 0;
}

.box-shot {
  width: 100%;
  padding: 10px;
  border-radius: 16px;
  background: var(--deep-3);
  box-shadow: var(--lift);
}

.box-figure figcaption {
  margin-top: var(--sp-3);
  color: var(--fg);
  font-size: var(--fs-small);
  line-height: 1.5;
}

@media (min-width: 1280px) {
  .box-figure { margin-right: -40px; }
}

.feats-title {
  margin-top: var(--sp-7);
  margin-bottom: var(--sp-4);
}

/* Three dark slips on coral: thumbnail, title, one sentence. */
.feats {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4);
  padding: 0;
  list-style: none;
}

@media (min-width: 721px) {
  .feats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.feat {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-5);
  border-radius: var(--r-slip);
}

.feat-shot {
  display: block;
  overflow: hidden;
  border-radius: 8px;
}

.feat-shot img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
}

.feat h4,
.feat p {
  padding-inline: var(--sp-2);
}

@media (max-width: 720px) {
  .feat {
    grid-template-columns: 112px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    gap: var(--sp-1) var(--sp-3);
    padding: var(--sp-3);
  }

  .feat-shot { grid-row: 1 / 3; align-self: start; }
  .feat-shot img { aspect-ratio: 4 / 5; }
  .feat h4 { font-size: 1.375rem; padding-inline: 0; }
  .feat p { padding-inline: 0; font-size: 0.875rem; }
}

.feat p {
  color: var(--fg-2);
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* Two sizes (DESIGN-R7 §3b): two deep picture cards in the feature cards' language. From 1200px the
   heading takes the first of the three feature columns and the cards the other two, so they line up
   with the cards above; from 900px the cards' rows (picture, name, line, memory, specs, links) line
   up across the pair through subgrid, so the two memory bars sit on one line. */
.sizes {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4);
  margin-top: var(--sp-7);
}

.sizes h3 {
  margin-bottom: var(--sp-3);
}

.sizes-p {
  max-width: var(--measure);
}

.size {
  display: grid;
  grid-template-rows: repeat(6, auto);
  align-content: start;
  row-gap: 6px;
  padding: var(--sp-3) var(--sp-3) 20px;
  border-radius: var(--r-slip);
}

.size > :not(.size-pic) {
  padding-inline: var(--sp-2);
}

/* The picture (the owner's R4 ruling: the transparent cut-outs, never photos): each machine stands on a
   lamp panel, as on the hero's dock, on one baseline. Widths keep the stage's ratio (52 : 100), so the
   two cards show the size difference at a glance. */
.size-cb { --pic-w: 41.6%; }
.size-ws { --pic-w: 80%; }

.size-pic {
  position: relative;
  aspect-ratio: 16 / 9;
  margin-bottom: var(--sp-1);
  border-radius: 8px;
  background: var(--lamp);
}

.size-pic img {
  position: absolute;
  left: 50%;
  bottom: 13%;
  width: var(--pic-w);
  translate: -50% 0;
}

/* Its contact shadow: the hero's, scaled to the machine (90 % of its width, a tenth as tall). */
.size-pic::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(13% - var(--pic-w) * 0.03);
  width: calc(var(--pic-w) * 0.9);
  aspect-ratio: 10 / 1;
  translate: -50% 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(11, 16, 53, 0.5), rgba(11, 16, 53, 0.24) 55%, rgba(11, 16, 53, 0));
}

/* The name and its platform on one baseline, as on the hero's dock. */
.size-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--sp-3);
}

.size-name p {
  color: var(--fg-3);
  font-size: var(--fs-small);
  font-weight: 600;
}

.size-line {
  color: var(--fg-2);
  font-size: 0.9375rem;
  line-height: 1.5;
}

/* Memory: label and value, then a bar on one scale for both cards (8 of 128 GB). The bars are
   decoration; the value is the text. */
.mem {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: end;
  align-items: baseline;
  column-gap: var(--sp-2);
  margin-top: var(--sp-1);
  font-size: 0.9375rem;
  line-height: 1.4;
}

.mem > * {
  grid-row: 1;
}

.mem > :not(b) {
  color: var(--fg-3);
}

.mem b {
  color: var(--fg);
  font-weight: 700;
}

.mem::before,
.mem::after {
  content: '';
  grid-row: 2;
  grid-column: 1 / -1;
  height: 10px;
  margin-top: 6px;
  border-radius: var(--r-pill);
}

/* The track must read (review finding 9): foam at 38 %, 3.3:1 on the card, so 8 of 128 is seen as a share. */
.mem::before {
  background: rgba(246, 242, 232, 0.38);
}

.mem::after {
  justify-self: start;
  width: 100%;
  background: var(--lamp);
}

.size-cb .mem::after {
  width: 6.25%;
}

.specs {
  display: grid;
  gap: 2px;
  margin-top: var(--sp-1);
  padding-block: 0;
  list-style: none;
  color: var(--fg-2);
  font-size: 0.875rem;
  line-height: 1.4;
}

/* A 20px icon on the first line of its row (line box 19.6px), so a wrapped row keeps its icon on top. */
.specs li {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
}

.specs .ico {
  width: 20px;
  height: 20px;
  color: var(--lamp);
}

/* 16px and a 16px gap, so the Workstation's two Bulgarian links (the longest pair) stay on one line in
   a 1200px card; a wrap there opens a hole in the ClawBox card across the shared row. */
.row-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  margin-top: var(--sp-1);
  font-size: 1rem;
  font-weight: 700;
}

/* 600 to 899px: one card per row, the picture on the left. */
@media (min-width: 600px) and (max-width: 899px) {
  .size {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    grid-template-rows: repeat(5, auto) 1fr;
    column-gap: var(--sp-3);
  }

  /* The panel runs the card's full height; the machine keeps its baseline near the bottom. */
  .size-pic {
    grid-row: 1 / -1;
    aspect-ratio: auto;
    min-height: 160px;
    margin: 0;
  }
}

@media (min-width: 900px) {
  .sizes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 0;
  }

  .sizes-head {
    grid-column: 1 / -1;
    margin-bottom: var(--sp-5);
  }

  .size {
    grid-row: span 6;
    grid-template-rows: subgrid;
  }
}

/* The heading column only from 1200px (review finding 10b): narrower, the Workstation card's longer
   lines wrap and open holes in the ClawBox card across the shared rows. */
@media (min-width: 1200px) {
  .sizes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sizes-head {
    grid-column: 1;
    grid-row: 1 / span 6;
    margin-bottom: 0;
    padding-right: var(--sp-5);
  }
}

/* ---------- 3 · #better, deep: four habits, a diagram and receipts each ---------- */
#h-whole { --role: var(--sea); }
#h-errors { --role: var(--coral); }
#h-docs { --role: var(--lamp); }
#h-guard { --role: var(--violet); }

.habits {
  margin-top: var(--sp-6);
}

.habit {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-5);
  padding: var(--sp-4) 0 var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--hairline);
}

.habit:last-child {
  border-bottom: 1px solid var(--hairline);
}

/* The habit's role colour: a 6px bar at the row's left edge. */
.habit::before {
  content: '';
  position: absolute;
  left: 0;
  top: var(--sp-4);
  bottom: var(--sp-4);
  width: 6px;
  border-radius: 3px;
  background: var(--role);
}

/* The text comes first in the DOM (a keyboard reaches the receipts before "Play again"); below 900px
   the picture still leads visually. */
@media (max-width: 899px) {
  .habit > .diagram,
  .habit > .diagram-fig {
    order: -1;
  }
}

/* From 900px up (review 2: at 768 the diagram column was 285px and its mono text 10px). Below that
   the row stacks, diagram first, and the panel keeps its 492px cap. */
@media (min-width: 900px) {
  .habit {
    grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
    column-gap: var(--sp-7);
    align-items: start;
  }

  .habit > .diagram,
  .habit > .diagram-fig {
    grid-column: 2;
    grid-row: 1;
  }

  .habit-text {
    grid-column: 1;
    grid-row: 1;
  }
}

/* The habit's icon tile stands in front of its title; the sentence and the receipts run full width. */
.habit-text {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  column-gap: var(--sp-4);
  align-items: start;
}

.habit-text > :not(.ico-tile, h3) {
  grid-column: 1 / -1;
}

.habit-line {
  max-width: var(--measure-lead);
  margin-top: var(--sp-3);
  color: var(--fg-2);
}

/* Receipts: paper slips, even on deep, with the one notch on the page (a CSS mask on the slip's
   paper, so the focus ring on the link itself is never clipped). */
.receipts {
  display: grid;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
  padding: 0;
  list-style: none;
}

.receipt {
  --fg: var(--deep);
  --fg-2: var(--deep-80);
  position: relative;
  isolation: isolate;
  display: grid;
  gap: 2px;
  padding: 10px var(--sp-4) 12px 26px;
  border-radius: var(--r-slip);
  color: var(--deep);
  text-decoration: none;
}

.receipt::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: var(--r-slip);
  background: var(--paper);
  -webkit-mask: radial-gradient(circle 7px at 0 50%, transparent 6.5px, #000 7px);
  mask: radial-gradient(circle 7px at 0 50%, transparent 6.5px, #000 7px);
}

.receipt-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--sp-3);
  color: var(--deep-80);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.receipt-repo {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--deep);
}

.receipt-text {
  font-size: 0.9375rem;
  line-height: 1.45;
}

.receipt:hover .receipt-text {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.receipt:focus-visible {
  outline-offset: 2px;
}

.better-total {
  max-width: var(--measure);
  margin-top: var(--sp-6);
  color: var(--fg-2);
}

/* ---------- 4 · #projects, paper ---------- */
.tiles {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-5);
  margin-top: var(--sp-7);
}

@media (min-width: 721px) {
  .tiles { grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: start; }
  .tile-live { grid-column: span 12; }
  .tile-hollow,
  .tile-invaders { grid-column: span 7; }
  .tile-meter,
  .tile-guard { grid-column: span 5; }
}

.tile {
  --bg: var(--paper-2);
  --link: var(--deep);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-5);
  border-radius: var(--r-slip);
  background: var(--bg);
}

.tile:not(.tile-live) > :not(.tile-img, .guard-panel) {
  padding-inline: var(--sp-2);
}

.tile h3 {
  margin-top: var(--sp-2);
  font-size: clamp(1.875rem, 1.4rem + 1.6vw, 2.75rem);
}

.tile-line {
  max-width: 60ch;
  font-size: 1.0625rem;
  line-height: 1.5;
}

.tile-more,
.tile-note {
  max-width: 60ch;
  color: var(--fg-2);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.tile-note {
  font-size: var(--fs-small);
}

.tile-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  margin-top: auto;
  padding-top: var(--sp-2);
  font-weight: 700;
}

.tile-img {
  overflow: hidden;
  border-radius: 10px;
  outline: 1px solid var(--deep-outline);
  outline-offset: -1px;
}

.tile-img img {
  width: 100%;
}

/* model-guard's routing table (COPY-R6 "p-guard, revised"): mono, on a navy panel. */
.guard-panel {
  padding: var(--sp-3) var(--sp-4);
  border-radius: 10px;
}

.guard-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.guard-table th,
.guard-table td {
  padding: var(--sp-2) var(--sp-3) var(--sp-2) 0;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
  vertical-align: top;
}

.guard-table th {
  color: var(--fg-3);
  font-weight: 400;
  vertical-align: bottom;
}

.guard-table tr:last-child td {
  border-bottom: 0;
}

.guard-table code {
  font-size: inherit;
  font-weight: 700;
}

/* At 320px the Bulgarian table's longest words (най-големият, подразбиране) set three columns wider than
   the tile (review finding 16): a tighter panel and cell gap, one point smaller. */
@media (max-width: 360px) {
  .guard-panel { padding-inline: var(--sp-3); }
  .guard-table { font-size: 0.75rem; }
  .guard-table th,
  .guard-table td { padding-right: var(--sp-2); }
}


.tile-img-dark {
  background: var(--deep);
}

.install {
  max-width: 100%;
}

.install code {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-code);
  background: var(--deep);
  color: var(--foam);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* The feature tile: deep, full width; text and the requests left, two app screens right. */
.tile-live {
  --bg: var(--deep);
  --link: var(--coral);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-6);
  padding: var(--sp-5);
  border-radius: var(--r-panel);
}

.tile-live h3 {
  margin-top: 0;
  font-size: clamp(2.25rem, 1.4rem + 3vw, 4rem);
  line-height: 0.92;
}

.live-text {
  display: grid;
  gap: var(--sp-4);
  align-content: start;
}

.live-how {
  max-width: 60ch;
  color: var(--fg-2);
}

.live-requests {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4);
  margin-top: var(--sp-2);
}

@media (min-width: 721px) {
  .live-requests { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.live-request {
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}

.live-request h4 {
  font-size: 1.625rem;
}

.request {
  margin-top: var(--sp-2);
  color: var(--fg-2);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.request-k {
  color: var(--fg);
  font-weight: 700;
}

.live-request .tile-links {
  margin-top: var(--sp-2);
  padding-inline: 0;
}

.live-shots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-4);
  align-self: center;
}

.live-shots img {
  width: 100%;
  border-radius: var(--r-slip);
  outline: 1px solid var(--line);
  outline-offset: -1px;
}

@media (min-width: 1024px) {
  .tile-live {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: var(--sp-7);
    /* The strip diagram (and its replay button) closes the text column: no empty band under it. */
    padding: var(--sp-7) var(--sp-7) var(--sp-4);
  }
}

/* ---------- 5 · #numbers, lamp ---------- */
.counts {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-6);
  margin-top: var(--sp-6);
  padding: 0;
  list-style: none;
  text-align: center;
}

/* Three across, each column as wide as its numeral or its line, so the widest count (3,700+) keeps
   the full display size. */
@media (min-width: 721px) {
  .counts {
    grid-template-columns: repeat(3, auto);
    justify-content: space-between;
    gap: var(--sp-5);
    text-align: left;
  }
}

.count {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: var(--sp-2);
}

@media (min-width: 721px) {
  .count { justify-items: start; }
}

.count-n {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(5rem, 13vw, 12.5rem);
  line-height: 0.82;
  white-space: nowrap;
}

.count-line {
  max-width: 30ch;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
}

.count-link {
  font-weight: 700;
}

.ranks {
  max-width: 70ch;
  margin-top: var(--sp-7);
  padding-top: var(--sp-5);
  border-top: 2px solid var(--fg);
  font-size: 1.0625rem;
}

.log-wrap {
  margin-top: var(--sp-7);
}

.log-title {
  margin-bottom: var(--sp-4);
}

.log {
  display: grid;
  gap: var(--sp-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.log-line {
  position: relative;
  padding-left: 22px;
  line-height: 1.45;
}

.log-line .dot {
  position: absolute;
  left: 2px;
  top: 0.45em;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--deep);
}

.log-line > a {
  font-weight: 600;
}

.log-meta {
  color: var(--fg-2);
  font-size: var(--fs-small);
  white-space: nowrap;
}

.log-more {
  margin-top: var(--sp-4);
}

.log-more summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: var(--sp-2) var(--sp-4);
  border: 2px solid var(--deep);
  border-radius: var(--r-pill);
  font-weight: 700;
  cursor: pointer;
}

.log-more summary:hover {
  background: var(--deep);
  color: var(--lamp);
}

.log-more[open] summary {
  margin-bottom: var(--sp-4);
}

.log-more .log-line {
  padding-left: 0;
}

.log-stamp {
  max-width: 70ch;
  margin-top: var(--sp-5);
  color: var(--fg-2);
  font-size: var(--fs-small);
}

/* ---------- 6 · #crew, deep ---------- */
#crew .intro {
  margin-bottom: var(--sp-6);
}

.rules {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4);
  margin-top: var(--sp-6);
}

@media (min-width: 1024px) {
  .rules { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

#r-refute { --role: var(--violet); }
#r-box { --role: var(--sea); }
#r-night { --role: var(--lamp); }

.rule {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-slip);
  background: var(--deep-2);
}

.rule h3 {
  font-size: clamp(1.75rem, 1.4rem + 1vw, 2.25rem);
}

.rule-how {
  color: var(--fg-2);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.rule-lesson {
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.rule-lesson b {
  color: var(--lamp);
  font-weight: 700;
}

.crew-same {
  max-width: var(--measure);
  margin-top: var(--sp-6);
  color: var(--fg-2);
}

.crew-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-6);
  margin-top: var(--sp-4);
  padding: 0;
  list-style: none;
  font-weight: 700;
}

/* ---------- 7 · #handoff, sea ---------- */
.handoff-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-7);
  align-items: end;
}

/* The portrait's column is fixed: as `auto` it grew to its caption's one-line width and squeezed the
   title into three lines in Bulgarian. */
@media (min-width: 900px) {
  .handoff-grid { grid-template-columns: minmax(0, 1fr) 280px; }
}

.run-summary {
  font-family: var(--font-display);
  font-size: var(--fs-sub);
  font-weight: 800;
  line-height: 1;
}

.handoff-why {
  max-width: 50ch;
  margin-top: var(--sp-4);
  font-size: 1.1875rem;
  line-height: 1.5;
}

.handoff-mail {
  margin-top: var(--sp-6);
}

.handoff-mail .btn {
  gap: var(--sp-3);
  font-size: clamp(1.0625rem, 0.9rem + 0.8vw, 1.375rem);
  padding-inline: var(--sp-5) var(--sp-6);
}

.handoff-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  margin-top: var(--sp-5);
  padding: 0;
  list-style: none;
  font-weight: 700;
}

.handoff-portrait {
  justify-self: start;
  width: min(100%, 280px);
}

.portrait {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 12%;
  border-radius: var(--r-panel);
  box-shadow: var(--lift);
}

.handoff-human {
  margin-top: var(--sp-3);
  font-size: var(--fs-small);
  line-height: 1.5;
}

@media (min-width: 900px) {
  .handoff-portrait { justify-self: end; }
}

@media (max-width: 720px) {
  .handoff-portrait { width: 200px; }
}

/* ---------- Footer, deep ---------- */
.site-footer {
  padding-block: var(--sp-8) var(--sp-7);
  border-top: 1px solid var(--line);
  font-size: var(--fs-small);
}

.footer-inner {
  display: grid;
  gap: var(--sp-3);
}

.footer-nav ol {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1) var(--sp-5);
  margin-bottom: var(--sp-4);
  padding: 0;
  list-style: none;
  font-weight: 700;
}

.footer-nav a {
  color: var(--foam);
}

.footer-line,
.footer-copy {
  max-width: 80ch;
  color: var(--fg-3);
}

.footer-copy {
  margin-top: var(--sp-3);
}

/* ---------- Motion: opt-in only ---------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  .chip,
  .run-steps a,
  .btn,
  .log-more summary {
    transition: background-color var(--t-state) var(--ease), color var(--t-state) var(--ease),
      border-color var(--t-state) var(--ease);
  }

  .receipt {
    transition: transform var(--t-state) var(--ease);
  }

  .receipt:hover,
  .receipt:focus-visible {
    transform: translateY(-2px);
  }

  .tile-img img {
    transition: transform 300ms var(--ease);
  }

  .tile:has(.tile-main:hover) .tile-img img,
  .tile:has(.tile-main:focus-visible) .tile-img img {
    transform: scale(1.02);
  }

  /* The memory bars fill once when "Two sizes" is seen (run.js adds .is-seen). They wait empty only
     once run.js is running (it marks the header .has-run): without JavaScript, if run.js fails, or with
     reduced motion, they are full from the start. */
  .mem::after {
    transform-origin: left;
    transition: transform 1100ms var(--ease) 150ms;
  }

  .has-run ~ main .sizes:not(.is-seen) .mem::after {
    transform: scaleX(0);
  }
}
