/* Cosmic background — three layers
   Layer 1 (canvas-fallback via body::before): always-visible static field rendered
       by CSS gradients; works even when JS fails or is blocked.
   Layer 2 (#starfield canvas): JS-driven multi-color stars with halo glow,
       drift, twinkle, scroll-parallax, and shooting stars.
   When JS works the canvas overlays on top of the fallback (transparent canvas
   bg means both layers contribute); when JS fails, fallback alone is visible. */

#starfield {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    /* Large viewport height: does not change when the mobile URL bar shows or
       hides, so the canvas (and the stars on it) stay put while scrolling. */
    height: 100lvh;
    z-index: var(--z-starfield);
    pointer-events: none;
    /* No background here — body::before handles the gradient + fallback stars
       so the canvas can stay fully transparent and the fallback shows through
       any JS-render gap. */
}

body {
    position: relative;
    background:
        radial-gradient(ellipse 80% 60% at 70% 10%, rgba(168, 85, 247, 0.18), transparent 60%),
        radial-gradient(ellipse 60% 50% at 20% 90%, rgba(34, 211, 238, 0.12), transparent 60%),
        var(--color-bg);
    background-attachment: fixed;
}

/* CSS-only fallback starfield — always renders, even if starfield.js
   is blocked, errors out, or hits a browser-side issue. Five layered
   radial-gradient star fields with subtle drift via background-position. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: var(--z-starfield);
    pointer-events: none;
    background-image:
        radial-gradient(1.4px 1.4px at 14% 22%, #ffffff 50%, transparent 100%),
        radial-gradient(1.2px 1.2px at 38% 67%, #ffffff 50%, transparent 100%),
        radial-gradient(1.6px 1.6px at 71% 18%, #ffffff 50%, transparent 100%);
    background-size:
        540px 540px, 620px 620px, 480px 480px;
    animation: starfield-drift 240s linear infinite;
    will-change: background-position;
}

@keyframes starfield-drift {
    0%   { background-position: 0 0, 0 0, 0 0; }
    100% { background-position:
            0 -540px, 0 -620px, 0 -480px; }
}

body > *:not(#starfield):not(.yv-svg-sprite):not(.site-header) { position: relative; z-index: var(--z-content); }
.yv-svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
    body::before { animation: none; }
}
