/*
 * Ouverture 3D des faire-part (Mélisse, Nacre).
 * Ajoutée à la publication par scripts/sync-static-demos.mjs : les sources demos/ restent intactes.
 */

/* Tant que la scène n'est pas posée, on ne montre pas la page (garde-fou : tout réapparaît après 2,5 s). */
html:not(.amorea-stage-on) {
  background: var(--amorea-sealed-backdrop, #f4ede3);
}
html:not(.amorea-stage-on) body {
  animation: amorea-stage-wait 0s 2.5s both;
}
@keyframes amorea-stage-wait {
  from { visibility: hidden; }
  to { visibility: visible; }
}

.amorea-stage {
  --stage-ink: #384829;
  --stage-accent: #84475e;
  --stage-font: Cormorant, Georgia, serif;
  --stage-top: #fbf5ea;
  --stage-bottom: #efe0c9;
  position: fixed;
  inset: 0;
  z-index: 2147483003;
  overflow: hidden;
  background: radial-gradient(120% 80% at 50% 38%, var(--stage-top), var(--stage-bottom));
  color: var(--stage-ink);
  font-family: var(--stage-font);
  transition: opacity .75s cubic-bezier(.4, 0, .2, 1);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
.amorea-stage[data-theme="nacre"] {
  --stage-ink: #42492f;
  --stage-accent: #8a6c3f;
  --stage-font: "Nacre Serif", Georgia, serif;
  --stage-top: #fbf7f0;
  --stage-bottom: #e9dfcf;
}

.amorea-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1.1s ease;
  cursor: pointer;
}
.amorea-stage[data-state="ready"] canvas,
.amorea-stage[data-state="opening"] canvas { opacity: 1; }

.amorea-stage-ui {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  padding: max(22px, env(safe-area-inset-top)) 16px max(26px, calc(env(safe-area-inset-bottom) + 18px));
  pointer-events: none;
  transition: opacity .5s ease, transform .6s cubic-bezier(.22, 1, .36, 1);
}
.amorea-stage[data-state="opening"] .amorea-stage-ui {
  opacity: 0;
  transform: translateY(10px);
}

.amorea-stage-kicker {
  margin: 0;
  font-size: .78rem;
  font-weight: 650;
  letter-spacing: .24em;
  text-transform: uppercase;
  text-align: center;
  opacity: .82;
}
.amorea-stage-kicker::after {
  content: "";
  display: block;
  width: 34px;
  height: 1px;
  margin: .7rem auto 0;
  background: currentColor;
  opacity: .45;
}

.amorea-stage-actions {
  grid-row: 3;
  display: grid;
  justify-items: center;
  gap: .45rem;
}
.amorea-stage-open {
  pointer-events: auto;
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--stage-ink) 35%, transparent);
  border-radius: 999px;
  padding: .78rem 1.6rem .8rem;
  background: color-mix(in srgb, #fffaf2 82%, transparent);
  color: var(--stage-ink);
  font: 600 .82rem/1 var(--stage-font);
  letter-spacing: .2em;
  text-transform: uppercase;
  box-shadow: 0 10px 30px -14px #4a3b2a66, inset 0 0 0 4px #fffaf2;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease, background .25s ease;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.amorea-stage-open:hover { transform: translateY(-1px); box-shadow: 0 14px 34px -14px #4a3b2a80, inset 0 0 0 4px #fffaf2; }
.amorea-stage-open:focus-visible { outline: 2px solid var(--stage-accent); outline-offset: 4px; }
.amorea-stage-hint {
  margin: 0;
  font-size: .9rem;
  font-style: italic;
  opacity: .7;
}

/* Chargement : un léger souffle sur le bouton. */
.amorea-stage[data-state="loading"] .amorea-stage-open { animation: amorea-stage-breathe 1.6s ease-in-out infinite; }
@keyframes amorea-stage-breathe { 50% { opacity: .72; } }

/* Ouverture simple (sans WebGL ou mouvements réduits) : on voit la vraie couverture, seul le bouton s'affiche. */
.amorea-stage[data-mode="simple"] {
  background: linear-gradient(to top, #2a221a59, transparent 32%);
  touch-action: auto;
}
.amorea-stage[data-mode="simple"] .amorea-stage-kicker,
.amorea-stage[data-mode="simple"] .amorea-stage-hint { display: none; }
.amorea-stage[data-mode="simple"] .amorea-stage-actions { margin-bottom: 7vh; }

.amorea-stage[data-state="done"] {
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .amorea-stage, .amorea-stage-ui, .amorea-stage canvas { transition-duration: .2s; }
  .amorea-stage[data-state="loading"] .amorea-stage-open { animation: none; }
}
