(function () {
  const backToTopButton = document.getElementById("back-to-top");

  if (backToTopButton) {
    function toggleBackToTop() {
      if (window.pageYOffset > 300) {
        backToTopButton.classList.add("visible");
      } else {
        backToTopButton.classList.remove("visible");
      }
    }

    backToTopButton.addEventListener("click", function () {
      window.scrollTo({
        top: 0,
        behavior: "smooth",
      });
    });

    window.addEventListener("scroll", toggleBackToTop);

    toggleBackToTop();
  }

  const listItems = document.querySelectorAll("li");
  listItems.forEach((item, index) => {
    if (!item.style.animationDelay) {
      item.style.animationDelay = `${0.1 + index * 0.05}s`;
    }
  });
})();
