/**
 * Atmosphere Overlay System
 *
 * CSS-only ambient atmospheric effects for section backgrounds.
 * Used sparingly (1-2 sections per page) to add depth and visual interest.
 * Network type is handled by JS (atmosphere-network.js).
 */

/* =============================================================================
   Network Canvas (JS-driven)
   ========================================================================== */

[data-atmosphere="network"] {
    position: relative;
}

[data-atmosphere="network"] [data-atmosphere-canvas] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

/* =============================================================================
   Container
   ========================================================================== */

[data-atmosphere-layer] {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

/* =============================================================================
   Orbs — Slow drifting radial gradient circles
   ========================================================================== */

@keyframes atmo-drift-1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(5%, -8%) scale(1.05); }
    66% { transform: translate(-3%, 5%) scale(0.95); }
}

@keyframes atmo-drift-2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(-7%, 4%) scale(1.08); }
    50% { transform: translate(4%, -6%) scale(0.92); }
    75% { transform: translate(-2%, 8%) scale(1.03); }
}

@keyframes atmo-drift-3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    40% { transform: translate(6%, 6%) scale(0.96); }
    80% { transform: translate(-5%, -4%) scale(1.06); }
}

[data-atmosphere-orb] {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, var(--atmo-color) 0%, transparent 70%);
    opacity: 0.15;
    will-change: transform;
}

[data-atmosphere-orb]:nth-child(1) {
    width: 40%;
    height: 40%;
    top: 10%;
    left: 5%;
    animation: atmo-drift-1 calc(20s * var(--motion-multiplier, 1)) ease-in-out infinite;
}

[data-atmosphere-orb]:nth-child(2) {
    width: 35%;
    height: 35%;
    top: 50%;
    right: 10%;
    animation: atmo-drift-2 calc(25s * var(--motion-multiplier, 1)) ease-in-out infinite;
}

[data-atmosphere-orb]:nth-child(3) {
    width: 30%;
    height: 30%;
    bottom: 10%;
    left: 30%;
    animation: atmo-drift-3 calc(22s * var(--motion-multiplier, 1)) ease-in-out infinite;
}

/* =============================================================================
   Glow — Single large radial gradient
   ========================================================================== */

[data-atmosphere-glow] {
    position: absolute;
    inset: -20%;
    background: radial-gradient(ellipse at 60% 40%, var(--atmo-color) 0%, transparent 60%);
    opacity: 0.2;
}

/* =============================================================================
   Grain — SVG noise overlay
   ========================================================================== */

[data-atmosphere-grain] {
    position: absolute;
    inset: 0;
    opacity: 0.08;
    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.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* =============================================================================
   Aurora — Animated gradient bands
   ========================================================================== */

@keyframes atmo-aurora {
    0%, 100% { transform: translateX(-10%) skewX(-5deg); opacity: 0.15; }
    50% { transform: translateX(10%) skewX(5deg); opacity: 0.25; }
}

[data-atmosphere-aurora] {
    position: absolute;
    inset: -20%;
    background: linear-gradient(
        135deg,
        transparent 20%,
        var(--atmo-color) 35%,
        transparent 50%,
        var(--atmo-color) 65%,
        transparent 80%
    );
    opacity: 0.2;
    animation: atmo-aurora calc(15s * var(--motion-multiplier, 1)) ease-in-out infinite;
    will-change: transform;
}

/* =============================================================================
   Intensity mappings
   ========================================================================== */

[data-atmosphere-intensity="subtle"] [data-atmosphere-orb] { opacity: 0.08; }
[data-atmosphere-intensity="subtle"] [data-atmosphere-glow] { opacity: 0.1; }
[data-atmosphere-intensity="subtle"] [data-atmosphere-grain] { opacity: 0.04; }
[data-atmosphere-intensity="subtle"] [data-atmosphere-aurora] { opacity: 0.1; }

[data-atmosphere-intensity="medium"] [data-atmosphere-orb] { opacity: 0.15; }
[data-atmosphere-intensity="medium"] [data-atmosphere-glow] { opacity: 0.2; }
[data-atmosphere-intensity="medium"] [data-atmosphere-grain] { opacity: 0.08; }
[data-atmosphere-intensity="medium"] [data-atmosphere-aurora] { opacity: 0.2; }

[data-atmosphere-intensity="strong"] [data-atmosphere-orb] { opacity: 0.25; }
[data-atmosphere-intensity="strong"] [data-atmosphere-glow] { opacity: 0.35; }
[data-atmosphere-intensity="strong"] [data-atmosphere-grain] { opacity: 0.12; }
[data-atmosphere-intensity="strong"] [data-atmosphere-aurora] { opacity: 0.3; }

/* =============================================================================
   Cursor reactivity for orbs
   ========================================================================== */

[data-atmosphere="orbs"] [data-atmosphere-orb]:nth-child(3) {
    animation: none;
    transform: translate(calc((var(--cursor-x, 0.5) - 0.5) * 20px), calc((var(--cursor-y, 0.5) - 0.5) * 20px));
    transition: transform 0.5s var(--ease-magical);
}

/* =============================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    [data-atmosphere-orb],
    [data-atmosphere-aurora] {
        animation: none !important;
    }
    [data-atmosphere="orbs"] [data-atmosphere-orb]:nth-child(3) {
        transition: none !important;
        transform: none !important;
    }
    /* Network is JS-driven particle simulation — heaviest motion class.
       Hiding the canvas stops paint entirely; the JS continues to no-op. */
    [data-atmosphere="network"] [data-atmosphere-canvas] {
        display: none !important;
    }
}

/* =============================================================================
   High contrast
   Atmospheric overlays reduce text contrast against the section surface;
   users requesting high contrast want them removed entirely.
   ========================================================================== */

@media (prefers-contrast: high) {
    [data-atmosphere] [data-atmosphere-layer],
    [data-atmosphere] [data-atmosphere-canvas] {
        display: none;
    }
}
