/* ============================================
   HackPulse Background Animation System
   ============================================

   Three coordinated layers:
   1. Base Motion Layer - Ambient gradient (CSS)
   2. Pulse Accent Layer - ECG sweep in hero (SVG)
   3. System Depth Layer - Parallax nodes (Canvas, desktop only)

   Brand color: #70C7BA / RGB(111,199,186)

   ============================================ */

/* ===========================================
   CONFIGURATION VARIABLES
   =========================================== */
:root {
    /* Animation Durations */
    --bg-gradient-duration: 24s;
    --pulse-duration: 2.5s;
    --pulse-delay: 10s;

    /* Opacity Values */
    --gradient-opacity: 0.12;
    --pulse-opacity: 0.35;
    --node-opacity: 0.4;
    --line-opacity: 0.15;

    /* Node Configuration (used by JS) */
    --node-count: 25;
    --parallax-intensity: 8;

    /* Brand Colors - matches site's cyan accent */
    --brand-primary: #49EACB;
    --brand-primary-rgb: 73, 234, 203;
}

/* ===========================================
   LAYER 1: BASE MOTION LAYER
   Ambient animated gradient - Always present
   =========================================== */

/* Main gradient container - applies to body */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -2;
    pointer-events: none;

    /* Multi-stop radial gradients for depth */
    background:
        /* Primary turquoise glow - top right */
        radial-gradient(
            ellipse 80% 50% at 85% 20%,
            rgba(var(--brand-primary-rgb), var(--gradient-opacity)) 0%,
            transparent 50%
        ),
        /* Secondary glow - bottom left */
        radial-gradient(
            ellipse 60% 40% at 15% 80%,
            rgba(var(--brand-primary-rgb), calc(var(--gradient-opacity) * 0.6)) 0%,
            transparent 45%
        ),
        /* Subtle center accent */
        radial-gradient(
            ellipse 50% 50% at 50% 50%,
            rgba(var(--brand-primary-rgb), calc(var(--gradient-opacity) * 0.3)) 0%,
            transparent 60%
        ),
        /* Base dark */
        var(--dark);

    background-size: 200% 200%, 200% 200%, 150% 150%, 100% 100%;
    background-position: 0% 0%, 100% 100%, 50% 50%, 0% 0%;

    /* Slow ambient animation */
    animation: ambientGradient var(--bg-gradient-duration) ease-in-out infinite;
}

@keyframes ambientGradient {
    0%, 100% {
        background-position: 0% 0%, 100% 100%, 50% 50%, 0% 0%;
    }
    25% {
        background-position: 50% 25%, 75% 75%, 60% 40%, 0% 0%;
    }
    50% {
        background-position: 100% 50%, 50% 50%, 40% 60%, 0% 0%;
    }
    75% {
        background-position: 50% 75%, 25% 75%, 55% 45%, 0% 0%;
    }
}

/* Vignette overlay for text contrast */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    pointer-events: none;

    /* Vignette from edges */
    background: radial-gradient(
        ellipse 70% 70% at 50% 50%,
        transparent 0%,
        rgba(10, 10, 15, 0.4) 100%
    );
}

/* ===========================================
   LAYER 2: PULSE ACCENT LAYER
   ECG-style sweep in hero section
   =========================================== */

.hero-pulse-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    pointer-events: none;
    overflow: visible;
    width: 100vw;
    margin-left: calc(-50vw + 50%);
}

.hero-pulse-svg {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100vw;
    height: 200px;
    transform: translateY(-50%);
    opacity: var(--pulse-opacity);
}

.pulse-line {
    fill: none;
    stroke: var(--brand-primary);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;

    /* Initial state - completely hidden until JS triggers */
    opacity: 0;
}

/* Glow effect on pulse */
.pulse-line-glow {
    fill: none;
    stroke: var(--brand-primary);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: blur(8px);

    /* Initial state - completely hidden until JS triggers */
    opacity: 0;
}

@keyframes pulseSweep {
    0% {
        stroke-dashoffset: 2000;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* Repeating pulse - handled by JS for better control */
.pulse-repeat .pulse-line,
.pulse-repeat .pulse-line-glow {
    animation: pulseSweep var(--pulse-duration) ease-in-out forwards,
               pulseFade 0.5s ease-out forwards;
    animation-delay: 1s, calc(var(--pulse-duration) + 1s);
}

@keyframes pulseFade {
    to {
        opacity: 0;
    }
}

/* ===========================================
   LAYER 3: SYSTEM DEPTH LAYER
   Parallax nodes - Desktop only (≥1024px)
   =========================================== */

.system-depth-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.system-depth-canvas.active {
    opacity: 1;
}

/* ===========================================
   ACCESSIBILITY: Reduced Motion
   =========================================== */

@media (prefers-reduced-motion: reduce) {
    /* Freeze base gradient */
    body::before {
        animation: none;
        background-position: 50% 50%, 50% 50%, 50% 50%, 0% 0%;
    }

    /* Disable pulse */
    .pulse-line,
    .pulse-line-glow {
        animation: none;
        stroke-dashoffset: 0;
        opacity: calc(var(--pulse-opacity) * 0.5);
    }

    /* Hide parallax canvas */
    .system-depth-canvas {
        display: none;
    }
}

/* ===========================================
   MOBILE: Simplified (gradient only)
   =========================================== */

@media (max-width: 1023px) {
    /* Hide parallax on mobile */
    .system-depth-canvas {
        display: none;
    }

    /* Simpler gradient animation on mobile for performance */
    body::before {
        animation-duration: 30s;
        background-size: 150% 150%, 150% 150%, 100% 100%, 100% 100%;
    }

    /* Reduce pulse intensity on mobile */
    .hero-pulse-svg {
        opacity: calc(var(--pulse-opacity) * 0.7);
    }
}

/* ===========================================
   PERFORMANCE OPTIMIZATIONS
   =========================================== */

/* GPU acceleration hints */
body::before,
body::after,
.hero-pulse-svg,
.system-depth-canvas {
    will-change: auto;
    transform: translateZ(0);
}

/* Reduce will-change when not animating */
@media (prefers-reduced-motion: reduce) {
    body::before,
    body::after,
    .hero-pulse-svg {
        will-change: auto;
    }
}
