/**
 * 3D HERO ANIMATION EFFECTS
 * Add this to your game.css or include as separate file
 * Creates immersive depth and motion for the hero banner
 */

/* ============================================
   3D HERO CONTAINER
   ============================================ */
.hero-3d-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
}

/* Base Layer - Video Background with Breathing Effect */
.hero-video-base {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    object-fit: cover;
    animation: videoBreathing 12s ease-in-out infinite;
    will-change: transform;
    z-index: 1;
}

@keyframes videoBreathing {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    25% {
        transform: translate(-50.5%, -50.3%) scale(1.02);
    }
    50% {
        transform: translate(-49.7%, -49.5%) scale(1.04);
    }
    75% {
        transform: translate(-49.5%, -50.2%) scale(1.01);
    }
}

/* Fallback: Static image background (for when video fails to load) */
.hero-layer-base {
    position: absolute;
    top: -5%;
    left: -5%;
    width: 110%;
    height: 110%;
    background-image: url('../assets/images/hero-banner.png');
    background-size: cover;
    background-position: center;
    animation: heroBreathing 8s ease-in-out infinite;
    will-change: transform;
}

@keyframes heroBreathing {
    0%, 100% {
        transform: scale(1) translate(0, 0);
    }
    25% {
        transform: scale(1.03) translate(-0.5%, -0.3%);
    }
    50% {
        transform: scale(1.05) translate(0.3%, 0.5%);
    }
    75% {
        transform: scale(1.02) translate(0.5%, -0.2%);
    }
}

/* Depth Gradient Overlay - Creates 3D Depth Illusion */
.hero-layer-depth {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 50% 30%, transparent 20%, rgba(15, 15, 26, 0.3) 60%),
        radial-gradient(ellipse at 50% 100%, rgba(15, 15, 26, 0.9) 0%, transparent 50%);
    pointer-events: none;
    z-index: 2;
}

/* Vignette Layer - Focus Effect */
.hero-layer-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 40%, rgba(10, 10, 20, 0.7) 100%);
    pointer-events: none;
    z-index: 8;
}

/* Animated Light Rays */
.hero-layer-rays {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    opacity: 0.15;
    z-index: 3;
}

.light-ray {
    position: absolute;
    top: -20%;
    width: 3px;
    height: 140%;
    background: linear-gradient(to bottom, 
        transparent 0%,
        rgba(255, 255, 255, 0.1) 20%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0.1) 80%,
        transparent 100%
    );
    transform-origin: top center;
    animation: rayMove 20s ease-in-out infinite;
}

.light-ray:nth-child(1) { left: 20%; animation-delay: 0s; transform: rotate(-15deg); }
.light-ray:nth-child(2) { left: 35%; animation-delay: -5s; width: 5px; transform: rotate(-8deg); }
.light-ray:nth-child(3) { left: 50%; animation-delay: -10s; transform: rotate(0deg); }
.light-ray:nth-child(4) { left: 65%; animation-delay: -15s; width: 4px; transform: rotate(8deg); }
.light-ray:nth-child(5) { left: 80%; animation-delay: -3s; transform: rotate(15deg); }

@keyframes rayMove {
    0%, 100% {
        opacity: 0.3;
        transform: rotate(var(--ray-angle, 0deg)) translateX(-20px);
    }
    50% {
        opacity: 0.6;
        transform: rotate(var(--ray-angle, 0deg)) translateX(20px);
    }
}

/* Floating Magical Particles */
.hero-layer-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 6;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, rgba(139, 92, 246, 1) 0%, transparent 70%);
    border-radius: 50%;
    animation: particleFloat 15s ease-in-out infinite;
    opacity: 0;
}

/* Generate 30 particles with varied positions and timings */
.particle:nth-child(1) { left: 5%; top: 80%; animation-delay: 0s; animation-duration: 12s; }
.particle:nth-child(2) { left: 10%; top: 70%; animation-delay: -2s; animation-duration: 14s; }
.particle:nth-child(3) { left: 15%; top: 85%; animation-delay: -4s; animation-duration: 11s; }
.particle:nth-child(4) { left: 20%; top: 75%; animation-delay: -1s; animation-duration: 13s; }
.particle:nth-child(5) { left: 25%; top: 90%; animation-delay: -6s; animation-duration: 15s; }
.particle:nth-child(6) { left: 30%; top: 65%; animation-delay: -3s; animation-duration: 12s; }
.particle:nth-child(7) { left: 35%; top: 80%; animation-delay: -8s; animation-duration: 14s; }
.particle:nth-child(8) { left: 40%; top: 70%; animation-delay: -5s; animation-duration: 11s; }
.particle:nth-child(9) { left: 45%; top: 85%; animation-delay: -2s; animation-duration: 13s; }
.particle:nth-child(10) { left: 50%; top: 75%; animation-delay: -7s; animation-duration: 15s; }
.particle:nth-child(11) { left: 55%; top: 90%; animation-delay: -4s; animation-duration: 12s; }
.particle:nth-child(12) { left: 60%; top: 65%; animation-delay: -9s; animation-duration: 14s; }
.particle:nth-child(13) { left: 65%; top: 80%; animation-delay: -1s; animation-duration: 11s; }
.particle:nth-child(14) { left: 70%; top: 70%; animation-delay: -6s; animation-duration: 13s; }
.particle:nth-child(15) { left: 75%; top: 85%; animation-delay: -3s; animation-duration: 15s; }
.particle:nth-child(16) { left: 80%; top: 75%; animation-delay: -8s; animation-duration: 12s; }
.particle:nth-child(17) { left: 85%; top: 90%; animation-delay: -5s; animation-duration: 14s; }
.particle:nth-child(18) { left: 90%; top: 65%; animation-delay: -2s; animation-duration: 11s; }
.particle:nth-child(19) { left: 95%; top: 80%; animation-delay: -7s; animation-duration: 13s; }
.particle:nth-child(20) { left: 8%; top: 60%; animation-delay: -4s; animation-duration: 16s; }
.particle:nth-child(21) { left: 22%; top: 55%; animation-delay: -9s; animation-duration: 12s; }
.particle:nth-child(22) { left: 38%; top: 50%; animation-delay: -1s; animation-duration: 14s; }
.particle:nth-child(23) { left: 52%; top: 45%; animation-delay: -6s; animation-duration: 11s; }
.particle:nth-child(24) { left: 68%; top: 55%; animation-delay: -3s; animation-duration: 15s; }
.particle:nth-child(25) { left: 82%; top: 50%; animation-delay: -8s; animation-duration: 13s; }
.particle:nth-child(26) { left: 12%; top: 40%; animation-delay: -5s; animation-duration: 17s; }
.particle:nth-child(27) { left: 28%; top: 35%; animation-delay: -2s; animation-duration: 12s; }
.particle:nth-child(28) { left: 48%; top: 30%; animation-delay: -7s; animation-duration: 14s; }
.particle:nth-child(29) { left: 72%; top: 35%; animation-delay: -4s; animation-duration: 11s; }
.particle:nth-child(30) { left: 88%; top: 40%; animation-delay: -9s; animation-duration: 15s; }

/* Different colored particles */
.particle:nth-child(3n) { background: radial-gradient(circle, rgba(236, 72, 153, 1) 0%, transparent 70%); } /* Pink */
.particle:nth-child(5n) { background: radial-gradient(circle, rgba(34, 197, 94, 1) 0%, transparent 70%); } /* Green */
.particle:nth-child(7n) { background: radial-gradient(circle, rgba(245, 158, 11, 1) 0%, transparent 70%); } /* Amber */
.particle:nth-child(11n) { background: radial-gradient(circle, rgba(59, 130, 246, 1) 0%, transparent 70%); width: 6px; height: 6px; } /* Blue larger */
.particle:nth-child(13n) { background: radial-gradient(circle, rgba(255, 255, 255, 1) 0%, transparent 70%); width: 3px; height: 3px; } /* White smaller */

@keyframes particleFloat {
    0% {
        transform: translateY(0) translateX(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(-20px) translateX(5px) scale(1);
    }
    50% {
        opacity: 0.8;
        transform: translateY(-150px) translateX(-10px) scale(1.2);
    }
    90% {
        opacity: 0.6;
        transform: translateY(-300px) translateX(15px) scale(0.8);
    }
    100% {
        transform: translateY(-350px) translateX(0) scale(0);
        opacity: 0;
    }
}

/* Magical Glow Orbs (larger floating lights) */
.hero-layer-orbs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 5;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(20px);
    animation: orbFloat 20s ease-in-out infinite;
    opacity: 0.3;
}

.orb-1 {
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.6) 0%, transparent 70%);
    left: 10%;
    top: 60%;
    animation-delay: 0s;
}

.orb-2 {
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.5) 0%, transparent 70%);
    left: 75%;
    top: 70%;
    animation-delay: -5s;
    animation-duration: 25s;
}

.orb-3 {
    width: 120px;
    height: 120px;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.4) 0%, transparent 70%);
    left: 50%;
    top: 50%;
    animation-delay: -10s;
    animation-duration: 30s;
}

.orb-4 {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.5) 0%, transparent 70%);
    left: 30%;
    top: 40%;
    animation-delay: -3s;
    animation-duration: 18s;
}

.orb-5 {
    width: 90px;
    height: 90px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.4) 0%, transparent 70%);
    left: 85%;
    top: 30%;
    animation-delay: -8s;
    animation-duration: 22s;
}

@keyframes orbFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.2;
    }
    25% {
        transform: translate(30px, -20px) scale(1.1);
        opacity: 0.4;
    }
    50% {
        transform: translate(-20px, 30px) scale(0.9);
        opacity: 0.3;
    }
    75% {
        transform: translate(-30px, -10px) scale(1.05);
        opacity: 0.35;
    }
}

/* Color Shift Overlay - Subtle Hue Animation */
.hero-layer-colorshift {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        135deg,
        rgba(139, 92, 246, 0.1) 0%,
        transparent 50%,
        rgba(236, 72, 153, 0.1) 100%
    );
    animation: colorShift 15s ease-in-out infinite;
    pointer-events: none;
    mix-blend-mode: overlay;
    z-index: 7;
}

@keyframes colorShift {
    0%, 100% {
        opacity: 0.3;
        filter: hue-rotate(0deg);
    }
    33% {
        opacity: 0.4;
        filter: hue-rotate(20deg);
    }
    66% {
        opacity: 0.35;
        filter: hue-rotate(-20deg);
    }
}

/* Moon Glow Effect */
.hero-layer-moonglow {
    position: absolute;
    top: 5%;
    left: 15%;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15) 0%, transparent 60%);
    border-radius: 50%;
    filter: blur(30px);
    animation: moonPulse 6s ease-in-out infinite;
    pointer-events: none;
    z-index: 4;
}

@keyframes moonPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.6;
    }
}

/* Fog/Mist Layer at Bottom */
.hero-layer-mist {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 30%;
    background: linear-gradient(to top, rgba(15, 15, 26, 0.8) 0%, transparent 100%);
    animation: mistDrift 30s linear infinite;
    pointer-events: none;
    z-index: 9;
}

@keyframes mistDrift {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(-50%);
    }
}

/* Dark Overlay for Content Readability */
.hero-layer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 26, 0.5);
    pointer-events: none;
    z-index: 10;
}

/* ============================================
   UPDATE HOME SCREEN STYLING
   ============================================ */
#home-screen.screen-3d {
    background: transparent !important;
}

#home-screen .screen-center {
    position: relative;
    z-index: 20;
}

/* Optional: Mouse-tracking subtle effect (add JS to enable) */
.hero-3d-container.mouse-track .hero-layer-base {
    transition: transform 0.3s ease-out;
}

/* Performance optimization for mobile */
@media (max-width: 768px) {
    .hero-layer-rays,
    .hero-layer-orbs {
        display: none;
    }
    
    .particle:nth-child(n+15) {
        display: none;
    }
    
    @keyframes heroBreathing {
        0%, 100% {
            transform: scale(1);
        }
        50% {
            transform: scale(1.02);
        }
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .hero-layer-base,
    .particle,
    .orb,
    .light-ray,
    .hero-layer-colorshift,
    .hero-layer-moonglow,
    .hero-layer-mist {
        animation: none !important;
    }
}
