/* Ceravion - Advanced Animations */

/* Particle System */
.particle-system {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    display: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--accent-crystal);
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat 8s infinite linear;
}

.particle:nth-child(odd) {
    background: var(--primary-light);
    animation-duration: 12s;
}

.particle:nth-child(3n) {
    background: var(--accent-gold);
    animation-duration: 10s;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) translateX(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) translateX(100px) scale(1);
        opacity: 0;
    }
}

/* Scroll Reveal Animations */
[data-reveal] {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.165, 0.84, 0.44, 1);
}

[data-reveal].revealed {
    opacity: 1;
    transform: translateY(0);
}

[data-reveal]:nth-child(1) { transition-delay: 0.1s; }
[data-reveal]:nth-child(2) { transition-delay: 0.2s; }
[data-reveal]:nth-child(3) { transition-delay: 0.3s; }
[data-reveal]:nth-child(4) { transition-delay: 0.4s; }

/* Text Shimmer Effect */
.text-shimmer {
    background: linear-gradient(90deg, 
        var(--cosmic-white) 0%, 
        var(--accent-crystal) 50%, 
        var(--cosmic-white) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 200% 0; }
    50% { background-position: -200% 0; }
}

/* Holographic Border Effect */
.holographic-border {
    position: relative;
    overflow: hidden;
}

.holographic-border::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: conic-gradient(
        from 0deg,
        var(--accent-crystal),
        var(--primary-light),
        var(--accent-gold),
        var(--accent-crystal)
    );
    border-radius: inherit;
    z-index: -1;
    animation: holographicRotate 4s linear infinite;
}

@keyframes holographicRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Cosmic Ripple Effect */
.cosmic-ripple {
    position: relative;
    overflow: hidden;
}

.cosmic-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.4) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.cosmic-ripple:hover::after {
    width: 300px;
    height: 300px;
}

/* Floating Animation */
.float-animation {
    animation: floatGentle 4s ease-in-out infinite;
}

.float-animation:nth-child(2n) {
    animation-delay: 1s;
    animation-duration: 5s;
}

.float-animation:nth-child(3n) {
    animation-delay: 2s;
    animation-duration: 6s;
}

@keyframes floatGentle {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-10px) rotate(1deg); }
    66% { transform: translateY(-5px) rotate(-1deg); }
}

/* Pulsing Glow */
.pulse-glow {
    animation: pulseGlow 2s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
    from {
        box-shadow: 0 0 5px var(--accent-crystal);
    }
    to {
        box-shadow: 0 0 20px var(--accent-crystal), 0 0 30px var(--accent-crystal);
    }
}

/* Typewriter Effect */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--accent-crystal);
    white-space: nowrap;
    animation: 
        typing 3.5s steps(40, end),
        blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--accent-crystal); }
}

/* Matrix Rain Effect */
.matrix-rain {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.matrix-rain::before {
    content: '✦ ⋆ ★ ✧ ⭐ 💫';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 200%;
    color: var(--accent-crystal);
    font-size: 2rem;
    line-height: 1;
    animation: matrixFall 10s linear infinite;
    opacity: 0.3;
    white-space: pre-wrap;
    word-spacing: 2rem;
}

@keyframes matrixFall {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(50%); }
}

/* Energy Wave */
.energy-wave {
    position: relative;
    overflow: hidden;
}

.energy-wave::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(6, 182, 212, 0.4) 50%, 
        transparent 100%);
    animation: energyWave 2s ease-in-out infinite;
}

@keyframes energyWave {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Constellation Connection Lines */
.constellation-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.constellation-line {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        var(--accent-crystal) 50%, 
        transparent 100%);
    opacity: 0;
    animation: drawLine 2s ease-in-out infinite;
}

@keyframes drawLine {
    0%, 100% { opacity: 0; width: 0; }
    50% { opacity: 0.6; width: 100%; }
}

/* Quantum Flicker */
.quantum-flicker {
    animation: quantumFlicker 0.1s infinite linear alternate;
}

@keyframes quantumFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.95; }
}

/* Morphing Shape */
.morphing-shape {
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    animation: morphShape 8s ease-in-out infinite;
}

@keyframes morphShape {
    0%, 100% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
    25% { border-radius: 58% 42% 75% 25% / 76% 46% 54% 24%; }
    50% { border-radius: 50% 50% 33% 67% / 55% 27% 73% 45%; }
    75% { border-radius: 33% 67% 58% 42% / 63% 68% 32% 37%; }
}

/* Parallax Layers */
.parallax-layer {
    transform: translateZ(0);
    will-change: transform;
}

.parallax-bg { transform: translate3d(0, var(--scroll-bg), 0); }
.parallax-mid { transform: translate3d(0, var(--scroll-mid), 0); }
.parallax-front { transform: translate3d(0, var(--scroll-front), 0); }

/* 3D Transform Effects */
.transform-3d {
    transform-style: preserve-3d;
    perspective: 1000px;
}

.rotate-3d {
    animation: rotate3D 20s linear infinite;
}

@keyframes rotate3D {
    0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
    33% { transform: rotateX(360deg) rotateY(0deg) rotateZ(0deg); }
    66% { transform: rotateX(360deg) rotateY(360deg) rotateZ(0deg); }
    100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg); }
}

/* Glitch Effect */
.glitch-effect {
    position: relative;
}

.glitch-effect::before,
.glitch-effect::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-effect::before {
    animation: glitch-1 0.5s infinite;
    color: var(--accent-crystal);
    z-index: -1;
}

.glitch-effect::after {
    animation: glitch-2 0.5s infinite;
    color: var(--accent-gold);
    z-index: -2;
}

@keyframes glitch-1 {
    0%, 14%, 15%, 49%, 50%, 99%, 100% { transform: translate(0); }
    15%, 49% { transform: translate(-2px, -1px); }
}

@keyframes glitch-2 {
    0%, 20%, 21%, 62%, 63%, 99%, 100% { transform: translate(0); }
    21%, 62% { transform: translate(2px, 1px); }
}

/* Stardust Trail */
.stardust-trail {
    position: relative;
}

.stardust-trail::after {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent-crystal);
    font-size: 0.8rem;
    opacity: 0;
    pointer-events: none;
    animation: stardustTrail 0.8s ease-out forwards;
}

@keyframes stardustTrail {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -300%) scale(1.5);
    }
}

/* Performance Optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
    .particle,
    .float-animation,
    .pulse-glow,
    .rotate-3d,
    .morphing-shape,
    .energy-wave::before,
    .matrix-rain::before,
    .holographic-border::before {
        animation: none !important;
    }
    
    .text-shimmer {
        background: var(--cosmic-white);
        -webkit-text-fill-color: var(--cosmic-white);
    }
    
    .cosmic-ripple::after {
        display: none;
    }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .particle-system,
    .matrix-rain,
    .constellation-lines {
        display: none;
    }
    
    .float-animation,
    .pulse-glow,
    .morphing-shape {
        animation-duration: 2s;
    }
}