let onScroll = null; export function init() { const bar = document.querySelector('.site-progress'); const nav = document.getElementById('site-nav'); onScroll = () => { const max = document.documentElement.scrollHeight - window.innerHeight; const p = max > 0 ? window.scrollY / max : 1; if (bar) bar.style.transform = `scaleX(${p})`; nav?.classList.toggle('scrolled', window.scrollY > 8); }; window.addEventListener('scroll', onScroll, { passive: true }); onScroll(); } export function destroy() { if (onScroll) window.removeEventListener('scroll', onScroll); onScroll = null; }