/* KDO Étincelle — page surprise */
body { overflow: hidden; height: 100vh; height: 100dvh; }

.scene-kdo { position: relative; z-index: 2; height: 100%; }
.ecran {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(56px, env(safe-area-inset-bottom));
  text-align: center;
  opacity: 0; visibility: hidden;
  transition: opacity .6s ease, visibility 0s linear .6s;
}
.ecran.actif { opacity: 1; visibility: visible; transition: opacity .6s ease, visibility 0s; }
.ecran-tap { cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.ecran:focus { outline: none; }

/* Chargement */
.pastille-charge { width: 44px; height: 44px; border-radius: 50%; border: 4px solid var(--bord); border-top-color: var(--corail); animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.carte-erreur { max-width: 420px; }
.carte-erreur h1 { font-size: 1.9rem; }
.carte-erreur p { color: var(--doux); margin-bottom: 24px; }

/* ---------- 1. Accueil ---------- */
.occasion {
  margin: 0 0 12px; padding: .4em 1em; border-radius: 999px;
  background: rgba(244, 184, 96, .18); color: var(--titre);
  font-weight: 700; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase;
}
.occasion:empty { display: none; }
.titre-accueil { font-size: clamp(1.85rem, 7.6vw, 3.1rem); max-width: 15em; margin: 0 auto 6px; font-weight: 500; }
.titre-accueil .prenom { color: var(--corail); font-weight: 700; }

.cadeau-zone { width: min(250px, 62vw, 34vh); margin: 4px auto 18px; }
.cadeau { width: 100%; overflow: visible; }
.cadeau .boite, .cadeau .couvercle { transform-box: fill-box; transform-origin: 50% 100%; }
.cadeau .lueur { transform-box: fill-box; transform-origin: center; animation: lueur 3s ease-in-out infinite; }
.cadeau .eclats use { transform-box: fill-box; transform-origin: center; animation: eclat 2.6s ease-in-out infinite; }
.cadeau .eclats use:nth-child(2) { animation-delay: .7s; }
.cadeau .eclats use:nth-child(3) { animation-delay: 1.3s; }
.cadeau .eclats use:nth-child(4) { animation-delay: 1.9s; }
#cadeau { animation: respire 2.8s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes respire { 0%, 100% { transform: rotate(-2deg) scale(1); } 50% { transform: rotate(2deg) scale(1.03); } }
@keyframes lueur { 0%, 100% { opacity: .55; transform: scale(.92); } 50% { opacity: 1; transform: scale(1.05); } }
@keyframes eclat { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }

.cadeau.ouvert { animation: secoue .45s ease-in-out; }
.cadeau.ouvert .couvercle { animation: envol .9s cubic-bezier(.2, .7, .3, 1) .35s forwards; }
.cadeau.ouvert .boite { animation: disparait .7s ease .7s forwards; }
.cadeau.ouvert .lueur { animation: flash .9s ease .35s forwards; }
@keyframes secoue { 0%, 100% { transform: none; } 20% { transform: rotate(-6deg); } 45% { transform: rotate(6deg); } 70% { transform: rotate(-4deg); } }
@keyframes envol { to { transform: translate(30%, -160%) rotate(28deg); opacity: 0; } }
@keyframes disparait { to { transform: scale(.6) translateY(20px); opacity: 0; } }
@keyframes flash { 40% { opacity: 1; transform: scale(1.8); } 100% { opacity: 0; transform: scale(2.4); } }

.bouton-ouvrir { min-height: 60px; padding: 0 2.2em; font-size: 1.15rem; animation: appel 2.2s ease-in-out infinite; }
@keyframes appel { 0%, 100% { box-shadow: 0 8px 22px rgba(232, 81, 63, .35), 0 0 0 0 rgba(255, 107, 91, .45); } 50% { box-shadow: 0 8px 22px rgba(232, 81, 63, .35), 0 0 0 14px rgba(255, 107, 91, 0); } }
.bouton-ouvrir.apparait { animation: pop .6s cubic-bezier(.3, 1.6, .5, 1), appel 2.2s ease-in-out .6s infinite; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }

/* Compte à rebours */
.compte { width: 100%; max-width: 420px; }
.compte-titre { margin: 0 0 10px; font-weight: 700; color: var(--doux); font-size: .9rem; letter-spacing: .06em; text-transform: uppercase; }
.compte-cases { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.compte-cases div {
  padding: 12px 4px 10px; border-radius: 18px;
  background: var(--carte); border: 1px solid var(--bord); box-shadow: var(--ombre);
}
.compte-cases b { display: block; font: 700 clamp(1.7rem, 8vw, 2.4rem)/1 var(--titres); color: var(--titre); font-variant-numeric: tabular-nums; }
.compte-cases span { font-size: .75rem; color: var(--doux); }
.compte-date { margin: 12px 0 0; color: var(--doux); font-style: italic; font-family: var(--titres); }
.lien-demo { margin-top: 14px; background: none; border: 0; color: var(--corail); font: 500 .9rem var(--textes); text-decoration: underline; cursor: pointer; padding: 8px; }

/* ---------- 4. Messages ---------- */
.message {
  max-width: 14em; margin: 0 auto;
  font: 500 clamp(1.9rem, 8.4vw, 3.4rem)/1.2 var(--titres); color: var(--titre);
  opacity: 0;
}
.message.long { font-size: clamp(1.5rem, 6.4vw, 2.6rem); max-width: 17em; }
.message.entre { animation: entre .9s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes entre { from { opacity: 0; transform: translateY(24px) scale(.97); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }
.points { position: absolute; bottom: max(84px, calc(env(safe-area-inset-bottom) + 70px)); display: flex; gap: 8px; }
.points i { width: 8px; height: 8px; border-radius: 50%; background: var(--bord); transition: background .3s, transform .3s; }
.points i.fait { background: var(--or); }
.points i.ici { background: var(--corail); transform: scale(1.35); }
.indice {
  position: absolute; bottom: max(48px, calc(env(safe-area-inset-bottom) + 34px)); margin: 0;
  color: var(--doux); font-size: .88rem; opacity: 0; transition: opacity .6s;
}
.indice.visible { opacity: 1; animation: souffle 2.4s ease-in-out infinite; }
@keyframes souffle { 50% { opacity: .45; } }

/* ---------- 5. Photos (polaroïds) ---------- */
.pile { position: relative; width: min(78vw, 340px, 52vh); aspect-ratio: 4 / 5.2; }
.polaroid {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: 12px 12px 0; border-radius: 6px;
  background: #FFFDF9; box-shadow: 0 18px 40px rgba(31, 20, 50, .25);
  transform: rotate(var(--rot, 0deg));
}
.polaroid .cliche { flex: 1; min-height: 0; border-radius: 3px; overflow: hidden; background: #EFE6DE; }
.polaroid img { width: 100%; height: 100%; object-fit: cover; }
.polaroid .legende { height: 58px; display: flex; align-items: center; justify-content: center; padding: 0 8px; font: italic 500 1.1rem/1.2 var(--titres); color: #3D2C5E; }
.polaroid.arrive { animation: arrive .8s cubic-bezier(.2, .8, .3, 1.1) both; }
.polaroid.part { animation: part .7s ease-in forwards; }
@keyframes arrive { from { opacity: 0; transform: translateY(-40px) rotate(calc(var(--rot) - 14deg)) scale(1.1); } to { opacity: 1; transform: rotate(var(--rot)); } }
@keyframes part { to { opacity: 0; transform: translateX(-130%) rotate(-24deg); } }

/* ---------- 6. Révélation finale ---------- */
.message-final {
  max-width: 11em; margin: 0 auto;
  font: 700 clamp(2.4rem, 11vw, 4.6rem)/1.08 var(--titres); color: var(--titre);
  opacity: 0;
}
.message-final.long { font-size: clamp(1.9rem, 8vw, 3.4rem); max-width: 14em; }
#e-final.actif .message-final { animation: revele 1.2s cubic-bezier(.2, .7, .2, 1) .2s forwards; }
@keyframes revele { from { opacity: 0; transform: scale(.7); filter: blur(10px); } 60% { opacity: 1; transform: scale(1.04); filter: blur(0); } to { opacity: 1; transform: none; } }
.signature { margin: 22px 0 0; font: italic 500 1.25rem var(--titres); color: var(--corail); opacity: 0; }
#e-final.actif .signature { animation: monte .8s ease 1.3s forwards; }
.fin-actions { margin-top: 34px; display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 320px; opacity: 0; }
#e-final.actif .fin-actions { animation: monte .8s ease 2.2s forwards; }
@keyframes monte { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Formule premium : un liseré doré qui scintille autour du message final */
.premium .message-final {
  background: linear-gradient(100deg, var(--titre) 0 40%, var(--or) 50%, var(--titre) 60% 100%);
  background-size: 250% 100%; background-position: 100% 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.premium #e-final.actif .message-final { animation: revele 1.2s cubic-bezier(.2, .7, .2, 1) .2s forwards, reflet 3.5s ease-in-out 1.6s infinite; }
@keyframes reflet { 0% { background-position: 100% 0; } 60%, 100% { background-position: -50% 0; } }

/* ---------- Son, signalement ---------- */
.son {
  position: fixed; z-index: 5; top: max(14px, env(safe-area-inset-top)); right: 14px;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--bord);
  background: var(--carte); color: var(--titre); box-shadow: var(--ombre);
  display: grid; place-items: center; cursor: pointer;
}
.son svg { width: 22px; height: 22px; }
.son .off { display: none; }
.son[aria-pressed="true"] .on { display: none; }
.son[aria-pressed="true"] .off { display: block; }
.signaler {
  position: fixed; z-index: 4; left: 0; right: 0; bottom: max(10px, env(safe-area-inset-bottom));
  width: max-content; margin: 0 auto; padding: 4px 8px;
  font-size: .72rem; color: var(--doux); opacity: .6; text-decoration: none;
}
.signaler:hover { opacity: 1; text-decoration: underline; }

/* ---------- Décor par occasion ---------- */
.effets { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; }
.decor { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.decor .d { position: absolute; top: 0; left: 0; will-change: transform; }
.decor .d svg { width: 100%; height: 100%; display: block; }
.decor .tombe { animation: tombe-d var(--d) linear var(--r) infinite; }
.decor .monte { animation: monte-d var(--d) linear var(--r) infinite; }
@keyframes tombe-d {
  from { transform: translate3d(var(--x), -12vh, 0) rotate(0deg); }
  50% { transform: translate3d(calc(var(--x) + var(--dx)), 50vh, 0) rotate(180deg); }
  to { transform: translate3d(var(--x), 112vh, 0) rotate(360deg); }
}
@keyframes monte-d {
  from { transform: translate3d(var(--x), 112vh, 0) rotate(-6deg); }
  50% { transform: translate3d(calc(var(--x) + var(--dx)), 50vh, 0) rotate(6deg); }
  to { transform: translate3d(var(--x), -20vh, 0) rotate(-6deg); }
}
.decor .coin { position: absolute; bottom: -6px; width: min(26vw, 150px); opacity: .92; }
.decor .coin.droite { right: 6px; }
.decor .coin.gauche { left: 6px; }
@media (max-height: 640px) { .decor .coin { width: min(20vw, 96px); } }
@media (min-width: 900px) { .decor .coin { width: 190px; bottom: 0; } .decor .coin.droite { right: 4vw; } .decor .coin.gauche { left: 4vw; } }

@media (prefers-reduced-motion: reduce) {
  .decor .d { display: none; }
  .message, .message-final, .signature, .fin-actions { opacity: 1 !important; }
}
