/* Advanced Animations & Microinteractions */

/* Base Animation Classes */
.animate-fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

.animate-slide-up {
    animation: slideUp 0.6s ease-out forwards;
}

.animate-slide-down {
    animation: slideDown 0.6s ease-out forwards;
}

.animate-slide-left {
    animation: slideLeft 0.6s ease-out forwards;
}

.animate-slide-right {
    animation: slideRight 0.6s ease-out forwards;
}

.animate-scale-in {
    animation: scaleIn 0.5s ease-out forwards;
}

.animate-bounce-in {
    animation: bounceIn 0.8s ease-out forwards;
}

.animate-rotate-in {
    animation: rotateIn 0.6s ease-out forwards;
}

.animate-pulse-glow {
    animation: pulseGlow 2s ease-in-out infinite;
}

.animate-shake {
    animation: shake 0.5s ease-in-out;
}

.animate-wiggle {
    animation: wiggle 1s ease-in-out infinite;
}

/* Stagger Animations */
.animate-stagger-1 { animation-delay: 0.1s; }
.animate-stagger-2 { animation-delay: 0.2s; }
.animate-stagger-3 { animation-delay: 0.3s; }
.animate-stagger-4 { animation-delay: 0.4s; }
.animate-stagger-5 { animation-delay: 0.5s; }

/* Hover Effects */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.hover-scale {
    transition: transform 0.2s ease;
}

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

.hover-rotate {
    transition: transform 0.3s ease;
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

.hover-glow {
    transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

/* Button Animations */
.btn-pulse {
    animation: btnPulse 1.5s ease-in-out infinite;
}

.btn-bounce {
    animation: btnBounce 0.6s ease-out;
}

.btn-success {
    animation: btnSuccess 0.6s ease-out;
}

/* Loading Animations */
.loading-spinner {
    animation: spin 1s linear infinite;
}

.loading-dots::after {
    content: '';
    animation: loadingDots 1.5s ease-in-out infinite;
}

.loading-wave {
    animation: loadingWave 1.2s ease-in-out infinite;
}

/* Progress Animations */
.progress-bar {
    animation: progressFill 2s ease-out forwards;
}

.progress-pulse {
    animation: progressPulse 1.5s ease-in-out infinite;
}

/* Card Animations */
.card-flip {
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.card-flip:hover {
    transform: rotateY(180deg);
}

.card-tilt {
    transition: transform 0.3s ease;
}

.card-tilt:hover {
    transform: perspective(1000px) rotateX(5deg) rotateY(-5deg);
}

/* Text Animations */
.text-reveal {
    animation: textReveal 1s ease-out forwards;
}

.text-typewriter {
    animation: typewriter 2s steps(40, end) forwards;
    white-space: nowrap;
    overflow: hidden;
    width: 0;
}

.text-glitch {
    animation: glitch 0.3s ease-in-out infinite alternate;
}

/* Icon Animations */
.icon-spin {
    animation: spin 2s linear infinite;
}

.icon-bounce {
    animation: iconBounce 1s ease-in-out infinite;
}

.icon-pulse {
    animation: iconPulse 1s ease-in-out infinite;
}

/* Form Animations */
.form-focus {
    transition: all 0.3s ease;
}

.form-focus:focus {
    transform: scale(1.02);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-success {
    animation: inputSuccess 0.6s ease-out;
}

.input-error {
    animation: inputError 0.6s ease-out;
}

/* Modal Animations */
.modal-enter {
    animation: modalEnter 0.3s ease-out forwards;
}

.modal-exit {
    animation: modalExit 0.3s ease-in forwards;
}

.modal-overlay-enter {
    animation: modalOverlayEnter 0.3s ease-out forwards;
}

.modal-overlay-exit {
    animation: modalOverlayExit 0.3s ease-in forwards;
}

/* Notification Animations */
.notification-enter {
    animation: notificationEnter 0.4s ease-out forwards;
}

.notification-exit {
    animation: notificationExit 0.3s ease-in forwards;
}

.notification-slide-in {
    animation: slideInRight 0.4s ease-out forwards;
}

.notification-slide-out {
    animation: slideOutRight 0.3s ease-in forwards;
}

/* Keyframe Definitions */

/* Basic Entrance Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

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

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

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

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0.5);
    }
    to {
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
}

/* Interactive Animations */
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 30px rgba(59, 130, 246, 0.8);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(3deg); }
    75% { transform: rotate(-3deg); }
}

/* Button Animations */
@keyframes btnPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
    }
}

@keyframes btnBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes btnSuccess {
    0% { transform: scale(1); background-color: #3b82f6; }
    50% { transform: scale(1.1); background-color: #10b981; }
    100% { transform: scale(1); background-color: #10b981; }
}

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

@keyframes loadingDots {
    0%, 80%, 100% { content: ''; }
    20% { content: '.'; }
    40% { content: '..'; }
    60% { content: '...'; }
}

@keyframes loadingWave {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.5); }
}

/* Progress Animations */
@keyframes progressFill {
    from { width: 0%; }
    to { width: 100%; }
}

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

/* Text Animations */
@keyframes textReveal {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes glitch {
    0% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
    100% { transform: translate(0); }
}

/* Icon Animations */
@keyframes iconBounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

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

/* Form Animations */
@keyframes inputSuccess {
    0% { border-color: #d1d5db; }
    50% { border-color: #10b981; }
    100% { border-color: #10b981; }
}

@keyframes inputError {
    0% { border-color: #d1d5db; transform: translateX(0); }
    25% { border-color: #ef4444; transform: translateX(-5px); }
    50% { border-color: #ef4444; transform: translateX(5px); }
    75% { border-color: #ef4444; transform: translateX(-5px); }
    100% { border-color: #ef4444; transform: translateX(0); }
}

/* Modal Animations */
@keyframes modalEnter {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

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

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

/* Notification Animations */
@keyframes notificationEnter {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

/* Utility Classes */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

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

/* Header Scroll Effects */
header.scrolled {
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

header.hidden {
    transform: translateY(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode header styles */
.dark header.scrolled {
    background-color: rgba(17, 24, 39, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Performance Optimizations */
.animate-gpu {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Tailwind-like animations for parity */
.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

.animate-bounce {
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(-25%);
    animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
  }
  50% {
    transform: translateY(0);
    animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
  }
}

.animate-ping {
  animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes ping {
  75%, 100% {
    transform: scale(2);
    opacity: 0;
  }
}
