/* ═══════════════════════════════════════════════════════
   Bear Hunt, Demystified — Cracktro Scroll, re-voiced
   Kingshot world: navy-black night · parchment · one amber
   signal · oxblood rubrication · drifting embers.
   Raw and punk, but medieval: Roman inscriptional display, literary
   manuscript serif, no CRT, no boxes. Mobile-first strip.
   ═══════════════════════════════════════════════════════ */

/* ─── Tokens ──────────────────────────────────────────── */
:root {
  color-scheme: dark;
  --void: #0B0E16;        /* ground — navy-black night      */
  --void-2: #121726;      /* one step up (fields)           */
  --navy: #1A2B47;        /* Kingshot deep navy             */
  --ink: #F1E3C2;         /* parchment ivory — prose         */
  --ink-dim: #C7BC9D;     /* secondary                       */
  --ink-muted: #9D957F;   /* tertiary (≥5.4:1 on void)       */
  --amber: #F5C851;       /* the one signal — active         */
  --amber-dim: #D3A33E;   /* antique gold — secondary signal */
  --oxblood: #8C3030;     /* failure, rubrication            */
  --ember: rgba(216, 166, 64, 0.18); /* drifting embers      */
  --ember-2: rgba(245, 200, 81, 0.11); /* embers, far layer   */
  --ember-3: rgba(241, 227, 194, 0.09); /* parchment motes    */
  --chrome: rgba(11, 14, 22, 0.9);  /* sticky bars (topbar/toc) */
  --signal-line: rgba(245, 200, 81, 0.35); /* amber hairlines */
  --signal-tint: rgba(245, 200, 81, 0.07); /* hover wash       */
  --signal-glow: rgba(245, 200, 81, 0.22); /* portrait inner glow */
  --signal-halo: rgba(245, 200, 81, 0.28); /* portrait hover halo */

  --display: 'Cinzel Decorative', 'Cinzel', serif;
  --display-2: 'Cinzel', 'Georgia', serif;
  --body: 'Alegreya', 'Georgia', serif;

  --step--1: clamp(1.05rem, 0.98rem + 0.35vw, 1.2rem);
  --step-0: clamp(1.2rem, 1.12rem + 0.4vw, 1.38rem);
  --step-1: clamp(1.55rem, 1.44rem + 0.55vw, 1.9rem);
  --step-2: clamp(2rem, 1.85rem + 0.75vw, 2.55rem);
  /* Section display step. The old floor (2.6rem/41.6px) was calibrated like
     --step-4 was not: the 1vw term only moves it ~4px across 280-430px, so the
     floor dominated every phone and the longest section word overflowed the
     measure and was cut by the html/body clip — "composition" 65px past the
     edge at 320, and far worse in German ("Zusammensetzung" 195px past at 320,
     99px past even at 430). The min() is the fix: below ~446px the step is
     purely viewport-relative, so it can no longer exceed the column, and above
     that the clamp governs exactly as before. Long compounds that still cannot
     fit one line wrap (see the heading overflow-wrap/hyphens rules). */
  --step-3: min(clamp(2.6rem, 2.4rem + 1vw, 3.5rem), 9.6vw);
  /* Hero display step, calibrated to fit: "DEMYSTIFIED" measures 7.889em
     in Cinzel Decorative 700 at the h1's 0.03em tracking, so the old
     3.4rem floor (429px wide) spilled off phones under ~460px. The 2.25rem
     floor fits a 320px viewport; the 6vw slope keeps desktop sizes. */
  --step-4: clamp(2.25rem, 1.05rem + 6vw, 4.8rem);
  /* Topbar brand: the widest brand, "KINGSHOT · DEMYSTIFIED", is 16.042em
     at 0.08em tracking — 398px at the old 1.55rem, a hair too wide for a
     phone. The 0.88rem floor fits it beside the language picker. */
  --step-brand: clamp(0.88rem, 0.5rem + 1.5vw, 1.9rem);

  --space-s: clamp(1rem, 0.9rem + 0.5vw, 1.3rem);
  --space-m: clamp(1.5rem, 1.35rem + 0.75vw, 2rem);
  --space-l: clamp(2.2rem, 2rem + 1vw, 3rem);
  --space-xl: clamp(4rem, 3.2rem + 4vw, 6rem);

  --maxw: 46rem;
  --topbar-h: 3rem;
}

/* ─── Arabic — the first RTL language ─────────────────── */
/* Font selection is per-glyph, so Latin runs (brand, numbers,
   formulas) still fall through to Alegreya inside Arabic
   copy. Amiri (naskh) + Aref Ruqaa (calligraphic display) keep
   the manuscript voice the Latin fonts already set. */
html[lang="ar"] {
  --body: 'Amiri', 'Alegreya', 'Georgia', serif;
  --display: 'Aref Ruqaa', 'Amiri', serif;
  --display-2: 'Aref Ruqaa', 'Amiri', serif;
}
/* Arabic script has no case and no italics, its letters join
   (tracking breaks the joins), and its ascenders/diacritics need
   taller heading lines than the Latin display fonts. */
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] h4,
html[lang="ar"] .tag, html[lang="ar"] .chips, html[lang="ar"] .toc a,
html[lang="ar"] .foot-main, html[lang="ar"] .calc-title,
html[lang="ar"] details summary, html[lang="ar"] .bars-cap,
html[lang="ar"] .waves-cap, html[lang="ar"] .slot-label,
html[lang="ar"] .brackets li, html[lang="ar"] .ledger a,
html[lang="ar"] .ledger-group { letter-spacing: 0; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] h4 { line-height: 1.25; }
html[lang="ar"] strong, html[lang="ar"] b, html[lang="ar"] .note,
html[lang="ar"] .egg-note, html[lang="ar"] .d-formula,
html[lang="ar"] .foot-sub b,
html[lang="ar"] .forge-n { font-style: normal; }

/* ─── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--void);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* fallback; the clip below is the real guard on iOS */
}

/* Guard: no glyph run may push a page-level horizontal scrollbar. clip
   (unlike hidden) does not create a scroll container, so the sticky
   topbar and TOC keep sticking to the viewport. */
html, body { overflow-x: clip; }

/* ─── Ember dust (three layers at three speeds) ───────── */
.dust {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.dust i {
  position: absolute; inset: -40%;
  background-repeat: repeat;
  will-change: transform;
}
.dust i:nth-child(1) {
  background-image: radial-gradient(circle, var(--ember) 1px, transparent 1.8px);
  background-size: 110px 110px;
  animation: dust-drift 150s linear infinite;
}
.dust i:nth-child(2) {
  background-image: radial-gradient(circle, var(--ember-2) 1.6px, transparent 2.4px);
  background-size: 170px 170px;
  animation: dust-drift 95s linear infinite reverse;
}
.dust i:nth-child(3) {
  background-image: radial-gradient(circle, var(--ember-3) 2.2px, transparent 3.2px);
  background-size: 250px 250px;
  animation: dust-drift 60s linear infinite;
}
@keyframes dust-drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-4%, -3%, 0); }
}

/* ─── Base surfaces ───────────────────────────────────── */
::selection { background: var(--amber); color: var(--void); }
h1, h2 { font-family: var(--display); font-weight: 700; line-height: 1.04; }
h3, h4 { font-family: var(--display-2); font-weight: 700; line-height: 1.04; }
/* A heading can never be cut at the glass: the backstop the hero h1 already
   carries, now on every display heading. The html/body clip that guards the
   dust field would otherwise hide the overhang instead of showing it. */
h1, h2, h3 { overflow-wrap: break-word; }
/* Below the width where even the widest common display word fits (see
   --step-3), break long compounds with a hyphen rather than mid-word: German
   is the language that proves it ("Zusammensetzung", "Truppenmischung"). */
@media (max-width: 620px) {
  h1, h2, h3 { hyphens: auto; }
}
h1 { font-size: var(--step-4); letter-spacing: 0.03em; text-transform: uppercase; }
h2 { font-size: var(--step-3); letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-dim); transition: color 0.45s cubic-bezier(0.16, 1, 0.3, 1); }
h3 { font-size: var(--step-1); letter-spacing: 0.02em; text-transform: uppercase; }
h4 { font-size: var(--step-1); }
p { max-width: 68ch; }
a { color: var(--amber); text-decoration-thickness: 1px; text-underline-offset: 4px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px dashed var(--amber); outline-offset: 3px; }
input { caret-color: var(--amber); }
strong, b { color: var(--ink); font-weight: 700; }

.skip-link {
  position: absolute; inset-inline-start: -9999px; top: 0; z-index: 100;
  background: var(--amber); color: var(--void);
  font-family: var(--body); font-style: italic;
  font-size: var(--step--1); letter-spacing: 0.06em;
  padding: 0.5rem 0.9rem; text-decoration: none;
}
.skip-link:focus { inset-inline-start: 0; }
/* The generic `a:hover { color: var(--ink) }` would turn the skip-link's
   ivory text on its amber pill (1.2:1) — keep void on amber on hover. */
.skip-link:hover { color: var(--void); }

/* ─── Topbar — fixed height, no gap ───────────────────── */
/* Three tracks, two of them equal: the brand sits left, the controls right,
   and the event strip lands on the bar's true centre rather than wherever
   space-between happens to leave it. Equal tracks mean the bar's centre is a
   real constraint — the strip must fit beside the masthead — so the strip's
   type is sized for it (events.css) and the masthead gives way first (below).
   Nothing can spill: a track that runs out clips its own item. */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: var(--chrome);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 0 var(--space-s);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-s);
}
.brand {
  grid-column: 1;
  font-family: var(--display); font-size: var(--step-brand); font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink); white-space: nowrap;
  min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
/* Where the strip is up (>=1240px) the masthead's size is capped by the room
   left beside it: half the bar, less the strip, the controls, the bar's own
   padding and its two gaps. The constant takes the WIDEST strip any language
   produces — Turkish's "Ana sayfa · Etkinlik Döngüsü …" at 664px, not English's
   588px — so a longer translation shrinks the masthead everywhere rather than
   clipping it in one language. For the longest brand ("KINGSHOT · DEMYSTIFIED",
   16.04em at 0.08em tracking) that is (100vw - 72rem)/32.1. Every page
   inherits the same size, so the masthead keeps one scale across the site
   instead of a different one per brand length; above ~1740px the cap stops
   biting and the brand is its full size. */
@media (min-width: 1800px) {
  .topbar .brand { font-size: clamp(0.9rem, min(var(--step-brand), calc((100vw - 72rem) / 32.1)), 1.9rem); }
}
/* Strip down (events.css), so the bar is two tracks and the masthead owns
   everything left of the controls. */
@media (max-width: 1799px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .topbar-right { grid-column: 2; }
}
.brand b { color: var(--amber); }
.brand-note { font-size: var(--step--1); color: var(--ink-muted); white-space: nowrap; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; }
.progress-fill { height: 100%; width: 100%; background: var(--amber); transform: scaleX(0); transform-origin: left; }
/* The bar fills from the reading edge. `width` on the block box already resolved
   to the right in RTL; scaleX keeps that, so the origin flips with the document. */
html[dir="rtl"] .progress-fill { transform-origin: right; }

/* ─── Main ────────────────────────────────────────────── */
main { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--space-s) var(--space-xl); }

/* ─── Hero ────────────────────────────────────────────── */
.hero { padding: var(--space-xl) 0 var(--space-l); }
/* Some translations' display words (de: ENTMYSTIFIZIERT, it: DEMISTIFICATO)
   still outrun a narrow phone — break them rather than the layout. */
.hero h1 { line-height: 1.05; overflow-wrap: break-word; }
.accent { color: var(--amber); }
.lede { margin-top: var(--space-s); color: var(--ink-dim); font-size: var(--step-0); }
.lede strong { color: var(--ink); }
.chips { margin-top: var(--space-m); font-size: var(--step--1); letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-muted); }
.chips span { color: var(--amber); }

/* ─── TOC — the rank rail, sticky under the topbar ────── */
/* Full-bleed appbar: the rail spans the viewport; the link
   row sits centered when it fits and scrolls from the left
   when it overflows (safe center). */
.toc {
  position: sticky; top: var(--topbar-h); z-index: 40;
  display: flex; justify-content: safe center;
  gap: 1.6rem; overflow-x: auto;
  padding: var(--space-s);
  background: var(--chrome);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  width: 100%;
}
.toc::-webkit-scrollbar { display: none; }
.toc a {
  flex: 0 0 auto; white-space: nowrap;
  font-family: var(--body); font-size: var(--step--1); font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  text-decoration: none; color: var(--ink-muted);
  transition: color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toc a:hover { color: var(--ink-dim); }
.toc a.active { color: var(--amber); }
.toc a.active::before { content: "❧ "; }

/* ─── Sections — depth layers ─────────────────────────── */
.section { position: relative; padding: var(--space-xl) 0; scroll-margin-top: calc(var(--topbar-h) + 3.5rem); }
/* Deep-link targets (js/deep-link.js) land below the sticky bar, like sections. */
details[id], [data-deep-link] { scroll-margin-top: calc(var(--topbar-h) + 3.5rem); }

/* The front caret — the leaf lives inside an always-reserved
   inline slot, so the heading text never reflows when the
   front layer changes; only opacity + transform animate.
   The slot mirrors to the inline-start side in RTL on its
   own, and reduced motion falls through to the blanket
   rule at the bottom of this file. */
.section h2::before {
  content: "❧";
  display: inline-block;
  width: 1.1em; /* the reserved gutter — constant in every state */
  color: var(--amber);
  opacity: 0;
  transform: rotate(-18deg) scale(0.75);
  transition:
    opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.section.front h2::before {
  opacity: 1;
  transform: rotate(0) scale(1);
  transition:
    opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
.section.front h2 { color: var(--ink); }
.section .lede { margin-bottom: var(--space-m); }

/* ─── Highlight / punchline ───────────────────────────── */
.hl { color: var(--amber); font-weight: 700; }
.punchline {
  margin: var(--space-m) 0;
  font-size: var(--step-2); line-height: 1.2;
  color: var(--ink);
  letter-spacing: 0.01em;
}

/* ─── Notes — the marginal gloss voice ────────────────── */
.note {
  margin-top: var(--space-m);
  font-size: var(--step--1);
  color: var(--ink-dim);
  font-style: italic;
}
.note strong, .note b { color: var(--ink); }

/* ─── Cards (no boxes — pure rank lines) ──────────────── */
.cards { display: grid; gap: var(--space-l); margin: var(--space-l) 0; }
.card h3 { margin-bottom: 0.5rem; display: flex; flex-direction: column; gap: 0.6rem; }
.card p { color: var(--ink-dim); }
.card p + p { margin-top: 0.6rem; }
.tag {
  align-self: flex-start;
  font-family: var(--body); font-size: var(--step--1); font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
}
.tag-lead { color: var(--amber); }
.tag-lead::before { content: "❧ "; }
.tag-you { color: var(--ink); }
.tag-you::before { content: "❧ "; color: var(--amber-dim); }

/* ─── Bars — the sqrt as measured columns ─────────────── */
.bars { margin: var(--space-m) 0 var(--space-l); }
.bars-cap { font-size: var(--step--1); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: var(--space-m); }
.bar-row { display: grid; grid-template-columns: 8rem 1fr 4.5rem; align-items: center; gap: 0.9rem; margin-bottom: 0.8rem; }
.bar-label { font-size: var(--step--1); color: var(--ink-dim); }
.bar-track { height: 16px; }
.bar-fill { height: 100%; width: calc(var(--p) * 1%); background: var(--amber-dim); }
.bar-row:nth-child(n + 4) .bar-fill,
.bar-row:last-child .bar-fill { background: var(--amber); }
.bar-value { font-family: var(--display-2); font-weight: 700; font-size: var(--step-1); color: var(--ink); text-align: right; }
.bar-row:last-child .bar-value { color: var(--amber); }

/* ─── Facts ───────────────────────────────────────────── */
.facts { list-style: none; display: grid; gap: 0.5rem; margin-top: var(--space-m); }
.facts li { font-size: var(--step--1); color: var(--ink-dim); }
.facts b { color: var(--amber); }

/* ─── Demo + slots ────────────────────────────────────── */
.demo { margin: var(--space-m) 0; }
.demo-title { font-size: var(--step-1); color: var(--ink); margin-bottom: var(--space-s); }
.demo-title b { color: var(--amber); }
.slot-row { display: flex; flex-direction: column; gap: var(--space-s); margin-bottom: var(--space-s); }
.slot-label { font-size: var(--step--1); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-muted); }
.slot-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.slot { width: 1.15rem; height: 1.15rem; background: var(--amber); }
.slot-value { font-family: var(--display-2); font-weight: 700; font-size: var(--step-3); color: var(--amber); }
.demo-sub { color: var(--ink-dim); font-size: var(--step--1); }
.demo-sub strong { color: var(--ink); }

/* ─── Calculators ─────────────────────────────────────── */
.calc { margin-top: var(--space-m); padding-top: var(--space-m); }
.calc-title { font-family: var(--body); font-size: var(--step--1); font-weight: 700; letter-spacing: 0.18em; color: var(--amber); margin-bottom: var(--space-s); }
.calc-row { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: var(--space-s); }
.calc-row label { font-size: var(--step--1); color: var(--ink-dim); }
.calc-row label output { color: var(--amber); }
input[type="number"], input[data-unit-input] {
  background: transparent; color: var(--ink);
  border: 0; border-bottom: 1px solid var(--ink-muted);
  border-radius: 0;
  padding: 0.4rem 0.1rem;
  font-family: var(--body); font-size: var(--step-1);
  width: 100%;
}
input[type="number"]:focus, input[data-unit-input]:focus { border-bottom-color: var(--amber); outline: none; }
input[type="range"] { accent-color: var(--amber); height: 2rem; width: 100%; }
.calc-out { font-size: var(--step--1); color: var(--ink-dim); }
.calc-out b { color: var(--amber); font-size: var(--step-0); }

/* ─── Waves — timing as ruled rails ───────────────────── */
.waves { margin: var(--space-m) 0; }
.waves-cap { font-size: var(--step--1); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: var(--space-m); }
.wave-row { display: grid; grid-template-columns: 2.6rem 1fr; align-items: center; gap: 0.8rem; margin-bottom: 0.7rem; }
.wave-label { font-family: var(--display-2); font-weight: 600; font-size: var(--step-1); color: var(--ink-dim); }
.wave-track { position: relative; height: 16px; }
.seg { position: absolute; top: 0; bottom: 0; }
.seg.march {
  inset-inline-start: calc(var(--w) / 8 * 100%);
  width: calc(var(--len) / 8 * 100%);
  background: var(--ink-dim);
  opacity: 0.65;
}
.seg.fire {
  inset-inline-start: calc(var(--w) / 8 * 100%);
  width: 16px; height: 16px; margin-inline-start: -8px; top: 0;
  background: var(--amber);
}
.wave-times { grid-column: 2; font-size: var(--step--1); color: var(--ink-muted); margin-top: -0.2rem; }
.wave-axis { display: flex; justify-content: space-between; margin-top: 0.8rem; font-size: var(--step--1); color: var(--ink-muted); }

/* ─── Brackets — rank line, dim to full signal ────────── */
.brackets { list-style: none; display: flex; flex-wrap: wrap; gap: 0.7rem 1.6rem; margin: var(--space-s) 0 var(--space-m); }
.brackets li { font-family: var(--display-2); font-weight: 600; font-size: var(--step-2); letter-spacing: 0.02em; color: var(--ink-dim); }
.brackets li:nth-child(n + 4) { color: var(--ink); }
.brackets li:nth-child(n + 5) { color: var(--amber); }
/* Damage numbers carry the bracket's rank brightness at full weight */
.brackets li b { color: inherit; font-weight: 700; }
/* The forge stamp: one hammer in the world's own grammar,
   inheriting the bracket's rank brightness. */
.forge {
  display: inline-flex; align-items: center; gap: 0.35em;
  margin-left: 0.3em; vertical-align: middle;
  color: inherit;
}
.forge-ico { width: 1em; height: 1em; display: block; }
.forge-n { font-family: var(--body); font-style: italic; font-size: 0.6em; letter-spacing: 0.02em; color: inherit; }

/* ─── Details / disclosures — prompt lines, no boxes ──── */
details { margin-top: var(--space-m); }
details summary {
  cursor: pointer;
  font-family: var(--body); font-size: var(--step--1); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--amber);
  padding: 0.4rem 0;
  list-style: none;
  display: inline-flex; align-items: center; gap: 0.5rem;
  user-select: none;
  transition: color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
details summary:hover { color: var(--ink); }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "❧ "; }
details[open] summary { color: var(--ink); }
.d-body { padding: 0.4rem 0 var(--space-m); color: var(--ink-dim); font-size: var(--step--1); }
.d-body ul { list-style: none; }
.d-body li { padding: 0.15rem 0; }
.d-body b { color: var(--ink); }
.d-formula { font-size: var(--step-1); color: var(--amber); margin: 0.6rem 0; font-style: italic; }

/* ─── Rules — the four ranks ──────────────────────────── */
.rule-list { list-style: none; display: grid; gap: var(--space-l); margin: var(--space-m) 0; }
.rule-list li { display: flex; gap: var(--space-m); align-items: flex-start; }
.rule-num {
  flex: 0 0 auto;
  width: 3.8rem; height: 3.8rem;
  display: grid; place-items: center;
  font-family: var(--display-2); font-weight: 700; font-size: var(--step-3);
  color: var(--void); background: var(--amber);
}
.rule-list h3 { margin-bottom: 0.2rem; }
.rule-list p { color: var(--ink-dim); font-size: var(--step--1); }
/* Reversed glyph cell — the failure mark (rubrication) */
.rev {
  background: var(--oxblood); color: var(--ink);
  padding: 0 0.45em;
  font-style: italic;
}

/* ─── Heroes — the roster as two worked queues ────────── */
.rank-blocks { display: grid; gap: var(--space-xl); margin-top: var(--space-m); }
.rank-block { min-width: 0; }
.rank-title {
  font-family: var(--display-2);
  font-weight: 700;
  font-size: var(--step-2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 0.3rem;
}
.rank-title::before { content: "❧ "; color: var(--amber-dim); }
.rank-lede { font-size: var(--step--1); color: var(--ink-dim); margin-bottom: var(--space-l); }
.rank-lede b { color: var(--ink); }

/* Each generation is a rank line: blackletter header, a gold
   hairline running out to the margin, then the queue of cards. */
.gen { margin-bottom: var(--space-l); }
.gen-title {
  display: flex; align-items: center; gap: 0.9rem;
  font-family: var(--body);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: var(--space-s);
}
.gen-title b { color: var(--ink-dim); font-size: 1.2em; letter-spacing: 0.08em; }
.gen-title::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(to right, var(--amber-dim), transparent);
  opacity: 0.55;
}

.hero-row { display: grid; gap: var(--space-s); }
.hero-card {
  display: flex; gap: var(--space-s); align-items: flex-start;
  padding: 0.3rem 0;
}
.hero-portrait {
  flex: 0 0 auto;
  width: 4.4rem; height: 4.4rem;
  object-fit: cover;
  border: 1px solid var(--amber-dim);
  border-radius: 2px;
  background: var(--void-2);
  box-shadow: inset 0 0 0 1px var(--signal-glow), 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.hero-card:hover .hero-portrait,
.hero-card:focus-within .hero-portrait {
  box-shadow: inset 0 0 0 1px var(--signal-glow), 0 0 0 1px var(--amber-dim), 0 0 22px var(--signal-halo);
}
.hero-meta { min-width: 0; }
.hero-name {
  display: flex; align-items: baseline; gap: 0.55rem; flex-wrap: wrap;
  font-family: var(--display-2);
  font-weight: 600;
  font-size: var(--step-0);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 0.2rem;
}
/* Tier stamps — the same rank squares as the four rules */
.tier {
  font-family: var(--display-2);
  font-weight: 700;
  font-size: 0.68em;
  line-height: 1;
  letter-spacing: 0.05em;
  padding: 0.22em 0.45em 0.12em;
  border-radius: 2px;
}
.tier-s { background: var(--amber); color: var(--void); }
.tier-a { background: var(--ink); color: var(--void); }
.tier-b { background: var(--ink-muted); color: var(--void); }
.hero-why { font-size: var(--step--1); color: var(--ink-dim); }
.hero-why b { color: var(--ink); }

.gen-gloss {
  margin-top: var(--space-s);
  padding-top: var(--space-s);
  border-top: 1px solid rgba(157, 149, 127, 0.18);
  font-size: var(--step--1);
  font-style: italic;
  color: var(--ink-muted);
}
.gen-gloss b { color: var(--ink-dim); }

@media (min-width: 640px) {
  .hero-portrait { width: 5rem; height: 5rem; }
  .hero-row { gap: var(--space-s) var(--space-l); }
}
@media (min-width: 900px) {
  .rank-blocks { grid-template-columns: 1fr 1fr; gap: var(--space-l) var(--space-xl); align-items: start; }
}

/* ─── Footer — the rubricated band ────────────────────── */
footer {
  position: relative; z-index: 1;
  padding: var(--space-l) var(--space-s) var(--space-xl);
  text-align: center;
}
.foot-main {
  display: inline-block;
  background: var(--amber); color: var(--void);
  font-family: var(--display-2); font-weight: 700; font-size: var(--step-1); letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0.55rem 1.3rem;
}
.foot-sub { margin: 0.8rem auto 0; font-size: var(--step--1); color: var(--ink-muted); }
.foot-sub b { color: var(--ink-dim); }
.foot-sub a { color: var(--ink-muted); text-decoration: underline; text-underline-offset: 3px; }
.foot-sub a:hover { color: var(--amber); }

/* ─── Scrollbar ───────────────────────────────────────── */
html { scrollbar-width: thin; scrollbar-color: var(--ink-muted) var(--void); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--void); }
::-webkit-scrollbar-thumb { background: var(--ink-muted); border: 3px solid var(--void); }

/* ─── < 700px: drop the brand note, keep the rail tight ─ */
@media (max-width: 700px) {
  .brand-note { display: none; }
}

/* ─── ≥ 640px ─────────────────────────────────────────── */
@media (min-width: 640px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .rule-list { grid-template-columns: 1fr 1fr; }
  .calc-row { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--space-m); }
  .calc-row input[type="number"], .calc-row input[type="range"] { width: 55%; }
  .slot-row { flex-direction: row; align-items: center; gap: var(--space-s); }
  .slot-grid { flex: 1; }
}

/* ─── Reduced motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .dust i { animation: none; }
}

/* ─── Easter eggs — the bear keeps notes ──────────────── */
.hedera {
  display: inline-block;
  margin: 0 0 var(--space-m);
  padding: 0.15rem 0.4rem;
  background: none; border: 0;
  color: var(--amber);
  font-family: var(--display-2);
  font-weight: 400;
  font-size: var(--step-2);
  line-height: 1;
  cursor: pointer;
  transform: rotate(-10deg);
  transition: transform 0.25s ease, color 0.25s ease, text-shadow 0.25s ease;
}
.hedera:hover, .hedera:focus-visible {
  color: var(--ink);
  text-shadow: 0 0 16px rgba(240, 196, 90, 0.6);
  transform: rotate(0deg) scale(1.1);
}

/* A functional toast — e.g. the copy confirmation on the Event Cycle page */
.egg-note {
  --tilt: -1.2deg;
  position: fixed;
  z-index: 90;
  max-width: min(21rem, calc(100vw - var(--space-l)));
  background: var(--ink);
  color: var(--void);
  font-style: italic;
  font-size: var(--step--1);
  line-height: 1.45;
  letter-spacing: 0.02em;
  padding: 0.7rem 0.95rem;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  transform: rotate(var(--tilt));
  pointer-events: none;
  animation: egg-rise 4.4s ease-out forwards;
}
@keyframes egg-rise {
  0%   { opacity: 0; transform: translateY(14px) rotate(var(--tilt)); }
  12%  { opacity: 1; transform: translateY(0) rotate(var(--tilt)); }
  72%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-24px) rotate(var(--tilt)); }
}

/* Rule five stays `hidden` in the markup (no JS reveal anymore); `hidden`
   alone loses to `.rule-list li { display: flex }`, so pin it. */
.rule-list li[hidden] { display: none; }

/* ─── Language picker — flag dropdown in the 3rem topbar ─ */
.topbar-right {
  display: flex; align-items: center;
  grid-column: 3;
  justify-self: end;
  gap: var(--space-s);
  min-width: 0;
}
.lang-picker { position: relative; }
.lang-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 1.65rem;
  padding: 0.18rem;
  background: transparent;
  border: 1px solid var(--ink-muted);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color 0.3s ease;
}
.lang-btn:hover, .lang-btn:focus-visible, .lang-btn.open {
  border-color: var(--amber);
  outline: none;
}
.lang-btn .flag { width: 100%; height: 100%; display: block; border-radius: 1px; }
.lang-menu {
  position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 60;
  min-width: 10.5rem; max-height: 62vh; overflow-y: auto;
  margin: 0; padding: 0.35rem;
  list-style: none;
  background: var(--void-2);
  border: 1px solid var(--ink-muted);
  border-radius: 3px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
}
.lang-menu li {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.34rem 0.5rem;
  cursor: pointer;
  font-family: var(--body); font-size: var(--step--1);
  color: var(--ink-dim);
  border-radius: 2px;
}
.lang-menu li:hover, .lang-menu li[aria-selected="true"] {
  color: var(--amber);
  background: var(--signal-tint);
}
.lang-menu .flag { width: 1.6rem; height: 0.96rem; flex: 0 0 auto; border-radius: 1px; }

.section[data-collapse] > h2 {
  display: flex;
  align-items: center;
  margin-bottom: 0;
}

.section[data-collapse] > h2::before { flex: none; }

.section-toggle {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  flex: 1;
  min-width: 0;
  justify-content: space-between;
  cursor: pointer;
  color: inherit;
}

.section-toggle:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 0.2rem;
  border-radius: 0.15rem;
}

.section-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  line-height: 1;
  color: var(--amber);
  font-family: var(--body);
  font-size: 0.72em;
  transform: rotate(0deg);
  transform-origin: center;
  transition: transform 0.2s ease, color 0.2s ease;
}

.section[data-collapsed] .section-chevron {
  transform: rotate(-90deg);
}

.section[data-collapsed] h2 {
  color: var(--ink-dim);
}

.section-body {
  padding-top: var(--space-m);
}

.section-body[hidden] {
  display: none !important;
}


.section-toggle > span:first-child { min-width: 0; }
.section-chevron { flex: none; }
.section[data-collapsed] { padding-block: var(--space-m); }
.section-body { min-width: 0; }

.section-chevron svg { display: block; width: 100%; height: 100%; }
