/**
 * Global Transitions and Animations
 *
 * This file contains:
 * - CSS variable definitions for consistent timing and easing
 * - Global transition rules for theme switching (light/dark mode)
 * - Reusable @keyframes for common animations
 *
 * Usage:
 * - Include this file early in your HTML to ensure variables are available
 * - Reference variables in component CSS: transition: background-color var(--transition-theme);
 * - Override timing for specific interactions when needed
 */

/* ===== CSS VARIABLE DEFINITIONS ===== */

:root {
    /* Theme Transition Variables (Light/Dark Mode Toggle) */
    --transition-theme-duration: 1s;
    --transition-theme-easing: cubic-bezier(0.65, -0.05, 0.29, 1.2);
    --transition-theme: var(--transition-theme-duration) var(--transition-theme-easing);

    /* Interactive Transition Variables (Hover, Focus, Active States) */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;

    /* Special Effect Transitions */
    --transition-modal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-toast: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ===== GLOBAL THEME TRANSITIONS ===== */

/*
 * Apply smooth theme transitions to all elements
 * This ensures light/dark mode toggle animates consistently across the entire UI
 */
*,
*::before,
*::after {
    transition-property: background-color, color, border-color, box-shadow, fill, stroke;
    transition-duration: var(--transition-theme-duration);
    transition-timing-function: var(--transition-theme-easing);
}

/*
 * Interactive elements get dual transitions:
 * - Theme properties: 1s smooth (light/dark mode)
 * - Interactive properties: 0.2s snappy (hover, focus)
 */
a,
button,
.btn,
input,
select,
textarea,
[role="button"],
[tabindex]:not([tabindex="-1"]) {
    transition:
        background-color var(--transition-theme),
        color var(--transition-theme),
        border-color var(--transition-theme),
        transform var(--transition-base),
        opacity var(--transition-base),
        box-shadow var(--transition-base);
}

/*
 * Disable transitions for elements that should change instantly
 */
.no-transition,
.no-transition *,
[data-no-transition] {
    transition: none !important;
}

/*
 * Reduce motion for users who prefer it (accessibility)
 */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

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

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

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

/* Slide In from Bottom */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Slide In from Top */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Slide In from Right */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* Bounce In */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
    }
}

/* Shake (for errors) */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* Pulse (for attention) */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Spin (for loading) */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

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

.animate-fadeIn {
    animation: fadeIn var(--transition-base) ease;
}

.animate-slideInUp {
    animation: slideInUp var(--transition-slow) ease;
}

.animate-slideInDown {
    animation: slideInDown var(--transition-slow) ease;
}

.animate-scaleIn {
    animation: scaleIn var(--transition-base) ease;
}

.animate-bounceIn {
    animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.animate-shake {
    animation: shake 0.5s ease;
}

.animate-pulse {
    animation: pulse 1.5s ease infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}
