document.addEventListener("DOMContentLoaded", function() {
    // 1. Change Navbar on Scroll
    window.addEventListener('scroll', function() {
        const nav = document.querySelector('.navbar');
        if (!nav) return;
        if (window.scrollY > 80) {
            nav.classList.add('scrolled');
        } else {
            nav.classList.remove('scrolled');
        }
    });

    // 2. Smooth Scrolling for Nav Links
    document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function (e) {
            e.preventDefault();
            document.querySelector(this.getAttribute('href')).scrollIntoView({
                behavior: 'smooth'
            });
        });
    });

    // 3. Simple Card Animation Trigger
    const observerOptions = {
        threshold: 0.1
    };

    const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
            if (entry.isIntersecting) {
                entry.target.classList.add('animate__fadeInUp');
                entry.target.style.opacity = "1";
            }
        });
    }, observerOptions);

    document.querySelectorAll('.disease-card').forEach(card => {
        card.style.opacity = "0"; // Start hidden
        card.classList.add('animate__animated');
        observer.observe(card);
    });
});