/* =================================
   COSMIC BACKGROUND ANIMATIONS
   ================================= */

@keyframes cosmicGradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

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

@keyframes particleFloat2 {
    0% {
        transform: translateY(100vh) translateX(0px);
        opacity: 0;
    }
    15% {
        opacity: 0.6;
    }
    85% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-100px) translateX(-15px);
        opacity: 0;
    }
}

/* =================================
   SUBTLE ELEMENT ANIMATIONS
   ================================= */

@keyframes gentleFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-2px);
    }
}

@keyframes searchPulse {
    0%, 100% {
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    50% {
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.3),
            inset 0 1px 0 rgba(255, 255, 255, 0.15),
            0 0 20px rgba(255, 255, 255, 0.05);
    }
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* =================================
   SHIMMER EFFECTS
   ================================= */

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

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* =================================
   LOGO ANIMATIONS
   ================================= */

@keyframes logoGlow {
    0%, 100% {
        filter: brightness(1.2) contrast(1.1);
    }
    50% {
        filter: brightness(1.4) contrast(1.2) drop-shadow(0 0 10px rgba(255, 255, 255, 0.3));
    }
}

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

/* =================================
   LOADING ANIMATIONS
   ================================= */

@keyframes loadingDots {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes progressBar {
    0% {
        width: 0%;
    }
    100% {
        width: 100%;
    }
}

/* =================================
   BACKGROUND PARTICLES
   ================================= */

.cosmic-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(-45deg, 
        #0a0a0f, 
        #1a1a2e, 
        #16213e, 
        #0f1419);
    background-size: 400% 400%;
    animation: cosmicGradient 20s ease infinite;
}

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

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: particleFloat 15s linear infinite;
}

.particle:nth-child(2n) {
    animation: particleFloat2 18s linear infinite;
    background: rgba(0, 122, 255, 0.4);
    width: 1px;
    height: 1px;
}

.particle:nth-child(3n) {
    animation-duration: 22s;
    background: rgba(255, 255, 255, 0.3);
}

/* =================================
   ENTRANCE ANIMATIONS
   ================================= */

.search-container {
    animation: fadeInScale 0.8s ease-out;
}

.search-orb {
    animation: searchPulse 6s ease-in-out infinite;
}

.search-card {
    animation: slideInUp 0.6s ease-out forwards;
    opacity: 0;
}

.search-card:nth-child(1) { animation-delay: 0.1s; }
.search-card:nth-child(2) { animation-delay: 0.2s; }
.search-card:nth-child(3) { animation-delay: 0.3s; }
.search-card:nth-child(4) { animation-delay: 0.4s; }
.search-card:nth-child(5) { animation-delay: 0.5s; }
.search-card:nth-child(6) { animation-delay: 0.6s; }
.search-card:nth-child(7) { animation-delay: 0.7s; }
.search-card:nth-child(8) { animation-delay: 0.8s; }

/* =================================
   HOVER INTERACTION ANIMATIONS
   ================================= */

.search-card:hover .card-icon img {
    animation: logoGlow 1.5s ease-in-out infinite;
}

.search-card:hover .card-count {
    animation: countUp 0.4s ease-out;
}

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

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .cosmic-background {
        animation: none;
        background: #1a1a2e;
    }
    
    .particles {
        display: none;
    }
    
    .search-orb {
        animation: none;
    }
}

/* =================================
   PERFORMANCE OPTIMIZATIONS
   ================================= */

.search-card,
.search-orb,
.card-icon {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

.particle {
    will-change: transform, opacity;
}

/* Remove animations on mobile for performance */
@media (max-width: 768px) {
    .particles {
        display: none;
    }
    
    .cosmic-background {
        animation-duration: 40s; /* Slower on mobile */
    }
    
    .search-card {
        animation: fadeInScale 0.4s ease-out forwards;
    }
}
