50);
// Never hide the nav while the mobile menu is open.
if (mobileMenuOpen) { navHidden = false; lastScrollY = y; return; }
// Keep nav visible near the top.
if (y < 40) { navHidden = false; lastScrollY = y; return; }
// Add a small threshold to avoid jitter on tiny scroll movements.
if (Math.abs(y - lastScrollY) < 8) return;
navHidden = (y > lastScrollY);
lastScrollY = y;
">