/**
 * Animations & Effects for Evenly Dialog
 * Keyframes, transitions, accessibility-aware animations
 * ~70 lines extracted from main HTML file
 */

/* ===========================================
   ACCESSIBILITY FIRST - REDUCED MOTION
   =========================================== */
@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;
    }
}

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

/* Pulse animation for listening/active states */
@keyframes pulse {
    0% { 
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7); 
    }
    70% { 
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0); 
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); 
    }
}

/* Spin animation for loading indicators */
@keyframes spin {
    0% { 
        transform: rotate(0deg); 
    }
    100% { 
        transform: rotate(360deg); 
    }
}

/* Shimmer animation for processing states */
@keyframes shimmer {
    0% { 
        background-position: -200% 0; 
    }
    100% { 
        background-position: 200% 0; 
    }
}

/* Fade in animation */
@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(10px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

/* Fade out animation */
@keyframes fadeOut {
    from { 
        opacity: 1; 
        transform: translateY(0); 
    }
    to { 
        opacity: 0; 
        transform: translateY(-10px); 
    }
}

/* Slide down animation for dropdowns */
@keyframes slideDown {
    from { 
        opacity: 0; 
        transform: translateY(-10px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* Bounce animation for notifications */
@keyframes bounce {
    0%, 20%, 53%, 80%, 100% { 
        transform: translate3d(0, 0, 0); 
    }
    40%, 43% { 
        transform: translate3d(0, -8px, 0); 
    }
    70% { 
        transform: translate3d(0, -4px, 0); 
    }
    90% { 
        transform: translate3d(0, -2px, 0); 
    }
}

/* ===========================================
   COMPONENT ANIMATIONS
   =========================================== */

/* Button hover effects */
.control-btn {
    transition: all var(--transition-fast);
}

.control-btn:hover,
.control-btn:focus {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.control-btn:active {
    transform: translateY(0);
    transition-duration: 0.1s;
}

/* Section item animations */
.section-item {
    transition: all var(--transition-fast);
}

.section-item:hover,
.section-item:focus {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Language dropdown animations */
.language-dropdown {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
    transition: all var(--transition-fast);
    pointer-events: none;
}

.language-dropdown.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: slideDown 0.2s ease-out;
    pointer-events: auto;
}

/* Language option hover effects */
.language-option {
    transition: background-color var(--transition-fast);
}

/* ===========================================
   PROCESSING & LOADING ANIMATIONS
   =========================================== */

/* Processing indicator shimmer effect */
.processing-indicator {
    background: linear-gradient(90deg, 
        var(--background-accent) 0%, 
        #bbdefb 50%, 
        var(--background-accent) 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* Spinner animation */
.spinner {
    font-size: 3rem;
    animation: spin 1.5s linear infinite;
    display: inline-block;
}

/* Loading dots animation */
@keyframes loadingDots {
    0%, 80%, 100% { 
        opacity: 0; 
    }
    40% { 
        opacity: 1; 
    }
}

.loading-dots span {
    display: inline-block;
    animation: loadingDots 1.4s infinite ease-in-out;
    animation-fill-mode: both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

/* ===========================================
   STATE-SPECIFIC ANIMATIONS
   =========================================== */

/* Listening state pulse */
.control-btn.listening {
    animation: pulse 1.5s infinite;
}

/* Active narration glow effect */
.control-btn.active-narration {
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.3);
    animation: pulse 2s infinite;
}

/* Focus ring animation */
*:focus {
    animation: focusRing 0.3s ease-out;
}

@keyframes focusRing {
    0% { 
        outline-width: 0; 
        outline-offset: 0; 
    }
    100% { 
        outline-width: 2px; 
        outline-offset: 2px; 
    }
}

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

/* Fade in for new content */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Fade out for removed content */
.fade-out {
    animation: fadeOut 0.3s ease-out;
}

/* Slide in from right for notifications */
@keyframes slideInRight {
    from { 
        transform: translateX(100%); 
        opacity: 0; 
    }
    to { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

/* Scale in for modals */
@keyframes scaleIn {
    from { 
        transform: scale(0.9); 
        opacity: 0; 
    }
    to { 
        transform: scale(1); 
        opacity: 1; 
    }
}

.scale-in {
    animation: scaleIn 0.2s ease-out;
}

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

/* Animation delays */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

/* Animation durations */
.duration-fast { animation-duration: 0.15s; }
.duration-normal { animation-duration: 0.3s; }
.duration-slow { animation-duration: 0.5s; }

/* Animation easing */
.ease-in { animation-timing-function: ease-in; }
.ease-out { animation-timing-function: ease-out; }
.ease-in-out { animation-timing-function: ease-in-out; }

/* Disable animations class */
.no-animations,
.no-animations * {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
}

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

/* Use transform and opacity for better performance */
.will-animate {
    will-change: transform, opacity;
}

/* Remove will-change after animation completes */
.animation-complete {
    will-change: auto;
}

/* GPU acceleration for smooth animations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
}