/* CSS Variables for Design System */
:root {
    /* Color Palette */
    --sun-gold: #FFB703;
    --warm-yellow: #FFD166;
    --deep-navy: #073B4C;
    --soft-teal: #118AB2;
    --mint: #06D6A0;
    --coral: #EF476F;
    --neutral: #F8FAFC;
    --dark-text: #1E293B;
    --light-text: #64748B;
    
    /* Typography Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    
    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
  }
  
  /* High Contrast Mode */
  .high-contrast {
    --sun-gold: #FFD700;
    --warm-yellow: #FFFF00;
    --deep-navy: #000080;
    --soft-teal: #008080;
    --mint: #00FF00;
    --coral: #FF0000;
    --neutral: #FFFFFF;
    --dark-text: #000000;
    --light-text: #333333;
  }
  
  /* Base Styles */
  * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }
  
  html {
    scroll-behavior: smooth;
  }
  
  body {
    font-family: "Cairo", "Noto Kufi Arabic", system-ui, sans-serif;
    background: var(--neutral);
    color: var(--dark-text);
    line-height: 1.6;
    overflow-x: hidden;
    direction: rtl;
  }
  
  /* Accessibility: Reduced Motion */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
    
    html {
      scroll-behavior: auto;
    }
  }
  
  /* Header & Navigation */
  .story-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  }
  
  .header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
  }
  
  .skip-btn {
    background: var(--coral);
    color: white;
    border: none;
    padding: var(--space-xs) var(--space-md);
    border-radius: 20px;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: var(--transition-base);
  }
  
  .skip-btn:hover,
  .skip-btn:focus {
    background: #D43A5F;
    transform: translateY(-1px);
  }
  
  .progress-container {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
  }
  
  .progress-bar {
    width: 200px;
    height: 4px;
    background: rgba(7, 59, 76, 0.2);
    border-radius: 2px;
    overflow: hidden;
  }
  
  .progress-fill {
    height: 100%;
    background: var(--sun-gold);
    width: 0%;
    transition: width var(--transition-slow);
  }
  
  .scene-indicators {
    display: flex;
    gap: var(--space-sm);
  }
  
  .scene-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--deep-navy);
    background: transparent;
    cursor: pointer;
    transition: var(--transition-base);
  }
  
  .scene-dot.active {
    background: var(--sun-gold);
    border-color: var(--sun-gold);
  }
  
  .scene-dot:hover {
    transform: scale(1.2);
  }
  
  /* Main Content & Scenes */
  .story-main {
    scroll-snap-type: y mandatory;
    height: 100vh;
    overflow-y: scroll;
  }
  
  .story-scene {
    height: 100vh;
    scroll-snap-align: start;
    display: none;
    position: relative;
  }
  
  .story-scene.active {
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .scene-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2xl);
    max-width: 1200px;
    width: 100%;
    padding: var(--space-2xl);
    align-items: center;
  }
  
  /* Visual Container */
  .visual-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .lottie-placeholder {
    width: 100%;
    max-width: 500px;
    height: 400px;
    background: linear-gradient(135deg, var(--warm-yellow), var(--sun-gold));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
  }
  
  .fallback-svg {
    width: 80%;
    height: 80%;
    object-fit: contain;
  }
  
  /* Text Container */
  .text-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
  }
  
  .scene-title {
    font-size: var(--text-3xl);
    color: var(--deep-navy);
    font-weight: 700;
    margin-bottom: var(--space-md);
  }
  
  /* Audio Controls */
  .audio-controls {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: white;
    padding: var(--space-md);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  }
  
  .play-btn {
    background: var(--soft-teal);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-base);
  }
  
  .play-btn:hover,
  .play-btn:focus {
    background: #0E7A9C;
    transform: scale(1.05);
  }
  
  .audio-waveform {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
  }
  
  .waveform-bar {
    width: 4px;
    height: 20px;
    background: var(--light-text);
    border-radius: 2px;
    animation: waveform 1.5s ease-in-out infinite;
  }
  
  .waveform-bar:nth-child(2) { animation-delay: 0.1s; }
  .waveform-bar:nth-child(3) { animation-delay: 0.2s; }
  .waveform-bar:nth-child(4) { animation-delay: 0.3s; }
  .waveform-bar:nth-child(5) { animation-delay: 0.4s; }
  
  @keyframes waveform {
    0%, 100% { height: 20px; }
    50% { height: 40px; }
  }
  
  /* Captions */
  .captions {
    background: rgba(7, 59, 76, 0.9);
    color: white;
    padding: var(--space-md);
    border-radius: 8px;
    font-size: var(--text-lg);
    line-height: 1.8;
    min-height: 80px;
    display: flex;
    align-items: center;
    text-align: center;
  }
  
  /* Hotspots */
  .hotspot-area {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
  }
  
  .hotspot {
    background: var(--coral);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-base);
    animation: pulse 2s infinite;
  }
  
  .hotspot:hover,
  .hotspot:focus {
    background: #D43A5F;
    transform: scale(1.1);
  }
  
  @keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
  }
  
  .hotspot-card {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: var(--space-lg);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 300px;
    z-index: 100;
    display: none;
  }
  
  .hotspot-card.active {
    display: block;
  }
  
  .close-hotspot {
    position: absolute;
    top: var(--space-sm);
    left: var(--space-sm);
    background: none;
    border: none;
    font-size: var(--text-xl);
    cursor: pointer;
    color: var(--light-text);
  }
  
  /* Mini-game: Shield Builder */
  .minigame-container {
    background: white;
    padding: var(--space-lg);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin-top: var(--space-lg);
  }
  
  .shield-parts {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    justify-content: center;
  }
  
  .shield-part {
    background: var(--soft-teal);
    color: white;
    padding: var(--space-md);
    border-radius: 8px;
    cursor: grab;
    user-select: none;
    transition: var(--transition-base);
  }
  
  .shield-part:hover {
    background: #0E7A9C;
    transform: translateY(-2px);
  }
  
  .shield-part.dragging {
    opacity: 0.5;
  }
  
  .assembly-area {
    border: 2px dashed var(--light-text);
    border-radius: 12px;
    padding: var(--space-2xl);
    text-align: center;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(248, 250, 252, 0.5);
  }
  
  .assembly-area.over {
    border-color: var(--mint);
    background: rgba(6, 214, 160, 0.1);
  }
  
  .shield-fallback {
    display: none;
    gap: var(--space-md);
    justify-content: center;
    margin-top: var(--space-lg);
  }
  
  .no-js .shield-fallback {
    display: flex;
  }
  
  .shield-step {
    background: var(--mint);
    color: white;
    border: none;
    padding: var(--space-md) var(--space-lg);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-base);
  }
  
  .shield-step:hover {
    background: #05B88B;
  }
  
  /* Scene 5: Energy Targets */
  .energy-targets {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
  }
  
  .energy-target {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--coral), transparent);
    border: 2px solid var(--coral);
    cursor: pointer;
    pointer-events: all;
    transition: var(--transition-base);
    animation: targetGlow 2s infinite;
  }
  
  .energy-target:hover {
    transform: scale(1.2);
  }
  
  .energy-target.active {
    background: radial-gradient(circle, var(--mint), transparent);
    border-color: var(--mint);
    animation: none;
  }
  
  .energy-target:nth-child(1) { top: 20%; left: 20%; }
  .energy-target:nth-child(2) { top: 20%; right: 20%; }
  .energy-target:nth-child(3) { bottom: 20%; left: 20%; }
  .energy-target:nth-child(4) { bottom: 20%; right: 20%; }
  
  @keyframes targetGlow {
    0%, 100% { box-shadow: 0 0 20px var(--coral); }
    50% { box-shadow: 0 0 40px var(--coral); }
  }
  
  /* Celebration */
  .celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(7, 59, 76, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
  }
  
  .celebration.active {
    display: flex;
  }
  
  .confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
  }
  
  .success-message {
    background: white;
    padding: var(--space-2xl);
    border-radius: 20px;
    text-align: center;
    z-index: 2001;
  }
  
  /* Final CTA */
  .final-cta {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-xl);
  }
  
  .cta-btn {
    padding: var(--space-lg) var(--space-2xl);
    border: none;
    border-radius: 12px;
    font-size: var(--text-lg);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
    text-align: center;
  }
  
  .download-btn {
    background: var(--sun-gold);
    color: var(--deep-navy);
  }
  
  .download-btn:hover {
    background: #E6A500;
    transform: translateY(-2px);
  }
  
  .quiz-btn {
    background: var(--mint);
    color: white;
  }
  
  .quiz-btn:hover {
    background: #05B88B;
    transform: translateY(-2px);
  }
  
  .replay-btn {
    background: transparent;
    color: var(--soft-teal);
    border: 2px solid var(--soft-teal);
  }
  
  .replay-btn:hover {
    background: var(--soft-teal);
    color: white;
    transform: translateY(-2px);
  }
  
  /* Mobile Controls */
  .mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    justify-content: space-around;
    padding: var(--space-md);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 1000;
  }
  
  .mobile-btn {
    background: var(--soft-teal);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-base);
  }
  
  .mobile-btn:hover {
    background: #0E7A9C;
    transform: scale(1.1);
  }
  
  /* Transcript Section */
  .transcript-section {
    padding: var(--space-2xl) 0;
    background: var(--neutral);
  }
  
  .container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
  }
  
  .transcript-content {
    background: white;
    padding: var(--space-2xl);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    line-height: 1.8;
  }
  
  .back-to-top {
    background: var(--deep-navy);
    color: white;
    border: none;
    padding: var(--space-md) var(--space-lg);
    border-radius: 8px;
    cursor: pointer;
    margin-top: var(--space-lg);
    transition: var(--transition-base);
  }
  
  .back-to-top:hover {
    background: #052A38;
    transform: translateY(-2px);
  }
  
  /* Accessibility Toggle */
  .a11y-toggle {
    position: fixed;
    top: var(--space-lg);
    left: var(--space-lg);
    background: var(--deep-navy);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1001;
    transition: var(--transition-base);
  }
  
  .a11y-toggle:hover {
    background: #052A38;
    transform: scale(1.1);
  }
  
  /* Responsive Design */
  @media (max-width: 768px) {
    .scene-content {
      grid-template-columns: 1fr;
      gap: var(--space-lg);
      text-align: center;
    }
    
    .visual-container {
      order: 1;
    }
    
    .text-container {
      order: 2;
    }
    
    .lottie-placeholder {
      height: 300px;
    }
    
    .scene-title {
      font-size: var(--text-2xl);
    }
    
    .header-nav {
      flex-direction: column;
      gap: var(--space-md);
    }
    
    .progress-container {
      width: 100%;
      justify-content: center;
    }
    
    .progress-bar {
      width: 150px;
    }
    
    .mobile-controls {
      display: flex;
    }
    
    .hotspot-area {
      flex-wrap: wrap;
    }
    
    .shield-parts {
      flex-direction: column;
      align-items: center;
    }
    
    .final-cta {
      flex-direction: column;
    }
  }
  
  @media (max-width: 480px) {
    :root {
      --text-3xl: 1.5rem;
      --text-2xl: 1.25rem;
    }
    
    .scene-content {
      padding: var(--space-lg);
    }
    
    .lottie-placeholder {
      height: 250px;
    }
    
    .audio-controls {
      flex-direction: column;
      gap: var(--space-sm);
    }
    
    .audio-waveform {
      width: 100%;
    }
  }
  
  /* Print Styles */
  @media print {
    .story-header,
    .mobile-controls,
    .audio-controls,
    .hotspot-area,
    .minigame-container,
    .energy-targets,
    .celebration {
      display: none !important;
    }
    
    .story-scene {
      display: block !important;
      height: auto;
      page-break-after: always;
    }
    
    .scene-content {
      display: block;
    }
  }