/* ==========================================================================
   Attend Class — Unified In-Card Frosted Story & Parkour Transitions
   Each frosted card houses BOTH its minimal editorial story AND its live
   animated 3D frosted-glass work stage. The consistent Educator lives inside
   each card and performs a unique, unhurried parkour movement out of one
   card and into the next as you scroll — seamless on desktop & mobile.
   ========================================================================== */

:root {
  --accent-rgb: 37, 99, 235;
  --accent-strong-rgb: 29, 78, 216;
  --accent-soft-rgb: 96, 165, 250;
  --complement-rgb: 235, 173, 37;
  --emerald-rgb: 16, 185, 129;
  --amber-rgb: 217, 119, 6;
  --cyan-rgb: 14, 151, 166;

  --accent: rgb(var(--accent-rgb));
  --accent-strong: rgb(var(--accent-strong-rgb));

  --bg-canvas: #eef3fb;
  --ink: #0f172a;
  --ink-secondary: #3b4a66;
  --ink-muted: #64748b;

  --glass-bg: rgba(255, 255, 255, 0.58);
  --glass-bg-strong: rgba(255, 255, 255, 0.84);
  --glass-border-top: rgba(255, 255, 255, 0.96);
  --glass-border: rgba(255, 255, 255, 0.68);
  --glass-border-bottom: rgba(var(--accent-rgb), 0.16);
  --glass-shadow:
    0 22px 54px -14px rgba(15, 32, 74, 0.12),
    0 4px 16px -2px rgba(15, 32, 74, 0.05),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.96),
    inset 0 -1.5px 0 rgba(var(--accent-rgb), 0.08);

  --svg-ink: #0f2147;
  --svg-ink-muted: #4b618a;

  --font-display: "Instrument Serif", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", "IBM Plex Sans Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
}

[dir="rtl"] {
  --font-display: "IBM Plex Sans Arabic", "Noto Sans Arabic", system-ui, sans-serif;
  --font-sans: "IBM Plex Sans Arabic", "Noto Sans Arabic", system-ui, sans-serif;
}

/* Attend Class accent palettes */
[data-accent="ocean"] {
  --accent-rgb: 14, 151, 166;
  --accent-strong-rgb: 11, 118, 130;
  --accent-soft-rgb: 34, 211, 238;
  --complement-rgb: 217, 119, 6;
}
[data-accent="indigo"] {
  --accent-rgb: 79, 70, 229;
  --accent-strong-rgb: 67, 56, 202;
  --accent-soft-rgb: 129, 140, 248;
  --complement-rgb: 234, 179, 8;
}
[data-accent="emerald"] {
  --accent-rgb: 5, 150, 105;
  --accent-strong-rgb: 4, 120, 87;
  --accent-soft-rgb: 52, 211, 153;
  --complement-rgb: 37, 99, 235;
}
[data-accent="violet"] {
  --accent-rgb: 124, 58, 237;
  --accent-strong-rgb: 109, 40, 217;
  --accent-soft-rgb: 167, 139, 250;
  --complement-rgb: 14, 165, 233;
}

/* Dark Frosted Obsidian-Crystal Mode */
html.dark-mode {
  --bg-canvas: #141722;
  --ink: #f8fafc;
  --ink-secondary: #cbd5e1;
  --ink-muted: #94a3b8;

  --glass-bg: rgba(28, 34, 52, 0.58);
  --glass-bg-strong: rgba(34, 42, 64, 0.84);
  --glass-border-top: rgba(255, 255, 255, 0.28);
  --glass-border: rgba(255, 255, 255, 0.14);
  --glass-border-bottom: rgba(var(--accent-soft-rgb), 0.24);
  --glass-shadow:
    0 26px 64px -14px rgba(0, 0, 0, 0.58),
    0 6px 18px rgba(0, 0, 0, 0.34),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.24),
    inset 0 -1.5px 0 rgba(var(--accent-soft-rgb), 0.14);

  --svg-ink: #f1f5f9;
  --svg-ink-muted: #a5b8d8;
}

/* Calm twilight wash when Electronic Exams card is in focus */
body.chapter-twilight:not(.is-dark) .atmosphere-twilight {
  opacity: 0.92;
}
body.chapter-twilight:not(.is-dark) .glass-header,
body.chapter-twilight:not(.is-dark) .chapter-rail {
  --ink: #f1f5f9;
  --ink-secondary: #cbd5e1;
  --glass-bg: rgba(20, 30, 56, 0.62);
  --glass-bg-strong: rgba(26, 38, 70, 0.88);
  --glass-border-top: rgba(255, 255, 255, 0.28);
  --glass-border: rgba(191, 219, 254, 0.18);
  color: #f1f5f9;
}

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

html {
  scroll-behavior: auto;
  scroll-snap-type: y proximity;
  background-color: var(--bg-canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html.is-autoplaying {
  scroll-snap-type: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: transparent;
  color: var(--ink);
  overflow-x: clip;
  touch-action: pan-y;
  transition: color 0.55s var(--ease-smooth);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2.5px solid rgba(var(--accent-rgb), 0.7); outline-offset: 3px; }

/* --------------------------------------------------------------------------
   Living Dual-Aura Frosted Atmosphere
   -------------------------------------------------------------------------- */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-color: var(--bg-canvas);
  transition: background-color 0.7s var(--ease-smooth);
  overflow: hidden;
}

.atmosphere-twilight {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(85vw 85vw at 72% 40%, rgba(37, 99, 235, 0.34) 0%, transparent 62%),
    radial-gradient(70vw 70vw at 18% 78%, rgba(79, 70, 229, 0.26) 0%, transparent 58%),
    linear-gradient(155deg, #0d1428 0%, #131f3f 55%, #10172e 100%);
  opacity: 0;
  transition: opacity 0.75s var(--ease-smooth);
}

html.dark-mode .atmosphere-twilight { opacity: 0.45; }

.aura-orb {
  position: absolute;
  border-radius: 50%;
  will-change: transform;
  transition: background 0.8s ease;
}
.aura-orb-1 {
  width: 78vw; height: 78vw; top: -24vw; left: -18vw;
  background: radial-gradient(circle, rgba(var(--complement-rgb), 0.18) 0%, rgba(var(--complement-rgb), 0.08) 38%, transparent 72%);
  animation: auraFloat1 18s ease-in-out infinite alternate;
}
.aura-orb-2 {
  width: 86vw; height: 86vw; top: -20vw; right: -20vw;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.19) 0%, rgba(var(--accent-rgb), 0.08) 38%, transparent 72%);
  animation: auraFloat2 22s ease-in-out infinite alternate;
}
.aura-orb-3 {
  width: 74vw; height: 74vw; bottom: -30vw; left: 18vw;
  background: radial-gradient(circle, rgba(var(--cyan-rgb), 0.14) 0%, rgba(var(--cyan-rgb), 0.05) 40%, transparent 72%);
  animation: auraFloat3 25s ease-in-out infinite alternate;
}
html.dark-mode .aura-orb-1 { background: radial-gradient(circle, rgba(var(--complement-rgb), 0.11) 0%, rgba(var(--complement-rgb), 0.04) 40%, transparent 72%); }
html.dark-mode .aura-orb-2 { background: radial-gradient(circle, rgba(var(--accent-soft-rgb), 0.17) 0%, rgba(var(--accent-soft-rgb), 0.06) 40%, transparent 72%); }

.atmosphere-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(var(--accent-rgb), 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.03) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 85% 75% at 50% 48%, #000 18%, transparent 82%);
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 50% 48%, #000 18%, transparent 82%);
}

@keyframes auraFloat1 { 0% { transform: translate3d(0,0,0) scale(1); } 100% { transform: translate3d(4vw,5vh,0) scale(1.08); } }
@keyframes auraFloat2 { 0% { transform: translate3d(0,0,0) scale(1.04); } 100% { transform: translate3d(-5vw,6vh,0) scale(0.95); } }
@keyframes auraFloat3 { 0% { transform: translate3d(0,0,0) scale(0.96); } 100% { transform: translate3d(3vw,-5vh,0) scale(1.06); } }

/* --------------------------------------------------------------------------
   Top Progress Hairline + Floating Frosted Pill Header
   -------------------------------------------------------------------------- */
.scroll-progress-track {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 60;
  pointer-events: none;
  background: rgba(var(--accent-rgb), 0.08);
}
.scroll-progress-bar {
  height: 100%; width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, rgb(var(--accent-rgb)), rgb(var(--accent-soft-rgb)), rgb(var(--emerald-rgb)));
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.55);
}
[dir="rtl"] .scroll-progress-bar { transform-origin: right center; }

.glass-header {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)), 1260px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px 7px 13px;
  border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(22px) saturate(175%);
  -webkit-backdrop-filter: blur(22px) saturate(175%);
  border: 1px solid var(--glass-border);
  border-top-color: var(--glass-border-top);
  box-shadow: var(--glass-shadow);
  transition: background 0.45s ease, border-color 0.45s ease, color 0.45s ease;
}

.brand-lockup {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; font-size: 0.98rem; letter-spacing: -0.03em; white-space: nowrap;
}
[dir="rtl"] .brand-lockup { letter-spacing: 0; }
.brand-icon {
  width: 34px; height: 34px; border-radius: 10px;
  box-shadow: 0 6px 14px rgba(var(--accent-rgb), 0.28), inset 0 1px 0 rgba(255,255,255,0.45);
  flex-shrink: 0;
}
.header-controls { display: flex; align-items: center; gap: 8px; }

.palette-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 8px; border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.07);
  border: 1px solid rgba(var(--accent-rgb), 0.14);
}
.swatch {
  width: 15px; height: 15px; border-radius: 50%; border: 2px solid transparent; padding: 0;
  transition: transform 0.22s var(--ease-spring), box-shadow 0.2s ease;
}
.swatch:hover { transform: scale(1.2); }
.swatch[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.65); transform: scale(1.14); }
.swatch[data-set-accent="azure"]   { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.swatch[data-set-accent="ocean"]   { background: linear-gradient(135deg, #22d3ee, #0e97a6); }
.swatch[data-set-accent="indigo"]  { background: linear-gradient(135deg, #818cf8, #4f46e5); }
.swatch[data-set-accent="emerald"] { background: linear-gradient(135deg, #34d399, #059669); }
.swatch[data-set-accent="violet"]  { background: linear-gradient(135deg, #a78bfa, #7c3aed); }

.lang-picker { position: relative; }
.lang-picker summary {
  list-style: none; display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--glass-border); border-top-color: var(--glass-border-top);
  background: rgba(255, 255, 255, 0.36); font-size: 0.78rem; font-weight: 750;
  color: var(--ink); cursor: pointer; user-select: none;
  transition: background 0.2s ease;
}
.lang-picker summary::-webkit-details-marker { display: none; }
html.dark-mode .lang-picker summary, body.chapter-twilight .lang-picker summary { background: rgba(255,255,255,0.09); }
.lang-picker summary:hover, .lang-picker[open] summary { background: rgba(var(--accent-rgb), 0.14); }

.lang-menu {
  position: absolute; top: calc(100% + 10px); inset-inline-end: 0;
  min-width: 152px; padding: 6px; border-radius: 18px;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-border); border-top-color: var(--glass-border-top);
  box-shadow: 0 18px 44px rgba(15, 32, 74, 0.22);
  display: flex; flex-direction: column; gap: 2px; z-index: 65;
}
.lang-option {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 8px 12px; border: 0; border-radius: 12px;
  background: transparent; font-size: 0.84rem; font-weight: 600; color: var(--ink);
  text-align: start; transition: background 0.16s ease, color 0.16s ease;
}
.lang-option:hover { background: rgba(var(--accent-rgb), 0.12); }
.lang-option[aria-current="true"] { background: rgba(var(--accent-rgb), 0.18); color: rgb(var(--accent-rgb)); font-weight: 750; }
html.dark-mode .lang-option[aria-current="true"], body.chapter-twilight .lang-option[aria-current="true"] { color: #93c5fd; }

.icon-pill-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 13px; border-radius: 999px;
  border: 1px solid var(--glass-border); border-top-color: var(--glass-border-top);
  background: rgba(255, 255, 255, 0.34); font-size: 0.81rem; font-weight: 650;
  color: var(--ink); transition: transform 0.2s var(--ease-spring), background 0.2s ease;
}
html.dark-mode .icon-pill-btn, body.chapter-twilight .icon-pill-btn { background: rgba(255,255,255,0.09); }
.icon-pill-btn:hover { transform: translateY(-1px); background: rgba(var(--accent-rgb), 0.14); }
.icon-pill-btn.is-playing { background: rgba(var(--accent-rgb), 0.18); border-color: rgba(var(--accent-rgb), 0.45); color: var(--accent); }
html.dark-mode .icon-pill-btn.is-playing, body.chapter-twilight .icon-pill-btn.is-playing { color: #93c5fd; }

.nav-login {
  font-size: 0.84rem; font-weight: 650; color: var(--ink-secondary);
  padding: 8px 10px; border-radius: 999px; transition: color 0.2s ease, background 0.2s ease;
}
.nav-login:hover { color: var(--ink); background: rgba(var(--accent-rgb), 0.08); }

.cta-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 999px; font-size: 0.86rem; font-weight: 700;
  letter-spacing: -0.01em; border: 1px solid rgba(255,255,255,0.28);
  background: linear-gradient(145deg, rgb(var(--accent-rgb)), rgb(var(--accent-strong-rgb)));
  color: #ffffff;
  box-shadow: 0 8px 22px -4px rgba(var(--accent-rgb), 0.42), inset 0 1.5px 0 rgba(255,255,255,0.38);
  transition: transform 0.24s var(--ease-spring), box-shadow 0.24s ease, filter 0.2s ease;
  white-space: nowrap;
}
.cta-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -6px rgba(var(--accent-rgb), 0.52), inset 0 1.5px 0 rgba(255,255,255,0.48);
  filter: brightness(1.06);
}

.cta-pill-glass {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; font-size: 0.86rem; font-weight: 650;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border); border-top-color: var(--glass-border-top);
  color: var(--ink); box-shadow: 0 8px 20px -6px rgba(15, 32, 74, 0.10), inset 0 1px 0 rgba(255,255,255,0.9);
  transition: transform 0.22s var(--ease-spring), border-color 0.2s ease;
  white-space: nowrap;
}
.cta-pill-glass:hover { transform: translateY(-2px); border-color: rgba(var(--accent-rgb), 0.42); }

/* --------------------------------------------------------------------------
   COMPACT GPU-COMPOSITED PARKOUR EDUCATOR ACTOR + TRANSIENT FX LAYER
   Moved via hardware-accelerated translate3d() so iPhone scrolls at 60-120fps
   without ever re-rasterizing a full-viewport SVG bitmap!
   -------------------------------------------------------------------------- */
#parkour-fx-svg {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 25;
  pointer-events: none;
  overflow: visible;
  display: none;
  direction: ltr;
  unicode-bidi: isolate;
}

#educator-actor {
  position: fixed;
  top: 0;
  left: 0;
  width: 380px;
  height: 380px;
  margin-left: -190px;
  margin-top: -310px;
  z-index: 26;
  pointer-events: none;
  will-change: transform;
  contain: layout style;
  direction: ltr;
}

#educator-overlay-svg {
  width: 380px;
  height: 380px;
  display: block;
  overflow: visible;
  direction: ltr;
  unicode-bidi: isolate;
}

/* --------------------------------------------------------------------------
   UNIFIED FROSTED STORY CARDS (Each card contains Copy + Animated SVG Work!)
   -------------------------------------------------------------------------- */
.story-shell {
  position: relative;
  width: min(100%, 1260px);
  margin: 0 auto;
  padding-top: calc(74px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  padding-inline-start: clamp(20px, 3.2vw, 48px);
  padding-inline-end: clamp(64px, 5vw, 76px);
}

.story-chapters {
  display: flex;
  flex-direction: column;
  gap: clamp(32px, 6vh, 68px);
}

.chapter {
  min-height: calc(100vh - 96px);
  min-height: calc(100dvh - 96px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  scroll-snap-align: center;
  scroll-snap-stop: normal;
}

.story-card {
  --card-press-y: 0px;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(310px, 405px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(18px, 2.8vw, 38px);
  padding: clamp(22px, 2.8vw, 38px);
  border-radius: 34px;
  background: var(--glass-bg);
  backdrop-filter: blur(24px) saturate(175%);
  -webkit-backdrop-filter: blur(24px) saturate(175%);
  border: 1.4px solid var(--glass-border);
  border-top-color: var(--glass-border-top);
  border-bottom-color: var(--glass-border-bottom);
  box-shadow: var(--glass-shadow);
  position: relative;
  overflow: visible;
  transform: translateY(var(--card-press-y));
  transition:
    transform 0.32s var(--ease-smooth),
    border-color 0.35s ease,
    box-shadow 0.35s ease,
    background 0.55s ease;
}

/* Alternate work-stage side inside odd cards (Right → Left → Right → Left)
   for a lively diagonal parkour path down the page! */
.chapter[data-flip="true"] .story-card {
  grid-template-columns: minmax(0, 1fr) minmax(310px, 405px);
}
.chapter[data-flip="true"] .card-copy {
  order: 2;
}
.chapter[data-flip="true"] .card-stage {
  order: 1;
}

/* Soft glass top sheen overlay clipped cleanly inside border radius */
.story-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.42) 0%,
    rgba(255, 255, 255, 0.06) 28%,
    transparent 60%,
    rgba(var(--accent-rgb), 0.05) 100%
  );
  pointer-events: none;
}

html.dark-mode .story-card::before {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.14) 0%,
    rgba(255, 255, 255, 0.02) 32%,
    transparent 62%,
    rgba(var(--accent-soft-rgb), 0.08) 100%
  );
}

/* Tactile luminous rim glow when the Educator vaults off or lands on a card! */
.story-card.is-touched {
  border-top-color: rgba(var(--accent-soft-rgb), 0.96);
  border-color: rgba(var(--accent-rgb), 0.44);
  box-shadow:
    0 28px 62px -12px rgba(var(--accent-rgb), 0.22),
    inset 0 2px 0 rgba(255, 255, 255, 0.96),
    inset 0 0 28px rgba(var(--accent-soft-rgb), 0.14);
}

/* Deep Frosted Twilight Sapphire Card for Electronic Exams (Chapter 3) */
.story-card.card-twilight {
  --ink: #f8fafc;
  --ink-secondary: #cbd5e1;
  --ink-muted: #94a3b8;
  --svg-ink: #f1f5f9;
  --svg-ink-muted: #a5b8d8;
  background: linear-gradient(145deg, rgba(22, 34, 68, 0.86), rgba(14, 22, 46, 0.90));
  border-color: rgba(147, 197, 253, 0.24);
  border-top-color: rgba(255, 255, 255, 0.30);
  box-shadow:
    0 28px 70px -14px rgba(6, 12, 34, 0.52),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.24);
  color: #f8fafc;
}
.story-card.card-twilight .kicker {
  color: #93c5fd;
  background: rgba(96, 165, 250, 0.18);
  border-color: rgba(147, 197, 253, 0.30);
}
.story-card.card-twilight h2 em { color: #93c5fd; }
.story-card.card-twilight .glass-chip {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.18);
  color: #e2e8f0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

/* Copy Column Inside Card */
.card-copy {
  position: relative;
  z-index: 2;
  min-width: 0;
}

.kicker {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgb(var(--accent-rgb));
  background: rgba(var(--accent-rgb), 0.11);
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  margin-bottom: 16px;
}
[dir="rtl"] .kicker { letter-spacing: 0; text-transform: none; font-size: 0.8rem; }
html.dark-mode .kicker { color: #93c5fd; background: rgba(96,165,250,0.16); border-color: rgba(147,197,253,0.28); }
.kicker-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; flex-shrink: 0; }

.card-copy h1,
.card-copy h2 {
  font-family: var(--font-display);
  font-weight: 400; line-height: 1.04; letter-spacing: -0.022em;
  margin: 0 0 14px; color: var(--ink); text-wrap: balance;
}
.card-copy h1 { font-size: clamp(2.55rem, 3.8vw, 3.65rem); }
.card-copy h2 { font-size: clamp(2.15rem, 3.2vw, 3.0rem); }
.card-copy h1 em, .card-copy h2 em { font-style: italic; color: rgb(var(--accent-rgb)); display: block; }
html.dark-mode .card-copy h1 em, html.dark-mode .card-copy h2 em { color: #93c5fd; }

[dir="rtl"] .card-copy h1, [dir="rtl"] .card-copy h2 { font-weight: 700; line-height: 1.24; letter-spacing: 0; }
[dir="rtl"] .card-copy h1 { font-size: clamp(2.1rem, 3.1vw, 2.95rem); }
[dir="rtl"] .card-copy h2 { font-size: clamp(1.85rem, 2.7vw, 2.55rem); }
[dir="rtl"] .card-copy h1 em, [dir="rtl"] .card-copy h2 em { font-style: normal; }

.chapter-body {
  font-size: 0.98rem; font-weight: 500; line-height: 1.64;
  color: var(--ink-secondary); margin: 0 0 20px;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.glass-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; font-size: 0.77rem; font-weight: 650;
  color: var(--ink); background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 12px rgba(15,32,74,0.06), inset 0 1px 0 rgba(255,255,255,0.9);
  font-variant-numeric: tabular-nums;
}
html.dark-mode .glass-chip {
  background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.18);
  color: #e2e8f0; box-shadow: inset 0 1px 0 rgba(255,255,255,0.14);
}
.glass-chip-dot { width: 6px; height: 6px; border-radius: 50%; background: rgb(var(--accent-rgb)); flex-shrink: 0; }
.glass-chip-dot.emerald { background: #10b981; }
.glass-chip-dot.amber   { background: #f59e0b; }
.glass-chip-dot.cyan    { background: #06b6d4; }

.card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.scroll-cue {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px;
  font-size: 0.78rem; font-weight: 650; color: var(--ink-muted);
}
.scroll-mouse {
  width: 18px; height: 28px; border-radius: 999px; border: 1.8px solid currentColor;
  position: relative; flex-shrink: 0;
}
.scroll-mouse::after {
  content: ""; position: absolute; top: 5px; left: 50%; width: 3px; height: 6px;
  margin-left: -1.5px; border-radius: 999px; background: currentColor;
  animation: wheelDrop 1.8s ease-in-out infinite;
}
@keyframes wheelDrop { 0%,100% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(9px); opacity: 0.15; } }
.finale-note {
  margin-top: 14px; font-size: 0.8rem; font-weight: 600; color: var(--ink-muted);
  display: flex; flex-wrap: wrap; gap: 8px 14px;
}

/* Inline Animated Work Stage Inside Each Card */
.card-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 940 / 680;
  max-height: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.card-scene-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  direction: ltr;
  unicode-bidi: isolate;
  user-select: none;
  -webkit-user-select: none;
}

/* --------------------------------------------------------------------------
   SVG Typography & Cel Micro-Animations
   -------------------------------------------------------------------------- */
.svg-label {
  font-family: var(--font-sans); font-weight: 700;
  fill: var(--svg-ink); font-variant-numeric: tabular-nums; unicode-bidi: plaintext;
}
.svg-label-muted {
  font-family: var(--font-sans); font-weight: 600;
  fill: var(--svg-ink-muted); font-variant-numeric: tabular-nums; unicode-bidi: plaintext;
}
.svg-mono {
  font-family: var(--font-sans); font-weight: 800; letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate;
}
[dir="rtl"] .svg-mono { letter-spacing: 0; }

.s5-row-bg { fill: rgba(255,255,255,0.56); stroke: rgba(255,255,255,0.9); stroke-width: 1.2; }
html.dark-mode .s5-row-bg { fill: rgba(255,255,255,0.08); stroke: rgba(191,219,254,0.22); }
.s1-qr-well { fill: rgba(255,255,255,0.94); }
html.dark-mode .s1-qr-well { fill: rgba(241,245,249,0.94); }

.cel-dash-flow { stroke-dasharray: 8 10; animation: celFlow 1.6s linear infinite; }
@keyframes celFlow { to { stroke-dashoffset: -36; } }

.cel-sparkle { transform-box: fill-box; transform-origin: center; animation: celTwinkle 2.4s steps(8, end) infinite; }
.cel-sparkle.d2 { animation-delay: -0.8s; animation-duration: 2.8s; }
.cel-sparkle.d3 { animation-delay: -1.5s; animation-duration: 2.1s; }
@keyframes celTwinkle {
  0%,100% { transform: scale(0.55) rotate(0deg); opacity: 0.35; }
  35%     { transform: scale(1.18) rotate(22deg); opacity: 0.95; }
  65%     { transform: scale(0.85) rotate(45deg); opacity: 0.55; }
}

.ble-ring { transform-box: fill-box; transform-origin: center; animation: bleRipple 2.8s cubic-bezier(0.22,1,0.36,1) infinite; }
.ble-ring.r2 { animation-delay: 0.9s; }
.ble-ring.r3 { animation-delay: 1.8s; }
@keyframes bleRipple { 0% { transform: scale(0.32); opacity: 0.72; } 100% { transform: scale(1.65); opacity: 0; } }

/* Pause SVG CSS animations on off-screen chapters for buttery mobile scroll */
.chapter:not(.is-near) .cel-dash-flow,
.chapter:not(.is-near) .cel-sparkle,
.chapter:not(.is-near) .ble-ring {
  animation-play-state: paused;
}

/* --------------------------------------------------------------------------
   Edge Floating Frosted Chapter Scrubber Rail
   -------------------------------------------------------------------------- */
.chapter-rail {
  position: fixed;
  inset-inline-end: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 45;
  display: flex; flex-direction: column; gap: 8px; padding: 10px 7px; border-radius: 999px;
  background: var(--glass-bg);
  backdrop-filter: blur(18px) saturate(165%); -webkit-backdrop-filter: blur(18px) saturate(165%);
  border: 1px solid var(--glass-border); border-top-color: var(--glass-border-top);
  box-shadow: var(--glass-shadow);
}
.rail-dot {
  width: 11px; height: 11px; padding: 0; border-radius: 999px;
  border: 1.5px solid rgba(var(--accent-rgb), 0.38); background: rgba(255,255,255,0.45);
  position: relative;
  transition: height 0.35s var(--ease-spring), background 0.25s ease, border-color 0.25s ease;
}
html.dark-mode .rail-dot, body.chapter-twilight .rail-dot { background: rgba(255,255,255,0.16); border-color: rgba(147,197,253,0.38); }
.rail-dot.is-active {
  height: 28px;
  background: linear-gradient(180deg, rgb(var(--accent-soft-rgb)), rgb(var(--accent-rgb)));
  border-color: rgba(255,255,255,0.85);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.55);
}
.rail-dot::after {
  content: attr(data-label);
  position: absolute; inset-inline-end: calc(100% + 12px); top: 50%;
  transform: translateY(-50%) translateX(6px); white-space: nowrap;
  padding: 5px 11px; border-radius: 999px; font-size: 0.72rem; font-weight: 700;
  color: var(--ink); background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border); box-shadow: 0 8px 20px rgba(15,32,74,0.14);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.22s var(--ease-smooth);
}
[dir="rtl"] .rail-dot::after { transform: translateY(-50%) translateX(-6px); }
.rail-dot:hover::after, .rail-dot:focus-visible::after { opacity: 1; transform: translateY(-50%) translateX(0); }

/* --------------------------------------------------------------------------
   Minimal Frosted Footer
   -------------------------------------------------------------------------- */
.story-footer {
  position: relative; z-index: 10;
  width: min(calc(100% - 32px), 1260px);
  margin: 0 auto calc(24px + env(safe-area-inset-bottom, 0px));
  padding: 18px 24px; border-radius: 22px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(165%); -webkit-backdrop-filter: blur(20px) saturate(165%);
  border: 1px solid var(--glass-border); border-top-color: var(--glass-border-top);
  box-shadow: var(--glass-shadow);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  scroll-snap-align: end;
  scroll-margin-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; font-size: 0.84rem; font-weight: 650; color: var(--ink-secondary); }
.footer-links a:hover { color: rgb(var(--accent-rgb)); }

/* Let the final chapter release cleanly to the footer without trapping scroll snap */
#chapter-6 {
  min-height: auto;
  padding-top: 24px;
  padding-bottom: 12px;
}

/* Mobile / Touch GPU Optimization: pause backdrop-busting orb drift & lighten blur radius */
@media (pointer: coarse), (max-width: 880px) {
  .aura-orb {
    animation: none !important;
  }
  .story-card {
    background: rgba(255, 255, 255, 0.74);
    backdrop-filter: blur(12px) saturate(145%);
    -webkit-backdrop-filter: blur(12px) saturate(145%);
  }
  html.dark-mode .story-card {
    background: rgba(26, 33, 52, 0.76);
  }
  .story-card.card-twilight {
    background: linear-gradient(145deg, rgba(22, 34, 68, 0.90), rgba(14, 22, 46, 0.94));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }
  .glass-header,
  .story-footer {
    backdrop-filter: blur(14px) saturate(150%);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
  }
}

/* --------------------------------------------------------------------------
   RESPONSIVE BREAKPOINTS:
   1. Tablet & Phone Portrait (Stacked inside each card: SVG on top, Copy below!)
   2. Phone Landscape (Compact Side-by-Side inside each card!)
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .palette-pill, .nav-login { display: none; }
}

/* Tablet & Phone Portrait */
@media (max-width: 880px) and (min-height: 541px), (max-width: 559px) {
  .story-shell {
    padding-top: calc(68px + env(safe-area-inset-top, 0px));
    padding-inline-start: calc(14px + env(safe-area-inset-left, 0px));
    padding-inline-end: calc(14px + env(safe-area-inset-right, 0px));
  }
  .story-chapters {
    gap: 28px;
  }
  .chapter {
    min-height: auto;
    padding: 8px 0;
    scroll-snap-align: start;
    scroll-margin-top: calc(64px + env(safe-area-inset-top, 0px));
  }
  .story-card,
  .chapter[data-flip="true"] .story-card {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px 18px 22px;
    border-radius: 26px;
  }
  .story-card .card-stage,
  .chapter[data-flip="true"] .story-card .card-stage {
    order: 1;
    aspect-ratio: 940 / 640;
    max-height: 360px;
  }
  .story-card .card-copy,
  .chapter[data-flip="true"] .story-card .card-copy {
    order: 2;
  }
  .chapter-rail { display: none; }
}

/* Phone Portrait Fine-Tuning (375px–559px) */
@media (max-width: 559px) {
  .glass-header {
    top: calc(8px + env(safe-area-inset-top, 0px));
    width: calc(100% - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
    padding: 5px 6px 5px 9px; gap: 6px;
  }
  .brand-icon { width: 30px; height: 30px; border-radius: 9px; }
  .brand-lockup { gap: 7px; font-size: 0.88rem; }
  .header-controls { gap: 5px; }
  .lang-picker summary { height: 34px; padding: 0 9px; font-size: 0.74rem; gap: 4px; }
  .icon-pill-btn { width: 34px; height: 34px; padding: 0; }
  .icon-pill-btn span { display: none; }
  .cta-pill { padding: 8px 13px; font-size: 0.78rem; }

  .story-card { padding: 14px 16px 18px; border-radius: 24px; }
  .story-card .card-stage,
  .chapter[data-flip="true"] .story-card .card-stage {
    max-height: 270px;
  }
  .kicker { font-size: 0.68rem; padding: 4px 10px; margin-bottom: 10px; }
  .card-copy h1 { font-size: 2.02rem; margin-bottom: 8px; }
  .card-copy h2 { font-size: 1.78rem; margin-bottom: 8px; }
  [dir="rtl"] .card-copy h1 { font-size: 1.7rem; }
  [dir="rtl"] .card-copy h2 { font-size: 1.54rem; }
  .chapter-body { font-size: 0.9rem; line-height: 1.54; margin-bottom: 14px; }
  .glass-chip { font-size: 0.72rem; padding: 5px 10px; }
  .card-actions { margin-top: 14px; gap: 8px; }
  .card-actions .cta-pill, .card-actions .cta-pill-glass { padding: 10px 14px; font-size: 0.82rem; }
  .scroll-cue { margin-top: 12px; font-size: 0.74rem; }
  .story-footer { width: calc(100% - 24px); padding: 14px 16px; gap: 10px; }
  .footer-links { gap: 12px; font-size: 0.78rem; }
}

@media (max-width: 380px) {
  .brand-lockup span { display: none; }
  .card-actions { flex-direction: column; }
  .card-actions .cta-pill, .card-actions .cta-pill-glass { width: 100%; }
}

/* Mobile & Short-Height Landscape (e.g., iPhone 844x390, 667x375):
   Sleek Side-by-Side Inside Each Card — 100% fits vertically! */
@media (min-width: 560px) and (max-height: 540px) {
  .glass-header {
    top: calc(6px + env(safe-area-inset-top, 0px));
    width: min(calc(100% - 20px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)), 1180px);
    padding: 4px 7px 4px 10px; gap: 8px;
  }
  .brand-icon { width: 28px; height: 28px; border-radius: 8px; }
  .brand-lockup { font-size: 0.86rem; gap: 7px; }
  .lang-picker summary, .icon-pill-btn { height: 30px; padding: 0 10px; font-size: 0.74rem; }
  .cta-pill { padding: 6px 13px; font-size: 0.76rem; }

  .story-shell {
    padding-top: calc(54px + env(safe-area-inset-top, 0px));
    padding-inline-start: calc(14px + env(safe-area-inset-left, 0px));
    padding-inline-end: calc(14px + env(safe-area-inset-right, 0px));
  }
  .story-chapters { gap: 18px; }
  .chapter {
    min-height: calc(100dvh - 58px);
    padding: 4px 0;
    scroll-snap-align: start;
    scroll-margin-top: calc(54px + env(safe-area-inset-top, 0px));
  }
  .story-card {
    grid-template-columns: minmax(230px, 43%) minmax(0, 1fr);
    gap: 16px;
    padding: 12px 18px;
    border-radius: 22px;
  }
  .chapter[data-flip="true"] .story-card {
    grid-template-columns: minmax(0, 1fr) minmax(230px, 43%);
  }
  .card-stage {
    max-height: calc(100dvh - 106px);
  }
  .kicker { font-size: 0.64rem; padding: 3px 9px; margin-bottom: 8px; }
  .card-copy h1 { font-size: 1.62rem; margin-bottom: 6px; }
  .card-copy h2 { font-size: 1.46rem; margin-bottom: 6px; }
  [dir="rtl"] .card-copy h1 { font-size: 1.4rem; }
  [dir="rtl"] .card-copy h2 { font-size: 1.3rem; }
  .chapter-body { font-size: 0.8rem; line-height: 1.44; margin-bottom: 10px; }
  .chip-row { gap: 5px; }
  .glass-chip { font-size: 0.68rem; padding: 4px 8px; }
  .card-actions { margin-top: 10px; gap: 7px; }
  .card-actions .cta-pill, .card-actions .cta-pill-glass { padding: 7px 12px; font-size: 0.75rem; }
  .scroll-cue { display: none; }
  .finale-note { margin-top: 8px; font-size: 0.72rem; gap: 4px 10px; }
  .chapter-rail { display: none; }
  .story-footer { padding: 12px 16px; margin-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; scroll-snap-type: none; }
  .aura-orb, .cel-dash-flow, .cel-sparkle, .ble-ring, .scroll-mouse::after { animation: none !important; }
}
