/**
 * Site-wide Animations and Transitions
 * 
 * Provides smooth animations for page elements, scroll effects, and interactions
 */

/* ============================================
   SCROLL REVEAL ANIMATIONS
   ============================================ */

/* Base state for elements that will animate on scroll */
/* IMPORTANT: These are OPT-IN - only elements with these classes will be hidden initially */
.scroll-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Fade in from left */
.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-reveal-left.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* Fade in from right */
.scroll-reveal-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* Scale up animation */
.scroll-reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.scroll-reveal-scale.revealed {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   SMOOTH PAGE TRANSITIONS
   ============================================ */

/* Page fade-in on load */
body {
    animation: pageLoadFade 0.5s ease-in;
}

@keyframes pageLoadFade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   BUTTON AND LINK ANIMATIONS
   ============================================ */

/* Smooth button hover effects */
.btn-animate {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-animate::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.btn-animate:hover::before {
    width: 300px;
    height: 300px;
}

/* Link underline animation */
.link-underline {
    position: relative;
    text-decoration: none;
}

.link-underline::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width 0.3s ease;
}

.link-underline:hover::after {
    width: 100%;
}

/* ============================================
   CARD ANIMATIONS
   ============================================ */

/* Card lift and glow effect */
.card-animate {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-animate:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Card image zoom on hover */
.card-image-zoom {
    overflow: hidden;
}

.card-image-zoom img {
    transition: transform 0.5s ease;
}

.card-image-zoom:hover img {
    transform: scale(1.1);
}

/* ============================================
   NAVIGATION ANIMATIONS
   ============================================ */

/* Smooth dropdown animations - OPT-IN ONLY */
.dropdown-menu-animated {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

.dropdown-menu-animated.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Mobile menu slide-in - OPT-IN ONLY */
.mobile-menu-animated {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

.mobile-menu-animated.open {
    transform: translateX(0);
}

/* ============================================
   LOADING ANIMATIONS
   ============================================ */

/* Spinner animation */
.spinner {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: currentColor;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Pulse animation for loading states */
.pulse-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* ============================================
   TEXT ANIMATIONS
   ============================================ */

/* Gradient text animation */
.text-gradient-animate {
    background: linear-gradient(90deg, #f59e0b, #ef4444, #8b5cf6, #3b82f6);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Typing animation */
.typing-animation {
    overflow: hidden;
    border-right: 2px solid;
    white-space: nowrap;
    animation: typing 3s steps(40) 1s 1 normal both, blink 0.75s step-end infinite;
}

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

/* ============================================
   STAGGER ANIMATIONS
   ============================================ */

/* Stagger children animations */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
    animation: staggerFadeIn 0.6s ease forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.6s; }

@keyframes staggerFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   PARALLAX EFFECTS
   ============================================ */

.parallax-slow {
    transition: transform 0.5s ease-out;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scroll-reveal,
    .scroll-reveal-left,
    .scroll-reveal-right,
    .scroll-reveal-scale {
        opacity: 1;
        transform: none;
    }
}

/* ============================================
   UTILITY ANIMATIONS
   ============================================ */

/* Shake animation for errors */
.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Success checkmark animation */
.checkmark {
    animation: checkmark 0.5s ease;
}

@keyframes checkmark {
    0% {
        transform: scale(0) rotate(45deg);
    }
    50% {
        transform: scale(1.2) rotate(45deg);
    }
    100% {
        transform: scale(1) rotate(45deg);
    }
}

/* Bounce animation */
.bounce-in {
    animation: bounceIn 0.6s ease;
}

@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);
    }
}

/* Slide up animation */
.slide-up {
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ============================================
   RIPPLE EFFECT
   ============================================ */

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ============================================
   INPUT FOCUS ANIMATIONS
   ============================================ */

.input-focused {
    transform: translateY(-2px);
    transition: transform 0.2s ease;
}

.input-focused label {
    color: #3b82f6;
    transition: color 0.2s ease;
}
