/* =========================================================
   Atmosphere — Weather background FX (light + dark)
   ========================================================= */

.fx-sun,
.fx-fog,
.fx-stars,
.fx-lightning,
.fx-particles,
.fx-clouds {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s var(--ease);
}

/* Theme visibility — forced on for both color modes */
body[data-theme="sunny"] .fx-sun,
body[data-theme="rainy"] .fx-particles,
body[data-theme="rainy"] .fx-clouds,
body[data-theme="thunderstorm"] .fx-particles,
body[data-theme="thunderstorm"] .fx-clouds,
body[data-theme="thunderstorm"] .fx-lightning,
body[data-theme="snowy"] .fx-particles,
body[data-theme="snowy"] .fx-clouds,
body[data-theme="cloudy"] .fx-clouds,
body[data-theme="cloudy"] .fx-particles,
body[data-theme="foggy"] .fx-fog,
body[data-theme="foggy"] .fx-clouds,
body[data-theme="foggy"] .fx-particles,
body[data-theme="night"] .fx-stars {
  opacity: 1;
}

/* ---------- SUN ---------- */
.fx-sun {
  overflow: visible;
}
.sun-core,
.sun-glow,
.sun-rays {
  position: absolute;
  top: 8%;
  right: 12%;
  border-radius: 50%;
  transform: translate(50%, -20%);
}
.sun-core {
  width: 88px;
  height: 88px;
  background: radial-gradient(circle at 35% 35%, #fff6c8 0%, #ffd34d 40%, #f5a623 75%, #e8890c 100%);
  box-shadow:
    0 0 40px rgba(255, 200, 60, 0.85),
    0 0 90px rgba(255, 170, 40, 0.45);
  animation: sunPulse 5s ease-in-out infinite;
  z-index: 3;
}
.sun-glow {
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(255, 200, 60, 0.45) 0%, rgba(255, 180, 40, 0.15) 40%, transparent 70%);
  animation: sunPulse 7s ease-in-out infinite reverse;
  z-index: 1;
}
.sun-rays {
  width: 160px;
  height: 160px;
  background: conic-gradient(
    from 0deg,
    transparent 0deg 12deg,
    rgba(255, 210, 80, 0.55) 12deg 18deg,
    transparent 18deg 42deg,
    rgba(255, 210, 80, 0.45) 42deg 48deg,
    transparent 48deg 72deg,
    rgba(255, 210, 80, 0.55) 72deg 78deg,
    transparent 78deg 102deg,
    rgba(255, 210, 80, 0.4) 102deg 108deg,
    transparent 108deg 132deg,
    rgba(255, 210, 80, 0.55) 132deg 138deg,
    transparent 138deg 162deg,
    rgba(255, 210, 80, 0.4) 162deg 168deg,
    transparent 168deg 192deg,
    rgba(255, 210, 80, 0.55) 192deg 198deg,
    transparent 198deg 222deg,
    rgba(255, 210, 80, 0.4) 222deg 228deg,
    transparent 228deg 252deg,
    rgba(255, 210, 80, 0.55) 252deg 258deg,
    transparent 258deg 282deg,
    rgba(255, 210, 80, 0.4) 282deg 288deg,
    transparent 288deg 312deg,
    rgba(255, 210, 80, 0.55) 312deg 318deg,
    transparent 318deg 342deg,
    rgba(255, 210, 80, 0.4) 342deg 348deg,
    transparent 348deg 360deg
  );
  animation: sunSpin 28s linear infinite;
  z-index: 2;
  filter: blur(0.5px);
  opacity: 0.85;
}
@keyframes sunPulse {
  0%, 100% { transform: translate(50%, -20%) scale(1); opacity: 0.9; }
  50% { transform: translate(50%, -20%) scale(1.08); opacity: 1; }
}
@keyframes sunSpin {
  from { transform: translate(50%, -20%) rotate(0deg); }
  to { transform: translate(50%, -20%) rotate(360deg); }
}

/* Light-mode sun — slightly softer but still visible */
body[data-mode="light"] .sun-core {
  box-shadow:
    0 0 50px rgba(255, 190, 50, 0.9),
    0 0 100px rgba(255, 160, 30, 0.5);
}
body[data-mode="light"] .sun-rays {
  opacity: 0.75;
}

/* ---------- CLOUDS ---------- */
.fx-clouds {
  overflow: hidden;
}
.cloud-puff {
  position: absolute;
  border-radius: 999px;
  background: rgba(180, 190, 210, 0.22);
  filter: blur(10px);
  animation: cloudDrift linear infinite;
}
body[data-mode="light"] .cloud-puff {
  background: rgba(120, 140, 170, 0.28);
}
body[data-theme="thunderstorm"] .cloud-puff,
body[data-theme="rainy"] .cloud-puff,
.cloud-puff--storm {
  background: rgba(70, 85, 110, 0.42);
}
body[data-theme="snowy"] .cloud-puff,
.cloud-puff--snow {
  background: rgba(200, 215, 235, 0.28);
}
body[data-mode="light"][data-theme="thunderstorm"] .cloud-puff,
body[data-mode="light"][data-theme="rainy"] .cloud-puff {
  background: rgba(90, 105, 130, 0.45);
}
body[data-mode="light"][data-theme="snowy"] .cloud-puff {
  background: rgba(170, 190, 215, 0.4);
}
@keyframes cloudDrift {
  0% { transform: translateX(-30vw); }
  100% { transform: translateX(110vw); }
}

/* ---------- RAIN / SNOW PARTICLES ---------- */
.fx-particles { overflow: hidden; }
.particle {
  position: absolute;
  top: -30px;
  pointer-events: none;
  will-change: transform;
}
.particle--rain {
  width: 2px;
  height: 16px;
  background: linear-gradient(to bottom, transparent, rgba(160, 200, 255, 0.85));
  border-radius: 2px;
  animation: rainFall linear infinite;
}
.particle--rain-heavy {
  width: 2.5px;
  height: 22px;
  background: linear-gradient(to bottom, transparent, rgba(180, 210, 255, 0.95));
  border-radius: 2px;
  animation: rainFallHeavy linear infinite;
}
body[data-mode="light"] .particle--rain {
  background: linear-gradient(to bottom, transparent, rgba(60, 110, 180, 0.7));
}
body[data-mode="light"] .particle--rain-heavy {
  background: linear-gradient(to bottom, transparent, rgba(40, 90, 160, 0.85));
}
.particle--snow {
  width: 5px;
  height: 5px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.55);
  animation: snowFall linear infinite;
}
body[data-mode="light"] .particle--snow {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 6px rgba(140, 170, 210, 0.6);
  border: 1px solid rgba(160, 190, 230, 0.5);
}
.particle--haze {
  border-radius: 999px;
  background: rgba(180, 195, 220, 0.16);
  filter: blur(12px);
  animation: hazeDrift linear infinite;
}
body[data-mode="light"] .particle--haze {
  background: rgba(120, 140, 170, 0.22);
}
@keyframes rainFall {
  0% { transform: translateY(0) translateX(0); opacity: 0.85; }
  100% { transform: translateY(110vh) translateX(18px); opacity: 0.12; }
}
@keyframes rainFallHeavy {
  0% { transform: translateY(0) translateX(0); opacity: 1; }
  100% { transform: translateY(110vh) translateX(28px); opacity: 0.18; }
}
@keyframes snowFall {
  0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0.95; }
  100% { transform: translateY(110vh) translateX(50px) rotate(200deg); opacity: 0.15; }
}
@keyframes hazeDrift {
  0% { transform: translateX(-8vw) translateY(0); opacity: 0.2; }
  40% { opacity: 0.55; }
  100% { transform: translateX(18vw) translateY(-12px); opacity: 0.15; }
}

/* ---------- FOG ---------- */
.fx-fog::before,
.fx-fog::after {
  content: "";
  position: absolute;
  left: -20%;
  width: 140%;
  height: 42%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(200, 210, 220, 0.18) 30%,
    rgba(160, 175, 195, 0.28) 50%,
    rgba(200, 210, 220, 0.18) 70%,
    transparent
  );
  filter: blur(28px);
  animation: fogDrift 26s ease-in-out infinite;
}
body[data-mode="light"] .fx-fog::before,
body[data-mode="light"] .fx-fog::after {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(150, 165, 185, 0.35) 30%,
    rgba(130, 145, 165, 0.45) 50%,
    rgba(150, 165, 185, 0.35) 70%,
    transparent
  );
}
.fx-fog::before { top: 22%; }
.fx-fog::after {
  top: 52%;
  animation-duration: 34s;
  animation-direction: reverse;
  opacity: 0.75;
}
@keyframes fogDrift {
  0%, 100% { transform: translateX(-6%); }
  50% { transform: translateX(6%); }
}

/* ---------- STARS ---------- */
.fx-stars::before,
.fx-stars::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 20%, rgba(255,255,255,0.9), transparent),
    radial-gradient(1px 1px at 25% 40%, rgba(255,255,255,0.65), transparent),
    radial-gradient(1.5px 1.5px at 40% 15%, rgba(255,255,255,0.95), transparent),
    radial-gradient(1px 1px at 55% 55%, rgba(255,255,255,0.55), transparent),
    radial-gradient(1.5px 1.5px at 70% 25%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 85% 45%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 15% 70%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 90% 10%, rgba(255,255,255,0.75), transparent);
  animation: starTwinkle 4s ease-in-out infinite;
}
.fx-stars::after {
  animation-delay: 2s;
  opacity: 0.75;
}
body[data-mode="light"][data-theme="night"] .fx-stars::before,
body[data-mode="light"][data-theme="night"] .fx-stars::after {
  /* Night weather in light UI — still show stars softly */
  opacity: 0.55;
  filter: contrast(1.2);
}
@keyframes starTwinkle {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

/* ---------- LIGHTNING ---------- */
.fx-lightning {
  overflow: hidden;
}
.bolt {
  position: absolute;
  top: 0;
  width: 3px;
  height: 0;
  background: linear-gradient(to bottom, #fff, #a8d4ff 40%, transparent);
  opacity: 0;
  filter: drop-shadow(0 0 8px #fff) drop-shadow(0 0 16px #7db7ff);
  clip-path: polygon(40% 0, 60% 0, 45% 35%, 70% 35%, 30% 100%, 42% 48%, 20% 48%);
  width: 40px;
}
.bolt-a { left: 28%; }
.bolt-b { left: 62%; width: 32px; }
.fx-lightning.flash {
  animation: skyFlash 0.45s ease-out;
}
.fx-lightning.flash .bolt-a {
  animation: boltStrike 0.45s ease-out;
}
.fx-lightning.flash .bolt-b {
  animation: boltStrike 0.45s ease-out 0.12s;
}
@keyframes skyFlash {
  0% { background: transparent; }
  12% { background: rgba(220, 235, 255, 0.28); }
  28% { background: transparent; }
  42% { background: rgba(200, 220, 255, 0.18); }
  100% { background: transparent; }
}
@keyframes boltStrike {
  0% { opacity: 0; height: 0; top: 0; }
  15% { opacity: 1; height: 55vh; }
  40% { opacity: 1; height: 55vh; }
  100% { opacity: 0; height: 55vh; }
}
body[data-mode="light"] .fx-lightning.flash {
  animation-name: skyFlashLight;
}
@keyframes skyFlashLight {
  0% { background: transparent; }
  12% { background: rgba(255, 255, 255, 0.55); }
  28% { background: transparent; }
  42% { background: rgba(200, 220, 255, 0.35); }
  100% { background: transparent; }
}

/* Floating weather icons */
.float-icon {
  animation: floatY 4.5s ease-in-out infinite;
}
.float-icon-slow {
  animation: floatY 6s ease-in-out infinite;
}
@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* Hero day/hour switch */
.hero.hero-swap {
  animation: heroSwap 0.55s var(--ease);
}
@keyframes heroSwap {
  0% { opacity: 0.55; transform: scale(0.97) translateY(8px); filter: blur(2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); filter: blur(0); }
}
.hero-icon.icon-out,
.hero-icon-wrap.icon-out {
  opacity: 0;
  transform: scale(0.85) translateY(8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.hero-icon.icon-pop,
.hero-icon-wrap.icon-pop,
.tomorrow-icon.icon-pop {
  animation: iconPop 0.55s var(--ease);
}
@keyframes iconPop {
  0% { opacity: 0; transform: scale(0.7) translateY(12px); }
  60% { opacity: 1; transform: scale(1.08) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.temp-swap {
  animation: tempSwap 0.45s var(--ease);
}
@keyframes tempSwap {
  0% { opacity: 0; transform: translateY(10px) scale(0.92); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Weather-matched burst overlays */
.hero-burst.is-active { opacity: 1; }
.burst-sunny.is-active {
  background: radial-gradient(circle, rgba(245, 197, 24, 0.55) 0%, transparent 70%);
  animation: burstSunny 0.85s ease-out;
}
@keyframes burstSunny {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0.9; }
  100% { transform: translate(-50%, -50%) scale(1.6); opacity: 0; }
}
.burst-rainy.is-active,
.burst-thunderstorm.is-active {
  background: repeating-linear-gradient(180deg, transparent 0 6px, rgba(147, 197, 253, 0.55) 6px 8px);
  mask-image: radial-gradient(circle, #000 20%, transparent 70%);
  animation: burstRain 0.8s linear;
}
@keyframes burstRain {
  0% { transform: translate(-50%, -70%); opacity: 0.85; }
  100% { transform: translate(-50%, -20%); opacity: 0; }
}
.burst-thunderstorm.is-active::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: rgba(200, 220, 255, 0.35);
  animation: burstFlash 0.7s ease-out;
}
@keyframes burstFlash {
  0%, 40%, 70% { opacity: 0; }
  15%, 55% { opacity: 1; }
  100% { opacity: 0; }
}
.burst-snowy.is-active {
  background-image:
    radial-gradient(circle at 30% 40%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 70% 35%, #fff 0 2.5px, transparent 3.5px),
    radial-gradient(circle at 50% 60%, #fff 0 2px, transparent 3px),
    radial-gradient(circle at 20% 70%, #fff 0 1.5px, transparent 2.5px),
    radial-gradient(circle at 80% 65%, #fff 0 2px, transparent 3px);
  animation: burstSnow 0.9s ease-out;
}
@keyframes burstSnow {
  0% { transform: translate(-50%, -60%) scale(0.8); opacity: 1; }
  100% { transform: translate(-50%, -20%) scale(1.2); opacity: 0; }
}
.burst-cloudy.is-active {
  background: radial-gradient(ellipse at center, rgba(148, 163, 184, 0.35), transparent 65%);
  filter: blur(8px);
  animation: burstCloud 0.85s ease-out;
}
@keyframes burstCloud {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0.7; }
  100% { transform: translate(-40%, -50%) scale(1.4); opacity: 0; }
}
.burst-foggy.is-active {
  background: linear-gradient(90deg, transparent, rgba(203, 213, 225, 0.45), transparent);
  filter: blur(12px);
  animation: burstFog 0.9s ease-out;
}
@keyframes burstFog {
  0% { transform: translate(-70%, -50%) scaleX(0.6); opacity: 0.8; }
  100% { transform: translate(-30%, -50%) scaleX(1.4); opacity: 0; }
}
.burst-night.is-active {
  background-image:
    radial-gradient(1.5px 1.5px at 30% 40%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 60% 35%, #fff, transparent),
    radial-gradient(1px 1px at 45% 60%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 70% 55%, #fff, transparent);
  animation: burstNight 0.9s ease-out;
}
@keyframes burstNight {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}

.neu:active { transform: scale(0.985); }
.hero-temp { animation: tempPop 0.55s var(--ease) both; }
@keyframes tempPop {
  from { opacity: 0; transform: scale(0.85) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.metrics-card { animation: cardRise 0.5s var(--ease) 0.08s both; }
.today-block { animation: cardRise 0.5s var(--ease) 0.16s both; }
@keyframes cardRise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
.hourly-item { animation: hourIn 0.4s var(--ease) both; }
.hourly-item:nth-child(1) { animation-delay: 0.05s; }
.hourly-item:nth-child(2) { animation-delay: 0.1s; }
.hourly-item:nth-child(3) { animation-delay: 0.15s; }
.hourly-item:nth-child(4) { animation-delay: 0.2s; }
.hourly-item:nth-child(5) { animation-delay: 0.25s; }
.hourly-item:nth-child(6) { animation-delay: 0.3s; }
.hourly-item:nth-child(7) { animation-delay: 0.35s; }
.hourly-item:nth-child(8) { animation-delay: 0.4s; }
@keyframes hourIn {
  from { opacity: 0; transform: translateY(14px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.hourly-item.is-active {
  animation: hourIn 0.4s var(--ease) both, glowPulse 2.4s ease-in-out infinite;
}
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(45, 140, 255, 0.45), 0 0 24px rgba(45, 140, 255, 0.45); }
  50% { box-shadow: 0 0 0 1px rgba(45, 140, 255, 0.65), 0 0 36px rgba(45, 140, 255, 0.7); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .float-icon,
  .float-icon-slow,
  .particle,
  .sun-core,
  .sun-glow,
  .sun-rays,
  .cloud-puff,
  .fx-fog::before,
  .fx-fog::after,
  .fx-stars::before,
  .fx-stars::after,
  .hourly-item.is-active,
  .hero.hero-swap,
  .hero-icon.icon-pop,
  .temp-swap,
  .hero-burst.is-active {
    animation: none !important;
  }
}
