/* ============================================================
   Animated background (aurora) — self-contained, removable unit.
   Pair: apps/ui/templates/ui/ambient.html + the include/link in base.html.
   Loop durations (30s / 38s) must match the phase-sync script in that partial.

   Perf: NO `filter: blur()` (the expensive part on weak GPUs). The soft falloff
   comes from the radial-gradient itself, which the compositor can cache and just
   translate each frame. Only `transform` is animated (GPU-composited).
   ============================================================ */

:root { --ambient-strength: .3; }
html[data-theme="light"] { --ambient-strength: .22; }

.ambient {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    contain: paint;
    view-transition-name: none;
}
.ambient__aurora {
    position: absolute;
    width: 75vmax;
    height: 75vmax;
    border-radius: 50%;
    opacity: var(--ambient-strength);
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}
.ambient__aurora--a {
    top: -28vmax;
    left: -18vmax;
    background: radial-gradient(circle at 50% 50%, var(--accent), rgba(0, 0, 0, 0) 72%);
    animation: aurora-a 30s linear infinite;
    animation-delay: var(--aurora-a-delay, 0s);
}
.ambient__aurora--b {
    right: -22vmax;
    bottom: -30vmax;
    background: radial-gradient(circle at 50% 50%, var(--accent2), rgba(0, 0, 0, 0) 72%);
    animation: aurora-b 38s linear infinite;
    animation-delay: var(--aurora-b-delay, 0s);
}
.page-immersive .ambient__aurora { opacity: calc(var(--ambient-strength) * 1.6); }

/* Continuous loops: multi-stop keyframes + linear timing (no `alternate`) so the
   motion never decelerates to a stop. First/last stops match for a seamless loop. */
@keyframes aurora-a {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    25% { transform: translate3d(12vmax, -6vmax, 0) scale(1.08); }
    50% { transform: translate3d(18vmax, 11vmax, 0) scale(1.14); }
    75% { transform: translate3d(6vmax, 16vmax, 0) scale(1.06); }
    100% { transform: translate3d(0, 0, 0) scale(1); }
}
@keyframes aurora-b {
    0% { transform: translate3d(0, 0, 0) scale(1.12); }
    25% { transform: translate3d(-11vmax, 6vmax, 0) scale(1.06); }
    50% { transform: translate3d(-17vmax, -10vmax, 0) scale(1); }
    75% { transform: translate3d(-5vmax, -15vmax, 0) scale(1.08); }
    100% { transform: translate3d(0, 0, 0) scale(1.12); }
}

/* Gallery animations-off switch disables the ambient too. */
html[data-motion="off"] .ambient__aurora { animation: none !important; }

/* `prefers-reduced-motion` (OS setting) disables the ambient — the standard,
   dependency-free "turn animations off" lever. The global rule in app.css
   already sets `animation: none`, so nothing else is needed here. */

