/* =========================================================
   Fiveswix — atmosphère : couches de décor
   Les variables d'ambiance sont enregistrées pour être animées (fondu de 2 s).
   ========================================================= */
@property --b0 { syntax: "<color>"; inherits: true; initial-value: #0f0a19; }
@property --b1 { syntax: "<color>"; inherits: true; initial-value: #27122f; }
@property --b2 { syntax: "<color>"; inherits: true; initial-value: #4a1f3c; }
@property --b3 { syntax: "<color>"; inherits: true; initial-value: #8a3e3a; }
@property --b4 { syntax: "<color>"; inherits: true; initial-value: #c97a45; }
@property --halo-1 { syntax: "<color>"; inherits: true; initial-value: #6a2f73; }
@property --halo-2 { syntax: "<color>"; inherits: true; initial-value: #d6713f; }
@property --halo-3 { syntax: "<color>"; inherits: true; initial-value: #b84a5a; }
@property --clouds { syntax: "<number>"; inherits: true; initial-value: 0.4; }
@property --fog { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --veil { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --stars { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --dim { syntax: "<number>"; inherits: true; initial-value: 0; }

:root {
  transition:
    --b0 var(--t-amb) var(--ease), --b1 var(--t-amb) var(--ease), --b2 var(--t-amb) var(--ease),
    --b3 var(--t-amb) var(--ease), --b4 var(--t-amb) var(--ease),
    --halo-1 var(--t-amb) var(--ease), --halo-2 var(--t-amb) var(--ease), --halo-3 var(--t-amb) var(--ease),
    --clouds var(--t-amb) var(--ease), --fog var(--t-amb) var(--ease), --veil var(--t-amb) var(--ease), --stars var(--t-amb) var(--ease), --dim var(--t-amb) var(--ease);
}

.atm { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.atm > * { position: absolute; }

.atm__gradient {
  inset: 0;
  background: linear-gradient(180deg, var(--b0) 0%, var(--b1) 28%, var(--b2) 56%, var(--b3) 80%, var(--b4) 100%);
}

/* Halo du soleil : --sun-x / --sun-y (nombres, % de la fenêtre) et `translate`, car animer left/top décalait la mise en page (CLS de jour) */
.sunglow {
  left: 0; top: 0; translate: calc(var(--sun-x) * 1vw - 50%) calc(var(--sun-y) * 1vh - 50%);
  width: 70vmax; height: 70vmax;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 240, 200, .55) 0%, rgba(255, 220, 160, .22) 18%, rgba(255, 200, 130, .08) 36%, rgba(255, 190, 120, 0) 60%);
  filter: blur(6px);
  opacity: 0;
  transition: opacity var(--t-amb) var(--ease), translate var(--t-amb) var(--ease);
  animation: breathe 14s ease-in-out infinite alternate;
}
/* Plein à 50 % (« voilé » : 45 % du plein) : à 60 et 70 %, le texte posé sur le décor près du cœur du halo perd davantage de contraste */
body[data-sun="full"] .sunglow { opacity: .5; }
body[data-sun="soft"] .sunglow { opacity: .225; }
@keyframes breathe { to { transform: translateY(-2%) scale(1.04); } }

/* Halos colorés dérivants */
.halo {
  border-radius: 50%;
  filter: blur(90px);
  mix-blend-mode: screen;
  opacity: .7;
  will-change: transform;
}
.halo--1 { width: 60vw; height: 60vw; left: -15vw; top: -20vw; background: radial-gradient(circle, var(--halo-1), transparent 70%); animation: drift1 26s ease-in-out infinite alternate; }
.halo--2 { width: 55vw; height: 55vw; right: -15vw; bottom: -18vw; background: radial-gradient(circle, var(--halo-2), transparent 70%); animation: drift2 32s ease-in-out infinite alternate; }
.halo--3 { width: 34vw; height: 34vw; left: 50%; top: 40%; background: radial-gradient(circle, var(--halo-3), transparent 70%); animation: drift3 28s ease-in-out infinite alternate; opacity: .45; }
@keyframes drift1 { to { transform: translate(10vw, 8vh) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-9vw, -7vh) scale(1.2); } }
@keyframes drift3 { to { transform: translate(-10vw, 10vh) scale(.9); } }

/* Lune dans le ciel (visible la nuit) */
.sky-moon {
  top: 12vh; right: 10vw;
  width: clamp(64px, 8vw, 110px); height: auto;
  opacity: 0;
  filter: drop-shadow(0 0 24px rgba(246, 217, 138, .35));
  transition: opacity var(--t-amb) var(--ease);
  animation: floaty 10s ease-in-out infinite alternate;
}
.sky-moon.is-visible { opacity: var(--moon-opacity, 1); }
@keyframes floaty { to { transform: translateY(-10px); } }

/* Bancs de nuages : densité = --clouds */
.cloudbank {
  left: -20vw; right: -20vw; height: 26vh;
  filter: blur(34px);
  opacity: calc(var(--clouds) * .6);
  background:
    radial-gradient(60% 100% at 20% 50%, rgba(255, 255, 255, .35), transparent 70%),
    radial-gradient(50% 100% at 65% 40%, rgba(255, 255, 255, .28), transparent 70%);
}
.cloudbank--1 { top: 6vh; animation: cloudDrift 140s linear infinite alternate; }
.cloudbank--2 { top: 28vh; opacity: calc(var(--clouds) * .4); animation: cloudDrift 180s linear infinite alternate-reverse; }
@keyframes cloudDrift { to { transform: translateX(8vw); } }

/* Brume : --fog */
.fog {
  left: 0; right: 0; bottom: 0; height: 48vh;
  background: linear-gradient(180deg, rgba(255, 235, 220, 0), rgba(255, 235, 220, .18) 60%, rgba(255, 235, 220, .34));
  filter: blur(14px);
  opacity: var(--fog);
}
.fogband {
  left: -10vw; right: -10vw; height: 14vh;
  filter: blur(26px);
  opacity: calc(var(--fog) * .35);
  background: linear-gradient(90deg, transparent, rgba(255, 235, 220, .6) 30%, rgba(255, 235, 220, .3) 60%, transparent);
}
.fogband--1 { bottom: 12vh; animation: fogDrift 60s ease-in-out infinite alternate; }
.fogband--2 { bottom: 4vh; opacity: calc(var(--fog) * .25); animation: fogDrift 80s ease-in-out infinite alternate-reverse; }
@keyframes fogDrift { to { transform: translateX(10vw); } }

/* Canvas des effets (pluie, neige, étoiles, éclairs) */
#fx { inset: 0; width: 100%; height: 100%; }

/* Voile blanc (brouillard, neige) */
.veil { inset: 0; background: #fff; opacity: var(--veil); }

/* Grain et vignette */
.grain {
  inset: 0; opacity: .045; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* Vignette + assombrissement du bas : contraste du texte sur l'horizon clair. Le premier voile, doux, se place derrière la capsule météo, les puces et l'indice de défilement
   (texte courant à 4,5:1 ou plus sur les 28 ambiances, contre 2,5:1 sans lui sur les plus claires). */
.vig {
  inset: 0;
  --pool-w: 85%; --pool-h: 30%; --pool-y: 73%; --pool-a: .46;
  background:
    radial-gradient(var(--pool-w) var(--pool-h) at 50% var(--pool-y), rgba(5, 4, 12, var(--pool-a)), rgba(5, 4, 12, calc(var(--pool-a) - .04)) 45%, transparent 100%),
    radial-gradient(120% 90% at 50% 40%, transparent 50%, rgba(5, 4, 12, .55) 100%),
    linear-gradient(180deg, transparent 55%, rgba(5, 4, 12, .35) 80%, rgba(5, 4, 12, .6) 100%);
}

@media (max-width: 480px) { .vig { --pool-w: 90%; --pool-h: 32%; --pool-y: 64%; --pool-a: .5; } } /* sur téléphone la capsule est plus haut dans l'écran */

/* Posée par atmosphere.js le temps d'appliquer la première ambiance : pas de fondu depuis la palette par défaut */
:root.no-amb-transition { transition: none; }
