/**
 * ============================================================================
 * QENEX UNIFIED DESIGN SYSTEM - ANIMATIONS
 * Version: 2.0.0
 * ============================================================================
 *
 * Signature animations and keyframes for the QENEX design system.
 * Import AFTER tokens.css
 */

/* ============================================================================
   CORE KEYFRAMES
   ============================================================================ */

/* Pulse - Used for "live" indicators */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Glow Pulse - For buttons and interactive elements */
@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(0, 240, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 30px rgba(0, 240, 255, 0.6), 0 0 60px rgba(0, 240, 255, 0.3);
    }
}

/* Spin - Loading spinners */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Counter Spin - Reverse rotation */
@keyframes spinReverse {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

/* Nebula Breathing - Background effect */
@keyframes nebulaPulse {
    0% {
        opacity: 0.5;
        transform: scale(1);
    }
    100% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Grid Float - Subtle background movement */
@keyframes gridFloat {
    0% {
        transform: translate(0, 0);
    }
    100% {
        transform: translate(60px, 60px);
    }
}

/* Fade In Up - Entry animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Down - Entry animation */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In - Simple fade */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Scale In - Pop entry */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Slide In Right - Drawer entry */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide In Left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Float - Gentle up/down motion */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Shimmer - Holographic effect */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Text Gradient Animation */
@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Particle Float - For background particles */
@keyframes particleFloat {
    0%, 100% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Orb Rotate - For atomic orbitals */
@keyframes orbRotate {
    from {
        transform: rotateX(70deg) rotateY(0deg);
    }
    to {
        transform: rotateX(70deg) rotateY(360deg);
    }
}

/* Orb Rotate Reverse */
@keyframes orbRotateReverse {
    from {
        transform: rotateX(70deg) rotateY(360deg);
    }
    to {
        transform: rotateX(70deg) rotateY(0deg);
    }
}

/* Data Pulse - For real-time indicators */
@keyframes dataPulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.4);
    }
    50% {
        opacity: 0.8;
        box-shadow: 0 0 0 10px transparent;
    }
}

/* Border Glow - Animated border */
@keyframes borderGlow {
    0%, 100% {
        border-color: rgba(0, 240, 255, 0.3);
    }
    50% {
        border-color: rgba(0, 240, 255, 0.6);
    }
}

/* Counter Animation - For number increments */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   ANIMATION UTILITY CLASSES
   ============================================================================ */

/* Apply animations */
.animate-pulse { animation: pulse 2s infinite; }
.animate-glow-pulse { animation: glowPulse 2s infinite; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-spin-slow { animation: spin 3s linear infinite; }
.animate-float { animation: float 3s ease-in-out infinite; }
.animate-shimmer { animation: shimmer 2s infinite; }
.animate-nebula { animation: nebulaPulse 8s ease-in-out infinite alternate; }
.animate-grid { animation: gridFloat 20s linear infinite; }

/* Entry animations */
.animate-fade-in {
    animation: fadeIn var(--duration-normal) ease forwards;
}

.animate-fade-in-up {
    animation: fadeInUp var(--duration-slow) ease forwards;
}

.animate-fade-in-down {
    animation: fadeInDown var(--duration-slow) ease forwards;
}

.animate-scale-in {
    animation: scaleIn var(--duration-normal) ease forwards;
}

.animate-slide-in-right {
    animation: slideInRight var(--duration-slow) ease forwards;
}

.animate-slide-in-left {
    animation: slideInLeft var(--duration-slow) ease forwards;
}

/* Staggered animations - add delay */
.animate-delay-100 { animation-delay: 100ms; }
.animate-delay-200 { animation-delay: 200ms; }
.animate-delay-300 { animation-delay: 300ms; }
.animate-delay-400 { animation-delay: 400ms; }
.animate-delay-500 { animation-delay: 500ms; }
.animate-delay-750 { animation-delay: 750ms; }
.animate-delay-1000 { animation-delay: 1000ms; }

/* Initial states for JS-triggered animations */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--duration-slow), transform var(--duration-slow);
}

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

/* ============================================================================
   HOVER EFFECTS
   ============================================================================ */

/* Lift on hover */
.hover-lift {
    transition: transform var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-4px);
}

/* Glow on hover */
.hover-glow {
    transition: box-shadow var(--transition-glow);
}

.hover-glow:hover {
    box-shadow: var(--glow-cyan);
}

.hover-glow-intense:hover {
    box-shadow: var(--glow-cyan-intense);
}

/* Scale on hover */
.hover-scale {
    transition: transform var(--transition-base);
}

.hover-scale:hover {
    transform: scale(1.02);
}

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

/* Border glow on hover */
.hover-border-glow {
    transition: border-color var(--transition-glow), box-shadow var(--transition-glow);
}

.hover-border-glow:hover {
    border-color: var(--brand-accent);
    box-shadow: var(--glow-cyan-sm);
}

/* ============================================================================
   DATA FLOW ANIMATION - Tech Stack Visualization
   ============================================================================ */

.data-flow-line {
    position: relative;
    overflow: hidden;
}

.data-flow-line::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -100%;
    width: 50%;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        var(--brand-accent),
        var(--brand-magenta),
        transparent
    );
    animation: dataFlowLine 2s linear infinite;
}

@keyframes dataFlowLine {
    0% { left: -100%; }
    100% { left: 200%; }
}

/* ============================================================================
   ATOMIC/ORBITAL ANIMATION - QENEX Logo
   ============================================================================ */

.atomic-container {
    position: relative;
    width: 100px;
    height: 100px;
    perspective: 1000px;
}

.atomic-core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    background: var(--gradient-button);
    border-radius: 50%;
    box-shadow: var(--glow-cyan-intense);
    animation: pulse 2s ease-in-out infinite;
}

.atomic-orbit {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid var(--brand-accent-dim);
    border-radius: 50%;
    animation: orbRotate 8s linear infinite;
}

.atomic-orbit:nth-child(2) {
    width: 60px;
    height: 60px;
    animation-duration: 6s;
}

.atomic-orbit:nth-child(3) {
    width: 80px;
    height: 80px;
    animation-duration: 10s;
    animation-direction: reverse;
}

.atomic-orbit:nth-child(4) {
    width: 100px;
    height: 100px;
    animation-duration: 14s;
}

.atomic-electron {
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background: var(--brand-accent);
    border-radius: 50%;
    box-shadow: var(--glow-cyan);
}

/* ============================================================================
   PARTICLE SYSTEM - Background Effect
   ============================================================================ */

.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--brand-accent);
    border-radius: 50%;
    opacity: 0.6;
    animation: particleFloat 15s infinite;
}

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

/* Magenta particles variant */
.particle.magenta {
    background: var(--brand-magenta);
}

/* ============================================================================
   GRADIENT TEXT ANIMATION
   ============================================================================ */

.gradient-text-animated {
    background: linear-gradient(
        135deg,
        var(--brand-accent),
        var(--brand-magenta),
        var(--brand-accent)
    );
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientFlow 4s ease infinite;
}

/* ============================================================================
   REDUCED MOTION SUPPORT
   ============================================================================ */

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

    .animate-on-scroll {
        opacity: 1;
        transform: none;
    }
}
