/* ═══════════════════════════════════════════════
   CELL DIPLOMACY — Stylesheet
   ═══════════════════════════════════════════════ */

/* ─── RESET & BASE ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Atmosphere defaults (frost) */
  --atm-bg: #0c0f14;
  --atm-text: #b8c4d4;
  --atm-dialogue: rgba(200, 215, 235, 0.92);
  --atm-accent: rgba(100, 160, 220, 0.35);
  --atm-muted: rgba(140, 160, 185, 0.5);
  --atm-glow: rgba(100, 160, 220, 0.15);
  --atm-speaker: #7ea8cc;

  /* Layout */
  --story-width: min(860px, 90vw);
  --story-padding-top: 8rem;
}

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--atm-accent) transparent;
}

body {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-size: clamp(15px, 1.1vw, 18px);
  line-height: 1.85;
  color: var(--atm-text);
  background: var(--atm-bg);
  transition: background-color 1.5s ease, color 1s ease;
  overflow-x: hidden;
}

/* ─── ATMOSPHERE ZONES ─── */

/* frost — arrival, cold blue-grey */
body.atm-frost {
  --atm-bg: #0c0f14;
  --atm-text: #b8c4d4;
  --atm-dialogue: rgba(200, 215, 235, 0.92);
  --atm-accent: rgba(100, 160, 220, 0.35);
  --atm-muted: rgba(140, 160, 185, 0.5);
  --atm-glow: rgba(100, 160, 220, 0.15);
  --atm-speaker: #7ea8cc;
}

/* dust — settlement market, warm amber */
body.atm-dust {
  --atm-bg: #14110a;
  --atm-text: #d4c8a8;
  --atm-dialogue: rgba(235, 225, 200, 0.93);
  --atm-accent: rgba(200, 150, 60, 0.4);
  --atm-muted: rgba(180, 155, 110, 0.5);
  --atm-glow: rgba(200, 150, 60, 0.12);
  --atm-speaker: #c4a050;
}

/* fire — council, political tension, deep orange-red */
body.atm-fire {
  --atm-bg: #16100a;
  --atm-text: #ddd0b5;
  --atm-dialogue: rgba(245, 235, 210, 0.94);
  --atm-accent: rgba(230, 130, 50, 0.45);
  --atm-muted: rgba(200, 160, 100, 0.5);
  --atm-glow: rgba(230, 130, 50, 0.15);
  --atm-speaker: #d4944a;
}

/* tavern — evenings, deep warm cozy */
body.atm-tavern {
  --atm-bg: #120e08;
  --atm-text: #d8ccb0;
  --atm-dialogue: rgba(240, 230, 205, 0.94);
  --atm-accent: rgba(220, 170, 70, 0.45);
  --atm-muted: rgba(190, 160, 110, 0.55);
  --atm-glow: rgba(220, 170, 70, 0.18);
  --atm-speaker: #c8a845;
}

/* horizon — departure, pale grey-blue dawn */
body.atm-horizon {
  --atm-bg: #0e1118;
  --atm-text: #c0cad8;
  --atm-dialogue: rgba(210, 220, 235, 0.92);
  --atm-accent: rgba(130, 170, 220, 0.3);
  --atm-muted: rgba(150, 170, 200, 0.45);
  --atm-glow: rgba(160, 190, 230, 0.12);
  --atm-speaker: #8ab0d4;
}


/* ─── SPLASH SCREEN ─── */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0c10;
  cursor: pointer;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}
.splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-inner {
  text-align: center;
}

.seal-svg {
  width: 120px;
  height: 120px;
  color: #8aa0b8;
  animation: sealPulse 3s ease-in-out infinite;
}

@keyframes sealPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

.splash-loader {
  width: 140px;
  height: 2px;
  background: rgba(138, 160, 184, 0.15);
  margin: 2rem auto 1.5rem;
  border-radius: 2px;
  overflow: hidden;
}
.splash-loader-bar {
  height: 100%;
  width: 0%;
  background: rgba(138, 160, 184, 0.6);
  border-radius: 2px;
  animation: loaderFill 2.5s ease-out forwards;
}
@keyframes loaderFill {
  to { width: 100%; }
}

.splash-hint {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: rgba(138, 160, 184, 0.4);
  letter-spacing: 3px;
  text-transform: uppercase;
  animation: hintBlink 2s ease-in-out infinite;
}
@keyframes hintBlink {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}


/* ─── COVER / HERO ─── */
.cover {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0a0c10;
  overflow: hidden;
  color: #8aa0b8;
}

.cover-snow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.snowflake {
  position: absolute;
  top: -10px;
  width: 3px;
  height: 3px;
  background: rgba(200, 215, 235, 0.5);
  border-radius: 50%;
  animation: snowFall linear infinite;
}
@keyframes snowFall {
  0% { transform: translateY(-10px) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(100vh) translateX(var(--snow-drift, 40px)); opacity: 0; }
}

.cover-content {
  position: relative;
  z-index: 3;
  text-align: center;
  margin-bottom: 12vh;
}

.cover-pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.55rem, 0.8vw, 0.75rem);
  letter-spacing: 4px;
  text-transform: uppercase;
  opacity: 0.45;
  margin-bottom: 1.5rem;
  animation: fadeInUp 1.5s ease 0.5s both;
}

.cover-title {
  font-family: 'EB Garamond', serif;
  font-weight: 700;
  line-height: 1;
  animation: fadeInUp 1.5s ease 0.8s both;
}
.title-cell {
  display: block;
  font-size: clamp(3rem, 8vw, 7rem);
  letter-spacing: 0.15em;
  opacity: 0.85;
}
.title-diplomacy {
  display: block;
  font-size: clamp(4rem, 11vw, 9.5rem);
  letter-spacing: 0.05em;
  font-style: italic;
  background: linear-gradient(180deg, rgba(138,160,184,1) 0%, rgba(138,160,184,0.5) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.cover-sub {
  font-family: 'EB Garamond', serif;
  font-size: clamp(0.9rem, 1.3vw, 1.2rem);
  letter-spacing: 6px;
  text-transform: uppercase;
  opacity: 0.35;
  margin-top: 1.5rem;
  animation: fadeInUp 1.5s ease 1.1s both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Settlement SVG */
.cover-settlement {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: auto;
  max-height: 35vh;
  color: #1a2030;
  z-index: 1;
}

.cover-windows rect {
  fill: rgba(220, 170, 70, 0.35);
  animation: windowFlicker 4s ease-in-out infinite alternate;
}
.cover-windows rect:nth-child(odd) { animation-delay: -1.5s; }
.cover-windows rect:nth-child(3n) { animation-delay: -3s; }
@keyframes windowFlicker {
  0%, 100% { fill: rgba(220, 170, 70, 0.3); }
  50% { fill: rgba(220, 170, 70, 0.5); }
}

/* Mech SVG */
.cover-mech {
  position: absolute;
  bottom: 3.5%;
  left: 3vw;
  width: clamp(60px, 8vw, 110px);
  height: auto;
  color: #141a24;
  z-index: 2;
  animation: mechWalk 3s ease-in-out infinite;
}
@keyframes mechWalk {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Scroll hint */
.cover-scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: rgba(138, 160, 184, 0.3);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 3px;
  text-transform: uppercase;
}
.scroll-dot {
  animation: scrollDotBounce 2s ease-in-out infinite;
}
@keyframes scrollDotBounce {
  0%, 100% { cy: 8; opacity: 1; }
  50% { cy: 20; opacity: 0.3; }
}


/* ─── STORY CONTAINER ─── */
.story {
  max-width: var(--story-width);
  margin: 0 auto;
  padding: var(--story-padding-top) 1.5rem 10rem;
}


/* ─── ACT TITLES ─── */
.act-title {
  font-family: 'EB Garamond', serif;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.08em;
  color: var(--atm-text);
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
  margin: 5rem 0 3rem;
  position: relative;
}
.act-title.visible {
  opacity: 0.7;
  transform: translateY(0);
}
.act-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 1px;
  background: var(--atm-accent);
  margin: 1rem auto 0;
}


/* ─── SCENE BREAKS ─── */
.scene-break {
  text-align: center;
  margin: 3.5rem 0;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.scene-break.visible { opacity: 0.4; }
.scene-break::before {
  content: '* \00a0\00a0\00a0 * \00a0\00a0\00a0 *';
  font-family: 'EB Garamond', serif;
  font-size: 1.2rem;
  color: var(--atm-muted);
  letter-spacing: 0.3em;
}


/* ─── PARAGRAPHS ─── */
.story-p {
  margin-bottom: 1.4rem;
  text-indent: 1.5em;
  color: var(--atm-text);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease, color 1s ease;
}
.story-p.visible {
  opacity: 1;
  transform: translateY(0);
}
.story-p:first-child {
  text-indent: 0;
}


/* ─── DIALOGUE ─── */
.story-d {
  margin-bottom: 1.2rem;
  padding-left: 1.8em;
  position: relative;
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.5s ease, transform 0.5s ease, color 1s ease;
}
.story-d.visible {
  opacity: 1;
  transform: translateY(0);
}
.story-d .speaker {
  font-family: 'EB Garamond', serif;
  font-weight: 700;
  color: var(--atm-speaker);
  font-size: 0.85em;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.15em;
  transition: color 1s ease;
}
.story-d .dialogue-text {
  color: var(--atm-dialogue);
  font-style: italic;
  transition: color 1s ease;
}


/* ─── STAGE DIRECTIONS ─── */
.story-stage {
  font-style: italic;
  color: var(--atm-muted);
  text-align: center;
  margin: 1.5rem 0;
  font-size: 0.9em;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.story-stage.visible { opacity: 0.7; }


/* ─── MECH VOICEBOX ─── */
.story-mech {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82em;
  letter-spacing: 0.05em;
  color: rgba(120, 200, 180, 0.85);
  background: rgba(120, 200, 180, 0.06);
  border-left: 2px solid rgba(120, 200, 180, 0.3);
  padding: 0.8em 1.2em;
  margin: 1.5rem 0;
  position: relative;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.story-mech.visible {
  opacity: 1;
  transform: translateX(0);
}
.story-mech::before {
  content: 'VOICEBOX';
  position: absolute;
  top: -0.6em;
  left: 1em;
  font-size: 0.6em;
  letter-spacing: 0.2em;
  background: var(--atm-bg);
  padding: 0 0.5em;
  color: rgba(120, 200, 180, 0.5);
  transition: background 1.5s ease;
}
/* glitch flicker */
.story-mech.visible {
  animation: mechGlitch 0.15s ease 0.6s 3;
}
@keyframes mechGlitch {
  0% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  50% { transform: translateX(3px); opacity: 0.7; }
  75% { transform: translateX(-1px); }
  100% { transform: translateX(0); }
}


/* ─── ERROR 404 BOX ─── */
.story-error {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78em;
  line-height: 1.6;
  color: rgba(230, 80, 80, 0.85);
  background: rgba(230, 80, 80, 0.05);
  border: 1px solid rgba(230, 80, 80, 0.2);
  border-radius: 4px;
  padding: 1.2em 1.5em;
  margin: 2rem auto;
  max-width: 500px;
  white-space: pre-line;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.6s ease, transform 0.4s ease;
}
.story-error.visible {
  opacity: 1;
  transform: scale(1);
  animation: errorBlink 0.1s ease 0.4s 5;
}
@keyframes errorBlink {
  0%, 100% { border-color: rgba(230, 80, 80, 0.2); }
  50% { border-color: rgba(230, 80, 80, 0.6); }
}
.story-error::before {
  content: '> SYSTEM DIAGNOSTIC';
  display: block;
  font-size: 0.75em;
  letter-spacing: 0.15em;
  color: rgba(230, 80, 80, 0.5);
  margin-bottom: 0.8em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid rgba(230, 80, 80, 0.1);
}


/* ─── FOOTNOTES (House of Leaves style) ─── */
.story-footnote {
  font-size: 0.78em;
  line-height: 1.6;
  color: var(--atm-muted);
  border-top: 1px solid rgba(150, 150, 150, 0.1);
  margin: 0.5rem 0 2rem;
  padding: 0.8rem 0 0;
  padding-left: 2em;
  position: relative;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  font-style: italic;
}
.story-footnote.visible {
  opacity: 0.7;
  transform: translateY(0);
}
.story-footnote .fn-number {
  position: absolute;
  left: 0;
  top: 0.8rem;
  font-style: normal;
  font-weight: 700;
  color: var(--atm-accent);
  font-family: 'EB Garamond', serif;
  font-size: 1.1em;
}
/* Footnote anchor in text */
.fn-ref {
  font-family: 'EB Garamond', serif;
  font-size: 0.75em;
  vertical-align: super;
  color: var(--atm-accent);
  cursor: default;
  margin-left: 2px;
  font-style: normal;
  font-weight: 700;
}


/* ═══════════════════════════════════════════════
   HOUSE OF LEAVES EFFECTS
   ═══════════════════════════════════════════════ */

/* ─── VADIM ESCALATION (8 levels) ─── */

/* Level 1 — barely louder */
.vadim-1 .dialogue-text,
.story-p.vadim-1 {
  font-size: 1.05em;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Level 2 — getting heated */
.vadim-2 .dialogue-text,
.story-p.vadim-2 {
  font-size: 1.15em;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Level 3 — shouting */
.vadim-3 .dialogue-text,
.story-p.vadim-3 {
  font-size: 1.3em;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.4;
}

/* Level 4 — yelling */
.vadim-4 .dialogue-text,
.story-p.vadim-4 {
  font-size: 1.5em;
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.35;
}

/* Level 5 — bellowing */
.vadim-5 .dialogue-text,
.story-p.vadim-5 {
  font-size: 1.75em;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

/* Level 6 — thundering */
.vadim-6 .dialogue-text,
.story-p.vadim-6 {
  font-size: 2.0em;
  font-weight: 800;
  letter-spacing: 0.07em;
  line-height: 1.25;
}

/* Level 7 — earthquake */
.vadim-7 .dialogue-text,
.story-p.vadim-7 {
  font-size: 2.3em;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

/* Level 8 — apocalyptic peak */
.vadim-8 .dialogue-text,
.story-p.vadim-8 {
  font-size: 2.6em;
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1.15;
}

/* Levels 4+ push into margins */
.vadim-4, .vadim-5 {
  margin-left: -1.5rem;
  margin-right: -1.5rem;
}
.vadim-6, .vadim-7, .vadim-8 {
  margin-left: -2.5rem;
  margin-right: -2.5rem;
}


/* ─── CASIMIR ECHO ─── */
.casimir-echo {
  padding-left: 3.5em !important;
  font-size: 0.88em;
  opacity: 0;
  position: relative;
}
.casimir-echo.visible { opacity: 0.65; }
/* When applied to a paragraph (not a dialogue element) */
.story-p.casimir-echo {
  color: var(--atm-muted) !important;
  font-style: italic;
}
.casimir-echo .speaker {
  font-size: 0.78em !important;
  opacity: 0.7;
}
.casimir-echo .dialogue-text {
  font-size: 0.92em;
  color: var(--atm-muted) !important;
}
.casimir-echo::before {
  content: '';
  position: absolute;
  left: 1.5em;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--atm-accent);
  opacity: 0.3;
}


/* ─── SEIZED WORD ─── */
.seized-word .dialogue-text {
  position: relative;
}
.word-target {
  transition: all 0.3s ease;
  position: relative;
  display: inline;
}
.word-target.seized {
  color: rgba(230, 130, 50, 0.9) !important;
  font-weight: 700;
  font-style: normal;
}
.word-target.seized::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background: rgba(230, 130, 50, 0.6);
  animation: seizeGlow 0.5s ease;
}
@keyframes seizeGlow {
  0% { width: 0; opacity: 0; }
  100% { width: 100%; opacity: 1; }
}


/* ─── PANIC RUN ─── */
.panic-run {
  transition: transform 0.3s ease, letter-spacing 0.3s ease !important;
}
.panic-run.visible {
  animation: panicDrift 0.6s ease 0.3s both;
}
@keyframes panicDrift {
  0% { transform: translateX(0) translateY(0) rotate(0deg); }
  30% { transform: translateX(5px) translateY(-2px) rotate(0.3deg); }
  60% { transform: translateX(15px) translateY(2px) rotate(-0.5deg); }
  100% { transform: translateX(25px) translateY(0) rotate(0.8deg); letter-spacing: 0.08em; }
}


/* ─── DRIFT RIGHT (trails off) ─── */
.drift-right.visible .dialogue-text {
  animation: driftRight 2s ease forwards;
}
@keyframes driftRight {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(40px); opacity: 0.5; }
}


/* ─── SHRINK AWAY ─── */
.shrink-away.visible .dialogue-text {
  animation: shrinkAway 1.5s ease forwards;
}
@keyframes shrinkAway {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.92); opacity: 0.6; }
}


/* ─── TILT ─── */
.tilt-right.visible {
  animation: tiltRight 0.4s ease 0.3s both;
}
@keyframes tiltRight {
  0% { transform: translateY(0) rotate(0); }
  100% { transform: translateY(0) rotate(1.2deg); }
}

.tilt-left.visible {
  animation: tiltLeft 0.4s ease 0.3s both;
}
@keyframes tiltLeft {
  0% { transform: translateY(0) rotate(0); }
  100% { transform: translateY(0) rotate(-1.2deg); }
}


/* ─── IMPACT DROP ─── */
.impact-drop.visible {
  animation: impactDrop 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}
@keyframes impactDrop {
  0% { transform: translateY(-15px); opacity: 0; }
  60% { transform: translateY(3px); }
  100% { transform: translateY(0); opacity: 1; }
}


/* ─── FINAL PARAGRAPH ─── */
.final-paragraph {
  text-align: center;
  text-indent: 0 !important;
  font-style: italic;
  margin-top: 3rem;
  font-size: 1.05em;
  opacity: 0;
  transition: opacity 1.5s ease !important;
}
.final-paragraph.visible {
  opacity: 0.85;
}


/* ─── WHISPER SPREAD ─── */
.whisper-spread.visible {
  animation: whisperGrow 1s ease both;
}
@keyframes whisperGrow {
  0% { font-size: 0.7em; opacity: 0.3; letter-spacing: 0.1em; }
  100% { font-size: 1em; opacity: 1; letter-spacing: normal; }
}


/* ─── LETTER EXPLOSION (YOUR WHAT) ─── */
.letter-explosion {
  display: inline;
}
.letter-explosion.visible {
  animation: letterExplode 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.2s both;
}
@keyframes letterExplode {
  0% { letter-spacing: normal; transform: scale(1); }
  40% { letter-spacing: 0.35em; transform: scale(1.25); }
  60% { letter-spacing: 0.4em; transform: scale(1.3); }
  100% { letter-spacing: 0.18em; transform: scale(1.12); }
}


/* ─── FREEZE / SHIVER ─── */
.freeze-shiver.visible {
  animation: freezeShiver 0.08s ease-in-out infinite alternate;
  color: rgba(160, 200, 230, 0.85) !important;
}
@keyframes freezeShiver {
  0% { transform: translateY(0) translateX(0); }
  25% { transform: translateY(-0.5px) translateX(0.5px); }
  50% { transform: translateY(0.5px) translateX(-0.3px); }
  75% { transform: translateY(-0.3px) translateX(-0.5px); }
  100% { transform: translateY(0.3px) translateX(0.3px); }
}


/* ─── HYSTERICAL LAUGHTER WOBBLE ─── */
.laughter-wobble.visible {
  animation: laughterWobble 0.3s ease-in-out infinite;
  transform-origin: center center;
}
@keyframes laughterWobble {
  0% { transform: translateY(0) rotate(0deg) scale(1); }
  15% { transform: translateY(-2px) rotate(-0.8deg) scale(1.01); }
  30% { transform: translateY(1px) rotate(0.6deg) scale(0.99); }
  50% { transform: translateY(-1px) rotate(-0.5deg) scale(1.02); }
  65% { transform: translateY(2px) rotate(0.9deg) scale(0.98); }
  80% { transform: translateY(-1px) rotate(-0.3deg) scale(1.01); }
  100% { transform: translateY(0) rotate(0deg) scale(1); }
}


/* ─── SOUL LEAVING BODY ─── */
.soul-leave.visible {
  animation: soulLeave 2.5s ease-out 0.3s both;
}
@keyframes soulLeave {
  0% { transform: translateY(0); opacity: 1; filter: blur(0); }
  30% { opacity: 0.7; }
  100% { transform: translateY(-18px); opacity: 0.35; filter: blur(0.8px); }
}


/* ─── SPEED BLUR (running text) ─── */
.speed-blur.visible {
  animation: speedBlur 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both;
}
@keyframes speedBlur {
  0% { transform: translateX(0) scaleX(1); filter: blur(0); opacity: 1; }
  30% { transform: translateX(15px) scaleX(0.97); filter: blur(1.5px); opacity: 0.8; }
  100% { transform: translateX(40px) scaleX(0.94); filter: blur(0.5px); opacity: 0.65; letter-spacing: -0.02em; }
}


/* ─── SILENCE WEIGHT (expanding space) ─── */
.silence-weight {
  transition: margin 1.5s ease, padding 1.5s ease, opacity 0.6s ease !important;
}
.silence-weight.visible {
  margin-top: 2.5rem !important;
  margin-bottom: 2.5rem !important;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
  text-align: center;
  text-indent: 0 !important;
  font-style: italic;
  opacity: 0.7 !important;
}


/* ─── VADIM RUMBLE (screen tremor before Vadim speaks) ─── */
.vadim-rumble.visible {
  animation: vadimRumble 0.4s ease 0.1s both;
}
@keyframes vadimRumble {
  0% { transform: translateX(0); }
  10% { transform: translateX(-1.5px); }
  20% { transform: translateX(2px); }
  30% { transform: translateX(-2.5px); }
  40% { transform: translateX(1.5px); }
  50% { transform: translateX(-1px); }
  60% { transform: translateX(2px); }
  70% { transform: translateX(-1.5px); }
  80% { transform: translateX(1px); }
  90% { transform: translateX(-0.5px); }
  100% { transform: translateX(0); }
}


/* ─── DOOR SLAM ─── */
.door-slam.visible {
  animation: doorSlam 0.35s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}
@keyframes doorSlam {
  0% { transform: translateX(-20px); opacity: 0; }
  50% { transform: translateX(4px); }
  70% { transform: translateX(-2px); }
  100% { transform: translateX(0); opacity: 1; }
}


/* ─── WHISPER CASCADE (staggered children) ─── */
.whisper-cascade.visible {
  animation: whisperGrow 1s ease both;
}
.whisper-cascade-2.visible {
  animation: whisperGrow 1s ease 0.4s both;
}
.whisper-cascade-3.visible {
  animation: whisperGrow 1s ease 0.8s both;
}
.whisper-cascade-4.visible {
  animation: whisperGrow 1s ease 1.2s both;
}


/* ─── MOUSTACHE TWITCH ─── */
.moustache-twitch.visible {
  animation: moustacheTwitch 0.12s ease 0.4s 4;
}
@keyframes moustacheTwitch {
  0% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-0.3px) rotate(0.15deg); }
  50% { transform: translateY(0.2px) rotate(-0.2deg); }
  75% { transform: translateY(-0.2px) rotate(0.1deg); }
  100% { transform: translateY(0) rotate(0); }
}


/* ─── DEFLATION / RESIGNATION SINK ─── */
.resignation-sink.visible {
  animation: resignSink 1.2s ease 0.4s both;
}
@keyframes resignSink {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(4px); opacity: 0.6; letter-spacing: -0.01em; }
}


/* ─── WARM GLOW PULSE (firelight) ─── */
.warm-glow.visible {
  animation: warmGlow 3s ease-in-out infinite alternate;
}
@keyframes warmGlow {
  0% { text-shadow: 0 0 0 transparent; }
  50% { text-shadow: 0 0 8px rgba(220, 170, 70, 0.08); }
  100% { text-shadow: 0 0 12px rgba(220, 170, 70, 0.12); }
}


/* ─── CARD FLIP REVEAL ─── */
.card-flip.visible {
  animation: cardFlip 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s both;
}
@keyframes cardFlip {
  0% { transform: perspective(600px) rotateX(90deg); opacity: 0; transform-origin: center bottom; }
  60% { transform: perspective(600px) rotateX(-5deg); opacity: 1; }
  100% { transform: perspective(600px) rotateX(0deg); opacity: 1; transform-origin: center bottom; }
}


/* ─── SCRAMBLE DECODE (mech text) ─── */
.scramble-decode {
  font-family: 'JetBrains Mono', monospace;
}
.scramble-decode .scramble-char {
  display: inline-block;
  animation: scrambleIn 0.05s steps(1) both;
  animation-delay: var(--char-delay, 0s);
}
@keyframes scrambleIn {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* ─── TYPEWRITER (mech voicebox) ─── */
.typewriter-mech .char {
  opacity: 0;
  animation: typeChar 0.03s steps(1) forwards;
  animation-delay: var(--char-delay, 0s);
}
@keyframes typeChar {
  to { opacity: 1; }
}
.typewriter-mech .char-glitch {
  opacity: 0;
  animation: typeCharGlitch 0.15s steps(1) forwards;
  animation-delay: var(--char-delay, 0s);
}
@keyframes typeCharGlitch {
  0% { opacity: 0; }
  33% { opacity: 0.7; content: attr(data-alt); }
  66% { opacity: 0.4; }
  100% { opacity: 1; }
}


/* ═══════════════════════════════════════════════
   OVERLAYS
   ═══════════════════════════════════════════════ */

.overlay-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px;
}

.overlay-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 998;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0,0,0,0.5) 100%);
}


/* ─── ZONE INDICATOR ─── */
.zone-indicator {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--atm-muted);
  opacity: 0;
  transition: opacity 0.6s ease, color 1s ease;
}
.zone-indicator.active { opacity: 0.6; }


/* ─── SOUND TOGGLE ─── */
.sound-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  width: 36px;
  height: 36px;
  border: 1px solid var(--atm-accent);
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  color: var(--atm-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 1s ease, color 1s ease, opacity 0.3s ease;
  opacity: 0.5;
}
.sound-toggle:hover { opacity: 0.9; }


/* ─── PARTICLES (DUST / SNOW in story) ─── */
.dust-particle {
  position: fixed;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: var(--atm-text);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  animation: dustFloat linear infinite;
}
@keyframes dustFloat {
  0% { transform: translateY(100vh) translateX(0); opacity: 0; }
  10% { opacity: 0.15; }
  90% { opacity: 0.15; }
  100% { transform: translateY(-10px) translateX(var(--dust-drift, 30px)); opacity: 0; }
}


/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 600px) {
  :root {
    --story-padding-top: 5rem;
  }
  .cover-mech { left: 1vw; width: 50px; }
  .vadim-4, .vadim-5 {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
  }
  .vadim-6, .vadim-7, .vadim-8 {
    margin-left: -1rem;
    margin-right: -1rem;
  }
  .vadim-5 .dialogue-text, .story-p.vadim-5 { font-size: 1.4em; }
  .vadim-6 .dialogue-text, .story-p.vadim-6 { font-size: 1.6em; }
  .vadim-7 .dialogue-text, .story-p.vadim-7 { font-size: 1.8em; }
  .vadim-8 .dialogue-text, .story-p.vadim-8 { font-size: 2.0em; }
  .story-d { padding-left: 1.2em; }
  .casimir-echo { padding-left: 2em !important; }
  .letter-explosion.visible { animation-name: letterExplodeMobile; }
  @keyframes letterExplodeMobile {
    0% { letter-spacing: normal; transform: scale(1); }
    40% { letter-spacing: 0.2em; transform: scale(1.15); }
    100% { letter-spacing: 0.1em; transform: scale(1.08); }
  }
  .speed-blur.visible {
    animation-name: speedBlurMobile;
  }
  @keyframes speedBlurMobile {
    0% { transform: translateX(0); filter: blur(0); opacity: 1; }
    100% { transform: translateX(20px); filter: blur(0.3px); opacity: 0.7; }
  }
}
