export function initMobileBackToTop(){ const backToTopButton = document.querySelector('.back-to-top'); const content = document.getElementById('content'); if (!backToTopButton || !content) { return; } const toggleBackToTop = () => { const shouldShow = window.innerWidth <= 768 && content.scrollTop > 320; backToTopButton.classList.toggle('visible', shouldShow); }; toggleBackToTop(); content.addEventListener('scroll', toggleBackToTop, { passive: true }); window.addEventListener('resize', toggleBackToTop, { passive: true }); }