document.addEventListener('DOMContentLoaded', function() { // 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' }); }); }); // Fade-in elements on scroll const fadeInElements = document.querySelectorAll('.fade-in'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('is-visible'); } else { // Optional: remove class when element scrolls out of view // entry.target.classList.remove('is-visible'); } }); }, { threshold: 0.1 // Trigger when 10% of the element is visible }); fadeInElements.forEach(element => { observer.observe(element); }); });