/* ============================================================
   VARIABLES — modifie ici la palette, les polices, les rythmes.
   ============================================================ */
:root{
  /* Palette : noir profond / bleu nuit / blanc / rose discret / doré léger */
  --noir-profond:   #05050a;
  --bleu-nuit-1:    #0a0f28;
  --bleu-nuit-2:    #131b3f;
  --blanc:          #f6f4f0;
  --rose-discret:   #e7c3ce;
  --rose-douce:     rgba(231, 195, 206, 0.35);
  --or-leger:       #d9b877;
  --or-vif:         #f0d9a3;

  --verre-fond:     rgba(255, 255, 255, 0.045);
  --verre-bord:     rgba(255, 255, 255, 0.12);

  --police-titre:   'Playfair Display', serif;
  --police-poeme:   'Cormorant Garamond', serif;
  --police-texte:   'EB Garamond', serif;

  --duree-lente:    1.8s;
  --duree-moyenne:  1.1s;
  --duree-courte:   0.6s;
  --ease-doux:      cubic-bezier(.19,1,.22,1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*{ box-sizing: border-box; }

html{
  scroll-behavior: smooth;
  scroll-snap-type: y proximity;
}

body{
  margin: 0;
  background: var(--noir-profond);
  color: var(--blanc);
  font-family: var(--police-texte);
  overflow-x: hidden;
  cursor: default;
}

/* Respect des préférences de mouvement réduit */
@media (prefers-reduced-motion: reduce){
  *{
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   CIEL ÉTOILÉ — canevas fixe derrière tout le contenu
   ============================================================ */
#sky-canvas{
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: radial-gradient(ellipse at 50% 20%, var(--bleu-nuit-2) 0%, var(--bleu-nuit-1) 45%, var(--noir-profond) 100%);
}

/* Calque des pétales / cœurs flottants, au-dessus du ciel, sous le texte */
#floating-layer{
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

/* ============================================================
   STRUCTURE DES SCÈNES
   ============================================================ */
main{
  position: relative;
  z-index: 2;
}

.scene{
  position: relative;
  min-height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8vh 6vw;
  text-align: center;
  scroll-snap-align: start;
}

.scene-inner{
  max-width: 780px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2.4rem;
}

.scene-dark{
  background: transparent;
}

/* Carte en verre dépoli (glassmorphism) */
.glass-card{
  background: var(--verre-fond);
  border: 1px solid var(--verre-bord);
  border-radius: 24px;
  padding: 3.2rem 2.4rem;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 8px 60px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
}

/* ============================================================
   SCÈNE 1 — L'ÉTOILE UNIQUE
   ============================================================ */
.single-star{
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blanc);
  margin: 0 auto 2rem;
  box-shadow: 0 0 8px 2px rgba(255,255,255,0.6);
  opacity: 0;
  transform: scale(0.3);
  animation: apparition-etoile 3.5s var(--ease-doux) forwards;
}

@keyframes apparition-etoile{
  0%   { opacity: 0; transform: scale(0.2); }
  40%  { opacity: 1; transform: scale(1.4); box-shadow: 0 0 30px 10px rgba(255,255,255,0.8); }
  100% { opacity: 1; transform: scale(1); box-shadow: 0 0 14px 4px rgba(255,255,255,0.55); }
}

.intro-line{
  font-family: var(--police-titre);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  letter-spacing: 0.02em;
  color: var(--blanc);
  opacity: 0;
}

.reveal-btn{
  opacity: 0;
}

/* Classe ajoutée en JS quand un élément doit apparaître en fondu */
.is-visible.intro-line{
  animation: fondu-monte var(--duree-lente) var(--ease-doux) forwards;
  animation-delay: 0.3s;
}
.is-visible.reveal-btn{
  animation: fondu-monte var(--duree-lente) var(--ease-doux) forwards;
}

@keyframes fondu-monte{
  from{ opacity: 0; transform: translateY(18px); }
  to{ opacity: 1; transform: translateY(0); }
}

/* ============================================================
   BOUTONS
   ============================================================ */
.cta-btn{
  font-family: var(--police-texte);
  font-size: 1.02rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--blanc);
  background: transparent;
  border: 1px solid var(--or-leger);
  border-radius: 999px;
  padding: 0.95rem 2.6rem;
  cursor: pointer;
  transition: background var(--duree-courte) var(--ease-doux),
              box-shadow var(--duree-courte) var(--ease-doux),
              transform var(--duree-courte) var(--ease-doux),
              color var(--duree-courte) var(--ease-doux);
}

.cta-btn:hover, .cta-btn:focus-visible{
  background: rgba(217, 184, 119, 0.12);
  box-shadow: 0 0 24px rgba(217, 184, 119, 0.35);
  transform: translateY(-2px);
  outline: none;
}

.cta-btn:focus-visible{
  outline: 2px solid var(--or-vif);
  outline-offset: 3px;
}

.choice-buttons{
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
  justify-content: center;
}

.choice-btn[data-path="heart"]{
  border-color: var(--rose-discret);
}
.choice-btn[data-path="heart"]:hover{
  background: rgba(231, 195, 206, 0.12);
  box-shadow: 0 0 24px rgba(231, 195, 206, 0.35);
}

/* Bouton son, fixe en haut à droite */
.glass-btn{
  background: var(--verre-fond);
  border: 1px solid var(--verre-bord);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--blanc);
  border-radius: 50%;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--duree-courte) var(--ease-doux), box-shadow var(--duree-courte) var(--ease-doux);
}
.glass-btn:hover{ transform: scale(1.08); box-shadow: 0 0 18px rgba(255,255,255,0.15); }

.sound-btn{
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 50;
  font-size: 1.1rem;
}
.sound-btn.is-muted #sound-icon{ opacity: 0.4; }

/* ============================================================
   TEXTES POÉTIQUES GÉNÉRIQUES
   ============================================================ */
.poetic-text{
  font-family: var(--police-poeme);
  font-style: italic;
  font-size: clamp(1.4rem, 3.2vw, 2rem);
  line-height: 1.6;
  color: var(--blanc);
  font-weight: 400;
}

.emphasis{
  color: var(--or-vif);
}

.fade-in-block{
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--duree-lente) var(--ease-doux), transform var(--duree-lente) var(--ease-doux);
}
.fade-in-block.is-visible{
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   SCÈNE 2 — LUMIÈRES DE SOUVENIRS
   ============================================================ */
.memory-lights{
  position: absolute;
  inset: 0;
  z-index: 0;
}
.memory-light{
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--or-vif);
  opacity: 0;
  box-shadow: 0 0 12px 4px rgba(240, 217, 163, 0.5);
  animation: pulse-souvenir 4.5s ease-in-out infinite;
}
@keyframes pulse-souvenir{
  0%, 100% { opacity: 0.15; transform: scale(0.8); }
  50%      { opacity: 0.9;  transform: scale(1.3); }
}

/* ============================================================
   SCÈNE 3 — LIGNES POÉTIQUES SÉQUENTIELLES
   ============================================================ */
.poetic-line{
  font-family: var(--police-poeme);
  font-style: italic;
  font-size: clamp(1.25rem, 2.8vw, 1.75rem);
  line-height: 1.7;
  color: var(--blanc);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 1.4s var(--ease-doux), transform 1.4s var(--ease-doux);
  margin: 0 0 0.6rem 0;
}
.poetic-line.is-visible{
  opacity: 1;
  transform: translateY(0);
}

#btn-scene3-continue{
  margin-top: 1.6rem;
  opacity: 0;
  transition: opacity 1.4s var(--ease-doux);
  pointer-events: none;
}
#btn-scene3-continue.is-visible{
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   VOILE DE TRANSITION (scène 4 -> lettre)
   ============================================================ */
#transition-veil{
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, var(--rose-douce) 0%, transparent 65%);
}
#transition-veil.veil-heart{
  animation: voile-coeur 1.6s var(--ease-doux) forwards;
}
#transition-veil.veil-moon{
  background: radial-gradient(circle at 50% 50%, rgba(180, 200, 255, 0.28) 0%, transparent 65%);
  animation: voile-lune 1.6s var(--ease-doux) forwards;
}
@keyframes voile-coeur{
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes voile-lune{
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ============================================================
   SCÈNE 5 — LA LETTRE
   ============================================================ */
.letter-wrapper{
  max-width: 680px;
}

.letter-intro{
  font-family: var(--police-poeme);
  font-style: italic;
  font-size: clamp(1.1rem, 2.4vw, 1.4rem);
  color: var(--rose-discret);
  min-height: 1.6em;
  opacity: 0;
  transition: opacity 1.2s var(--ease-doux);
}
.letter-intro.is-visible{ opacity: 1; }

.letter-paper{
  text-align: left;
  font-family: var(--police-texte);
  font-size: clamp(1.02rem, 2vw, 1.18rem);
  line-height: 1.9;
  color: var(--blanc);
}

.letter-signature-top{
  font-family: var(--police-poeme);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--or-vif);
  margin-bottom: 1.4rem;
}

#letter-body p{
  margin: 0 0 1.3rem 0;
}

/* Curseur clignotant façon machine à écrire */
.typing-cursor::after{
  content: '|';
  display: inline-block;
  margin-left: 2px;
  animation: clignote 0.9s steps(1) infinite;
  color: var(--or-leger);
}
@keyframes clignote{
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ============================================================
   SCÈNE FINALE — CIEL, LUNE, MESSAGE ÉTERNEL
   ============================================================ */
.scene-final{
  min-height: 130vh;
  flex-direction: column;
  padding-top: 14vh;
}

.moon{
  position: relative;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  margin-bottom: 3rem;
  background: radial-gradient(circle at 35% 30%, #fffdf5 0%, var(--or-vif) 55%, #cbb27a 100%);
  box-shadow: 0 0 60px 18px rgba(240, 217, 163, 0.35);
  opacity: 0;
  animation: lever-lune 3s var(--ease-doux) forwards;
  animation-delay: 0.4s;
}
@keyframes lever-lune{
  from{ opacity: 0; transform: translateY(40px) scale(0.8); }
  to{ opacity: 1; transform: translateY(0) scale(1); }
}

.final-lines{
  display: flex;
  flex-direction: column;
  gap: 2.6rem;
  max-width: 720px;
}

.final-line{
  font-family: var(--police-poeme);
  font-style: italic;
  font-size: clamp(1.3rem, 3vw, 1.9rem);
  line-height: 1.7;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 2s var(--ease-doux), transform 2s var(--ease-doux);
}
.final-line.is-visible{
  opacity: 1;
  transform: translateY(0);
}

.signature-final{
  color: var(--or-vif);
  margin-top: 1rem;
}

/* ============================================================
   PÉTALES & CŒURS FLOTTANTS (générés dynamiquement, styles animés ici)
   ============================================================ */
.petale{
  position: absolute;
  top: -20px;
  width: 11px;
  height: 15px;
  background: linear-gradient(135deg, var(--rose-discret), rgba(231,195,206,0.15));
  border-radius: 60% 0 60% 0;
  opacity: 0.75;
  will-change: transform, opacity;
  animation-name: chute-petale;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes chute-petale{
  0%{
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0.85;
  }
  100%{
    transform: translate3d(var(--derive, 40px), 110vh, 0) rotate(340deg);
    opacity: 0;
  }
}

.coeur-discret{
  position: absolute;
  bottom: -30px;
  font-size: 14px;
  color: var(--rose-discret);
  opacity: 0;
  will-change: transform, opacity;
  animation-name: montee-coeur;
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
  filter: drop-shadow(0 0 6px rgba(231,195,206,0.5));
}

@keyframes montee-coeur{
  0%{
    transform: translate3d(0, 0, 0) scale(0.8);
    opacity: 0;
  }
  15%{
    opacity: 0.55;
  }
  85%{
    opacity: 0.35;
  }
  100%{
    transform: translate3d(var(--derive, -20px), -100vh, 0) scale(1.1);
    opacity: 0;
  }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px){
  .scene{ padding: 6vh 5.5vw; }
  .glass-card{ padding: 2.2rem 1.5rem; border-radius: 18px; }
  .scene-inner{ gap: 1.8rem; }
  .choice-buttons{ flex-direction: column; width: 100%; }
  .choice-btn{ width: 100%; }
  .sound-btn{ top: 16px; right: 16px; width: 40px; height: 40px; }
}

@media (max-width: 380px){
  .cta-btn{ padding: 0.85rem 1.8rem; font-size: 0.92rem; }
}
