/**
 * Animations Stylesheet
 * GSAP configurations, transitions, and micro-interactions
 */

/* =========================================
   KEYFRAME ANIMATIONS
   ========================================= */

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

/* Fade In Up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Down */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scale In */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* Slide In Left */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* Pulse */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Slow Pulse for backgrounds */
@keyframes pulse-slow {
    0%, 100% {
        opacity: 0.15;
        transform: scale(1);
    }
    50% {
        opacity: 0.25;
        transform: scale(1.05);
    }
}

.animate-pulse-slow {
    animation: pulse-slow 8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Shimmer (for loading states) */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

/* Gold Gradient Shine */
@keyframes goldShine {
    to {
        background-position: 200% center;
    }
}

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

/* =========================================
   ANIMATION CLASSES
   ========================================= */

/* Fade animations */
.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.6s ease-out forwards;
}

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

/* Slide animations */
.animate-slide-in-right {
    animation: slideInRight 0.6s ease-out forwards;
}

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

/* Bounce animation */
.animate-bounce {
    animation: bounce 2s infinite;
}

/* Pulse animation */
.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* =========================================
   LOADING STATES
   ========================================= */

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

.skeleton-text {
    height: 1rem;
    border-radius: var(--radius-sm);
}

.skeleton-title {
    height: 2rem;
    border-radius: var(--radius-sm);
    width: 60%;
}

.skeleton-image {
    height: 200px;
    border-radius: var(--radius-base);
}

/* =========================================
   PAGE TRANSITIONS
   ========================================= */

.page-transition-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-transition-enter-active {
    opacity: 1;
    transform: translateX(0) translateY(0);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-transition-exit {
    opacity: 1;
    transform: translateX(0) translateY(0);
}

.page-transition-exit-active {
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Mobile swipe transitions */
@media (max-width: 767px) {
    .page-transition-enter {
        transform: translateX(100%);
    }

    .page-transition-enter-active {
        transform: translateX(0);
    }

    .page-transition-exit-active {
        transform: translateX(-100%);
    }
}

/* =========================================
   SCROLL ANIMATIONS
   ========================================= */

/* Elements that animate on scroll */
.scroll-reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Parallax elements */
.parallax {
    will-change: transform;
}

/* =========================================
   HOVER & INTERACTION EFFECTS
   ========================================= */

/* Ripple Effect for buttons - Enhanced */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.2) 50%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.7s cubic-bezier(0.34, 1.56, 0.64, 1), height 0.7s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.5s ease;
    opacity: 0;
}

.ripple:active::after {
    width: 400px;
    height: 400px;
    opacity: 1;
}

/* Smooth Lift on Hover */
.lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

/* Grow on Hover */
.grow {
    transition: transform var(--transition-base);
}

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

/* Glow Effect - Enhanced */
.glow {
    transition: all var(--transition-slow);
    position: relative;
}

.glow::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: var(--gradient-gold-shine);
    background-size: 300% 300%;
    border-radius: inherit;
    opacity: 0;
    z-index: -1;
    filter: blur(15px);
    transition: opacity var(--transition-slow);
}

.glow:hover {
    box-shadow: 0 0 30px rgba(197, 160, 89, 0.8), 0 0 60px rgba(197, 160, 89, 0.4);
}

.glow:hover::before {
    opacity: 0.7;
    animation: goldShine 3s linear infinite;
}

/* Icon Spin on Hover */
.icon-spin-hover:hover {
    animation: rotate 0.6s ease;
}

/* =========================================
   HERO SECTION ANIMATIONS
   ========================================= */

.hero-anim {
    opacity: 0;
    transform: translateY(30px);
}

.hero-anim.animated {
    animation: fadeInUp 1s ease-out forwards;
}

/* Scroll Indicator */
.scroll-indicator {
    animation: bounce 2s infinite;
}

/* =========================================
   MOBILE TOUCH FEEDBACK
   ========================================= */

/* Touch ripple effect */
.touch-ripple {
    position: relative;
    overflow: hidden;
}

.touch-ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(197, 160, 89, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.5s ease, height 0.5s ease, opacity 0.5s ease;
    opacity: 0;
}

.touch-ripple:active::before {
    width: 200px;
    height: 200px;
    opacity: 1;
}

/* Touch scale feedback */
.touch-scale {
    transition: transform 0.1s ease;
}

.touch-scale:active {
    transform: scale(0.95);
}

/* =========================================
   GSAP ANIMATION HELPERS
   ========================================= */

/* Will-change for performance */
.will-animate {
    will-change: transform, opacity;
}

/* Hardware acceleration */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* =========================================
   SPECIAL EFFECTS
   ========================================= */

/* Gradient Text Animation */
.gradient-text-animated {
    background: linear-gradient(
        90deg,
        var(--color-gold-primary),
        var(--color-gold-light),
        var(--color-gold-primary),
        var(--color-gold-light)
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: goldShine 3s linear infinite;
}

/* Blur fade in */
.blur-in {
    filter: blur(10px);
    opacity: 0;
    animation: blurIn 0.8s ease forwards;
}

@keyframes blurIn {
    to {
        filter: blur(0);
        opacity: 1;
    }
}

/* Typewriter effect */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--color-gold-primary);
    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; }
}

/* =========================================
   REDUCED MOTION
   ========================================= */

/* =========================================
   ADVANCED ANIMATION EFFECTS
   ========================================= */

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

.float {
    animation: float 3s ease-in-out infinite;
}

/* Smooth Fade Scale In */
@keyframes fadeScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.animate-fade-scale-in {
    animation: fadeScaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Gradient Shift */
@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.animate-gradient {
    background-size: 200% 200%;
    animation: gradientShift 5s ease infinite;
}

/* Smooth Border Draw */
@keyframes borderDraw {
    0% {
        stroke-dashoffset: 1000;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

/* Magnetic Hover Effect */
.magnetic {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Tilt Effect */
.tilt {
    transition: transform 0.3s ease;
}

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

/* Shimmer Text */
@keyframes shimmerText {
    0% {
        background-position: -500%;
    }
    100% {
        background-position: 500%;
    }
}

.text-shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.2) 0%,
        rgba(197, 160, 89, 0.8) 20%,
        rgba(255, 255, 255, 0.2) 40%,
        rgba(197, 160, 89, 0.8) 60%,
        rgba(255, 255, 255, 0.2) 80%,
        rgba(197, 160, 89, 0.8) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmerText 3s linear infinite;
}

/* =========================================
   REDUCED MOTION
   ========================================= */

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

    .parallax {
        transform: none !important;
    }

    .scroll-reveal {
        opacity: 1 !important;
        transform: none !important;
    }

    .float,
    .animate-gradient,
    .text-shimmer {
        animation: none !important;
    }
}

/* =========================================
   MOBILE MENU ANIMATIONS
   ========================================= */

/* Body state when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Slide in from right animation */
@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Slide in from bottom animation */
@keyframes slideInFromBottom {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scale up animation */
@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Glow pulse animation */
@keyframes glowPulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

/* Menu item hover shimmer */
@keyframes menuShimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 200%;
    }
}

/* =========================================
   MORPHING NAVBAR ANIMATIONS
   ========================================= */

/* Gradient flow animation for border */
@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Breathing glow animation for morphed navbar */
@keyframes breathingGlow {
    0%, 100% {
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.35),
            0 0 0 1px rgba(255, 255, 255, 0.05) inset,
            0 0 40px rgba(197, 160, 89, 0.08);
    }
    50% {
        box-shadow: 
            0 8px 32px rgba(0, 0, 0, 0.35),
            0 0 0 1px rgba(255, 255, 255, 0.05) inset,
            0 0 60px rgba(197, 160, 89, 0.15);
    }
}

/* Shimmer sweep animation for buttons */
@keyframes shimmerSweep {
    0% {
        left: -100%;
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        left: 200%;
        opacity: 0;
    }
}

/* Donate button pulse animation */
@keyframes donatePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(197, 160, 89, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(197, 160, 89, 0);
    }
}

/* Navbar morph entrance animation */
@keyframes navbarMorphIn {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* Navbar unmorph animation (return to full width) */
@keyframes navbarUnmorph {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Active indicator slide animation */
@keyframes indicatorSlide {
    0% {
        transform: scaleX(0.8);
        opacity: 0;
    }
    100% {
        transform: scaleX(1);
        opacity: 1;
    }
}

/* Progress bar glow pulse */
@keyframes progressGlow {
    0%, 100% {
        box-shadow: 0 0 8px rgba(197, 160, 89, 0.4);
    }
    50% {
        box-shadow: 0 0 16px rgba(197, 160, 89, 0.6);
    }
}

/* Gold border spin (for special states) */
@keyframes borderSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Navbar entrance animation class */
.navbar-morph-enter {
    animation: navbarMorphIn 500ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Navbar breathing glow class */
.navbar-container.morphed.breathing {
    animation: breathingGlow 4s ease-in-out infinite;
}

/* Progress bar active state */
.navbar-progress-fill.active {
    animation: progressGlow 2s ease-in-out infinite;
}

/* =========================================
   MORPHING NAVBAR - REDUCED MOTION
   ========================================= */

@media (prefers-reduced-motion: reduce) {
    .navbar-container,
    .navbar-container.morphed,
    .navbar-gradient-border,
    .navbar-progress-fill,
    .navbar-active-indicator,
    .nav-link,
    .btn-donate,
    .logo-icon,
    .logo-text {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
    
    /* Keep essential visibility transitions */
    .navbar-container.morphed {
        transform: translateX(-50%);
    }
}
