/* animations.css — Micro-interactions and animation system
 *
 * Staggered entrances, counter animations, skeleton transitions,
 * and other visual polish. Respects prefers-reduced-motion.
 */

/* ─── Staggered Card Entrance ─────────────────────────────── */
@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-cards > .card,
.animate-cards > [class*="metric"],
.animate-cards > [class*="stat"] {
    animation: cardEntrance 300ms ease-out both;
}

.animate-cards > :nth-child(1) { animation-delay: 0ms; }
.animate-cards > :nth-child(2) { animation-delay: 60ms; }
.animate-cards > :nth-child(3) { animation-delay: 80ms; }
.animate-cards > :nth-child(4) { animation-delay: 100ms; }
.animate-cards > :nth-child(5) { animation-delay: 120ms; }
.animate-cards > :nth-child(6) { animation-delay: 140ms; }
.animate-cards > :nth-child(7) { animation-delay: 160ms; }
.animate-cards > :nth-child(8) { animation-delay: 180ms; }

/* ─── Fade In (keyframe defined in components.css) ────────── */
.animate-fade-in {
    animation: fadeIn 250ms ease-out;
}

/* ─── Slide In From Bottom ────────────────────────────────── */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slide-up {
    animation: slideUp 300ms ease-out;
}

/* ─── Slide In From Right ─────────────────────────────────── */
@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(16px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-right {
    animation: slideRight 250ms ease-out;
}

/* ─── Scale In (modals, dropdowns) ────────────────────────── */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-scale-in {
    animation: scaleIn 180ms ease-out;
}

/* ─── Skeleton to Content Crossfade ───────────────────────── */
@keyframes skeletonFade {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

.skeleton-to-content {
    animation: skeletonFade 200ms ease-out;
}

/* ─── Toast (keyframes defined in components.css) ─────────── */
/* .toast-enter/.toast-exit use toastIn/toastOut from components.css */

/* ─── Badge Bounce ────────────────────────────────────────── */
@keyframes badgeBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.badge-animate {
    animation: badgeBounce 300ms ease-out;
}

/* ─── Pulse Ring (status indicators) ──────────────────────── */
@keyframes pulseRing {
    0% {
        box-shadow: 0 0 0 0 currentColor;
        opacity: 0.6;
    }
    100% {
        box-shadow: 0 0 0 8px currentColor;
        opacity: 0;
    }
}

.animate-pulse-ring::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    animation: pulseRing 1.5s ease-out infinite;
}

/* ─── Number Counter Transition ───────────────────────────── */
.animate-number {
    transition: opacity 150ms ease;
}

.animate-number-flash {
    animation: numberFlash 400ms ease-out;
}

@keyframes numberFlash {
    0% { color: var(--accent); }
    100% { color: inherit; }
}

/* ─── Table Row Add/Remove ────────────────────────────────── */
@keyframes rowSlideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateX(0);
        max-height: 100px;
    }
}

.animate-row-in {
    animation: rowSlideIn 250ms ease-out;
}

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