/* ===== ANIMATION KEYFRAMES ===== */

/* Fade Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

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

/* Slide Animations */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

/* Bounce Animation */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    25% {
        transform: translateY(-15px) scale(1.05);
    }
    50% {
        transform: translateY(0) scale(1);
    }
    75% {
        transform: translateY(-7px) scale(0.98);
    }
}

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

/* Pulse Animation */
@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.4);
    }
    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 15px rgba(46, 204, 113, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

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

/* Spin Animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Float Animation */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Wiggle Animation */
@keyframes wiggle {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-5deg);
    }
    75% {
        transform: rotate(5deg);
    }
}

/* Heartbeat Animation */
@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.3);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.3);
    }
    70% {
        transform: scale(1);
    }
}

/* Success Check Animation */
@keyframes checkmark {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* Progress Fill Animation */
@keyframes progressFill {
    from {
        width: 0%;
    }
    to {
        width: var(--target-width);
    }
}

/* Page Load Stagger Animations */
.animate-on-scroll.visible {
    animation: fadeInUp 0.6s ease forwards;
}

/* Stagger children */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
}

.stagger-children.visible > *:nth-child(1) {
    animation: fadeInUp 0.5s ease 0.1s forwards;
}

.stagger-children.visible > *:nth-child(2) {
    animation: fadeInUp 0.5s ease 0.2s forwards;
}

.stagger-children.visible > *:nth-child(3) {
    animation: fadeInUp 0.5s ease 0.3s forwards;
}

.stagger-children.visible > *:nth-child(4) {
    animation: fadeInUp 0.5s ease 0.4s forwards;
}

.stagger-children.visible > *:nth-child(5) {
    animation: fadeInUp 0.5s ease 0.5s forwards;
}

.stagger-children.visible > *:nth-child(6) {
    animation: fadeInUp 0.5s ease 0.6s forwards;
}

/* Card Entrance */
.card-entrance {
    animation: bounceIn 0.6s ease forwards;
}

/* Button Hover Effects */
.btn-primary {
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-primary:active::before {
    width: 300px;
    height: 300px;
}

/* Icon Button Ripple */
.icon-btn {
    position: relative;
    overflow: hidden;
}

.icon-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

.icon-btn:focus:not(:active)::after {
    animation: ripple 1s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    20% {
        transform: scale(25, 25);
        opacity: 0.3;
    }
    100% {
        opacity: 0;
        transform: scale(40, 40);
    }
}

/* Progress Animated Fill */
.progress-animate {
    animation: progressFill 1.5s ease-out forwards;
}

/* Tab Transition */
.tab-content {
    animation: fadeIn 0.4s ease;
}

/* Toast Animations */
.toast {
    animation: slideInRight 0.3s ease;
}

.toast.hiding {
    animation: slideOutRight 0.3s ease forwards;
}

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

/* Modal Overlay Animation */
.modal {
    animation: fadeIn 0.3s ease;
}

.modal.closing {
    animation: fadeOut 0.3s ease forwards;
}

/* Chapter Card Hover Lift */
.chapter-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chapter-card:hover {
    animation: lift 0.3s ease forwards;
}

@keyframes lift {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-8px);
    }
}

/* Task Card Slide In */
.task-card {
    animation: slideInLeft 0.4s ease;
}

/* Smooth Counter Animation */
.counter {
    display: inline-block;
    transition: all 0.3s ease;
}

/* Calendar Cell Hover */
.day-column {
    transition: all 0.2s ease;
}

.day-column:hover {
    animation: pulse 0.5s ease;
}

/* Weightage Badge Pop */
.weightage-badge {
    animation: bounceIn 0.5s ease;
}

/* Book Preloader */
.page {
    animation: bookFlip 1.5s ease-in-out infinite;
    transform-origin: left center;
}

/* Notification Dot */
.notification-dot {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Shimmer Loading Skeleton */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        rgba(255, 255, 255, 0.5) 50%,
        var(--bg-tertiary) 100%
    );
    background-size: 200% 100%;
    animation: shimmer-move 1.5s infinite linear;
    border-radius: var(--radius-md);
}

/* Confetti Animation (for achievements) */
@keyframes confetti-fall {
    0% {
        opacity: 1;
        transform: translateY(-100%) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

/* Success Celebration */
.celebration {
    animation: celebrate 0.6s ease;
}

@keyframes celebrate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Haptic Feedback */
.btn:active,
.icon-btn:active {
    transform: scale(0.95);
}

/* Smooth Transitions for Interactive Elements */
a,
button,
.tab-btn,
.chapter-card,
.task-card,
.session-block {
    transition: all 0.2s ease;
}

/* GPU Acceleration hint */
.gpu-accelerated {
    transform: translateZ(0);
    will-change: transform;
}

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