/* ==========================================================================
   Spook Spook Park : couche d'animations (ajoutée le 04/11/2026)
   Fichier à part : retirer la balise <link> et le <script> du HTML pour revenir
   à la version d'avant (sauvegardes : spook_park.v4-avant-animations.*).

   Principes : mouvements doux et rassurants (un fantôme gentil, pas de peur),
   rien ne clignote, on n'anime que transform / opacity / translate / scale / rotate.
   Tout s'arrête avec prefers-reduced-motion (règle globale de spook_park.css
   + garde-fous en bas de ce fichier).
   Le fil conducteur : le parc se visite en petits wagons sur des rails.
   ========================================================================== */

/* ---------- 1. Rail du site : un wagon-fantôme roule entre les pages ---------- */
@media (max-width: 899px) {
  .site-header { position: relative; }
}
.rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* même largeur utile que le contenu de l'en-tête */
  padding-inline: calc((100% - min(var(--container), 100% - 2 * var(--gutter))) / 2 + 6px);
  pointer-events: none;
}
.rail::before,
.rail::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; }
.rail::before { height: 2px; margin-top: -1px; background: var(--border-control); opacity: 0.5; }
.rail::after {
  height: 8px;
  margin-top: -4px;
  background: repeating-linear-gradient(90deg, var(--border-control) 0 2px, transparent 2px 14px);
  opacity: 0.3;
}
.rail-station {
  position: relative;
  z-index: 1;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--brand);
  background: var(--surface);
  transition: background-color 400ms var(--ease), scale 400ms var(--ease);
}
.rail-station.is-active { background: var(--brand); scale: 1.3; }
.rail-wagon {
  position: absolute;
  left: 0;
  top: 50%;
  z-index: 2;
  width: 30px;
  height: 24px;
  margin-top: -19px;
  will-change: transform;
}
.rail-wagon::before { /* la caisse du wagon */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  height: 11px;
  border-radius: 4px 4px 5px 5px;
  background: var(--brand);
}
.rail-wagon::after { /* les deux roues */
  content: "";
  position: absolute;
  left: 5px;
  bottom: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 14px 0 0 var(--ink);
}
.rail-wagon .icon {
  position: absolute;
  left: 50%;
  top: -2px;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  fill: var(--surface);
  stroke: var(--brand);
  z-index: 1;
}
.rail-wagon.is-rolling { filter: drop-shadow(0 0 6px var(--glow)); }
.rail-wagon.is-rolling .icon { animation: sp-sway 0.55s ease-in-out infinite alternate; }
@keyframes sp-sway { from { rotate: -7deg; } to { rotate: 7deg; } }

/* ---------- 2. Entrée de page et apparition au fil du scroll ---------- */
.page.sp-enter { animation: sp-page-in 0.5s var(--ease) backwards; }
@keyframes sp-page-in { from { opacity: 0; translate: 0 12px; } }

.js-anim [data-reveal] {
  transition: opacity 0.7s var(--ease) var(--d, 0ms), translate 0.7s var(--ease) var(--d, 0ms);
}
.js-anim [data-reveal]:not(.is-in) { opacity: 0; translate: 0 22px; }

@keyframes sp-rise { from { opacity: 0; translate: 0 10px; } }

/* Cartes de parcs : elles arrivent l'une après l'autre quand la liste se remplit */
.parks-list > * { animation: sp-rise 0.5s var(--ease) backwards; }
.parks-list > :nth-child(2) { animation-delay: 70ms; }
.parks-list > :nth-child(3) { animation-delay: 140ms; }
.parks-list > :nth-child(4) { animation-delay: 210ms; }
.parks-list > :nth-child(n+5) { animation-delay: 280ms; }

/* ---------- 3. Accueil : petits fantômes qui flottent sur les bords ---------- */
#accueil { position: relative; }
.hero-wisps {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: min(100%, 640px);
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.hero-wisp {
  position: absolute;
  width: 34px;
  height: 34px;
  opacity: 0;
  color: var(--brand);
  animation: sp-wisp 14s ease-in-out infinite;
}
.hero-wisp .icon { width: 100%; height: 100%; fill: var(--surface); stroke: currentColor; }
/* Sur écran étroit, pas de marge libre : ils passeraient devant le texte */
@media (max-width: 1099px) { .hero-wisps { display: none; } }
.hero-wisp:nth-child(1) { left: 3%; top: 36%; }
.hero-wisp:nth-child(2) { right: 4%; top: 16%; animation-delay: -5s; }
.hero-wisp:nth-child(3) { right: 9%; top: 64%; animation-delay: -9s; width: 26px; height: 26px; }
@keyframes sp-wisp {
  0%, 100% { opacity: 0; translate: 0 16px; rotate: -5deg; }
  20%, 80% { opacity: 0.55; }
  50% { translate: 0 -20px; rotate: 5deg; opacity: 0.6; }
}

/* ---------- 4. Plan : le chemin de rails relie les 4 attractions ---------- */
.plan-rail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.plan-rail path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.plan-rail .bed { stroke: var(--pin-bg); stroke-opacity: 0.4; stroke-width: 9; stroke-dasharray: 1; animation: sp-draw 2.4s 0.4s ease-out backwards; }
.plan-rail .ties { stroke: var(--glow); stroke-width: 4; stroke-dasharray: 4 17; animation: sp-march 1.6s linear infinite; }
@keyframes sp-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes sp-march { to { stroke-dashoffset: -21; } }
.plan-cart { position: absolute; left: 0; top: 0; width: 34px; height: 34px; pointer-events: none; will-change: transform; filter: drop-shadow(0 0 6px var(--glow)); }
.plan-cart .icon { width: 100%; height: 100%; fill: var(--surface); stroke: var(--brand); }

/* Repères : ils apparaissent un à un, puis un anneau doux les signale */
.pin { animation: sp-pin-pop 0.7s var(--ease) backwards; transition: background-color var(--t) var(--ease), border-color var(--t) var(--ease), color var(--t) var(--ease), transform 250ms var(--ease); }
.pin-maison { animation-delay: 0.3s; }
.pin-foret { animation-delay: 0.45s; }
.pin-lagune { animation-delay: 0.6s; }
.pin-labo { animation-delay: 0.75s; }
.pin:hover { transform: translate(-50%, -50%) scale(1.1); }
.pin::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px solid var(--glow);
  opacity: 0;
  pointer-events: none;
  animation: sp-ring 3.6s ease-out infinite;
}
.pin-foret::after { animation-delay: 0.9s; }
.pin-lagune::after { animation-delay: 1.8s; }
.pin-labo::after { animation-delay: 2.7s; }
@keyframes sp-pin-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
  60% { opacity: 1; transform: translate(-50%, -50%) scale(1.14); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes sp-ring { 0% { opacity: 0.9; scale: 0.8; } 70%, 100% { opacity: 0; scale: 1.5; } }

/* ---------- 5. Détails qui donnent envie de cliquer ---------- */
.btn { transition-property: background-color, border-color, color, box-shadow, translate; }
.btn:hover { translate: 0 -2px; }
.btn:active { translate: 0 1px; }
.brand:hover .brand-logo { animation: sp-wiggle 0.8s ease-in-out; }
@keyframes sp-wiggle { 0%, 100% { rotate: 0deg; } 30% { rotate: -3deg; } 65% { rotate: 3deg; } }
.main-nav a.nav-cta { animation: sp-cta-glow 5s ease-in-out infinite; }
@keyframes sp-cta-glow { 0%, 70%, 100% { box-shadow: 0 0 0 0 transparent; } 85% { box-shadow: 0 0 0 7px rgba(255, 226, 154, 0.55); } }

/* Modale : elle monte doucement, le fond s'assombrit en fondu */
.modal[open] { animation: sp-modal-in 0.45s var(--ease); }
.modal[open]::backdrop { animation: sp-fade 0.35s ease both; }
@keyframes sp-modal-in { from { opacity: 0; translate: 0 24px; scale: 0.96; } }
@keyframes sp-fade { from { opacity: 0; } }

/* Calendrier : la date choisie fait un petit bond */
.day[aria-pressed="true"] { animation: sp-pop 0.4s var(--ease); }
@keyframes sp-pop { 0% { scale: 0.85; } 55% { scale: 1.12; } 100% { scale: 1; } }

/* Billet : il sort de l'imprimante, des étincelles suivent (JS) */
.ticket:not([hidden]) { animation: sp-ticket 0.85s var(--ease) backwards; transform-origin: top center; }
@keyframes sp-ticket {
  from { opacity: 0; translate: 0 -20px; rotate: -2deg; clip-path: inset(0 0 100% 0); }
  60% { clip-path: inset(0 0 0 0); }
  to { opacity: 1; translate: 0 0; rotate: 0deg; clip-path: inset(0 0 0 0); }
}

/* Formulaires : messages qui apparaissent en douceur */
.field-error:not([hidden]) { animation: sp-rise 0.35s var(--ease); }
.status:not(:empty) { animation: sp-rise 0.45s var(--ease); }

/* ---------- 6. Garde-fous mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1 !important; translate: none !important; }
  .hero-wisps, .plan-cart, .pin::after { display: none; }
  .rail-wagon { transition: none; filter: none; }
  .btn:hover, .btn:active, .pin:hover { translate: none; }
  .pin:hover { transform: translate(-50%, -50%); }
}
