/* Custom animations */
@keyframes blob {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -40px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}
@keyframes blob2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-40px, 30px) scale(1.05); }
    66% { transform: translate(25px, -15px) scale(0.95); }
}
@keyframes blob3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(20px, 25px) scale(1.08); }
    66% { transform: translate(-15px, -20px) scale(0.92); }
}
.animate-blob { animation: blob 8s ease-in-out infinite; }
.animate-blob2 { animation: blob2 10s ease-in-out infinite; }
.animate-blob3 { animation: blob3 9s ease-in-out infinite; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
    .card-hover { transition: none !important; }
    .card-hover:hover { transform: none !important; }
    .animate-blob, .animate-blob2, .animate-blob3 { animation: none !important; }
}
</style>

<sm-file path="script.js">
(function () {
    'use strict';

    // ── Mobile menu ──────────────────────────────────────────
    const menuBtn = document.getElementById('menuBtn');
    const mobileMenu = document.getElementById('mobileMenu');
    const menuIconOpen = document.getElementById('menuIconOpen');
    const menuIconClose = document.getElementById('menuIconClose');
    const mobileLinks = mobileMenu.querySelectorAll('a');

    menuBtn.addEventListener('click', function () {
        const isOpen = !mobileMenu.classList.contains('hidden');
        mobileMenu.classList.toggle('hidden');
        menuIconOpen.classList.toggle('hidden');
        menuIconClose.classList.toggle('hidden');
    });

    mobileLinks.forEach(function (link) {
        link.addEventListener('click', function () {
            mobileMenu.classList.add('hidden');
            menuIconOpen.classList.remove('hidden');
            menuIconClose.classList.add('hidden');
        });
    });

    // ── Navbar scroll effect ─────────────────────────────────
    const navbar = document.getElementById('navbar');
    let lastScroll = 0;

    function updateNavbar() {
        const scrollY = window.scrollY;
        if (scrollY > 60) {
            navbar.classList.add('nav-scrolled');
        } else {
            navbar.classList.remove('nav-scrolled');
        }
        lastScroll = scrollY;
    }

    window.addEventListener('scroll', updateNavbar, { passive: true });
    updateNavbar();

    // ── Smooth scroll for anchor links ───────────────────────
    document.querySelectorAll('a[href^="#"]').forEach(function (anchor) {
        anchor.addEventListener('click', function (e) {
            const target = document.querySelector(this.getAttribute('href'));
            if (target) {
                e.preventDefault();
                const offset = 80;
                const top = target.getBoundingClientRect().top + window.scrollY - offset;
                window.scrollTo({ top: top, behavior: 'smooth' });
            }
        });
    });

    // ── Scroll reveal (below-the-fold only, progressive enhancement) ─
    if (window.matchMedia('(prefers-reduced-motion: no-preference)').matches) {
        const reveals = document.querySelectorAll('.reveal');

        const observer = new IntersectionObserver(function (entries) {
            entries.forEach(function (entry) {
                if (entry.isIntersecting) {
                    entry.target.classList.add('revealed');
                    observer.unobserve(entry.target);
                }
            });
        }, {
            threshold: 0.12,
            rootMargin: '0px 0px -40px 0px'
        });

        reveals.forEach(function (el) {
            el.style.opacity = '0';
            el.style.transform = 'translateY(28px)';
            el.style.transition = 'opacity 0.7s cubic-bezier(.4,0,.2,1), transform 0.7s cubic-bezier(.4,0,.2,1)';
            observer.observe(el);
        });
    } else {
        // If reduced-motion is preferred, show everything immediately
        document.querySelectorAll('.reveal').forEach(function (el) {
            el.classList.add('revealed');
        });
    }
})();
</script>
