/* ==============================================
   EduCore — Animation Library
   Micro-interactions · Skeletons · Transitions
   ============================================== */

/* ── KEYFRAMES ────────────────────────────────── */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

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

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 0.45;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

@keyframes counterUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-6px);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes progressIndeterminate {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(400%);
    }
}


/* ── ANIMATION UTILITY CLASSES ───────────────── */

.animate-fadeInUp {
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-fadeInDown {
    animation: fadeInDown 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-fadeInLeft {
    animation: fadeInLeft 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-slideInRight {
    animation: slideInRight 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-scaleIn {
    animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-bounceIn {
    animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.animate-counterUp {
    animation: counterUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.animate-gradient {
    background-size: 200% 200%;
    animation: gradientShift 4s ease infinite;
}

/* ── Material 3 Spring Physics ── */
@keyframes m3SpringSpatial {
    0% { transform: scale(0.8) translateY(40px); opacity: 0; }
    40% { transform: scale(1.03) translateY(-4px); opacity: 0.8; }
    70% { transform: scale(0.98) translateY(2px); opacity: 0.95; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes m3EffectsSpring {
    0% { opacity: 0; filter: blur(4px); }
    100% { opacity: 1; filter: blur(0); }
}

@keyframes m3SpringLoading {
    0% { left: -30%; width: 20%; }
    50% { left: 40%; width: 50%; }
    100% { left: 110%; width: 20%; }
}

.animate-spring-spatial {
    animation: m3SpringSpatial 0.65s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

.animate-spring-effects {
    animation: m3EffectsSpring 0.45s cubic-bezier(0.25, 0.8, 0.25, 1) both;
}



/* ── STAGGERED ENTRANCE DELAYS ───────────────── */

.animate-stagger-1  { animation-delay: 0.05s; }
.animate-stagger-2  { animation-delay: 0.10s; }
.animate-stagger-3  { animation-delay: 0.15s; }
.animate-stagger-4  { animation-delay: 0.20s; }
.animate-stagger-5  { animation-delay: 0.25s; }
.animate-stagger-6  { animation-delay: 0.30s; }
.animate-stagger-7  { animation-delay: 0.35s; }
.animate-stagger-8  { animation-delay: 0.40s; }
.animate-stagger-9  { animation-delay: 0.45s; }
.animate-stagger-10 { animation-delay: 0.50s; }

/* Ensure staggered items start invisible */
[class*="animate-stagger-"] {
    opacity: 0;
}


/* ── LOADING SKELETONS ───────────────────────── */

.skeleton {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg,
        #F0F2F5 0%,
        #E8ECF1 40%,
        #F0F2F5 60%,
        #F0F2F5 100%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: var(--radius-md, 0.5rem);
}

.skeleton-text {
    height: 14px;
    width: 100%;
    margin-bottom: 0.625rem;
    border-radius: var(--radius-sm, 0.375rem);
}

.skeleton-text:last-child {
    width: 65%;
    margin-bottom: 0;
}

.skeleton-text.short {
    width: 40%;
}

.skeleton-text.medium {
    width: 70%;
}

.skeleton-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-circle.sm {
    width: 32px;
    height: 32px;
}

.skeleton-circle.lg {
    width: 64px;
    height: 64px;
}

.skeleton-card {
    padding: 1.5rem;
    border-radius: var(--radius-xl, 1rem);
    min-height: 120px;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: var(--radius-md, 0.5rem);
}

.skeleton-image {
    width: 100%;
    height: 180px;
    border-radius: var(--radius-lg, 0.75rem);
}

/* Skeleton stat card layout */
.skeleton-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
}

/* Skeleton table row */
.skeleton-row {
    display: flex;
    gap: 1.5rem;
    padding: 1rem 0;
    border-bottom: 1px solid #F3F4F6;
}

.skeleton-row .skeleton-text {
    margin-bottom: 0;
}


/* ── BUTTON RIPPLE EFFECT ────────────────────── */

.btn-ripple {
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.btn-ripple .ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    width: 100px;
    height: 100px;
    margin-top: -50px;
    margin-left: -50px;
    animation: ripple 0.6s linear;
    pointer-events: none;
}

/* Dark ripple for light buttons */
.btn-ripple.ripple-dark .ripple-effect {
    background: rgba(0, 0, 0, 0.08);
}


/* ── PAGE TRANSITIONS ────────────────────────── */

.page-enter {
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.page-exit {
    animation: fadeOut 0.2s ease both;
}

.page-slide-enter {
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-enter {
    animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.modal-exit {
    animation: fadeOut 0.2s ease both;
}


/* ── PROGRESS BAR (INDETERMINATE) ────────────── */

.progress-indeterminate {
    position: relative;
    overflow: hidden;
    height: 3px;
    background: rgba(var(--primary-rgb, 36, 54, 101), 0.1);
    border-radius: var(--radius-full, 9999px);
}

.progress-indeterminate::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 30%;
    height: 100%;
    background: var(--gradient-primary, linear-gradient(135deg, #243665, #34508a));
    border-radius: inherit;
    animation: progressIndeterminate 1.5s ease-in-out infinite;
}


/* ── HOVER MICRO-INTERACTIONS ────────────────── */

.hover-scale {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hover-scale:hover {
    transform: scale(1.03);
}

.hover-brightness {
    transition: filter 0.2s ease;
}

.hover-brightness:hover {
    filter: brightness(1.05);
}


/* ── REDUCED MOTION ──────────────────────────── */

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

    .skeleton {
        animation: none;
        background: #F0F2F5;
    }

    [class*="animate-stagger-"] {
        opacity: 1;
    }
}
