/**
 * Animation Utility Classes
 * Reusable animations for entrances, exits, and micro-interactions
 * Requirements: 10.1, 10.2, 10.3, 10.4
 */

/* ============================================
   ANIMATION VARIABLES
   ============================================ */

:root {
    /* Duration */
    --duration-fast: 150ms;
    --duration-normal: 200ms;
    --duration-medium: 300ms;
    --duration-slow: 500ms;

    /* Easing functions */
    --easing-ease-in: cubic-bezier(0.4, 0, 1, 1);
    --easing-ease-out: cubic-bezier(0, 0, 0.2, 1);
    --easing-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
    --easing-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   ENTRANCE ANIMATIONS
   ============================================ */

/* Fade In */
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.animate-fade-in {
    animation: fade-in var(--duration-normal) var(--easing-ease-out);
}

/* Slide In from Top */
@keyframes slide-in-top {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-slide-in-top {
    animation: slide-in-top var(--duration-medium) var(--easing-ease-out);
}

/* Slide In from Bottom */
@keyframes slide-in-bottom {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.animate-slide-in-bottom {
    animation: slide-in-bottom var(--duration-medium) var(--easing-ease-out);
}

/* Slide In from Left */
@keyframes slide-in-left {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.animate-slide-in-left {
    animation: slide-in-left var(--duration-medium) var(--easing-ease-out);
}

/* Slide In from Right */
@keyframes slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.animate-slide-in-right {
    animation: slide-in-right var(--duration-medium) var(--easing-ease-out);
}

/* Scale In */
@keyframes scale-in {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.animate-scale-in {
    animation: scale-in var(--duration-normal) var(--easing-ease-out);
}

/* Zoom In */
@keyframes zoom-in {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.animate-zoom-in {
    animation: zoom-in var(--duration-medium) var(--easing-spring);
}

/* ============================================
   EXIT ANIMATIONS
   ============================================ */

/* Fade Out */
@keyframes fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.animate-fade-out {
    animation: fade-out var(--duration-normal) var(--easing-ease-in);
}

/* Slide Out to Top */
@keyframes slide-out-top {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

.animate-slide-out-top {
    animation: slide-out-top var(--duration-normal) var(--easing-ease-in);
}

/* Slide Out to Bottom */
@keyframes slide-out-bottom {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

.animate-slide-out-bottom {
    animation: slide-out-bottom var(--duration-normal) var(--easing-ease-in);
}

/* Slide Out to Left */
@keyframes slide-out-left {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

.animate-slide-out-left {
    animation: slide-out-left var(--duration-normal) var(--easing-ease-in);
}

/* Slide Out to Right */
@keyframes slide-out-right {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.animate-slide-out-right {
    animation: slide-out-right var(--duration-normal) var(--easing-ease-in);
}

/* Scale Out */
@keyframes scale-out {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0.9);
        opacity: 0;
    }
}

.animate-scale-out {
    animation: scale-out var(--duration-normal) var(--easing-ease-in);
}

/* Zoom Out */
@keyframes zoom-out {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0);
        opacity: 0;
    }
}

.animate-zoom-out {
    animation: zoom-out var(--duration-normal) var(--easing-ease-in);
}

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.animate-bounce {
    animation: bounce var(--duration-slow) var(--easing-ease-in-out) infinite;
}

/* Pulse */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s var(--easing-ease-in-out) infinite;
}

/* Shake */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

.animate-shake {
    animation: shake var(--duration-slow) var(--easing-ease-in-out);
}

/* Spin */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Ping */
@keyframes ping {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    75%, 100% {
        transform: scale(2);
        opacity: 0;
    }
}

.animate-ping {
    animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

/* ============================================
   TRANSITION UTILITIES
   ============================================ */

.transition-none {
    transition: none !important;
}

.transition-all {
    transition: all var(--duration-normal) var(--easing-ease-in-out);
}

.transition-colors {
    transition: color var(--duration-normal) var(--easing-ease-in-out),
                background-color var(--duration-normal) var(--easing-ease-in-out),
                border-color var(--duration-normal) var(--easing-ease-in-out);
}

.transition-opacity {
    transition: opacity var(--duration-normal) var(--easing-ease-in-out);
}

.transition-transform {
    transition: transform var(--duration-normal) var(--easing-ease-in-out);
}

/* Duration modifiers */
.duration-fast {
    transition-duration: var(--duration-fast) !important;
}

.duration-normal {
    transition-duration: var(--duration-normal) !important;
}

.duration-medium {
    transition-duration: var(--duration-medium) !important;
}

.duration-slow {
    transition-duration: var(--duration-slow) !important;
}

/* ============================================
   ANIMATION DELAYS
   ============================================ */

.delay-0 { animation-delay: 0ms; }
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-500 { animation-delay: 500ms; }

/* ============================================
   ANIMATION FILL MODES
   ============================================ */

.fill-none { animation-fill-mode: none; }
.fill-forwards { animation-fill-mode: forwards; }
.fill-backwards { animation-fill-mode: backwards; }
.fill-both { animation-fill-mode: both; }

/* ============================================
   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;
    }

    /* Disable specific animations */
    .animate-bounce,
    .animate-pulse,
    .animate-spin,
    .animate-ping {
        animation: none !important;
    }

    /* Keep fade animations but make them instant */
    .animate-fade-in,
    .animate-fade-out {
        animation-duration: 0.01ms !important;
    }
}
