/* Import cute and elegant Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&family=Pacifico&display=swap');

:root {
  /* Color Palette - Soft pastels, warm creams, and cozy browns */
  --bg-primary: #fff5f6;
  --bg-envelope-page: #ffeef0;
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(255, 182, 193, 0.4);
  
  --primary: hsl(345, 95%, 72%);          /* Soft rose pink */
  --primary-dark: hsl(345, 75%, 55%);     /* Deep rose */
  --primary-light: #ffe5e9;               /* Light blush */
  
  --secondary: hsl(25, 45%, 42%);         /* Teddy bear brown */
  --secondary-light: hsl(25, 30%, 82%);   /* Cute cream snout */
  --secondary-dark: hsl(25, 50%, 25%);    /* Teddy nose/eyes */
  
  --accent-gold: hsl(45, 100%, 75%);      /* Warm birthday candle light */
  --accent-mint: hsl(150, 60%, 85%);      /* Soft green leaf */
  --accent-sky: hsl(200, 80%, 90%);       /* Balloon blue */
  --accent-lavender: hsl(270, 70%, 92%);  /* Balloon violet */
  
  --text-main: hsl(345, 35%, 22%);        /* Dark cherry text */
  --text-muted: hsl(345, 20%, 45%);
  
  --font-cute: 'Pacifico', cursive;
  --font-main: 'Outfit', sans-serif;
  
  --shadow-sm: 0 4px 10px rgba(255, 182, 193, 0.15);
  --shadow-md: 0 10px 30px rgba(255, 182, 193, 0.25);
  --shadow-lg: 0 20px 50px rgba(255, 150, 170, 0.35);
  
  --transition-smooth: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --transition-envelope: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-main);
  overflow-x: hidden;
  min-height: 100vh;
}

/* Background Music Toggle Button */
.audio-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  background: var(--card-bg);
  border: 2px solid var(--primary-light);
  color: var(--primary-dark);
  font-size: 1.2rem;
  padding: 10px 14px;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
  backdrop-filter: blur(10px);
}

.audio-toggle:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
  background-color: #fff;
}

.audio-toggle:active {
  transform: scale(0.95);
}

.audio-toggle svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Canvas Particle Layer (Confetti & Petals) */
#canvas-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 600;
}

/* LANDING ENVELOPE SCREEN */
.landing-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  background: radial-gradient(circle at center, #fff6f7 0%, var(--bg-envelope-page) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 500;
  transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1), visibility 1s;
}

.landing-screen.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.landing-title {
  font-family: var(--font-cute);
  font-size: 2.8rem;
  color: var(--primary-dark);
  margin-bottom: 40px;
  text-shadow: 2px 2px 0px #fff;
  text-align: center;
  animation: float 4s ease-in-out infinite;
  padding: 0 20px;
}

.envelope-container {
  position: relative;
  width: 320px;
  height: 220px;
  cursor: pointer;
  perspective: 1000px;
  margin-bottom: 30px;
}

/* The Envelope body */
.envelope {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffcbd3;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  transform-style: preserve-3d;
  transition: var(--transition-envelope);
}

/* Envelope Flap (Triangle pointing down) */
.envelope::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-top: 120px solid #ffa3b1;
  transform-origin: top;
  z-index: 30;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), z-index 0s linear;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.05));
}

/* Envelope Left & Right folds */
.envelope::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid #ffd4db;
  border-right: 160px solid #ffd4db;
  border-top: 110px solid transparent;
  border-bottom: 110px solid #ffd4db;
  border-radius: 0 0 8px 8px;
  z-index: 20;
  filter: drop-shadow(-2px 0 5px rgba(0,0,0,0.02));
}

/* Envelope front pocket (just visual overlap) */
.envelope-pocket {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 160px solid transparent;
  border-right: 160px solid transparent;
  border-bottom: 110px solid #ffe3e7;
  z-index: 25;
  border-radius: 0 0 8px 8px;
}

/* The Letter inside the envelope */
.envelope-letter {
  position: absolute;
  bottom: 5px;
  left: 15px;
  width: 290px;
  height: 190px;
  background: #fff;
  border-radius: 6px;
  padding: 20px;
  box-sizing: border-box;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: var(--transition-envelope);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.envelope-letter p {
  font-family: var(--font-cute);
  font-size: 1.6rem;
  color: var(--primary-dark);
  text-align: center;
}

.envelope-letter span {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Wax Seal Stamp on Flap */
.wax-seal {
  position: absolute;
  top: 95px;
  left: 140px;
  width: 40px;
  height: 40px;
  background: radial-gradient(circle, var(--primary) 60%, var(--primary-dark) 100%);
  border-radius: 50%;
  z-index: 35;
  box-shadow: 0 4px 8px rgba(220, 20, 60, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-envelope);
}

.wax-seal::after {
  content: '♥';
  color: #fff;
  font-size: 1.4rem;
  margin-top: -2px;
}

/* Hover effects for landing screen */
.envelope-container:hover .envelope {
  transform: translateY(-5px) rotate(1deg);
  box-shadow: var(--shadow-lg);
}

.envelope-container:hover .wax-seal {
  transform: scale(1.1);
}

/* ACTIVE OPEN STATE (WHEN CLICKED) */
.envelope-container.open .envelope::before {
  transform: rotateX(180deg);
  z-index: 5;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), z-index 0s linear 0.4s;
}

.envelope-container.open .wax-seal {
  transform: translateY(-110px) rotateX(180deg) scale(0.8);
  opacity: 0;
  pointer-events: none;
}

.envelope-container.open .envelope-letter {
  transform: translateY(-120px);
  z-index: 15;
  box-shadow: var(--shadow-md);
  transition-delay: 0.4s;
}

.landing-tip {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.8;
  animation: pulse 1.8s infinite ease-in-out;
}

.landing-tip svg {
  width: 16px;
  height: 16px;
  fill: var(--primary);
}


/* MAIN STORYBOOK PAGES (SCROLL SNAP) */
.storybook-container {
  display: none; /* Shown after envelope opens */
  width: 100%;
  height: 100dvh;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 100;
}

.story-card {
  width: 100vw;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
}

/* Background Gradients for each page */
#card-welcome {
  background: linear-gradient(135deg, #fff5f6 0%, #ffe4e8 100%);
}

#card-roses {
  background: linear-gradient(135deg, #ffe4e8 0%, #ffd4db 100%);
}

#card-wishes {
  background: linear-gradient(135deg, #ffd4db 0%, #ffe8d6 100%);
}

#card-cake {
  background: linear-gradient(135deg, #ffe8d6 0%, #fff6f7 100%);
}

/* Glassmorphism card contents */
.card-content {
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 28px;
  width: 100%;
  max-width: 600px;
  padding: 40px 30px;
  text-align: center;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(15px);
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

/* Decorative Card elements */
.card-decor {
  position: absolute;
  top: 15px;
  width: calc(100% - 30px);
  display: flex;
  justify-content: space-between;
  padding: 0 10px;
  pointer-events: none;
}

.card-decor svg {
  width: 24px;
  height: 24px;
  fill: var(--primary);
  opacity: 0.4;
}

/* Custom Scroll Indicators */
.scroll-hint {
  position: absolute;
  bottom: 25px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  z-index: 20;
  pointer-events: auto;
}

.scroll-hint svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  animation: bounce 1.8s infinite;
}

/* Headings and Texts */
.card-title {
  font-family: var(--font-cute);
  font-size: 2.5rem;
  color: var(--primary-dark);
  text-shadow: 1px 1px 0px #fff;
  line-height: 1.2;
}

.card-subtitle {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-main);
  max-width: 460px;
}

.highlight-text {
  font-family: var(--font-cute);
  font-size: 1.8rem;
  color: var(--primary-dark);
  margin-top: 8px;
}


/* SVG ILLUSTRATIONS & CUTE CHARACTER STYLING */
.svg-illustration {
  width: 200px;
  height: 200px;
  filter: drop-shadow(0 10px 15px rgba(255, 182, 193, 0.25));
  margin: 10px 0;
}

/* Cute Bear SVG Styling & Animations */
.bear-ears {
  transform-origin: 50% 30%;
  animation: earWiggle 5s ease-in-out infinite;
}

.bear-ear-left {
  transform-origin: 35px 30px;
}

.bear-ear-right {
  transform-origin: 165px 30px;
}

.bear-eye {
  transform-origin: 75px 80px;
  animation: blink 4s infinite step-end;
}
.bear-eye-right {
  transform-origin: 125px 80px;
}

.bear-paw-wave {
  transform-origin: 160px 145px;
  animation: wavePaw 3s ease-in-out infinite;
}

.bear-blush {
  animation: pulseBlush 3s ease-in-out infinite alternate;
}

/* Rose Illustration SVG Styling & Animations */
.rose-stem {
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
}

.rose-petal-bud {
  transform-origin: center;
  animation: bloom 6s ease-in-out infinite alternate;
}

/* Floating Balloons */
.balloon-group {
  display: flex;
  gap: 15px;
  margin-bottom: 10px;
}

.balloon {
  animation: floatBalloon 6s ease-in-out infinite alternate;
  width: 50px;
  height: 70px;
}

.balloon:nth-child(2) {
  animation-delay: -2s;
  animation-duration: 7s;
}

.balloon:nth-child(3) {
  animation-delay: -4s;
  animation-duration: 5s;
}

/* Cake & Candle Interactive elements */
.cake-flame {
  transform-origin: bottom center;
  animation: flicker 0.8s ease-in-out infinite alternate;
  cursor: pointer;
  transition: opacity 0.3s;
}

.cake-flame.blown-out {
  opacity: 0;
  pointer-events: none;
}

.cake-candle-wick {
  cursor: pointer;
}

/* INTERACTIVE JAR OF WISHES */
.wishes-jar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
}

.jar-svg {
  width: 120px;
  height: 160px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.jar-svg:hover {
  transform: rotate(5deg) scale(1.05);
}

.jar-svg:active {
  transform: scale(0.95);
}

.jar-note-popup {
  background: #fffdf5;
  border: 2px dashed var(--primary);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-sm);
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  transition: var(--transition-smooth);
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.jar-note-text {
  font-family: var(--font-cute);
  font-size: 1.35rem;
  color: var(--primary-dark);
  text-align: center;
  line-height: 1.4;
}

.jar-button {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 12px 24px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 8px;
}

.jar-button:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.jar-button:active {
  transform: translateY(0);
}


/* INTERACTIVE CAKE STATE styling */
.cake-button {
  margin-top: 10px;
  background: var(--primary-dark);
  color: white;
  border: none;
  padding: 12px 30px;
  border-radius: 50px;
  font-family: var(--font-main);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  font-size: 1rem;
  letter-spacing: 0.5px;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cake-button:hover {
  background: var(--primary);
  transform: scale(1.05) translateY(-2px);
}

.cake-button:active {
  transform: scale(0.95);
}

/* Bouquet Builder styling */
.bouquet-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 10px;
  z-index: 20;
}
.flower-btn {
  border: none;
  padding: 10px 18px;
  border-radius: 50px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
}
.flower-btn:hover {
  transform: scale(1.05) translateY(-2px);
  box-shadow: var(--shadow-md);
}
.flower-btn:active {
  transform: scale(0.95);
}

/* CARD TRANSITIONS / SCROLL-DRIVEN ANIMATIONS */
/* We enforce smooth progressive reveals for modern browsers */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes cardFadeIn {
      from {
        opacity: 0.2;
        transform: translateY(120px) scale(0.92);
      }
      to {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
    }
    
    @keyframes cardFadeOut {
      from {
        opacity: 1;
        transform: translateY(0) scale(1);
      }
      to {
        opacity: 0.2;
        transform: translateY(-120px) scale(0.92);
      }
    }

    .story-card > .card-content {
      animation:
        cardFadeIn auto linear backwards,
        cardFadeOut auto linear forwards;
      animation-timeline: view();
      animation-range: entry 5% entry 95%, exit 5% exit 95%;
    }
  }
}

/* Fallback transitions using Intersection Observer (JS adds classes) for unsupported browsers */
@supports not ((animation-timeline: view()) and (animation-range: entry)) {
  .story-card > .card-content {
    opacity: 0;
    transform: translateY(50px) scale(0.95);
  }
  .story-card > .card-content.reveal-in {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }
  .story-card > .card-content.reveal-out {
    opacity: 0;
    transform: translateY(-50px) scale(0.95);
    transition: opacity 0.8s ease, transform 0.8s ease;
  }
}


/* ANIMATION KEYFRAMES */
@keyframes float {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-10px) rotate(-1deg);
  }
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-8px);
  }
  60% {
    transform: translateY(-4px);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.03);
    opacity: 1;
  }
}

@keyframes earWiggle {
  0%, 90%, 100% {
    transform: rotate(0deg);
  }
  92% {
    transform: rotate(-8deg);
  }
  94% {
    transform: rotate(8deg);
  }
  96% {
    transform: rotate(-5deg);
  }
  98% {
    transform: rotate(5deg);
  }
}

@keyframes blink {
  0%, 96%, 100% {
    transform: scaleY(1);
  }
  98% {
    transform: scaleY(0.1);
  }
}

@keyframes wavePaw {
  0%, 75%, 100% {
    transform: rotate(0deg);
  }
  80% {
    transform: rotate(-25deg);
  }
  84% {
    transform: rotate(15deg);
  }
  88% {
    transform: rotate(-20deg);
  }
  92% {
    transform: rotate(10deg);
  }
  96% {
    transform: rotate(-5deg);
  }
}

@keyframes bloom {
  0% {
    transform: scale(0.85) rotate(-3deg);
  }
  100% {
    transform: scale(1.05) rotate(3deg);
  }
}

@keyframes floatBalloon {
  0% {
    transform: translateY(0) rotate(-2deg);
  }
  100% {
    transform: translateY(-12px) rotate(2deg);
  }
}

@keyframes flicker {
  0% {
    transform: scale(1) rotate(-1deg);
    filter: drop-shadow(0 0 4px var(--accent-gold));
  }
  50% {
    transform: scale(1.05) rotate(2deg);
    filter: drop-shadow(0 0 8px var(--accent-gold));
  }
  100% {
    transform: scale(0.95) rotate(-2deg);
    filter: drop-shadow(0 0 5px var(--accent-gold));
  }
}

@keyframes pulseBlush {
  0% {
    opacity: 0.35;
  }
  100% {
    opacity: 0.65;
  }
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(10px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes popInFlower {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Mic Pulse Animation */
@keyframes pulseMic {
  0% {
    box-shadow: 0 0 0 0 rgba(163, 225, 201, 0.8);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(163, 225, 201, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(163, 225, 201, 0);
  }
}
.pulse-mic {
  animation: pulseMic 1.6s infinite;
}

.signature-from {
  font-family: var(--font-cute);
  font-size: 1.8rem;
  color: var(--primary-dark);
  margin-top: 15px;
  opacity: 0.95;
}
.signature-name {
  font-family: var(--font-cute);
  font-size: 2.2rem;
  color: var(--text-main);
  text-shadow: 2px 2px 0px #fff;
  margin-top: 5px;
  animation: float 4s ease-in-out infinite;
}
.signature-ps {
  font-size: 0.95rem;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 10px;
  font-weight: 500;
}

/* RESPONSIVENESS */
@media (max-width: 480px) {
  .landing-title {
    font-size: 2.2rem;
  }
  
  .envelope-container {
    width: 280px;
    height: 190px;
  }
  
  .envelope::before {
    border-left-width: 140px;
    border-right-width: 140px;
    border-top-width: 105px;
  }
  
  .envelope::after {
    border-left-width: 140px;
    border-right-width: 140px;
    border-bottom-width: 95px;
  }
  
  .envelope-pocket {
    border-left-width: 140px;
    border-right-width: 140px;
    border-bottom-width: 95px;
  }
  
  .envelope-letter {
    width: 250px;
    height: 160px;
  }
  
  .envelope-letter p {
    font-size: 1.3rem;
  }
  
  .wax-seal {
    top: 80px;
    left: 120px;
  }

  .card-content {
    padding: 30px 20px;
  }
  
  .card-title {
    font-size: 2rem;
  }
  
  .card-subtitle {
    font-size: 0.95rem;
  }
  
  .svg-illustration {
    width: 160px;
    height: 160px;
  }
}
