// Smooth scroll for anchor links document.addEventListener('click', function(e) { if (e.target.matches('a[href^="#"]')) { e.preventDefault(); const target = document.querySelector(e.target.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth' }); } } }); // Intersection Observer for animations const animateOnScroll = () => { const elements = document.querySelectorAll('.animate'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('animate-visible'); } }); }, { threshold: 0.1 }); elements.forEach(el => observer.observe(el)); }; // Mobile menu toggle const setupMobileMenu = () => { const menuBtn = document.querySelector('.mobile-menu-btn'); const mobileMenu = document.querySelector('.mobile-menu'); if (menuBtn && mobileMenu) { menuBtn.addEventListener('click', () => { const isOpen = mobileMenu.style.display === 'flex'; mobileMenu.style.display = isOpen ? 'none' : 'flex'; }); } }; // Initialize all functions document.addEventListener('DOMContentLoaded', () => { animateOnScroll(); setupMobileMenu(); });