/** * Lightweight scroll reveal using IntersectionObserver. * Respects prefers-reduced-motion. */ document.documentElement.classList.add('js-loaded'); function initScrollReveal() { if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return; const elements = document.querySelectorAll('[data-reveal]'); if (!elements.length) return; const observer = new IntersectionObserver( (entries) => { entries.forEach((entry) => { entry.target.classList.toggle('revealed', entry.isIntersecting); }); }, { threshold: 0.15, rootMargin: '0px 0px -40px 0px', }, ); elements.forEach((el) => observer.observe(el)); } document.addEventListener('DOMContentLoaded', initScrollReveal);