/* ==========================================
   CLEAN CSS FOR BIRTHDAY EXPERIENCE
   Minimal, focused styling for 7-scene flow
   ========================================== */

:root {
  /* ==========================================
     DESIGN SYSTEM 2.0 TOKENS
     ========================================== */

  /* --- 1. Colors --- */
  --color-bg-deep: #030407;        /* Deep black */
  --color-surface: #0a0e14;        /* Dark blue-black */
  --color-surface-elevated: #111822; /* Slightly lighter */
  
  --color-primary: #00ffff;        /* Elegant cyan */
  --color-primary-soft: rgba(0, 255, 255, 0.15); /* Transparent cyan */
  --color-secondary: #fdfbf7;      /* Warm white */
  
  --color-text-primary: var(--color-secondary);
  --color-text-muted: #8a9bb0;     /* Cool gray */
  --color-accent-glow: rgba(0, 255, 255, 0.4); /* Soft cyan glow */

  /* --- 2. Typography --- */
  --font-display: 'Playfair Display', serif;
  --font-body: 'Inter', sans-serif;
  --font-quote: 'Cormorant Garamond', serif;

  --text-xs: clamp(0.75rem, 1vw, 0.875rem);
  --text-sm: clamp(0.875rem, 1.2vw, 1rem);
  --text-base: clamp(1rem, 1.5vw, 1.125rem);
  --text-lg: clamp(1.25rem, 2vw, 1.5rem);
  --text-xl: clamp(1.5rem, 3vw, 2rem);
  --text-2xl: clamp(2rem, 4vw, 3rem);
  --text-3xl: clamp(2.5rem, 5vw, 4rem);

  /* --- 3. Spacing Scale --- */
  --space-xs: clamp(4px, 1vw, 8px);
  --space-sm: clamp(8px, 2vw, 16px);
  --space-md: clamp(16px, 3vw, 24px);
  --space-lg: clamp(24px, 4vw, 32px);
  --space-xl: clamp(32px, 5vw, 48px);
  --space-2xl: clamp(48px, 8vw, 80px);

  /* --- 4. Border Radius --- */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 16px;
  --radius-glass: 24px;

  /* --- 5. Soft Depth System --- */
  --shadow-ambient: 0 30px 60px rgba(0, 0, 0, 0.9);
  --shadow-contact: 0 4px 15px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 20px 40px rgba(0, 0, 0, 0.8), 0 0 15px rgba(0, 255, 255, 0.1);
  --shadow-inner: inset 0 1px 1px rgba(255, 255, 255, 0.03);
  --shadow-rim-cyan: 0 0 10px rgba(0, 255, 255, 0.05), inset 0 0 0 1px rgba(0, 255, 255, 0.15);

  /* --- 6. Glass Materials --- */
  --glass-bg: linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  --glass-border: 1px solid rgba(255, 255, 255, 0.05);
  --glass-blur: blur(32px);
  --glass-highlight: inset 0 1px 1px rgba(255, 255, 255, 0.1);
  
  /* --- 7. Motion Tokens --- */
  --duration-fast: 250ms;
  --duration-normal: 500ms;
  --duration-slow: 1200ms;
  --ease-cinematic: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-cinematic-inout: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-body);
  background: var(--color-bg-deep);
  color: var(--color-text-primary);
  overflow: hidden;
  /* Cinematic Cursor hides default */
  cursor: none;
}

/* ==========================================
   GLOBAL CINEMATIC ELEMENTS
   ========================================== */

.ambient-bloom {
  display: none;
}

.vignette-overlay {
  display: none;
}

/* ==========================================
   CINEMATIC CURSOR (BUTTERFLY)
   ========================================== */

#cursor-butterfly {
  position: fixed;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Smooth interpolation trailing */
  transition: transform 0.1s var(--ease-cinematic);
}

.cursor-wing-left,
.cursor-wing-right {
  position: absolute;
  width: 7px;
  height: 12px;
  border: 1px solid rgba(0, 255, 255, 0.6);
  background: rgba(0, 255, 255, 0.1);
}

.cursor-wing-left {
  right: 50%;
  border-radius: 50% 50% 10% 50%;
  transform-origin: right center;
  animation: flapLeft 2.5s infinite alternate ease-in-out;
}

.cursor-wing-right {
  left: 50%;
  border-radius: 50% 50% 50% 10%;
  transform-origin: left center;
  animation: flapRight 2.5s infinite alternate ease-in-out;
}

/* Hover State */
#cursor-butterfly.hovering {
  transform: translate(-50%, -50%) rotate(15deg) scale(1.1);
}
#cursor-butterfly.hovering .cursor-wing-left {
  animation: flapLeft 0.8s infinite alternate ease-in-out;
}
#cursor-butterfly.hovering .cursor-wing-right {
  animation: flapRight 0.8s infinite alternate ease-in-out;
}

/* Click State */
#cursor-butterfly.clicking .cursor-wing-left {
  animation: flapLeft 0.15s infinite alternate ease-in-out;
}
#cursor-butterfly.clicking .cursor-wing-right {
  animation: flapRight 0.15s infinite alternate ease-in-out;
}

@keyframes flapLeft {
  0% { transform: rotateY(0deg) rotateZ(-15deg); }
  100% { transform: rotateY(65deg) rotateZ(-10deg); }
}

@keyframes flapRight {
  0% { transform: rotateY(0deg) rotateZ(15deg); }
  100% { transform: rotateY(-65deg) rotateZ(10deg); }
}

/* ==========================================
   SCENE STRUCTURE
   ========================================== */

.scene {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 10;
}

.scene.active {
  display: flex;
}

.scene-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ==========================================
   PROGRESS DOTS
   ========================================== */

.progress-dots {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: var(--space-sm);
  z-index: 100;
}

.progress-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: all var(--duration-normal) var(--ease-spring);
  /* Cursor handles interaction, pointer is hidden */
}

.progress-dot.active {
  background: var(--color-primary);
  box-shadow: 0 0 15px var(--color-primary-soft);
  transform: scale(1.3);
}

.progress-dot.completed {
  background: rgba(255, 255, 255, 0.4);
}

/* ==========================================
   GLASS BUTTON (SHARED)
   ========================================== */

.glass-button {
  padding: var(--space-sm) var(--space-lg);
  border: var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-glass);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  transition: all var(--duration-fast) var(--ease-spring);
  box-shadow: var(--shadow-contact), var(--shadow-rim-cyan);
  z-index: 50;
  /* Hover handled by cinematic cursor magnetic pull, but fallback below */
}

.glass-button:hover {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: var(--shadow-glow), var(--shadow-rim-cyan), var(--glass-highlight);
  color: var(--color-primary);
  transform: translateY(-1px);
}

/* ==========================================
   TYPEWRITER CURSOR
   ========================================== */

.typewriter-cursor {
  animation: cursorBlink 0.8s step-end infinite;
  color: var(--accent-primary);
  margin-left: 3px;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ==========================================
   SCENE 1: INTRO
   ========================================== */

#scene-intro {
  background: var(--color-bg-deep);
}

.intro-text {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 400;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.3;
  max-width: 80%;
  margin-bottom: var(--space-2xl);
  z-index: 10;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.intro-btn {
  position: absolute;
  bottom: var(--space-2xl);
  z-index: 10;
}

/* ==========================================
   SCENE 2: MEMORIES
   ========================================== */

#scene-memories {
  background: var(--color-bg-deep);
  flex-direction: column;
  overflow-y: auto;
}

.memories-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  margin: var(--space-xl) 0;
  z-index: 10;
}

.memory-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-xl);
  max-width: 1400px;
  width: 100%;
  z-index: 10;
}

.memory-card {
  width: 100%;
  height: 360px;
  /* Cursor handled by cinematic interaction */
  perspective: 1500px;
  transform-style: preserve-3d;
}

.memory-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform var(--duration-slow) var(--ease-spring);
  transform-style: preserve-3d;
}

.memory-card.flipped .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card-front,
.memory-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--radius-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-ambient), var(--shadow-inner);
}

.memory-card:hover .memory-card-front,
.memory-card:hover .memory-card-back {
  box-shadow: var(--shadow-glow), var(--shadow-inner);
}

.memory-card-front {
  background: var(--color-surface);
  overflow: hidden;
  transform: rotateY(0deg);
}

.memory-card-front::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 20%,
    rgba(255, 255, 255, 0.05) 30%,
    rgba(0, 255, 255, 0.1) 45%,
    rgba(255, 255, 255, 0.1) 55%,
    transparent 65%
  );
  background-size: 250% 250%;
  background-position: 100% 100%;
  transition: opacity var(--duration-normal) var(--ease-cinematic-inout);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

.memory-card:hover .memory-card-front::after {
  opacity: 1;
  animation: elegantSheen 2.5s var(--ease-cinematic-inout) infinite;
}

@keyframes elegantSheen {
  0% { background-position: 100% 100%; }
  100% { background-position: 0% 0%; }
}

.memory-card-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-spring);
}

.memory-card:hover .memory-card-front img {
  transform: scale(1.08);
}

.memory-card-back {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur) saturate(1.2);
  border: var(--glass-border);
  transform: rotateY(180deg);
  padding: var(--space-lg);
  text-align: center;
  box-shadow: var(--shadow-ambient), var(--shadow-rim-cyan);
}

.memory-card-back p {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 300;
  letter-spacing: 0.02em;
  line-height: 1.6;
  color: var(--color-text-primary);
}

#memories-next {
  position: absolute;
  bottom: var(--space-2xl);
}

/* ==========================================
   SCENE 3: CAKE
   ========================================== */

#scene-cake {
  background: var(--color-bg-deep);
}

.cake-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0, 255, 255, 0.1) 0%, transparent 70%);
  border-radius: 50%;
  filter: blur(40px);
  pointer-events: none;
  z-index: 2;
}

.cake-wish-text {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  position: absolute;
  top: var(--space-2xl);
  z-index: 10;
  opacity: 0;
  color: var(--color-text-primary);
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  letter-spacing: -0.02em;
}

.cake-instruction {
  position: absolute;
  bottom: var(--space-2xl);
  font-size: var(--text-base);
  font-family: var(--font-body);
  text-align: center;
  z-index: 10;
  opacity: 0.8;
  color: var(--color-text-muted);
}


/* ==========================================
   SCENE 4: BIRTHDAY MESSAGE
   ========================================== */

#scene-birthday-letter {
  background: var(--color-bg-deep);
}

.birthday-message-parchment {
  max-width: 800px;
  background: linear-gradient(135deg, #fffffb 0%, #f9f6ef 100%);
  background-image: url('https://www.transparenttextures.com/patterns/cream-paper.png');
  padding: var(--space-2xl) var(--space-xl);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,0,0,0.05);
  font-size: var(--text-xl);
  line-height: 1.9;
  text-align: center;
  z-index: 10;
  color: #1a1a1a;
  font-family: var(--font-quote);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5), inset 0 0 20px rgba(0,0,0,0.02);
}

/* ==========================================
   SCENE 5: ENVELOPE
   ========================================== */

#scene-envelope {
  background: transparent;
}

.envelope-container {
  perspective: 2000px;
  z-index: 10;
}

.envelope {
  position: relative;
  width: 360px;
  height: 240px;
  cursor: pointer;
  transform-style: preserve-3d;
}

.envelope-back {
  position: absolute;
  inset: 0;
  /* Premium Dark Charcoal Exterior */
  background: linear-gradient(135deg, #1e2634 0%, #0d1117 100%);
  border-radius: var(--radius-md);
  /* Cyan rim lighting + cinematic drop shadow */
  box-shadow: 
    var(--shadow-ambient), 
    var(--shadow-contact),
    var(--shadow-glow),
    inset 0 1px 1px rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(0, 255, 255, 0.15);
}

.letter-paper {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  height: 216px; /* Initial height matching envelope */
  /* Warm cream interior paper */
  background: linear-gradient(180deg, #fffffb 0%, #f9f6ef 100%);
  background-image: url('https://www.transparenttextures.com/patterns/cream-paper.png');
  border-radius: 6px;
  padding: 35px 30px;
  /* Soft shadow for depth, subtle edge translucency */
  box-shadow: 
    0 15px 35px rgba(0,0,0,0.4),
    inset 0 0 20px rgba(0,0,0,0.02),
    inset 0 1px 1px rgba(255,255,255,1);
  overflow: visible;
  z-index: 2;
  transform-style: preserve-3d;
}

.letter-text {
  font-family: var(--font-quote);
  font-size: var(--text-base);
  line-height: 1.9;
  letter-spacing: 0.5px;
  color: #1a1a1a;
  min-height: 150px;
}

.envelope-front {
  position: absolute;
  inset: 0;
  /* Matches back dark paper */
  background: linear-gradient(135deg, #242c3d 0%, #131924 100%);
  border-radius: 8px;
  clip-path: polygon(0 0, 50% 50%, 100% 0, 100% 100%, 0 100%);
  /* Soft edge highlight */
  box-shadow: inset 0 0 1px rgba(255, 255, 255, 0.1);
  z-index: 3;
}

.envelope-front::after {
  /* Subtle inner drop shadow mimicking folds */
  content: '';
  position: absolute;
  inset: 0;
  background: transparent;
  clip-path: polygon(0 0, 50% 50%, 100% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 5px 15px rgba(0,0,0,0.1);
  pointer-events: none;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Dark Charcoal flap */
  background: linear-gradient(180deg, #1e2634 0%, #151b26 100%);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  clip-path: polygon(0 0, 100% 0, 50% 60%);
  box-shadow: var(--shadow-inner), var(--shadow-contact);
  transform-origin: top;
  transform-style: preserve-3d;
  /* Spring physics will be applied by GSAP, but keep a fallback */
  transition: transform var(--duration-slow) var(--ease-spring);
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pure CSS Cyan Wax Seal with Embossed Butterfly */
.envelope-seal {
  position: absolute;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 50px;
  height: 50px;
  background: radial-gradient(circle at 30% 30%, var(--color-primary), #0088aa 60%, #004466);
  border-radius: 50%;
  /* Specular glossy highlight + drop shadow */
  box-shadow: 
    inset 2px 2px 5px rgba(255,255,255,0.6),
    inset -3px -3px 8px rgba(0,0,0,0.4),
    var(--shadow-contact),
    0 1px 3px var(--color-primary-soft);
  z-index: 5;
  transition: opacity var(--duration-normal) ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Embossed Butterfly inside Seal */
.envelope-seal::before,
.envelope-seal::after {
  content: '';
  position: absolute;
  background: transparent;
  /* Creates the two wings using border-radius and borders */
  width: 16px;
  height: 18px;
  border-radius: 50% 50% 10% 50%;
  border: 2px solid rgba(0, 40, 60, 0.7);
  box-shadow: 
    inset 1px 1px 2px rgba(255,255,255,0.4),
    1px 1px 1px rgba(255,255,255,0.3);
}

.envelope-seal::before {
  transform: translate(-7px, -1px) rotate(-30deg);
}
.envelope-seal::after {
  border-radius: 50% 50% 50% 10%;
  transform: translate(7px, -1px) rotate(30deg);
}

.envelope.open .envelope-flap {
  transform: rotateX(-175deg);
}
.envelope.open .envelope-seal {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================
   SCENE 6: GIFTS
   ========================================== */

#scene-gifts {
  background: #050508;
  perspective: 1400px;
}

.gift-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================
   SCENE 7: ENDING
   ========================================== */

#scene-ending {
  background: var(--color-bg-deep);
}

.ending-text {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(3rem, 6vw, 5rem);
  text-align: center;
  z-index: 10;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  padding: var(--space-xl) var(--space-2xl);
  border-radius: var(--radius-glass);
  border: var(--glass-border);
  box-shadow: var(--shadow-ambient), var(--shadow-rim-cyan);
  text-shadow: 0 0 20px var(--color-primary-soft), 0 0 40px rgba(0, 255, 255, 0.1);
  color: var(--color-text-primary);
}

/* ==========================================
   EMOJI INLINE STYLING
   ========================================== */

.emoji {
  height: 1.2em;
  width: 1.2em;
  margin: 0 0.05em 0 0.1em;
  vertical-align: -0.1em;
}

/* ==========================================
   ANIMATIONS
   ========================================== */

@keyframes floating {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-20px); }
}

/* ==========================================
   SCENE 3: MEMORY PHOTO GAME (Catch Your Memories)
   ========================================== */
#scene-hearts { background: var(--color-bg-deep); }
.memory-photo-container {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  perspective: 1500px; z-index: 5;
}

/* Phase 3 Memory Card modifiers */
.phase3-card {
  width: 320px;
  aspect-ratio: 3 / 4;
  max-width: 32vw;
  height: auto;
}

.memory-card.caught {
  box-shadow: var(--shadow-rim-cyan), var(--shadow-glow);
}

.memory-card.caught .memory-card-front::after {
  opacity: 1;
  animation: holo 0.5s ease-out forwards;
}

.memory-card.escaping {
  filter: blur(8px);
  pointer-events: none;
}

.memory-video-frame {
  width: clamp(300px, 70vw, 800px);
  aspect-ratio: 16/9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-ambient), var(--shadow-rim-cyan);
  border: var(--glass-border);
  background: var(--color-surface);
  display: none;
  z-index: 10;
}
.memory-video-frame video { width: 100%; height: 100%; object-fit: cover; }
