/* Animations — Keyframes and utility classes */
/* Max duration: 0.3s per spec */

/* ===== Keyframes ===== */

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slide-in-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-down {
    from {
        opacity: 0;
        transform: translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-left {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===== Animation utilities ===== */

.animate-fade-in {
    animation: fade-in 0.3s ease forwards;
}

.animate-fade-out {
    animation: fade-out 0.3s ease forwards;
}

.animate-slide-in-up {
    animation: slide-in-up 0.3s ease forwards;
}

.animate-slide-in-down {
    animation: slide-in-down 0.3s ease forwards;
}

.animate-slide-in-left {
    animation: slide-in-left 0.3s ease forwards;
}

.animate-slide-in-right {
    animation: slide-in-right 0.3s ease forwards;
}

.animate-scale-in {
    animation: scale-in 0.3s ease forwards;
}

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

/* ===== Staggered animations ===== */

.stagger > * {
    opacity: 0;
    animation: slide-in-up 0.3s ease forwards;
}

.stagger > *:nth-child(1) { animation-delay: 0s; }
.stagger > *:nth-child(2) { animation-delay: 0.05s; }
.stagger > *:nth-child(3) { animation-delay: 0.1s; }
.stagger > *:nth-child(4) { animation-delay: 0.15s; }
.stagger > *:nth-child(5) { animation-delay: 0.2s; }
.stagger > *:nth-child(6) { animation-delay: 0.25s; }

/* ===== Transition utilities ===== */

.transition-fast {
    transition: all var(--transition-fast);
}

.transition-base {
    transition: all var(--transition-base);
}

.transition-slow {
    transition: all var(--transition-slow);
}

/* ===== Reduced motion ===== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== HTMX transitions ===== */

.htmx-settling {
    opacity: 1;
}

.htmx-swapping {
    opacity: 0;
    transition: opacity 0.15s ease-out;
}

.htmx-added {
    animation: fade-in 0.3s ease forwards;
}
