/* StudyBuddy AI - Animations and Transitions */

/* Animation Variables */
:root {
    --ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53);
    --ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19);
    --ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1);
    --ease-in-out-quad: cubic-bezier(0.455, 0.03, 0.515, 0.955);
    --ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1);
    --ease-back: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Loading Animations */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }
    14% {
        transform: scale(1.1);
    }
    28% {
        transform: scale(1);
    }
    42% {
        transform: scale(1.1);
    }
    70% {
        transform: scale(1);
    }
}

/* Entrance Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Exit Animations */
@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes fadeOutUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-30px);
    }
}

@keyframes fadeOutDown {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(30px);
    }
}

@keyframes slideOutUp {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-100%);
        opacity: 0;
    }
}

@keyframes slideOutDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes scaleOut {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0);
        opacity: 0;
    }
}

/* Special Effects */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

@keyframes wobble {
    0% {
        transform: translateX(0%);
    }
    15% {
        transform: translateX(-25%) rotate(-5deg);
    }
    30% {
        transform: translateX(20%) rotate(3deg);
    }
    45% {
        transform: translateX(-15%) rotate(-3deg);
    }
    60% {
        transform: translateX(10%) rotate(2deg);
    }
    75% {
        transform: translateX(-5%) rotate(-1deg);
    }
    100% {
        transform: translateX(0%);
    }
}

@keyframes rubber {
    from {
        transform: scale3d(1, 1, 1);
    }
    30% {
        transform: scale3d(1.25, 0.75, 1);
    }
    40% {
        transform: scale3d(0.75, 1.25, 1);
    }
    50% {
        transform: scale3d(1.15, 0.85, 1);
    }
    65% {
        transform: scale3d(0.95, 1.05, 1);
    }
    75% {
        transform: scale3d(1.05, 0.95, 1);
    }
    to {
        transform: scale3d(1, 1, 1);
    }
}

@keyframes swing {
    20% {
        transform: rotate3d(0, 0, 1, 15deg);
    }
    40% {
        transform: rotate3d(0, 0, 1, -10deg);
    }
    60% {
        transform: rotate3d(0, 0, 1, 5deg);
    }
    80% {
        transform: rotate3d(0, 0, 1, -5deg);
    }
    to {
        transform: rotate3d(0, 0, 1, 0deg);
    }
}

@keyframes tada {
    from {
        transform: scale3d(1, 1, 1);
    }
    10%, 20% {
        transform: scale3d(0.9, 0.9, 0.9) rotate3d(0, 0, 1, -3deg);
    }
    30%, 50%, 70%, 90% {
        transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, 3deg);
    }
    40%, 60%, 80% {
        transform: scale3d(1.1, 1.1, 1.1) rotate3d(0, 0, 1, -3deg);
    }
    to {
        transform: scale3d(1, 1, 1);
    }
}

/* Progressive Loading Animation */
@keyframes progressiveFill {
    0% {
        width: 0%;
    }
    25% {
        width: 25%;
    }
    50% {
        width: 50%;
    }
    75% {
        width: 75%;
    }
    100% {
        width: 100%;
    }
}

/* Skeleton Loading Animation */
@keyframes skeleton {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

/* Ripple Effect Animation */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* Typing Animation */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* Floating Animation */
@keyframes float {
    0% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-20px);
    }
    100% {
        transform: translateY(0px);
    }
}

/* Glow Animation */
@keyframes glow {
    0% {
        box-shadow: 0 0 5px var(--primary-color);
    }
    50% {
        box-shadow: 0 0 20px var(--primary-color), 0 0 30px var(--primary-color);
    }
    100% {
        box-shadow: 0 0 5px var(--primary-color);
    }
}

/* Notification Animation */
@keyframes notificationBounce {
    0% {
        transform: translateX(100%) scale(0.8);
        opacity: 0;
    }
    20% {
        transform: translateX(-10px) scale(1.1);
        opacity: 1;
    }
    40% {
        transform: translateX(5px) scale(0.95);
    }
    60% {
        transform: translateX(-2px) scale(1.02);
    }
    80% {
        transform: translateX(1px) scale(0.98);
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* Count Up Animation */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Success Checkmark Animation */
@keyframes checkmark {
    0% {
        stroke-dashoffset: 100;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes checkmarkCircle {
    0% {
        stroke-dashoffset: 166;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* Error X Animation */
@keyframes errorX {
    0% {
        stroke-dashoffset: 30;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* Loading Dots Animation */
@keyframes loadingDots {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Screen Transition Animations */
.screen-enter {
    animation: slideInRight 0.3s var(--ease-out-cubic);
}

.screen-exit {
    animation: slideOutLeft 0.3s var(--ease-in-cubic);
}

.screen-enter-back {
    animation: slideInLeft 0.3s var(--ease-out-cubic);
}

.screen-exit-back {
    animation: slideOutRight 0.3s var(--ease-in-cubic);
}

/* Component Animations */
.animate-fade-in {
    animation: fadeIn 0.3s var(--ease-out-quad);
}

.animate-fade-in-up {
    animation: fadeInUp 0.5s var(--ease-out-cubic);
}

.animate-fade-in-down {
    animation: fadeInDown 0.5s var(--ease-out-cubic);
}

.animate-slide-in-up {
    animation: slideInUp 0.4s var(--ease-out-cubic);
}

.animate-scale-in {
    animation: scaleIn 0.3s var(--ease-back);
}

.animate-zoom-in {
    animation: zoomIn 0.3s var(--ease-out-cubic);
}

.animate-bounce {
    animation: bounce 2s infinite;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-heartbeat {
    animation: heartbeat 1.5s ease-in-out infinite;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

.animate-glow {
    animation: glow 2s ease-in-out infinite alternate;
}

.animate-shake {
    animation: shake 0.5s;
}

.animate-wobble {
    animation: wobble 1s;
}

.animate-rubber {
    animation: rubber 1s;
}

.animate-swing {
    animation: swing 1s;
}

.animate-tada {
    animation: tada 1s;
}

/* Staggered Animations */
.stagger-children > * {
    animation-delay: calc(var(--index, 0) * 0.1s);
}

.stagger-children-slow > * {
    animation-delay: calc(var(--index, 0) * 0.2s);
}

/* Loading States */
.loading-spinner {
    animation: spin 1s linear infinite;
}

.loading-dots span:nth-child(1) {
    animation: loadingDots 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation: loadingDots 1.4s ease-in-out infinite 0.2s;
}

.loading-dots span:nth-child(3) {
    animation: loadingDots 1.4s ease-in-out infinite 0.4s;
}

.skeleton-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: skeleton 1.2s ease-in-out infinite;
}

/* Progress Animations */
.progress-fill {
    transition: width 0.5s var(--ease-out-cubic);
}

.progress-circle {
    transition: stroke-dashoffset 0.5s var(--ease-out-cubic);
}

/* Button Animations */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

/* Hover Animations */
.hover-lift {
    transition: transform 0.2s var(--ease-out-quad);
}

.hover-lift:hover {
    transform: translateY(-4px);
}

.hover-grow {
    transition: transform 0.2s var(--ease-out-quad);
}

.hover-grow:hover {
    transform: scale(1.05);
}

.hover-bounce {
    transition: transform 0.2s var(--ease-out-quad);
}

.hover-bounce:hover {
    animation: bounce 0.6s;
}

/* Toast Animations */
.toast-enter {
    animation: notificationBounce 0.5s var(--ease-out-cubic);
}

.toast-exit {
    animation: slideOutRight 0.3s var(--ease-in-cubic);
}

/* Modal Animations */
.modal-enter {
    animation: fadeIn 0.3s var(--ease-out-quad);
}

.modal-enter .modal-content {
    animation: scaleIn 0.3s var(--ease-back);
}

.modal-exit {
    animation: fadeOut 0.3s var(--ease-in-quad);
}

/* Tab Animations */
.tab-content-enter {
    animation: fadeInUp 0.3s var(--ease-out-cubic);
}

.tab-indicator {
    transition: transform 0.3s var(--ease-out-cubic);
}

/* Camera Capture Animation */
.capture-flash {
    animation: flash 0.2s;
}

@keyframes flash {
    0% {
        background: rgba(255, 255, 255, 0);
    }
    50% {
        background: rgba(255, 255, 255, 0.8);
    }
    100% {
        background: rgba(255, 255, 255, 0);
    }
}

/* Success/Error State Animations */
.success-enter {
    animation: zoomIn 0.5s var(--ease-back), glow 1s ease-in-out;
}

.error-enter {
    animation: shake 0.5s, fadeIn 0.3s;
}

/* Count Animation for Statistics */
.count-up {
    animation: countUp 0.6s var(--ease-out-cubic);
}

/* Parallax Effect */
.parallax-bg {
    transform: translateY(0);
    transition: transform 0.1s ease-out;
}

/* Scroll Animations */
.scroll-fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s var(--ease-out-cubic), transform 0.6s var(--ease-out-cubic);
}

.scroll-fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

.scroll-slide-in-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.6s var(--ease-out-cubic), transform 0.6s var(--ease-out-cubic);
}

.scroll-slide-in-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-slide-in-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.6s var(--ease-out-cubic), transform 0.6s var(--ease-out-cubic);
}

.scroll-slide-in-right.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Performance Optimizations */
.will-animate {
    will-change: transform, opacity;
}

/* Remove animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .animate-bounce,
    .animate-pulse,
    .animate-heartbeat,
    .animate-float,
    .animate-glow {
        animation: none;
    }
    
    .loading-spinner {
        animation: none;
    }
    
    .skeleton-loading {
        animation: none;
        background: #f0f0f0;
    }
    
    .hover-lift:hover,
    .hover-grow:hover {
        transform: none;
    }
}
