/* ========================================
   ANIMATIONS & EFFECTS
   Futuristic Arcade Transitions
   ======================================== */

/* ========================================
   KEYFRAME ANIMATIONS
   ======================================== */

/* Background Animations */
@keyframes twinkle {

    0%,
    100% {
        opacity: 0.6;
        transform: scale(1);
    }

    50% {
        opacity: 0.9;
        transform: scale(1.05);
    }
}

@keyframes gridMove {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(50px);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -30px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

/* Text Animations */
@keyframes textGlow {
    0% {
        text-shadow:
            0 0 10px rgba(0, 255, 255, 0.5),
            0 0 20px rgba(0, 255, 255, 0.3),
            0 0 30px rgba(255, 0, 255, 0.2);
    }

    100% {
        text-shadow:
            0 0 20px rgba(0, 255, 255, 0.8),
            0 0 30px rgba(0, 255, 255, 0.5),
            0 0 40px rgba(255, 0, 255, 0.4);
    }
}

@keyframes flicker {

    0%,
    100% {
        opacity: 1;
    }

    41%,
    43% {
        opacity: 0.8;
    }

    45%,
    47% {
        opacity: 0.9;
    }

    49% {
        opacity: 0.85;
    }
}

/* Logo Animation */
@keyframes logoFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

/* Progress Bar Animation */
@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

/* Score Animation */
@keyframes scorePulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

/* Correct Answer Animation */
@keyframes correctPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(57, 255, 20, 0.7);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(57, 255, 20, 0.7);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(57, 255, 20, 0.5);
    }
}

/* Wrong Answer Animation */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-10px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(10px);
    }
}

/* Particle Explosion */
@keyframes particleExplode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* ========================================
   SCREEN TRANSITIONS
   ======================================== */

/* Fade In */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Fade Out */
@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Slide Up */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide Down */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Zoom In */
@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Zoom Out */
@keyframes zoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

/* Rotate In */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0.5);
    }

    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* ========================================
   TRANSITION CLASSES
   ======================================== */

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

.slide-up {
    animation: slideUp 0.6s ease forwards;
}

.slide-down {
    animation: slideDown 0.6s ease forwards;
}

.zoom-in {
    animation: zoomIn 0.5s ease forwards;
}

.zoom-out {
    animation: zoomOut 0.5s ease forwards;
}

.rotate-in {
    animation: rotateIn 0.7s ease forwards;
}

/* ========================================
   PARTICLE EFFECTS
   ======================================== */

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

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--neon-cyan);
    box-shadow: 0 0 10px currentColor;
    animation: particleExplode 1s ease-out forwards;
}

.particle.magenta {
    background: var(--neon-magenta);
}

.particle.green {
    background: var(--neon-green);
}

.particle.purple {
    background: var(--neon-purple);
}

/* ========================================
   FEEDBACK ANIMATIONS
   ======================================== */

.success-flash {
    animation: successFlash 0.5s ease;
}

@keyframes successFlash {

    0%,
    100% {
        background: transparent;
    }

    50% {
        background: rgba(57, 255, 20, 0.2);
    }
}

.error-flash {
    animation: errorFlash 0.5s ease;
}

@keyframes errorFlash {

    0%,
    100% {
        background: transparent;
    }

    50% {
        background: rgba(255, 51, 102, 0.2);
    }
}

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

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(0, 255, 255, 0.2);
    border-top-color: var(--neon-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: var(--spacing-lg) auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-dots {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: var(--spacing-lg) 0;
}

.loading-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--neon-cyan);
    animation: dotPulse 1.4s infinite ease-in-out;
}

.loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes dotPulse {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

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

.glow-on-hover {
    transition: all 0.3s ease;
}

.glow-on-hover:hover {
    filter: drop-shadow(0 0 15px currentColor);
}

.scale-on-hover {
    transition: transform 0.3s ease;
}

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

/* ========================================
   ENTRANCE ANIMATIONS (Staggered)
   ======================================== */

.stagger-fade-in>* {
    opacity: 0;
    animation: fadeIn 0.5s ease forwards;
}

.stagger-fade-in>*:nth-child(1) {
    animation-delay: 0.1s;
}

.stagger-fade-in>*:nth-child(2) {
    animation-delay: 0.2s;
}

.stagger-fade-in>*:nth-child(3) {
    animation-delay: 0.3s;
}

.stagger-fade-in>*:nth-child(4) {
    animation-delay: 0.4s;
}

.stagger-fade-in>*:nth-child(5) {
    animation-delay: 0.5s;
}

.stagger-fade-in>*:nth-child(6) {
    animation-delay: 0.6s;
}

/* ========================================
   VICTORY CELEBRATION
   ======================================== */

.victory-animation {
    animation: victoryPulse 1s ease infinite;
}

@keyframes victoryPulse {

    0%,
    100% {
        transform: scale(1);
        filter: drop-shadow(0 0 20px var(--neon-cyan));
    }

    50% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 40px var(--neon-magenta));
    }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--neon-cyan);
    animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ========================================
   QUESTION TRANSITION
   ======================================== */

.question-enter {
    animation: questionSlide 0.5s ease forwards;
}

@keyframes questionSlide {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.question-exit {
    animation: questionSlideOut 0.5s ease forwards;
}

@keyframes questionSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(-100px);
    }
}

/* ========================================
   NEON BORDER ANIMATION
   ======================================== */

.neon-border {
    position: relative;
    border: 2px solid transparent;
    background: linear-gradient(var(--dark-bg), var(--dark-bg)) padding-box,
        linear-gradient(135deg, var(--neon-cyan), var(--neon-magenta), var(--neon-purple)) border-box;
    animation: neonRotate 3s linear infinite;
}

@keyframes neonRotate {
    0% {
        filter: hue-rotate(0deg);
    }

    100% {
        filter: hue-rotate(360deg);
    }
}

/* ========================================
   GLITCH EFFECT (Optional)
   ======================================== */

.glitch {
    position: relative;
}

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

.glitch::before {
    animation: glitch-1 0.3s infinite;
    color: var(--neon-cyan);
    z-index: -1;
}

.glitch::after {
    animation: glitch-2 0.3s infinite;
    color: var(--neon-magenta);
    z-index: -2;
}

@keyframes glitch-1 {

    0%,
    100% {
        transform: translate(0);
    }

    33% {
        transform: translate(-2px, 2px);
    }

    66% {
        transform: translate(2px, -2px);
    }
}

@keyframes glitch-2 {

    0%,
    100% {
        transform: translate(0);
    }

    33% {
        transform: translate(2px, -2px);
    }

    66% {
        transform: translate(-2px, 2px);
    }
}

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

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

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}