/**
 * 3D Animated Background - PQCrypta KeyVault
 * CSP-Compliant: No inline styles
 */

/* Background Container */
.vault-background-3d {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    background: linear-gradient(135deg, #0a0a1e 0%, #1a0a28 50%, #0a0a1e 100%);
    perspective: 1000px;
}

/* Animated Grid Layer */
.bg-grid-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    transform: translate(-50%, -50%) rotateX(60deg) rotateZ(0deg);
    transform-style: preserve-3d;
    animation: grid-rotate 60s linear infinite;
}

/* Grid Lines - Horizontal */
.bg-grid-line-h {
    position: absolute;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(0, 212, 255, 0.3) 50%,
        transparent 100%);
    box-shadow: 0 0 5px rgba(0, 212, 255, 0.4);
}

.bg-grid-line-h:nth-child(1) { top: 10%; animation: pulse-line 3s ease-in-out infinite; }
.bg-grid-line-h:nth-child(2) { top: 20%; animation: pulse-line 3s ease-in-out 0.5s infinite; }
.bg-grid-line-h:nth-child(3) { top: 30%; animation: pulse-line 3s ease-in-out 1s infinite; }
.bg-grid-line-h:nth-child(4) { top: 40%; animation: pulse-line 3s ease-in-out 1.5s infinite; }
.bg-grid-line-h:nth-child(5) { top: 50%; animation: pulse-line 3s ease-in-out 2s infinite; }
.bg-grid-line-h:nth-child(6) { top: 60%; animation: pulse-line 3s ease-in-out 2.5s infinite; }
.bg-grid-line-h:nth-child(7) { top: 70%; animation: pulse-line 3s ease-in-out 1s infinite; }
.bg-grid-line-h:nth-child(8) { top: 80%; animation: pulse-line 3s ease-in-out 1.5s infinite; }
.bg-grid-line-h:nth-child(9) { top: 90%; animation: pulse-line 3s ease-in-out 0.5s infinite; }

/* Grid Lines - Vertical */
.bg-grid-line-v {
    position: absolute;
    width: 1px;
    height: 100%;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(123, 44, 191, 0.3) 50%,
        transparent 100%);
    box-shadow: 0 0 5px rgba(123, 44, 191, 0.4);
}

.bg-grid-line-v:nth-child(10) { left: 10%; animation: pulse-line 4s ease-in-out infinite; }
.bg-grid-line-v:nth-child(11) { left: 20%; animation: pulse-line 4s ease-in-out 0.5s infinite; }
.bg-grid-line-v:nth-child(12) { left: 30%; animation: pulse-line 4s ease-in-out 1s infinite; }
.bg-grid-line-v:nth-child(13) { left: 40%; animation: pulse-line 4s ease-in-out 1.5s infinite; }
.bg-grid-line-v:nth-child(14) { left: 50%; animation: pulse-line 4s ease-in-out 2s infinite; }
.bg-grid-line-v:nth-child(15) { left: 60%; animation: pulse-line 4s ease-in-out 2.5s infinite; }
.bg-grid-line-v:nth-child(16) { left: 70%; animation: pulse-line 4s ease-in-out 1s infinite; }
.bg-grid-line-v:nth-child(17) { left: 80%; animation: pulse-line 4s ease-in-out 1.5s infinite; }
.bg-grid-line-v:nth-child(18) { left: 90%; animation: pulse-line 4s ease-in-out 0.5s infinite; }

/* Floating Orbs Layer */
.bg-orbs-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

/* Individual Orbs */
.bg-orb {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%,
        rgba(0, 212, 255, 0.4),
        rgba(123, 44, 191, 0.2));
    box-shadow:
        0 0 20px rgba(0, 212, 255, 0.3),
        0 0 40px rgba(123, 44, 191, 0.2),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    animation: float-orb 20s ease-in-out infinite;
    filter: blur(1px);
}

.bg-orb:nth-child(1) {
    top: 10%;
    left: 15%;
    width: 100px;
    height: 100px;
    animation-duration: 25s;
    animation-delay: 0s;
}

.bg-orb:nth-child(2) {
    top: 60%;
    left: 70%;
    width: 150px;
    height: 150px;
    animation-duration: 30s;
    animation-delay: 5s;
}

.bg-orb:nth-child(3) {
    top: 30%;
    left: 80%;
    width: 80px;
    height: 80px;
    animation-duration: 20s;
    animation-delay: 10s;
}

.bg-orb:nth-child(4) {
    top: 70%;
    left: 20%;
    width: 120px;
    height: 120px;
    animation-duration: 35s;
    animation-delay: 15s;
}

.bg-orb:nth-child(5) {
    top: 40%;
    left: 40%;
    width: 90px;
    height: 90px;
    animation-duration: 28s;
    animation-delay: 8s;
}

/* Quantum Particles */
.bg-particles-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.bg-particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(0, 212, 255, 0.6);
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0, 212, 255, 0.8);
    animation: particle-drift 15s linear infinite;
}

/* Staggered particle animations */
.bg-particle:nth-child(odd) {
    animation-duration: 20s;
    background: rgba(123, 44, 191, 0.6);
    box-shadow: 0 0 4px rgba(123, 44, 191, 0.8);
}

/* Animations */
@keyframes grid-rotate {
    0% {
        transform: translate(-50%, -50%) rotateX(60deg) rotateZ(0deg);
    }
    100% {
        transform: translate(-50%, -50%) rotateX(60deg) rotateZ(360deg);
    }
}

@keyframes pulse-line {
    0%, 100% {
        opacity: 0.3;
        filter: brightness(1);
    }
    50% {
        opacity: 0.8;
        filter: brightness(1.5);
    }
}

@keyframes float-orb {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.4;
    }
    25% {
        transform: translate(30px, -40px) scale(1.1);
        opacity: 0.6;
    }
    50% {
        transform: translate(-20px, -80px) scale(0.9);
        opacity: 0.5;
    }
    75% {
        transform: translate(-40px, -40px) scale(1.05);
        opacity: 0.7;
    }
}

@keyframes particle-drift {
    0% {
        transform: translate(0, 100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--drift-x, 100px), -100vh) scale(1);
        opacity: 0;
    }
}

/* Energy Wave Effect */
.bg-wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200px;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(0, 212, 255, 0.05) 50%,
        rgba(123, 44, 191, 0.1) 100%);
    animation: wave-pulse 8s ease-in-out infinite;
    filter: blur(30px);
}

@keyframes wave-pulse {
    0%, 100% {
        transform: translateY(0) scaleY(1);
        opacity: 0.3;
    }
    50% {
        transform: translateY(-50px) scaleY(1.2);
        opacity: 0.6;
    }
}

/* ===== Performance Optimizations ===== */
.vault-background-3d,
.bg-grid-layer,
.bg-orbs-layer,
.bg-particles-layer {
    will-change: transform;
    backface-visibility: hidden;
}

/* ===== Responsive Adjustments ===== */
@media (max-width: 768px) {
    /* Reduce complexity on mobile */
    .bg-grid-layer {
        animation-duration: 90s; /* Slower on mobile */
    }

    .bg-orb {
        filter: blur(2px); /* More blur on mobile for performance */
    }

    .bg-particle {
        display: none; /* Hide particles on mobile */
    }
}

/* Animations always enabled - removed prefers-reduced-motion override */
