document.addEventListener("DOMContentLoaded", function () {
let header = document.querySelector(".whb-main-header");
function updateHeader() {
if (window.scrollY > 50) {
// Sticky mode
header.style.background = "rgba(255, 255, 255, 0.95)";
header.style.color = "black";
header.querySelectorAll("a").forEach(link => link.style.color = "black");
} else {
// Stato iniziale
header.style.background = "linear-gradient(to bottom, rgba(51, 51, 51, 0.7), rgba(51, 51, 51, 0))";
header.style.color = "white";
header.querySelectorAll("a").forEach(link => link.style.color = "white");
}
}
header.addEventListener("mouseenter", function () {
if (window.scrollY <= 50) {
header.style.background = "white";
header.style.color = "black";
header.querySelectorAll("a").forEach(link => link.style.color = "black");
}
});
header.addEventListener("mouseleave", function () {
if (window.scrollY <= 50) {
header.style.background = "linear-gradient(to bottom, rgba(51, 51, 51, 0.7), rgba(51, 51, 51, 0))";
header.style.color = "white";
header.querySelectorAll("a").forEach(link => link.style.color = "white");
}
});
window.addEventListener("scroll", updateHeader);
updateHeader();
});