document.addEventListener("DOMContentLoaded", function () {
const btn = document.getElementById("scrollTopBtn");
if (!btn) return;
// Show / hide button based on scroll position
window.addEventListener("scroll", function () {
if (window.scrollY > 300) {
btn.classList.add("show");
} else {
btn.classList.remove("show");
}
});
// Scroll to top when clicked
btn.addEventListener("click", function () {
window.scrollTo({
top: 0,
behavior: "smooth"
});
});
});