/* ========================================
   AWESOME SCROLL EXPERIENCE
   Agricultural Theme with Dynamic Backgrounds
   ======================================== */

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Body with transition for background changes */
body {
    transition: background 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow-x: hidden;
    /* Optimize for mobile scrolling */
    -webkit-overflow-scrolling: touch;
}

/* Animated background layers */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    opacity: 0;
    transition: opacity 1.5s ease;
}

/* Scroll-based background classes */
body.scroll-stage-1 {
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 50%, #e8f5e9 100%);
}

body.scroll-stage-2 {
    background: linear-gradient(135deg, #c8e6c9 0%, #dcedc8 50%, #c8e6c9 100%);
}

body.scroll-stage-3 {
    background: linear-gradient(135deg, #a5d6a7 0%, #c5e1a5 50%, #a5d6a7 100%);
}

body.scroll-stage-4 {
    background: linear-gradient(135deg, #81c784 0%, #aed581 50%, #81c784 100%);
}

body.scroll-stage-5 {
    background: linear-gradient(135deg, #66bb6a 0%, #9ccc65 50%, #66bb6a 100%);
}

/* Floating particles animation */
.scroll-particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    background: rgba(76, 175, 80, 0.15);
    border-radius: 50%;
    animation: floatParticle 20s infinite ease-in-out;
}

.particle:nth-child(1) {
    width: 80px;
    height: 80px;
    left: 10%;
    animation-delay: 0s;
    animation-duration: 25s;
}

.particle:nth-child(2) {
    width: 60px;
    height: 60px;
    left: 30%;
    animation-delay: 2s;
    animation-duration: 20s;
}

.particle:nth-child(3) {
    width: 100px;
    height: 100px;
    left: 50%;
    animation-delay: 4s;
    animation-duration: 30s;
}

.particle:nth-child(4) {
    width: 70px;
    height: 70px;
    left: 70%;
    animation-delay: 6s;
    animation-duration: 22s;
}

.particle:nth-child(5) {
    width: 90px;
    height: 90px;
    left: 85%;
    animation-delay: 8s;
    animation-duration: 28s;
}

@keyframes floatParticle {
    0%, 100% {
        transform: translateY(100vh) translateX(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.3;
    }
    50% {
        transform: translateY(-10vh) translateX(50px) rotate(180deg);
        opacity: 0.5;
    }
    90% {
        opacity: 0.3;
    }
}

/* Leaf elements */
.scroll-leaf {
    position: absolute;
    width: 40px;
    height: 40px;
    object-fit: contain;
    opacity: 0.3;
    animation: leafFall 15s infinite ease-in-out;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.scroll-leaf:nth-child(6) {
    left: 15%;
    animation-delay: 0s;
    animation-duration: 18s;
}

.scroll-leaf:nth-child(7) {
    left: 45%;
    animation-delay: 4s;
    animation-duration: 16s;
}

.scroll-leaf:nth-child(8) {
    left: 75%;
    animation-delay: 8s;
    animation-duration: 20s;
}

@keyframes leafFall {
    0% {
        transform: translateY(-100px) rotate(0deg) scale(1);
        opacity: 0;
    }
    10% {
        opacity: 0.4;
    }
    50% {
        transform: translateY(50vh) rotate(180deg) scale(1.1);
        opacity: 0.5;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(100vh) rotate(360deg) scale(0.9);
        opacity: 0;
    }
}

/* Mobile-optimized leaf animation */
@media (max-width: 768px) {
    @keyframes leafFall {
        0% {
            transform: translateY(-50px) rotate(0deg);
            opacity: 0;
        }
        20% {
            opacity: 0.3;
        }
        80% {
            opacity: 0.3;
        }
        100% {
            transform: translateY(100vh) rotate(180deg);
            opacity: 0;
        }
    }
}

/* Fade-in animations for sections */
.fade-in-section {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.fade-in-section.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Slide-in from left */
.slide-in-left {
    opacity: 0;
    transform: translateX(-100px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.slide-in-left.is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Slide-in from right */
.slide-in-right {
    opacity: 0;
    transform: translateX(100px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.slide-in-right.is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Scale-in animation */
.scale-in {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.scale-in.is-visible {
    opacity: 1;
    transform: scale(1);
}

/* Parallax effect for sections */
.parallax-section {
    position: relative;
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}

/* Scroll progress indicator */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: linear-gradient(90deg, #4caf50 0%, #8bc34a 50%, #cddc39 100%);
    z-index: 9999;
    transition: width 0.1s ease;
    box-shadow: 0 2px 10px rgba(76, 175, 80, 0.5);
}

/* Pulse effect on scroll */
@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
    }
    50% {
        box-shadow: 0 0 30px rgba(76, 175, 80, 0.6);
    }
}

.scroll-progress.scrolling {
    animation: pulseGlow 1s ease-in-out infinite;
}

/* Smooth transitions for all sections */
section {
    position: relative;
    z-index: 1;
}

/* Card hover effects enhanced */
.card {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

/* Stagger animation for lists */
.stagger-animation > * {
    opacity: 0;
    transform: translateY(30px);
    animation: staggerFadeIn 0.6s ease-out forwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.6s; }

@keyframes staggerFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    /* Disable particles completely on mobile */
    .particle {
        display: none !important;
    }
    
    /* Optimize leaf animations for mobile */
    .scroll-leaf {
        width: 25px !important;
        height: 25px !important;
        opacity: 0.3;
        animation-duration: 12s !important; /* Faster animation */
        will-change: transform; /* Optimize for animations */
    }
    
    /* Simpler animations for mobile */
    .fade-in-section,
    .slide-in-left,
    .slide-in-right,
    .scale-in {
        transform: translateY(15px);
        transition-duration: 0.5s; /* Faster transitions */
    }
    
    .slide-in-left {
        transform: translateX(-30px); /* Less movement */
    }
    
    .slide-in-right {
        transform: translateX(30px); /* Less movement */
    }
    
    .scale-in {
        transform: scale(0.9); /* Less scaling */
    }
    
    /* Optimize progress bar for mobile */
    .scroll-progress {
        height: 3px;
        transition-duration: 0.2s; /* Faster updates */
    }
    
    /* Disable complex animations on mobile */
    .scroll-progress.scrolling {
        animation: none; /* Remove glow animation on mobile */
    }
    
    /* Optimize background transitions */
    body {
        transition-duration: 1s; /* Faster background changes */
    }
    
    /* Reduce card hover effects on mobile */
    .card:hover {
        transform: translateY(-5px) scale(1.01); /* Less dramatic effect */
    }
    
    /* Optimize stagger animations */
    .stagger-animation > * {
        animation-duration: 0.4s; /* Faster stagger */
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    
    body,
    body::before,
    .fade-in-section,
    .slide-in-left,
    .slide-in-right,
    .scale-in,
    .card,
    .particle,
    .scroll-leaf {
        animation: none !important;
        transition: none !important;
    }
    
    .scroll-progress {
        animation: none !important;
    }
}

/* Print styles */
@media print {
    .scroll-particles,
    .scroll-progress,
    .particle,
    .scroll-leaf {
        display: none !important;
    }
    
    body {
        background: white !important;
    }
}
