window.addEventListener("load", function () { const loginBtn = document.querySelector(".navbar_login"); if (!loginBtn) return; const DESKTOP_BREAKPOINT = 992; function getSectionAtNavbar() { const sections = document.querySelectorAll("[data-nav-theme]"); let found = null; sections.forEach(function (section) { const rect = section.getBoundingClientRect(); if (rect.top <= 120 && rect.bottom >= 60) { found = section; } }); return found; } function updateLoginColor() { if (window.innerWidth < DESKTOP_BREAKPOINT) { loginBtn.style.removeProperty("color"); return; } const section = getSectionAtNavbar(); const theme = section ? section.getAttribute("data-nav-theme") : "dark"; loginBtn.style.setProperty("color", theme === "light" ? "#171717" : "#f6f3ec", "important"); } updateLoginColor(); window.addEventListener("scroll", updateLoginColor, { passive: true }); window.addEventListener("resize", updateLoginColor, { passive: true }); });