100) {
navbar.classList.add("shadow-sm");
} else {
navbar.classList.remove("shadow-sm");
}
}
// Reading Progress Bar Logic
const progress = document.getElementById("reading-progress");
if (progress) {
const scrollTotal = document.documentElement.scrollHeight - window.innerHeight;
const scrollPos = window.scrollY;
const width = (scrollPos / scrollTotal) * 100;
progress.style.width = width + "%";
}
// Back to top button visibility
if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 300) {
mybutton.classList.remove("d-none");
} else {
mybutton.classList.add("d-none");
}
};
mybutton.addEventListener("click", function () {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
});