/* ===== ADVANCED ANIMATIONS ===== */

/* Scroll-triggered animations */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

.animate-slide-left {
    opacity: 0;
    transform: translateX(-100px);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-slide-left.animated {
    opacity: 1;
    transform: translateX(0);
}

.animate-slide-right {
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-slide-right.animated {
    opacity: 1;
    transform: translateX(0);
}

.animate-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.animate-scale.animated {
    opacity: 1;
    transform: scale(1);
}

/* Staggered animations */
.stagger-animation {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.stagger-animation.animated {
    opacity: 1;
    transform: translateY(0);
}

.stagger-animation:nth-child(1) { transition-delay: 0.1s; }
.stagger-animation:nth-child(2) { transition-delay: 0.2s; }
.stagger-animation:nth-child(3) { transition-delay: 0.3s; }
.stagger-animation:nth-child(4) { transition-delay: 0.4s; }
.stagger-animation:nth-child(5) { transition-delay: 0.5s; }
.stagger-animation:nth-child(6) { transition-delay: 0.6s; }

/* Africa continent animation */
.africa-ignite {
    position: relative;
    overflow: hidden;
}

.africa-ignite::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 49%, rgba(102, 126, 234, 0.3) 50%, transparent 51%);
    animation: ignite-sweep 3s ease-in-out infinite;
    opacity: 0;
}

.africa-ignite.active::before {
    opacity: 1;
}

@keyframes ignite-sweep {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
    100% { transform: translateX(200%); }
}

/* Neural network animation */
.neural-pulse {
    position: relative;
}

.neural-pulse::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: neural-pulse 2s ease-in-out infinite;
}

@keyframes neural-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 99, 255, 0.7);
        transform: translate(-50%, -50%) scale(1);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(76, 99, 255, 0);
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 99, 255, 0);
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Particle system animation */
.particle-system {
    position: relative;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 50%;
    pointer-events: none;
    animation: particle-float 8s linear infinite;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; }
.particle:nth-child(2) { left: 20%; animation-delay: 1s; }
.particle:nth-child(3) { left: 30%; animation-delay: 2s; }
.particle:nth-child(4) { left: 40%; animation-delay: 3s; }
.particle:nth-child(5) { left: 50%; animation-delay: 4s; }
.particle:nth-child(6) { left: 60%; animation-delay: 5s; }
.particle:nth-child(7) { left: 70%; animation-delay: 6s; }
.particle:nth-child(8) { left: 80%; animation-delay: 7s; }

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

/* Typewriter effect */
.typewriter {
    overflow: hidden;
    border-right: 3px solid var(--primary-color);
    white-space: nowrap;
    animation: typewriter 4s steps(40, end), blink-cursor 1s infinite;
}

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

@keyframes blink-cursor {
    from, to { border-color: transparent; }
    50% { border-color: var(--primary-color); }
}

/* Morphing shapes */
.morphing-shape {
    width: 100px;
    height: 100px;
    background: var(--gradient-primary);
    border-radius: 50%;
    animation: morph 6s ease-in-out infinite;
}

@keyframes morph {
    0%, 100% {
        border-radius: 50%;
        transform: rotate(0deg);
    }
    25% {
        border-radius: 25%;
        transform: rotate(90deg);
    }
    50% {
        border-radius: 10%;
        transform: rotate(180deg);
    }
    75% {
        border-radius: 25%;
        transform: rotate(270deg);
    }
}

/* Glitch effect */
.glitch {
    position: relative;
    color: var(--text-primary);
}

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

.glitch::before {
    animation: glitch-anim-1 0.3s ease-in-out infinite alternate-reverse;
    color: #ff006e;
    z-index: -1;
}

.glitch::after {
    animation: glitch-anim-2 0.3s ease-in-out infinite alternate-reverse;
    color: #00f5ff;
    z-index: -2;
}

@keyframes glitch-anim-1 {
    0% { clip: rect(132px, 9999px, 142px, 0); }
    10% { clip: rect(40px, 9999px, 50px, 0); }
    20% { clip: rect(89px, 9999px, 99px, 0); }
    30% { clip: rect(21px, 9999px, 31px, 0); }
    40% { clip: rect(65px, 9999px, 75px, 0); }
    50% { clip: rect(156px, 9999px, 166px, 0); }
    60% { clip: rect(93px, 9999px, 103px, 0); }
    70% { clip: rect(37px, 9999px, 47px, 0); }
    80% { clip: rect(17px, 9999px, 27px, 0); }
    90% { clip: rect(115px, 9999px, 125px, 0); }
    100% { clip: rect(44px, 9999px, 54px, 0); }
}

@keyframes glitch-anim-2 {
    0% { clip: rect(129px, 9999px, 139px, 0); }
    10% { clip: rect(36px, 9999px, 46px, 0); }
    20% { clip: rect(85px, 9999px, 95px, 0); }
    30% { clip: rect(18px, 9999px, 28px, 0); }
    40% { clip: rect(61px, 9999px, 71px, 0); }
    50% { clip: rect(152px, 9999px, 162px, 0); }
    60% { clip: rect(89px, 9999px, 99px, 0); }
    70% { clip: rect(33px, 9999px, 43px, 0); }
    80% { clip: rect(13px, 9999px, 23px, 0); }
    90% { clip: rect(111px, 9999px, 121px, 0); }
    100% { clip: rect(40px, 9999px, 50px, 0); }
}

/* Loading animation */
.loading-dots {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
}

.loading-dots div {
    position: absolute;
    top: 33px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--primary-color);
    animation-timing-function: cubic-bezier(0, 1, 1, 0);
}

.loading-dots div:nth-child(1) {
    left: 8px;
    animation: loading-dots-1 0.6s infinite;
}

.loading-dots div:nth-child(2) {
    left: 8px;
    animation: loading-dots-2 0.6s infinite;
}

.loading-dots div:nth-child(3) {
    left: 32px;
    animation: loading-dots-2 0.6s infinite;
}

.loading-dots div:nth-child(4) {
    left: 56px;
    animation: loading-dots-3 0.6s infinite;
}

@keyframes loading-dots-1 {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

@keyframes loading-dots-3 {
    0% { transform: scale(1); }
    100% { transform: scale(0); }
}

@keyframes loading-dots-2 {
    0% { transform: translate(0, 0); }
    100% { transform: translate(24px, 0); }
}

/* Holographic effect */
.holographic {
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    background-size: 250% 100%;
    animation: holographic-shine 3s ease-in-out infinite;
}

@keyframes holographic-shine {
    0% { background-position: -250% 0; }
    50% { background-position: 250% 0; }
    100% { background-position: -250% 0; }
}

/* Data stream animation */
.data-stream {
    position: relative;
    overflow: hidden;
}

.data-stream::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 10px,
        rgba(76, 99, 255, 0.1) 10px,
        rgba(76, 99, 255, 0.1) 11px
    );
    animation: data-flow 2s linear infinite;
}

@keyframes data-flow {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Matrix effect */
.matrix-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.1;
    z-index: -1;
}

.matrix-rain {
    position: absolute;
    top: -100%;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
    font-size: 14px;
    animation: matrix-drop 3s linear infinite;
}

@keyframes matrix-drop {
    0% {
        transform: translateY(-100vh);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh);
        opacity: 0;
    }
}

/* Breathing animation */
.breathing {
    animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Magnetic hover effect */
.magnetic-hover {
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.magnetic-hover:hover {
    transform: scale(1.05);
}

/* Circuit board animation */
.circuit-board {
    position: relative;
    background: 
        linear-gradient(90deg, transparent 49%, rgba(76, 99, 255, 0.1) 50%, transparent 51%),
        linear-gradient(0deg, transparent 49%, rgba(76, 99, 255, 0.1) 50%, transparent 51%);
    background-size: 20px 20px;
    animation: circuit-pulse 4s ease-in-out infinite;
}

@keyframes circuit-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

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

.energy-wave::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(76, 99, 255, 0.3), transparent);
    animation: energy-sweep 2s ease-in-out infinite;
}

@keyframes energy-sweep {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Quantum dots animation */
.quantum-dots {
    position: relative;
}

.quantum-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: quantum-float 3s ease-in-out infinite;
}

.quantum-dot:nth-child(1) { top: 20%; left: 30%; animation-delay: 0s; }
.quantum-dot:nth-child(2) { top: 60%; left: 70%; animation-delay: 1s; }
.quantum-dot:nth-child(3) { top: 80%; left: 20%; animation-delay: 2s; }

@keyframes quantum-float {
    0%, 100% { 
        transform: translateY(0) scale(1);
        opacity: 0.5;
    }
    50% { 
        transform: translateY(-20px) scale(1.2);
        opacity: 1;
    }
}

/* Performance optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}