/* ============================================================
   DOUDOUNE ROMANTIQUE — Styles
   Ambiance cinématique élégante, responsive, sans dépendances
   ============================================================ */

/* --- Variables & reset --- */
:root {
  --color-bg-deep:    #030008;
  --color-bg-night:   #0a0014;
  --color-rose:       #ff6b9d;
  --color-rose-soft:  #ffb3cc;
  --color-violet:     #9b59b6;
  --color-violet-deep:#6c3483;
  --color-gold:       #ffd1dc;
  --color-white-soft: rgba(255, 240, 245, 0.95);
  --font-display:     'Georgia', 'Times New Roman', serif;
  --font-body:        'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --ease-cinematic:   cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-bounce:      cubic-bezier(0.34, 1.56, 0.64, 1);
  --glow-rose:        0 0 30px rgba(255, 107, 157, 0.6),
                      0 0 60px rgba(255, 107, 157, 0.3),
                      0 0 100px rgba(155, 89, 182, 0.2);
  --glow-strong:      0 0 40px rgba(255, 107, 157, 0.8),
                      0 0 80px rgba(255, 107, 157, 0.5),
                      0 0 140px rgba(232, 67, 147, 0.3);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg-deep);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  touch-action: none;
  user-select: none;
}

/* --- Application --- */
.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--color-bg-deep);
}

/* --- Couches canvas --- */
.canvas-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#canvas-bg       { z-index: 1; }
#canvas-nebula   { z-index: 2; }
#canvas-particles{ z-index: 3; }
#canvas-effects  { z-index: 5; }
#canvas-mouse    { z-index: 6; pointer-events: none; }

/* --- Halos CSS décoratifs --- */
.halo {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  filter: blur(60px);
  transition: opacity 3s var(--ease-cinematic);
  will-change: opacity, transform;
}

.halo-1 {
  width:  min(60vw, 500px);
  height: min(60vw, 500px);
  top: 10%;
  left: -10%;
  background: radial-gradient(circle, rgba(255, 107, 157, 0.35) 0%, transparent 70%);
}

.halo-2 {
  width:  min(50vw, 420px);
  height: min(50vw, 420px);
  bottom: 5%;
  right: -5%;
  background: radial-gradient(circle, rgba(155, 89, 182, 0.3) 0%, transparent 70%);
}

.halo-3 {
  width:  min(40vw, 350px);
  height: min(40vw, 350px);
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255, 179, 204, 0.25) 0%, transparent 70%);
}

.halo.visible {
  opacity: 1;
}

.halo.pulse {
  animation: haloPulse 4s ease-in-out infinite;
}

@keyframes haloPulse {
  0%, 100% { transform: scale(1);   opacity: 0.7; }
  50%       { transform: scale(1.15); opacity: 1;   }
}

.halo-3.pulse {
  animation: haloPulseCenter 4s ease-in-out infinite;
}

@keyframes haloPulseCenter {
  0%, 100% { transform: translateX(-50%) scale(1);   opacity: 0.7; }
  50%       { transform: translateX(-50%) scale(1.15); opacity: 1;   }
}

/* --- Overlay textuel --- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.text-scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.2s var(--ease-cinematic),
              visibility 0s linear 1.2s;
  pointer-events: none;
  padding: 1.5rem;
  text-align: center;
}

.text-scene.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 1.2s var(--ease-cinematic),
              visibility 0s linear 0s;
}

.text-scene.fade-out {
  opacity: 0;
  visibility: hidden;
  transition: opacity 1.5s var(--ease-cinematic),
              visibility 0s linear 1.5s;
}

/* --- Scène 6 : Titre principal --- */
.title-scene {
  gap: 1rem;
}

.main-title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 5vw, 3.2rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1.35;
  color: var(--color-white-soft);
  text-shadow: var(--glow-rose);
  letter-spacing: 0.04em;
  animation: titlePulse 3s ease-in-out infinite;
}

.title-scene.active .main-title {
  animation: titleAppear 1.8s var(--ease-cinematic) forwards,
             titlePulse 3s ease-in-out 1.8s infinite;
}

@keyframes titleAppear {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.92);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes titlePulse {
  0%, 100% { text-shadow: var(--glow-rose); }
  50%       { text-shadow: var(--glow-strong); }
}

.title-heart {
  display: block;
  opacity: 0;
  transform: scale(0.5);
}

.title-scene.active .title-heart {
  animation: heartFadeIn 1.2s var(--ease-bounce) 0.4s forwards;
}

.title-scene.active .title-heart:last-child {
  animation-delay: 0.7s;
}

@keyframes heartFadeIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Icônes cœur SVG --- */
.heart-icon {
  display: block;
  fill: var(--color-rose);
  filter: drop-shadow(0 0 8px rgba(255, 107, 157, 0.8))
          drop-shadow(0 0 20px rgba(255, 107, 157, 0.4));
}

.heart-icon-sm { width: clamp(28px, 5vw, 44px); height: auto; }
.heart-icon-md { width: clamp(36px, 6vw, 56px); height: auto; }
.heart-icon-lg { width: clamp(48px, 8vw, 72px); height: auto; }
.heart-icon-xl { width: clamp(56px, 10vw, 90px); height: auto; }

/* --- Scène 7 : Machine à écrire --- */
.typewriter-scene {
  justify-content: center;
}

.typewriter-text {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 3.5vw, 2rem);
  font-style: italic;
  line-height: 1.7;
  color: var(--color-gold);
  text-shadow: 0 0 20px rgba(255, 209, 220, 0.5),
               0 0 40px rgba(255, 107, 157, 0.3);
  max-width: 90vw;
  white-space: pre-wrap;
}

.typewriter-cursor {
  display: inline-block;
  font-size: clamp(1.1rem, 3.5vw, 2rem);
  color: var(--color-rose-soft);
  animation: cursorBlink 0.8s step-end infinite;
  margin-left: 2px;
  opacity: 0;
}

.typewriter-scene.active .typewriter-cursor {
  opacity: 1;
}

.typewriter-scene.done .typewriter-cursor {
  opacity: 0;
  animation: none;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* --- Scène 9 : JE T'AIME --- */
.love-scene {
  gap: 0.5rem;
}

.love-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 10vw, 6rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #fff;
  text-shadow: var(--glow-strong);
}

.love-scene.active .love-title {
  animation: loveZoomIn 1.4s var(--ease-bounce) forwards,
             lovePulse 2.5s ease-in-out 1.4s infinite;
}

@keyframes loveZoomIn {
  from {
    opacity: 0;
    transform: scale(0.3);
    filter: blur(12px);
  }
  60% {
    opacity: 1;
    transform: scale(1.08);
    filter: blur(0);
  }
  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

@keyframes lovePulse {
  0%, 100% {
    transform: scale(1);
    text-shadow: var(--glow-strong);
  }
  50% {
    transform: scale(1.04);
    text-shadow: 0 0 60px rgba(255, 107, 157, 1),
                 0 0 120px rgba(255, 107, 157, 0.6),
                 0 0 180px rgba(232, 67, 147, 0.4);
  }
}

.love-scene.active .love-heart {
  animation: heartFadeIn 1s var(--ease-bounce) 0.6s forwards;
  opacity: 0;
}

/* --- Scène 10 : Bouton cœur --- */
.button-scene {
  pointer-events: none;
}

.button-scene.active {
  pointer-events: auto;
}

.heart-button {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  outline: none;
  transform: scale(0);
  opacity: 0;
  transition: transform 0.3s var(--ease-bounce);
  -webkit-tap-highlight-color: transparent;
}

.button-scene.active .heart-button {
  animation: buttonAppear 1s var(--ease-bounce) forwards,
             buttonPulse 2s ease-in-out 1s infinite;
}

@keyframes buttonAppear {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes buttonPulse {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 20px rgba(255,107,157,0.6)); }
  50%       { transform: scale(1.06); filter: drop-shadow(0 0 40px rgba(255,107,157,0.9)); }
}

.heart-button:hover {
  transform: scale(1.08) !important;
  filter: drop-shadow(0 0 50px rgba(255,107,157,1)) !important;
}

.heart-button:active {
  transform: scale(0.95) !important;
}

.heart-button-shape {
  width: clamp(160px, 40vw, 260px);
  height: auto;
  display: block;
}

.heart-button-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-body);
  font-size: clamp(0.85rem, 2.5vw, 1.15rem);
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  white-space: nowrap;
  pointer-events: none;
}

/* --- Scène 11 : Finale JE T'AIME --- */
.finale-love {
  gap: 0.5rem;
  z-index: 12;
}

.finale-love-title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 14vw, 8rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: var(--glow-strong);
}

.finale-love.active .finale-love-title {
  animation: finaleZoom 1.2s var(--ease-bounce) forwards,
             lovePulse 2s ease-in-out 1.2s infinite;
}

@keyframes finaleZoom {
  from {
    opacity: 0;
    transform: scale(0.2);
    filter: blur(16px);
  }
  to {
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
  }
}

.finale-love.active .finale-heart {
  opacity: 0;
  animation: heartFadeIn 0.8s var(--ease-bounce) 0.5s forwards;
}

/* --- Scène 13 : Pour toujours --- */
.forever-scene {
  gap: 0.8rem;
  z-index: 13;
}

.forever-text {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 5vw, 2.8rem);
  font-style: italic;
  font-weight: 400;
  color: var(--color-white-soft);
  text-shadow: var(--glow-rose);
  letter-spacing: 0.06em;
}

.forever-scene.active .forever-text {
  animation: foreverAppear 1.5s var(--ease-cinematic) forwards,
             titlePulse 3.5s ease-in-out 1.5s infinite;
}

@keyframes foreverAppear {
  from {
    opacity: 0;
    transform: translateY(20px);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.forever-scene.active .forever-heart {
  opacity: 0;
  animation: heartFadeIn 1s var(--ease-bounce) 0.8s forwards;
}

/* --- Voile de fondu global --- */
.fade-veil {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: var(--color-bg-deep);
  opacity: 0;
  pointer-events: none;
  transition: opacity 2.5s var(--ease-cinematic);
}

.fade-veil.active {
  opacity: 1;
  pointer-events: all;
}

/* --- Fond pulsant (scène 11+) --- */
.app.bg-pulse {
  animation: bgPulseAnim 1.5s ease-in-out infinite;
}

@keyframes bgPulseAnim {
  0%, 100% { filter: brightness(1); }
  50%       { filter: brightness(1.15); }
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .main-title {
    font-size: clamp(1.3rem, 6vw, 2rem);
  }

  .typewriter-text {
    font-size: clamp(0.95rem, 4vw, 1.3rem);
    padding: 0 0.5rem;
  }

  .love-title {
    letter-spacing: 0.06em;
  }

  .heart-button-shape {
    width: clamp(140px, 55vw, 200px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
