document.addEventListener("DOMContentLoaded", function () { const header = document.querySelector(".custom-header"); if (!header) return; let lastScrollY = window.scrollY; const thresholdTop = 80; const delta = 12; function handleScroll() { const currentScrollY = window.scrollY; const difference = currentScrollY - lastScrollY; if (currentScrollY ≤ thresholdTop) { header.classList.remove("scrolled-down"); lastScrollY = currentScrollY; return; } if (difference ≥ delta) { header.classList.add("scrolled-down"); lastScrollY = currentScrollY; return; } if (difference ≤ -delta) { header.classList.remove("scrolled-down"); lastScrollY = currentScrollY; return; } } window.addEventListener("scroll", handleScroll, { passive: true }); });