/* ==========================================================================
   THE MEMORY GIFT — CINEMATIC ROMANTIC CORE DESIGN SYSTEM
   Midnight Burgundy (#17080F), Deep Wine (#2B101B), Romantic Rose (#B96A82),
   Champagne Gold (#D9B781), Warm Ivory (#FFF3F0)
   ========================================================================== */

:root {
  /* Core Color Palette */
  --c-midnight-burgundy: #17080F;
  --c-deep-wine: #2B101B;
  --c-burgundy: #702C3C;
  --c-dark-wine: #4A1D2A;
  --c-warm-mauve: #754153;
  --c-romantic-rose: #B96A82;
  --c-dusty-pink: #D994AA;
  --c-muted-rose: #A65C6C;
  --c-warm-ivory: #FFF3F0;
  --c-soft-blush: #D8B9BC;
  --c-charcoal: #33272B;
  --c-deep-void: #0E0508;
  --c-wine-black: #1A0A0F;
  --c-gold-accent: #D9B781;
  --c-champagne-gold: #D9B781;
  --c-gold-dim: #A8835A;
  --c-rose-gold: #C4917A;

  /* Typography */
  --font-somar: 'Somar', 'Cairo', 'Tajawal', 'Amiri', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Amiri', serif;

  /* Transitions */
  --t-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  --t-cinematic: all 0.8s cubic-bezier(0.25, 1, 0.5, 1);

  /* Layout Max Widths */
  --max-content: 1200px;
  --max-text: 760px;
  --max-media: 960px;
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html {
  width: 100%;
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
  overflow-x: clip;
  background-color: var(--c-deep-void);
  color: var(--c-warm-ivory);
  font-family: var(--font-somar);
  font-size: 16px;
  line-height: 1.7;
  text-align: center;
  user-select: none;
  -webkit-touch-callout: none;
}

/* Arabic text containers get RTL */
.letter-body-arabic,
.revealed-quote-box,
.card-caption-text,
.chapter-subtitle-ar,
.video-info-caption,
.locked-gift-sub,
.verify-question-sub,
.signature-block,
.verify-step-badge,
.the-end-text,
.the-end-sub,
.admin-discrete-link {
  direction: rtl;
}

/* Long-form Arabic text aligns right */
.letter-body-arabic,
.revealed-quote-box {
  text-align: right;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ambient-glow, .ambient-particles, .floating-heart-bg {
    display: none !important;
  }
}

/* ================================================
   ROMANTIC AMBIENT PARTICLES (LIGHTWEIGHT GPU-ONLY)
   Pure CSS transform3d & opacity keyframes. 60 FPS.
   ================================================ */
.ambient-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.particle {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
}

/* Heart Particle */
.p-heart {
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23B96A82' opacity='0.55'%3E%3Cpath d='M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 6px rgba(185, 106, 130, 0.4));
}

/* Gold Sparkle Particle */
.p-sparkle {
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23D9B781' opacity='0.6'%3E%3Cpath d='M12 0l2.5 9.5L24 12l-9.5 2.5L12 24l-2.5-9.5L0 12l9.5-2.5z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 8px rgba(217, 183, 129, 0.5));
}

/* Dust Glow Particle */
.p-dust {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 183, 129, 0.6) 0%, rgba(185, 106, 130, 0) 70%);
}

/* Staggered Floating Keyframes */
@keyframes floatDrift1 {
  0% { transform: translate3d(0, 105vh, 0) rotate(0deg) scale(0.8); opacity: 0; }
  15% { opacity: 0.65; }
  85% { opacity: 0.65; }
  100% { transform: translate3d(40px, -10vh, 0) rotate(35deg) scale(1.1); opacity: 0; }
}

@keyframes floatDrift2 {
  0% { transform: translate3d(0, 105vh, 0) rotate(0deg) scale(0.9); opacity: 0; }
  20% { opacity: 0.7; }
  80% { opacity: 0.7; }
  100% { transform: translate3d(-50px, -10vh, 0) rotate(-40deg) scale(0.85); opacity: 0; }
}

@keyframes floatDrift3 {
  0% { transform: translate3d(0, 105vh, 0) rotate(0deg) scale(0.7); opacity: 0; }
  25% { opacity: 0.6; }
  75% { opacity: 0.6; }
  100% { transform: translate3d(30px, -10vh, 0) rotate(20deg) scale(1.05); opacity: 0; }
}

.p-1 { left: 8%; animation: floatDrift1 20s cubic-bezier(0.4, 0, 0.2, 1) infinite; animation-delay: 0s; }
.p-2 { left: 18%; animation: floatDrift2 24s cubic-bezier(0.4, 0, 0.2, 1) infinite; animation-delay: 4s; }
.p-3 { left: 28%; animation: floatDrift3 28s cubic-bezier(0.4, 0, 0.2, 1) infinite; animation-delay: 9s; }
.p-4 { left: 42%; animation: floatDrift1 22s cubic-bezier(0.4, 0, 0.2, 1) infinite; animation-delay: 2s; }
.p-5 { left: 55%; animation: floatDrift2 26s cubic-bezier(0.4, 0, 0.2, 1) infinite; animation-delay: 7s; }
.p-6 { left: 68%; animation: floatDrift3 21s cubic-bezier(0.4, 0, 0.2, 1) infinite; animation-delay: 1s; }
.p-7 { left: 78%; animation: floatDrift1 25s cubic-bezier(0.4, 0, 0.2, 1) infinite; animation-delay: 11s; }
.p-8 { left: 88%; animation: floatDrift2 23s cubic-bezier(0.4, 0, 0.2, 1) infinite; animation-delay: 5s; }
.p-9 { left: 94%; animation: floatDrift3 27s cubic-bezier(0.4, 0, 0.2, 1) infinite; animation-delay: 13s; }
.p-10 { left: 35%; animation: floatDrift2 29s cubic-bezier(0.4, 0, 0.2, 1) infinite; animation-delay: 15s; }

/* Scrollbar */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: var(--c-deep-void);
}
::-webkit-scrollbar-thumb {
  background: var(--c-dark-wine);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--c-burgundy);
}

/* ================================================
   AMBIENT LIGHTING ORBS — LIGHTWEIGHT GRADIENTS
   NO blur filters for maximum 60fps performance
   ================================================ */
.ambient-glow {
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
  z-index: 1;
  opacity: 0.35;
}

.ambient-orb-1 {
  width: 600px;
  height: 600px;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(112, 44, 60, 0.45) 0%, rgba(112, 44, 60, 0) 70%);
}

.ambient-orb-2 {
  width: 700px;
  height: 700px;
  bottom: -180px;
  left: 50%;
  transform: translateX(-30%);
  background: radial-gradient(circle, rgba(43, 16, 27, 0.55) 0%, rgba(43, 16, 27, 0) 70%);
}

/* Vignette */
.cinema-vignette {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 900;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(14, 5, 8, 0.75) 100%);
}

/* ================================================
   CHAPTER PROGRESS BAR — HORIZONTALLY CENTERED
   ================================================ */
.chapter-progress-bar {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 20px;
  background: rgba(23, 8, 15, 0.75);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(217, 183, 129, 0.15);
  border-radius: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: opacity 0.4s ease;
  direction: ltr;
}

.chapter-progress-bar.hidden {
  opacity: 0;
  pointer-events: none;
}

.progress-node {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.3s ease;
  direction: rtl;
}

.progress-node:hover {
  opacity: 0.75;
}

.progress-node.active {
  opacity: 1;
}

.progress-node.completed {
  opacity: 0.75;
}

.node-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--c-soft-blush);
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.progress-node.active .node-dot {
  background-color: var(--c-champagne-gold);
  box-shadow: 0 0 10px var(--c-champagne-gold);
  transform: scale(1.4);
}

.progress-node.completed .node-dot {
  background-color: var(--c-romantic-rose);
}

.node-title {
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  color: var(--c-warm-ivory);
  font-weight: 500;
  white-space: nowrap;
}

/* Sound & Control Pills */
.experience-controls {
  position: fixed;
  top: 24px;
  left: 28px;
  z-index: 950;
  display: flex;
  align-items: center;
  gap: 12px;
  direction: ltr;
}

.cinema-btn-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(23, 8, 15, 0.75);
  border: 1px solid rgba(217, 183, 129, 0.15);
  color: var(--c-warm-ivory);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--t-smooth);
}

.cinema-btn-icon:hover {
  background: var(--c-dark-wine);
  border-color: var(--c-champagne-gold);
  color: var(--c-champagne-gold);
  transform: translateY(-2px);
}

.cinema-btn-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Discrete Admin Link */
.admin-discrete-link {
  position: fixed;
  bottom: 16px;
  right: 20px;
  z-index: 950;
  opacity: 0.15;
  transition: opacity 0.4s ease;
  color: var(--c-soft-blush);
  text-decoration: none;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 5px;
}
.admin-discrete-link:hover {
  opacity: 0.8;
}

/* ================================================
   MASTER CENTERING ARCHITECTURE
   ================================================ */
#cinema-app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  padding: 0;
}

.scene-container {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  margin: 0 auto;
}

/* Inactive scenes are completely removed from flow */
.scene {
  display: none !important;
  width: 100%;
  margin-inline: auto;
  box-sizing: border-box;
}

/* Only the active scene is displayed and centered */
.scene.active {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  padding: 90px 20px 70px;
  margin-inline: auto;
  animation: sceneFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes sceneFadeIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ================================================
   MASTER BUTTONS — PREMIUM ROMANTIC CTA
   ================================================ */
.btn-cinema {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 15px 38px;
  background: linear-gradient(135deg, var(--c-burgundy) 0%, var(--c-dark-wine) 100%);
  color: var(--c-warm-ivory);
  font-family: var(--font-somar);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid rgba(216, 185, 188, 0.2);
  border-radius: 40px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(74, 29, 42, 0.35);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  position: relative;
  overflow: hidden;
  letter-spacing: 0.3px;
  margin-inline: auto;
}

.btn-cinema::after {
  content: '';
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  transform: skewX(-25deg);
  transition: none;
  pointer-events: none;
}

.btn-cinema:hover::after {
  left: 150%;
  transition: left 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-cinema:hover {
  transform: translateY(-2px) scale(1.02);
  border-color: var(--c-romantic-rose);
  box-shadow: 0 14px 35px rgba(112, 44, 60, 0.45);
}

.btn-cinema:active {
  transform: translateY(0) scale(0.99);
}

.btn-cinema:focus-visible {
  outline: 2px solid var(--c-champagne-gold);
  outline-offset: 3px;
}

.btn-cinema svg {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-cinema-gold {
  background: linear-gradient(135deg, #7A3546 0%, #4A1D2A 100%);
  border-color: rgba(217, 183, 129, 0.35);
  color: var(--c-champagne-gold);
  box-shadow: 0 10px 25px rgba(217, 183, 129, 0.15);
}

.btn-cinema-gold:hover {
  border-color: var(--c-champagne-gold);
  box-shadow: 0 14px 35px rgba(217, 183, 129, 0.25);
}

/* Input Shake Animation */
.input-shake {
  animation: inputShake 0.45s ease;
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
}

/* Lightbox Modal */
.cinema-lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(14, 5, 8, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.4s ease;
  padding: 30px;
}

.cinema-lightbox.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 85vh;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(217, 183, 129, 0.15);
}

.lightbox-caption {
  margin-top: 18px;
  font-size: 1.05rem;
  color: var(--c-soft-blush);
  text-align: center;
  max-width: 600px;
  direction: rtl;
}

.lightbox-close {
  position: absolute;
  top: 25px;
  right: 35px;
  background: none;
  border: none;
  color: var(--c-warm-ivory);
  font-size: 2.2rem;
  cursor: pointer;
  opacity: 0.6;
  transition: var(--t-smooth);
  z-index: 1001;
}

.lightbox-close:hover {
  opacity: 1;
  color: var(--c-champagne-gold);
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .scene.active {
    padding: 70px 16px 80px;
  }

  .experience-controls {
    top: auto;
    bottom: 68px;
    left: 16px;
  }

  .chapter-progress-bar {
    top: auto;
    bottom: 20px;
    padding: 6px 14px;
    gap: 8px;
  }

  .node-title {
    display: none;
  }

  .progress-node.active .node-title {
    display: inline-block;
    font-size: 0.68rem;
  }
}

@media (max-width: 390px) {
  body {
    font-size: 15px;
  }

  .scene.active {
    padding: 65px 12px 85px;
  }

  .btn-cinema {
    padding: 13px 28px;
    font-size: 0.92rem;
  }
}
