/* ==========================================================================
   ABANDONED BUT NOT FORGOTTEN
   Interactive Historical Space Exploration Storybook Stylesheet
   ========================================================================== */

:root {
  --bg-deep: #080c16;
  --bg-surface: #101728;
  --bg-surface-elevated: #18233c;
  --bg-card: rgba(20, 30, 52, 0.88);
  --bg-hud: rgba(11, 16, 31, 0.92);
  
  --primary-gold: #f6c043;
  --primary-gold-bright: #ffe07a;
  --primary-gold-glow: rgba(246, 192, 67, 0.35);
  --apollo-teal: #36d1dc;
  --apollo-cyan: #5b86e5;
  --saturn-orange: #ff7e47;
  
  --text-main: #f0f4fc;
  --text-muted: #9eb1d4;
  --text-dim: #65779c;
  --text-highlight: #ffffff;
  
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-active: rgba(246, 192, 67, 0.45);
  --border-glow: 0 0 16px rgba(246, 192, 67, 0.25);
  
  --font-serif: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Consolas", "Courier New", monospace;
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --dialogue-font-size: 1.15rem;
  --line-height: 1.7;
  
  --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* High Contrast Mode */
body.high-contrast {
  --bg-deep: #000000;
  --bg-surface: #0a0a0a;
  --bg-surface-elevated: #161616;
  --bg-card: #121212;
  --bg-hud: #000000;
  --primary-gold: #ffff00;
  --primary-gold-bright: #ffffff;
  --primary-gold-glow: rgba(255, 255, 0, 0.5);
  --text-main: #ffffff;
  --text-muted: #e0e0e0;
  --border-subtle: #ffffff;
  --border-active: #ffff00;
}

/* Font Size Adjustments */
body.font-small { --dialogue-font-size: 1rem; }
body.font-medium { --dialogue-font-size: 1.18rem; }
body.font-large { --dialogue-font-size: 1.35rem; }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  color: inherit;
  transition: all var(--transition-fast);
}

button:focus-visible {
  outline: 2px solid var(--primary-gold);
  outline-offset: 3px;
}

/* App Container */
.storybook-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  background: radial-gradient(circle at 50% 20%, #152244 0%, #080c16 85%);
}

/* ==========================================================================
   Header Navigation Bar
   ========================================================================== */
.storybook-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(8, 12, 22, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #f6c043, #ff7e47);
  border-radius: var(--radius-md);
  color: #080c16;
  font-size: 1.25rem;
  box-shadow: 0 0 12px var(--primary-gold-glow);
}

.title-group {
  display: flex;
  flex-direction: column;
}

.main-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary-gold-bright);
  text-transform: uppercase;
}

.sub-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* Center Indicator */
.center-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  padding: 6px 16px;
  border-radius: var(--radius-full);
}

.chapter-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary-gold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.indicator-divider {
  color: var(--text-dim);
}

.scene-name-badge {
  font-size: 0.82rem;
  color: var(--text-main);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  color: var(--text-main);
  font-weight: 500;
}

.nav-pill-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.nav-pill-btn.active {
  background: var(--primary-gold-glow);
  border-color: var(--primary-gold);
  color: var(--primary-gold-bright);
}

.nav-icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.nav-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--primary-gold-bright);
}

/* ==========================================================================
   Main Stage: Illustration Area & Interactive Canvas
   ========================================================================== */
.stage-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 16px 20px 24px 20px;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

.illustration-viewport {
  position: relative;
  width: 100%;
  max-width: 1100px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--border-subtle);
  background-color: #0b101d;
}

.illustration-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity var(--transition-slow), transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  transform: scale(1.0);
}

.illustration-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity var(--transition-slow);
}

.illustration-image.zooming {
  transform: scale(1.03);
}

.illustration-image.fade-out {
  opacity: 0;
}

.illustration-image.fade-in {
  opacity: 1;
}

/* Subtle Vignette & Lighting Filter */
.viewport-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, transparent 65%, rgba(4, 7, 14, 0.6) 100%),
              linear-gradient(to bottom, rgba(8, 12, 22, 0.25) 0%, transparent 20%, transparent 70%, rgba(8, 12, 22, 0.85) 100%);
  z-index: 2;
}

/* Interactive Hotspot Markers */
.hotspots-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.hotspot-node {
  position: absolute;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.hotspot-pin {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(246, 192, 67, 0.95);
  color: #080c16;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: bold;
  box-shadow: 0 0 0 4px rgba(246, 192, 67, 0.35), 0 4px 12px rgba(0,0,0,0.5);
  transition: all var(--transition-fast);
  position: relative;
}

.hotspot-ring {
  position: absolute;
  inset: -8px;
  border: 2px solid var(--primary-gold);
  border-radius: 50%;
  animation: pulse-ring 2.2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
  pointer-events: none;
}

@keyframes pulse-ring {
  0% { transform: scale(0.7); opacity: 1; }
  70% { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}

.hotspot-node:hover .hotspot-pin {
  transform: scale(1.18);
  background: #ffffff;
  color: #ff7e47;
  box-shadow: 0 0 0 6px var(--primary-gold-glow), 0 6px 16px rgba(0,0,0,0.6);
}

.hotspot-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-active);
  color: var(--text-highlight);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.hotspot-node:hover .hotspot-tooltip,
.hotspot-node:focus-visible .hotspot-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Fallback Notice for Images */
.image-fallback-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #101729;
  color: var(--text-muted);
  padding: 40px;
  text-align: center;
  gap: 12px;
}

.fallback-icon {
  font-size: 3rem;
  color: var(--primary-gold);
}

/* Floating Badges inside Viewport */
.viewport-info-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 15;
  pointer-events: none;
}

.info-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 16, 28, 0.75);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.info-pill strong {
  color: var(--primary-gold-bright);
}

.hotspots-hint-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(246, 192, 67, 0.2);
  backdrop-filter: blur(8px);
  border: 1px solid var(--primary-gold);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary-gold-bright);
}

.hotspots-hint-btn:hover {
  background: rgba(246, 192, 67, 0.35);
}

/* ==========================================================================
   Dialogue HUD / Bottom Interface
   ========================================================================== */
.dialogue-hud {
  width: 100%;
  max-width: 1100px;
  margin-top: 14px;
  background: var(--bg-hud);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: all var(--transition-normal);
}

/* Dialogue Header */
.dialogue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding-bottom: 10px;
}

.speaker-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.speaker-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(246, 192, 67, 0.15);
  border: 1px solid var(--primary-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.speaker-text-group {
  display: flex;
  flex-direction: column;
}

.speaker-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-gold-bright);
  letter-spacing: 0.02em;
}

.speaker-role-label {
  font-size: 0.74rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dialogue-meta-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.passage-counter {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Dialogue Body / Original Verbatim Script Passage */
.dialogue-content {
  min-height: 84px;
  display: flex;
  align-items: center;
}

.dialogue-quote {
  font-family: var(--font-serif);
  font-size: var(--dialogue-font-size);
  line-height: var(--line-height);
  color: var(--text-main);
  letter-spacing: 0.015em;
  transition: opacity var(--transition-fast);
}

.dialogue-quote.speaking {
  color: #ffffff;
  text-shadow: 0 0 12px rgba(246, 192, 67, 0.4);
}

/* Dialogue Controls Footer */
.dialogue-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-top: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Primary Action Buttons */
.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-main);
}

.hud-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.hud-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.hud-btn-primary {
  background: linear-gradient(135deg, #f6c043, #ff7e47);
  border: 1px solid var(--primary-gold-bright);
  color: #080c16;
  font-weight: 700;
}

.hud-btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #ffd05b, #ff9261);
  box-shadow: 0 4px 14px var(--primary-gold-glow);
}

.hud-btn-accent {
  background: rgba(54, 209, 220, 0.15);
  border: 1px solid var(--apollo-teal);
  color: var(--apollo-teal);
}

.hud-btn-accent:hover:not(:disabled) {
  background: rgba(54, 209, 220, 0.28);
  color: #ffffff;
}

/* Audio Waveform Animation */
.audio-waves {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 14px;
}

.wave-bar {
  width: 2.5px;
  background-color: currentColor;
  border-radius: 1px;
  height: 4px;
}

.wave-active .wave-bar:nth-child(1) { animation: wave 1s infinite ease-in-out; }
.wave-active .wave-bar:nth-child(2) { animation: wave 1s infinite 0.2s ease-in-out; }
.wave-active .wave-bar:nth-child(3) { animation: wave 1s infinite 0.4s ease-in-out; }
.wave-active .wave-bar:nth-child(4) { animation: wave 1s infinite 0.15s ease-in-out; }

@keyframes wave {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}

/* Immersive Mode Toggle State */
body.immersive-mode .storybook-header {
  transform: translateY(-100%);
  transition: transform var(--transition-normal);
}

body.immersive-mode .dialogue-hud {
  opacity: 0.15;
  transform: translateY(20px);
}

body.immersive-mode .dialogue-hud:hover {
  opacity: 1;
  transform: translateY(0);
}

/* Immersive Floating Exit Button */
.immersive-exit-btn {
  display: none;
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  background: rgba(10, 16, 28, 0.85);
  border: 1px solid var(--primary-gold);
  color: var(--primary-gold-bright);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
}

body.immersive-mode .immersive-exit-btn {
  display: inline-flex;
}

/* ==========================================================================
   Modals & Drawers: Educational Cards & Chapter Navigation
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 14, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), var(--border-glow);
  display: flex;
  flex-direction: column;
  position: relative;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-backdrop.open .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.02);
}

.modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fact-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fact-badge.verified {
  background: rgba(46, 204, 113, 0.2);
  border: 1px solid #2ecc71;
  color: #2ecc71;
}

.fact-badge.category {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary-gold-bright);
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 1.25rem;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.dossier-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dossier-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--apollo-teal);
  letter-spacing: 0.06em;
}

.dossier-value {
  font-size: 0.94rem;
  line-height: 1.6;
  color: var(--text-main);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Chapter Navigator Drawer */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chapter-item-card {
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition-fast);
}

.chapter-item-card.active {
  border-color: var(--primary-gold);
  background: rgba(246, 192, 67, 0.06);
}

.chapter-item-card.locked {
  opacity: 0.75;
  border-style: dashed;
}

.chapter-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chapter-number-pill {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary-gold);
}

.status-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.status-tag.ready {
  background: rgba(46, 204, 113, 0.2);
  color: #2ecc71;
  border: 1px solid #2ecc71;
}

.status-tag.awaiting {
  background: rgba(255, 126, 71, 0.2);
  color: #ff9e79;
  border: 1px solid #ff7e47;
}

.chapter-card-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-highlight);
}

.chapter-card-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.chapter-card-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.placeholder-box {
  background: rgba(255, 126, 71, 0.08);
  border-left: 3px solid #ff7e47;
  padding: 8px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.78rem;
  color: #ffbba3;
}

/* ==========================================================================
   Settings Modal Styling
   ========================================================================== */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.setting-label-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
}

.setting-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.toggle-switch.active {
  background: var(--primary-gold);
  border-color: var(--primary-gold-bright);
}

.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.toggle-switch.active .toggle-knob {
  transform: translateX(20px);
  background: #080c16;
}

/* ==========================================================================
   Keyboard Shortcut Legend Banner (Accessible HUD)
   ========================================================================== */
.keyboard-legend-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 8px 20px;
  font-size: 0.72rem;
  color: var(--text-dim);
  background: rgba(8, 12, 22, 0.9);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.kbd-badge {
  display: inline-block;
  padding: 1px 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  font-family: var(--font-mono);
  color: var(--primary-gold);
  margin-right: 4px;
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */
@media (max-width: 900px) {
  .storybook-header {
    height: auto;
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .center-indicator {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .stage-container {
    padding: 10px 12px 16px 12px;
  }

  .dialogue-hud {
    padding: 14px 16px;
  }

  .dialogue-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .hud-group {
    justify-content: center;
    width: 100%;
  }
}

@media (max-width: 600px) {
  .main-title {
    font-size: 0.9rem;
  }
  
  .sub-title {
    display: none;
  }

  .nav-pill-btn span:not(.pill-icon) {
    display: none;
  }

  .dialogue-quote {
    font-size: 1.05rem;
  }

  .keyboard-legend-bar {
    display: none;
  }
}

/* ==========================================================================
   Ending Sequence & Title Screen (A Small Blue World)
   ========================================================================== */
.ending-screen {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, #0e1933 0%, #03060c 85%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.6s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 30px;
  text-align: center;
}

.ending-screen.active {
  opacity: 1;
  pointer-events: auto;
}

.ending-content {
  max-width: 820px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  transform: translateY(24px) scale(0.95);
  transition: transform 1.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.ending-screen.active .ending-content {
  transform: translateY(0) scale(1);
}

.ending-badge {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--apollo-teal);
}

.ending-title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5.5vw, 3.6rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--primary-gold-bright);
  text-transform: uppercase;
  text-shadow: 0 0 35px var(--primary-gold-glow), 0 4px 20px rgba(0, 0, 0, 0.9);
  line-height: 1.25;
}

.ending-subtitle {
  font-size: clamp(1.05rem, 2.2vw, 1.45rem);
  color: var(--text-muted);
  letter-spacing: 0.08em;
  font-style: italic;
  font-family: var(--font-serif);
}

.ending-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Cinematic ending zoom animation on viewport */
.illustration-viewport.ending-zoom {
  transform: scale(0.92);
  opacity: 0.2;
  transition: transform 2.2s cubic-bezier(0.16, 1, 0.3, 1), opacity 2.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   THEME STYLING: MARS VS MOON
   ========================================================================== */
body.theme-mars {
  --primary-gold: #ff6b3d;
  --primary-gold-bright: #ff9e7d;
  --primary-gold-glow: rgba(255, 107, 61, 0.45);
  --bg-deep: #0e0503;
  --bg-surface: #1a0a05;
  --bg-surface-elevated: #281008;
  --bg-card: rgba(35, 15, 8, 0.92);
  --bg-hud: rgba(18, 6, 2, 0.95);
  --saturn-orange: #ff5722;
  --border-active: rgba(255, 107, 61, 0.6);
  --border-glow: 0 0 16px rgba(255, 107, 61, 0.3);
}

body.theme-moon {
  --primary-gold: #38bdf8;
  --primary-gold-bright: #93c5fd;
  --primary-gold-glow: rgba(56, 189, 248, 0.45);
  --bg-deep: #050b14;
  --bg-surface: #0a1324;
  --bg-surface-elevated: #11203b;
  --bg-card: rgba(12, 23, 44, 0.92);
  --bg-hud: rgba(7, 14, 28, 0.95);
  --saturn-orange: #60a5fa;
  --border-active: rgba(56, 189, 248, 0.6);
  --border-glow: 0 0 16px rgba(56, 189, 248, 0.3);
}

/* ==========================================================================
   FIRST SCREEN: STORY GATEWAY (MARS OPENS FIRST)
   ========================================================================== */
/* ==========================================================================
   STORYBOOK INTRODUCTION PAGE & GATEWAY (TRANSFERRED FROM STORYBOOK)
   ========================================================================== */
.story-gateway {
  position: fixed;
  inset: 0;
  z-index: 500;
  min-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #14192b 0%, #070a14 55%, #04060b 100%);
  display: block;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.story-gateway.closed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.gw-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.gw-stars {
  position: absolute;
  inset: -10%;
  background:
    radial-gradient(1.5px 1.5px at 12% 22%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 68%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 44% 14%, #cfe 50%, transparent 51%),
    radial-gradient(1px 1px at 61% 80%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 77% 30%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 90% 62%, #fde 50%, transparent 51%),
    radial-gradient(1px 1px at 5% 90%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 46%, #fff 50%, transparent 51%);
  background-size: 520px 520px;
  opacity: 0.55;
  animation: drift 160s linear infinite;
}

@keyframes drift {
  to { transform: translate3d(-520px, -260px, 0); }
}

.gw-inner {
  position: relative;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(14px, 2.4vw, 30px) clamp(16px, 4vw, 40px) 24px;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 1.8vw, 22px);
  min-height: 100%;
  justify-content: center;
}

.gw-head {
  text-align: center;
  max-width: 820px;
  margin: 0 auto;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 0.74rem;
  color: #7d8596;
}

.gw-title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.9rem, 4.4vw, 3.3rem);
  line-height: 1.06;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: #f2efe9;
}

.gw-sub {
  margin: 12px 0 0;
  letter-spacing: 0.2em;
  font-size: clamp(0.72rem, 1.4vw, 0.92rem);
  color: #b9bfcc;
  text-transform: uppercase;
}

.gw-intro {
  margin: 12px auto 0;
  max-width: 64ch;
  line-height: 1.65;
  color: #b9bfcc;
  font-size: clamp(0.98rem, 1.5vw, 1.1rem);
}

.story-pick {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 2vw, 22px);
}

.story-card {
  position: relative;
  display: flex;
  align-items: flex-end;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #0b0f1a;
  cursor: pointer;
  min-height: clamp(170px, 27vh, 290px);
  isolation: isolate;
  transition: transform 0.35s ease, border-color 0.25s, box-shadow 0.35s;
}

.story-card .card-img {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform 1.2s ease, filter 0.4s;
  filter: saturate(0.9) brightness(0.82);
  z-index: -2;
}

.story-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 7, 13, 0.1) 0%, rgba(5, 7, 13, 0.5) 45%, rgba(5, 7, 13, 0.95) 100%);
  z-index: -1;
}

.story-card:hover .card-img {
  transform: scale(1.05);
}

.story-card:has(input:checked),
.story-card.selected {
  border-color: var(--c, #fff);
  box-shadow: 0 0 0 2px var(--c, #fff), 0 18px 50px -12px var(--c, #fff);
  transform: translateY(-3px);
}

.story-card:has(input:checked) .card-img,
.story-card.selected .card-img {
  filter: saturate(1.05) brightness(1);
}

.story-card:has(input:focus-visible) {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.story-card[data-story="mars"] { --c: #ff9466; }
.story-card[data-story="moon"] { --c: #9ccfff; }

.card-body {
  position: static;
  width: 100%;
  padding: clamp(14px, 2vw, 24px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.card-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--c);
  font-weight: 700;
}

.card-title {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
  font-size: clamp(1.5rem, 3vw, 2.3rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
}

.card-desc {
  font-size: 0.92rem;
  line-height: 1.5;
  color: #b9bfcc;
  max-width: 46ch;
}

.card-check {
  display: none;
}

.story-card:has(input:checked) .card-check,
.story-card.selected .card-check {
  display: grid;
  position: absolute;
  right: 14px;
  top: 14px;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--c);
  color: #111;
  font-weight: 800;
}

.setup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(12px, 2vw, 24px);
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.setup-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setup-label {
  font-size: 0.74rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #7d8596;
}

.setup-hint {
  margin: 0;
  font-size: 0.88rem;
  color: #b9bfcc;
  line-height: 1.45;
  min-height: 2.6em;
}

.seg {
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.04);
  gap: 4px;
}

.seg button {
  flex: 1;
  min-height: 46px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #b9bfcc;
  padding: 6px 12px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.seg button[aria-checked="true"] {
  background: #f2efe9;
  color: #0a0d16;
  font-weight: 700;
}

.seg button:not([aria-checked="true"]):hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f2efe9;
}

.begin-row {
  text-align: center;
  margin-top: 4px;
}

.btn-begin {
  min-height: 56px;
  padding: 0 clamp(24px, 5vw, 56px);
  border: 0;
  border-radius: 999px;
  background: var(--accent, #ff9466);
  color: #1b0a03;
  font-weight: 800;
  font-size: 1.08rem;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 30px -10px var(--accent, #ff9466);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, filter 0.2s, background 0.2s;
}

.btn-begin:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.06);
}

.btn-begin:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: #7d8596;
  box-shadow: none;
  cursor: not-allowed;
}

.begin-note {
  margin: 10px 0 0;
  min-height: 1.4em;
  font-size: 0.88rem;
  color: #b9bfcc;
}

.gw-foot {
  text-align: center;
  margin-top: 4px;
}

.link-btn {
  background: none;
  border: 0;
  color: #b9bfcc;
  text-decoration: underline;
  text-underline-offset: 3px;
  min-height: 44px;
  padding: 0 10px;
  font-size: 0.92rem;
  cursor: pointer;
  transition: color 0.2s;
}

.link-btn:hover {
  color: #f2efe9;
}

/* Credits & Disclosures Modal Content */
#credits-body {
  line-height: 1.65;
  color: #b9bfcc;
  font-size: 0.95rem;
}

#credits-body h3 {
  color: #f2efe9;
  margin: 18px 0 6px;
  font-size: 1.05rem;
  font-family: var(--font-serif);
}

#credits-body h3:first-child {
  margin-top: 0;
}

#credits-body ul {
  padding-left: 20px;
  margin: 6px 0 14px;
}

#credits-body li {
  margin: 6px 0;
  color: #cbd5e1;
}

/* Responsive Gateway */
@media (max-width: 860px) {
  .story-pick {
    grid-template-columns: 1fr;
  }
  .story-card {
    min-height: 170px;
  }
  .setup {
    grid-template-columns: 1fr;
  }
  .setup-hint {
    min-height: 0;
  }
  .begin-row {
    position: sticky;
    bottom: 0;
    z-index: 6;
    padding: 14px 0 calc(10px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, rgba(5, 7, 13, 0), #05070d 38%);
  }
  .btn-begin {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .gw-stars {
    animation: none;
  }
}

@media (max-height: 820px) and (min-width: 861px) {
  .story-card {
    min-height: clamp(150px, 24vh, 230px);
  }
  .gw-title {
    font-size: clamp(1.8rem, 3.6vw, 2.8rem);
  }
}

/* ==========================================================================
   HEADER CONTROLS: STORY & LANGUAGE SWITCHERS
   ========================================================================== */
.story-switcher-control {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}

.story-pill {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  transition: all 0.2s;
}

.story-pill.active {
  background: var(--primary-gold);
  color: #000000;
  box-shadow: 0 0 12px var(--primary-gold-glow);
}

.lang-switcher-control {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.lang-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.2s;
}

.lang-pill.active {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   PLAYBACK MODE SWITCHER (AUTO / MANUAL)
   ========================================================================== */
.mode-switcher-control {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  border: 1px solid transparent;
}

.mode-pill:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.mode-pill.active {
  background: rgba(16, 185, 129, 0.25);
  color: #a7f3d0;
  border: 1px solid rgba(16, 185, 129, 0.5);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
}

body.theme-mars .mode-pill.active {
  background: rgba(255, 87, 34, 0.25);
  color: #ffccbc;
  border: 1px solid rgba(255, 87, 34, 0.6);
  box-shadow: 0 0 10px rgba(255, 87, 34, 0.4);
}

body.theme-moon .mode-pill.active {
  background: rgba(56, 189, 248, 0.25);
  color: #bae6fd;
  border: 1px solid rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

/* ==========================================================================
   VIDEO AUDIO STATUS & SYNCHRONIZED SUBTITLES
   ========================================================================== */
.video-audio-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(255, 87, 34, 0.25);
  border: 1px solid #ff5722;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ffab91;
  cursor: pointer;
  animation: pulseAudio 2.5s infinite;
}

@keyframes pulseAudio {
  0%, 100% { box-shadow: 0 0 8px rgba(255, 87, 34, 0.3); }
  50% { box-shadow: 0 0 18px rgba(255, 87, 34, 0.7); }
}

/* Subtitles: bottom of the picture, size chosen in Settings (default Medium). */
body {
  --sub-small: 0.8rem;
  --sub-medium: 0.95rem;
  --sub-large: 1.2rem;
  --sub-xlarge: 1.5rem;
  --subtitle-font-size: var(--sub-medium);
}
@media (max-width: 640px) {
  body {
    --sub-small: 0.68rem;
    --sub-medium: 0.78rem;
    --sub-large: 0.95rem;
    --sub-xlarge: 1.15rem;
  }
}
body.subs-small  { --subtitle-font-size: var(--sub-small); }
body.subs-medium { --subtitle-font-size: var(--sub-medium); }
body.subs-large  { --subtitle-font-size: var(--sub-large); }
body.subs-xlarge { --subtitle-font-size: var(--sub-xlarge); }

.viewport-subtitles-container {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 92%;
  max-width: 720px;
  max-height: calc(100% - 24px);   /* never taller than the picture */
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.viewport-subtitles {
  background: rgba(5, 5, 10, 0.82);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: var(--subtitle-font-size);
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  display: none;
  max-width: 100%;
  max-height: 100%;
  overflow-y: auto;                /* very long lines scroll inside the box instead of spilling out */
  overflow-wrap: anywhere;
}

.viewport-subtitles.active {
  display: inline-block;
}

/* Playback Speed Control */
.hud-speed-wrapper {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.hud-select {
  background: var(--bg-surface-elevated);
  color: #ffffff;
  border: 1px solid var(--border-subtle);
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.hud-select:focus {
  outline: none;
  border-color: var(--primary-gold);
}

.hud-btn-icon {
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.hud-btn-icon.active {
  background: rgba(255, 255, 255, 0.2);
  color: var(--primary-gold-bright);
}


