/** * Back to Top Button Functionality * * Controls the visibility and behavior of the back to top button * based on scroll position. */ document.addEventListener('DOMContentLoaded', function() { const backToTopBtn = document.getElementById('back-to-top-btn'); if (!backToTopBtn) return; // Show/hide button based on scroll position window.addEventListener('scroll', function() { if (window.pageYOffset > 300) { backToTopBtn.classList.add('show'); } else { backToTopBtn.classList.remove('show'); } }); // Smooth scroll to top when clicked backToTopBtn.addEventListener('click', function(e) { e.preventDefault(); window.scrollTo({ top: 0, behavior: 'smooth' }); }); });