// Custom JS for the theme document.addEventListener('DOMContentLoaded', function() { // Smooth scroll for anchor links const links = document.querySelectorAll('a[href^="#"]'); links.forEach(link => { link.addEventListener('click', function(e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); // Back to top button const backToTopButton = document.createElement('button'); backToTopButton.textContent = "↑"; backToTopButton.classList.add('back-to-top'); document.body.appendChild(backToTopButton); backToTopButton.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth' }); }); window.addEventListener('scroll', () => { if (window.scrollY > 200) { backToTopButton.classList.add('visible'); } else { backToTopButton.classList.remove('visible'); } }); });