/* ===== AMBIANCE : jour/nuit + météo =====
   ambiance.js écrit deux attributs sur <html> :
     data-ambiance = "jour" | "nuit"
     data-meteo    = "clair" | "nuageux" | "pluie" | "neige"
   Ce fichier ne contient que des RÉACTIONS à ces attributs.
   À charger APRÈS style.css : <link rel="stylesheet" href="ambiance.css"> */

/* Changement de couleur en douceur */
body { transition: background-color 0.6s ease, color 0.6s ease; }

/* NUIT : on redéfinit les variables de style.css, tout le site suit. */
:root[data-ambiance="nuit"] {
  --couleur-fond: #121c17;
  --couleur-texte: #e8e6df;
  --couleur-accent: #ff8a80;
}

/* Le dessin d'accueil devient un empilement de calques :
   fond (ton dessin) < ::before (nuit) < ::after (météo) < contenu (titre).
   isolation: isolate crée un espace d'empilement propre à .hero,
   ce qui permet à z-index: -1 de passer SOUS le texte mais AU-DESSUS du dessin. */
.hero { position: relative; isolation: isolate; }

.hero::before,
.hero::after {
  content: "";                     /* obligatoire pour qu'un pseudo-élément existe */
  position: absolute;
  inset: 0;                        /* raccourci de top/right/bottom/left: 0 */
  z-index: -1;
  pointer-events: none;            /* les clics traversent le calque */
  opacity: 0;                      /* invisible par défaut */
  transition: opacity 1s ease;     /* apparition en fondu */
}

/* Calque 1 : la nuit (voile bleu sombre) */
.hero::before { background-color: rgba(8, 18, 60, 0.55); }
:root[data-ambiance="nuit"] .hero::before { opacity: 1; }

/* Calque 2 : la météo */
:root[data-meteo="nuageux"] .hero::after {
  opacity: 1;
  background-color: rgba(120, 130, 140, 0.35);
}

:root[data-meteo="pluie"] .hero::after {
  opacity: 1;
  background-color: rgba(50, 60, 80, 0.35);
  /* une fine strie diagonale, répétée en mosaïque (40x70 px), puis animée */
  background-image: linear-gradient(100deg, transparent 48%, rgba(255, 255, 255, 0.45) 49%, rgba(255, 255, 255, 0.45) 50%, transparent 51%);
  background-size: 40px 70px;
  animation: pluie 0.6s linear infinite;
}

:root[data-meteo="neige"] .hero::after {
  opacity: 1;
  background-color: rgba(200, 210, 225, 0.2);
  /* un point blanc répété en mosaïque (60x60 px), puis animé vers le bas */
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 2px, transparent 3px);
  background-size: 60px 60px;
  animation: neige 5s linear infinite;
}

@keyframes pluie { to { background-position: -12px 70px; } }
@keyframes neige { to { background-position: 0 60px; } }

/* Respect des personnes sensibles aux animations */
@media (prefers-reduced-motion: reduce) {
  .hero::after { animation: none; }
}