// Handle navigation for all links document.querySelectorAll('a').forEach(anchor => { // Skip if it's an external link or has a different protocol if (anchor.href && anchor.href.startsWith(window.location.origin)) { anchor.addEventListener('click', function(e) { // Only prevent default for anchor links if (this.getAttribute('href').startsWith('#')) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); } // Allow normal navigation for other internal links }); } }); document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); // Intersection Observer for animations const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('animate-fadeIn'); observer.unobserve(entry.target); } }); }, { threshold: 0.1, rootMargin: '0px 0px -100px 0px' }); document.querySelectorAll('[class*="animate-"]').forEach(el => { observer.observe(el); }); // Better mobile menu toggle (for future implementation) function setupMobileMenu() { const menuButton = document.querySelector('[aria-controls="mobile-menu"]'); if (menuButton) { const menu = document.getElementById('mobile-menu'); menuButton.addEventListener('click', () => { const expanded = menuButton.getAttribute('aria-expanded') === 'true'; menuButton.setAttribute('aria-expanded', !expanded); menu.classList.toggle('hidden'); }); } } // Initialize when DOM is loaded document.addEventListener('DOMContentLoaded', () => { setupMobileMenu(); // Replace icons in main document feather.replace(); // Replace icons in any existing custom elements document.querySelectorAll('custom-navbar, custom-footer').forEach(el => { if (el.shadowRoot) { const icons = el.shadowRoot.querySelectorAll('[data-feather]'); icons.forEach(icon => { feather.replace(icon); }); } }); });