/* Sci-Fi Animated Background with Connected Particles */
.sci-fi-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, #0a0a0a 0%, #000000 100%);
    z-index: -10;
    overflow: hidden;
}

.sci-fi-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Background Grid Pattern */
.sci-fi-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 150, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 150, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    background-position: 0 0, 0 0;
    animation: grid-move 20s linear infinite;
    opacity: 0.3;
}

@keyframes grid-move {
    0% { transform: translate(0, 0); }
    100% { transform: translate(50px, 50px); }
}

/* Ambient Lighting Effects */
.sci-fi-background::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(0, 150, 255, 0.1) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    animation: ambient-pulse 8s ease-in-out infinite alternate;
}

@keyframes ambient-pulse {
    0% { 
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(1);
    }
    100% { 
        opacity: 0.1;
        transform: translate(-50%, -50%) scale(1.2);
    }
}

/* Particle System CSS (fallback) */
.particle-system {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #00d4ff;
    border-radius: 50%;
    box-shadow: 0 0 6px #00d4ff, 0 0 12px #00d4ff;
    animation: particle-float 15s infinite linear;
}

.particle.orange {
    background: #ff6b35;
    box-shadow: 0 0 6px #ff6b35, 0 0 12px #ff6b35;
}

.particle:nth-child(odd) {
    animation-duration: 20s;
    animation-delay: -5s;
}

.particle:nth-child(3n) {
    animation-duration: 18s;
    animation-delay: -8s;
}

.particle:nth-child(4n) {
    animation-duration: 22s;
    animation-delay: -12s;
}

@keyframes particle-float {
    0% {
        transform: translateY(100vh) translateX(-50px) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) translateX(50px) rotate(360deg);
        opacity: 0;
    }
}

/* Scan Line Effect */
.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00d4ff, transparent);
    animation: scan-line-move 6s linear infinite;
    opacity: 0.6;
}

@keyframes scan-line-move {
    0% {
        top: -2px;
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        top: 100%;
        opacity: 0;
    }
}

/* Energy Waves */
.energy-wave {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: energy-wave-expand 4s ease-out infinite;
}

.energy-wave:nth-child(2) {
    animation-delay: 1s;
}

.energy-wave:nth-child(3) {
    animation-delay: 2s;
}

@keyframes energy-wave-expand {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
        border-width: 2px;
    }
    100% {
        width: 600px;
        height: 600px;
        opacity: 0;
        border-width: 0;
    }
}

/* Corner Accents */
.corner-accent {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 2px solid transparent;
    background: linear-gradient(45deg, #00d4ff, #ff6b35) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: subtract;
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask-composite: subtract;
}

.corner-accent.top-left {
    top: 20px;
    left: 20px;
    border-top: 2px solid #00d4ff;
    border-left: 2px solid #00d4ff;
    animation: corner-glow 3s ease-in-out infinite alternate;
}

.corner-accent.top-right {
    top: 20px;
    right: 20px;
    border-top: 2px solid #00d4ff;
    border-right: 2px solid #00d4ff;
    animation: corner-glow 3s ease-in-out infinite alternate-reverse;
}

.corner-accent.bottom-left {
    bottom: 20px;
    left: 20px;
    border-bottom: 2px solid #ff6b35;
    border-left: 2px solid #ff6b35;
    animation: corner-glow 3s ease-in-out infinite alternate;
}

.corner-accent.bottom-right {
    bottom: 20px;
    right: 20px;
    border-bottom: 2px solid #ff6b35;
    border-right: 2px solid #ff6b35;
    animation: corner-glow 3s ease-in-out infinite alternate-reverse;
}

@keyframes corner-glow {
    0% {
        opacity: 0.3;
        filter: drop-shadow(0 0 5px currentColor);
    }
    100% {
        opacity: 0.8;
        filter: drop-shadow(0 0 15px currentColor);
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sci-fi-background::before {
        background-size: 30px 30px;
    }
    
    .corner-accent {
        width: 60px;
        height: 60px;
    }
    
    .particle {
        width: 2px;
        height: 2px;
    }
}

/* Performance optimizations - only for actively animated elements */
.sci-fi-background .particle:not(.static),
.sci-fi-background .grid-line:not(.static),
.sci-fi-background .floating-element:not(.static) {
    will-change: transform;
    backface-visibility: hidden;
}

/* Static elements don't need will-change */
.sci-fi-background .static {
    will-change: auto;
}

/* Reduce animations on lower-end devices */
@media (prefers-reduced-motion: reduce) {
    .sci-fi-background * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        will-change: auto !important;
    }
}