/* Ambient overlays — subtle mood-enhancing CSS effects layered on the home frame.
   No canvas overhead. Uses ::before/::after pseudo-elements on the ambient container.
   Each effect class is toggled by the ambient controller in app.js. */

/* Container sits above scrim, below content */
.ambient-layer {
  position: absolute;
  inset: 0;
  z-index: var(--z-weather-fx);
  pointer-events: none;
  overflow: hidden;
}

/* ─── Floating Light Particles (Night / Late Night) ─────────────────────── */
.ambient-layer.fx-particles::before,
.ambient-layer.fx-particles::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  animation: floatParticle 18s ease-in-out infinite;
}

.ambient-layer.fx-particles::before {
  width: 3px;
  height: 3px;
  background: rgba(255, 248, 220, 0.35);
  top: 60%;
  left: 20%;
  animation-delay: 0s;
  box-shadow:
    40px -80px 0 rgba(255, 248, 220, 0.2),
    120px -30px 0 rgba(255, 248, 220, 0.15),
    200px -100px 0 rgba(255, 248, 220, 0.25),
    280px -60px 0 rgba(255, 248, 220, 0.1),
    350px -120px 0 rgba(255, 248, 220, 0.2),
    80px -150px 0 rgba(255, 248, 220, 0.12),
    180px -180px 0 rgba(255, 248, 220, 0.18);
}

.ambient-layer.fx-particles::after {
  width: 2px;
  height: 2px;
  background: rgba(200, 220, 255, 0.25);
  top: 40%;
  left: 50%;
  animation-delay: -6s;
  animation-duration: 22s;
  box-shadow:
    -60px 40px 0 rgba(200, 220, 255, 0.15),
    -140px 80px 0 rgba(200, 220, 255, 0.2),
    30px 60px 0 rgba(200, 220, 255, 0.12),
    90px -20px 0 rgba(200, 220, 255, 0.18),
    -20px -40px 0 rgba(200, 220, 255, 0.1);
}

@keyframes floatParticle {
  0%   { opacity: 0;    transform: translateY(0) translateX(0); }
  15%  { opacity: 0.7; }
  50%  { opacity: 0.4;  transform: translateY(-40px) translateX(15px); }
  85%  { opacity: 0.6; }
  100% { opacity: 0;    transform: translateY(-80px) translateX(-10px); }
}

/* ─── Soft Bokeh Circles (Golden Hour / Dusk) ───────────────────────────── */
.ambient-layer.fx-bokeh::before,
.ambient-layer.fx-bokeh::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  filter: blur(8px);
}

.ambient-layer.fx-bokeh::before {
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, rgba(233, 176, 97, 0.18) 0%, transparent 70%);
  top: 25%;
  right: 15%;
  animation: bokehDrift 20s ease-in-out infinite;
}

.ambient-layer.fx-bokeh::after {
  width: 45px;
  height: 45px;
  background: radial-gradient(circle, rgba(216, 180, 106, 0.14) 0%, transparent 70%);
  bottom: 30%;
  left: 20%;
  animation: bokehDrift 24s ease-in-out infinite reverse;
  animation-delay: -4s;
}

@keyframes bokehDrift {
  0%   { opacity: 0;   transform: translate(0, 0) scale(0.8); }
  20%  { opacity: 0.8; transform: translate(10px, -8px) scale(1); }
  50%  { opacity: 0.5; transform: translate(20px, -15px) scale(1.1); }
  80%  { opacity: 0.7; transform: translate(5px, -5px) scale(0.95); }
  100% { opacity: 0;   transform: translate(0, 0) scale(0.8); }
}

/* ─── Subtle Lens Flare (Dawn / Morning) ────────────────────────────────── */
.ambient-layer.fx-flare::before {
  content: "";
  position: absolute;
  top: -20%;
  right: -10%;
  width: 200px;
  height: 200px;
  background: radial-gradient(ellipse at center,
    rgba(255, 240, 200, 0.12) 0%,
    rgba(255, 220, 160, 0.06) 40%,
    transparent 70%);
  animation: flareSweep 30s ease-in-out infinite;
  opacity: 0;
}

@keyframes flareSweep {
  0%   { opacity: 0;   transform: translate(0, 0) scale(0.6); }
  25%  { opacity: 0.8; transform: translate(-30px, 30px) scale(1); }
  50%  { opacity: 0.4; transform: translate(-50px, 50px) scale(1.2); }
  75%  { opacity: 0.6; transform: translate(-20px, 20px) scale(0.9); }
  100% { opacity: 0;   transform: translate(0, 0) scale(0.6); }
}

/* ─── Film Grain (Cozy / Lo-fi vibes) ───────────────────────────────────── */
.ambient-layer.fx-grain::before {
  content: "";
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.03;
  animation: grainShift 0.5s steps(4) infinite;
  mix-blend-mode: overlay;
}

@keyframes grainShift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-2%, -1%); }
  50%  { transform: translate(1%, 2%); }
  75%  { transform: translate(-1%, -2%); }
  100% { transform: translate(2%, 1%); }
}

/* ─── Gentle Vignette Pulse (Always-on, very subtle) ────────────────────── */
.ambient-layer.fx-vignette::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 120px 40px rgba(0, 0, 0, 0.15);
  animation: vignettePulse 12s ease-in-out infinite;
  opacity: 0.6;
}

@keyframes vignettePulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.7; }
}

/* ─── Lite Mode Overrides (TV / Chromecast low-GPU budget) ──────────────── */
.lite-mode .ambient-layer.fx-grain::before {
  display: none !important;
  animation: none !important;
}

.lite-mode .ambient-layer.fx-bokeh::before,
.lite-mode .ambient-layer.fx-bokeh::after {
  filter: none;
}

/* ─── Reduced Motion ────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .ambient-layer * {
    animation: none !important;
  }
  .ambient-layer::before,
  .ambient-layer::after {
    animation: none !important;
    opacity: 0 !important;
  }
  .ambient-layer.fx-vignette::after {
    opacity: 0.5 !important;
    animation: none !important;
  }
}
