/* Keyframes */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

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

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

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

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

@keyframes slideInUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes orbit {
    from { transform: rotate(0deg) translateX(20px) rotate(0deg); }
    to { transform: rotate(360deg) translateX(20px) rotate(-360deg); }
}

@keyframes stripe {
    to { background-position: 30px 0; }
}

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

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

/* Animation Classes */
.fade-in { animation: fadeIn 0.4s ease both; }
.fade-in-up { animation: fadeInUp 0.5s ease both; }
.fade-in-scale { animation: fadeInScale 0.3s ease both; }
.bounce-in { animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* Staggered animations */
.stagger > * { animation: fadeInUp 0.4s ease both; }
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }
.stagger > *:nth-child(7) { animation-delay: 0.35s; }
.stagger > *:nth-child(8) { animation-delay: 0.4s; }

/* Orbit animation for progress */
.orbit-ring {
    width: 60px;
    height: 60px;
    position: relative;
    margin: 0 auto;
}

.orbit-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    top: 50%;
    left: 50%;
    margin: -5px;
    animation: orbit 1.5s linear infinite;
}

.orbit-dot:nth-child(2) {
    animation-delay: -0.5s;
    background: var(--success);
}

.orbit-dot:nth-child(3) {
    animation-delay: -1s;
    background: var(--warning);
}

/* Progress bar stripe animation */
.progress-bar-fill {
    position: relative;
}

.progress-bar-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%);
    background-size: 30px 30px;
    animation: stripe 1s linear infinite;
}

/* Card hover effects */
.group-card {
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

/* Pulse ready button */
.pulse-ready {
    position: relative;
    overflow: hidden;
}

.pulse-ready::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(45deg, var(--primary), var(--success), var(--primary));
    background-size: 200% 200%;
    animation: shimmer 3s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.pulse-ready:hover::before { opacity: 0.6; }

/* Mode card selection animation */
.mode-card {
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Upload zone pulse on drag */
.upload-zone.drag-over {
    animation: pulse 1s ease infinite;
}

/* Toast exit */
.toast.exit {
    animation: slideInRight 0.3s ease reverse forwards;
}

/* Smooth screen transitions */
.screen.active .card {
    animation: fadeInUp 0.4s ease both;
}

.screen.active .card:nth-child(2) { animation-delay: 0.08s; }
.screen.active .card:nth-child(3) { animation-delay: 0.16s; }
.screen.active .card:nth-child(4) { animation-delay: 0.24s; }
.screen.active .card:nth-child(5) { animation-delay: 0.32s; }

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


@keyframes screenIn {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Drag animations */
.student-item {
    transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease, background 0.2s ease;
}

.student-item.dragging {
    transform: scale(1.05) rotate(1deg);
    opacity: 0.7;
    box-shadow: 0 8px 24px rgba(88, 166, 255, 0.3);
    z-index: 100;
    background: var(--primary-bg);
}

.student-item.drag-over {
    transform: translateY(4px);
    border-top: 3px solid var(--primary);
    padding-top: 5px;
}

.group-card.drag-over {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px var(--primary), var(--shadow-lg);
}

/* Progress overlay animation */
.progress-overlay {
    animation: overlayIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes overlayIn {
    from { opacity: 0; backdrop-filter: blur(0); }
    to { opacity: 1; backdrop-filter: blur(8px); }
}

.progress-modal {
    animation: modalBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalBounceIn {
    from { opacity: 0; transform: scale(0.85) translateY(20px); }
    50% { transform: scale(1.02) translateY(-4px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Tab panel transition */
.tab-panel.active {
    animation: tabSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* Card entrance with spring */
.screen.active .card {
    animation: cardSpringIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

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

.screen.active .mode-cards .mode-card {
    animation: cardSpringIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.screen.active .mode-cards .mode-card:nth-child(1) { animation-delay: 0.05s; }
.screen.active .mode-cards .mode-card:nth-child(2) { animation-delay: 0.1s; }
.screen.active .mode-cards .mode-card:nth-child(3) { animation-delay: 0.15s; }
.screen.active .mode-cards .mode-card:nth-child(4) { animation-delay: 0.2s; }

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

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