/** * ScrollToTop — fixed ↑ button that appears after scrolling down. * Smooth-scrolls back to the top when clicked. */ 'use client'; import { useState, useEffect } from 'react'; const SHOW_THRESHOLD = 300; export function ScrollToTop() { const [visible, setVisible] = useState(false); useEffect(() => { const onScroll = () => { setVisible(window.scrollY > SHOW_THRESHOLD); }; window.addEventListener('scroll', onScroll, { passive: true }); return () => window.removeEventListener('scroll', onScroll); }, []); const scrollToTop = () => { window.scrollTo({ top: 0, behavior: 'smooth' }); }; return ( ); }