/* ==================================================================
   ANIMATIONS — Festival du Menhir
   ------------------------------------------------------------------
   UTILISATION DANS UNE PAGE (dossier pages/) :

     <h2 data-anim="monte">Titre</h2>
         → l'élément apparaît en montant quand il entre à l'écran.

     <p data-anim="monte" data-anim-delai="200">…</p>
         → même chose, 200 millisecondes plus tard (pratique en cascade).

     <img class="flotte" …>      → flotte doucement en continu
     <img class="balance" …>     → se balance en continu

   Animations d'apparition disponibles (valeur de data-anim) :
     apparition, monte, descend, glisse-gauche, glisse-droite,
     zoom, tampon, surgit, billet

   AJOUTER VOTRE PROPRE ANIMATION :
     1. Écrivez un @keyframes ci-dessous, ex. @keyframes tourne { … }
     2. Ajoutez une ligne :
        .est-visible[data-anim="tourne"] { animation-name: tourne; }
     3. Utilisez data-anim="tourne" dans une page.

   Astuce : les animations utilisent les propriétés translate, scale
   et rotate (et non transform) pour ne pas écraser l'inclinaison
   déjà donnée à certains éléments (billets…).

   Les visiteurs qui ont demandé à réduire les animations dans leur
   système ne voient aucune animation (règle en bas de fichier).
   ================================================================== */

/* Avant leur apparition, les éléments animés sont invisibles
   (uniquement si JavaScript fonctionne, sinon tout reste visible). */
/* Sécurité : si le script ne se lance pas, tout s'affiche quand même après 2,5 s. */
.avec-js [data-anim]:not(.est-visible) { opacity: 0; animation: secours-visible 0s 2.5s forwards; }
@keyframes secours-visible { to { opacity: 1; } }

.est-visible[data-anim] {
  animation-duration: .8s;
  animation-timing-function: cubic-bezier(.2, .7, .2, 1);
  animation-fill-mode: both;
}
.est-visible[data-anim="apparition"]    { animation-name: apparition; }
.est-visible[data-anim="monte"]         { animation-name: monte; }
.est-visible[data-anim="descend"]       { animation-name: descend; }
.est-visible[data-anim="glisse-gauche"] { animation-name: glisse-gauche; }
.est-visible[data-anim="glisse-droite"] { animation-name: glisse-droite; }
.est-visible[data-anim="zoom"]          { animation-name: zoom; }
.est-visible[data-anim="tampon"]        { animation-name: tampon; animation-duration: .9s; animation-timing-function: cubic-bezier(.3, 1.6, .5, 1); }
.est-visible[data-anim="surgit"]        { animation-name: surgit; animation-duration: 1.1s; }
.est-visible[data-anim="billet"]        { animation-name: billet; animation-duration: .9s; animation-timing-function: cubic-bezier(.3, 1.5, .5, 1); }

@keyframes apparition    { from { opacity: 0; } to { opacity: 1; } }
@keyframes monte         { from { opacity: 0; translate: 0 40px; } to { opacity: 1; translate: 0 0; } }
@keyframes descend       { from { opacity: 0; translate: 0 -40px; } to { opacity: 1; translate: 0 0; } }
@keyframes glisse-gauche { from { opacity: 0; translate: -60px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes glisse-droite { from { opacity: 0; translate: 60px 0; } to { opacity: 1; translate: 0 0; } }
@keyframes zoom          { from { opacity: 0; scale: .85; } to { opacity: 1; scale: 1; } }
@keyframes tampon        { from { opacity: 0; scale: 1.35; rotate: -6deg; } to { opacity: 1; scale: 1; rotate: 0deg; } }
@keyframes surgit        { from { opacity: 0; translate: 0 45%; } to { opacity: 1; translate: 0 0; } }
@keyframes billet        { from { opacity: 0; translate: 0 -80px; rotate: 8deg; } to { opacity: 1; translate: 0 0; rotate: 0deg; } }

/* Animations en boucle, à mettre en classe : class="flotte" */
.flotte  { animation: flotte 5s ease-in-out infinite; }
.balance { animation: balance 3.5s ease-in-out infinite; transform-origin: 50% 100%; }
@keyframes flotte  { 50% { translate: 0 -12px; } }
@keyframes balance { 25% { rotate: -3deg; } 75% { rotate: 3deg; } }

/* Le menhir du logo se balance un peu au survol */
.barre-logo:hover img { animation: balance 1.2s ease-in-out; }

/* Ouverture du menu plein écran */
.menu-plein:not([hidden]) .menu-plein-carte { animation: descend .45s cubic-bezier(.2, .8, .2, 1) both; }
.menu-plein:not([hidden]) .menu-grands li { animation: glisse-gauche .5s cubic-bezier(.2, .8, .2, 1) both; }
.menu-plein:not([hidden]) .menu-grands li:nth-child(2) { animation-delay: .05s; }
.menu-plein:not([hidden]) .menu-grands li:nth-child(3) { animation-delay: .1s; }
.menu-plein:not([hidden]) .menu-grands li:nth-child(4) { animation-delay: .15s; }
.menu-plein:not([hidden]) .menu-grands li:nth-child(5) { animation-delay: .2s; }
.menu-plein:not([hidden]) .menu-grands li:nth-child(6) { animation-delay: .25s; }
.menu-plein:not([hidden]) .menu-plein-menhir { animation: surgit .7s .15s cubic-bezier(.2, .8, .2, 1) both; }

/* Aperçu dans l'éditeur : tout est visible tout de suite */
.mode-apercu [data-anim] { opacity: 1 !important; animation: none !important; }

/* Respect du réglage « réduire les animations » */
@media (prefers-reduced-motion: reduce) {
  .avec-js [data-anim]:not(.est-visible) { opacity: 1; }
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
