'use client'; import { useEffect, useState } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faBookOpen } from '@fortawesome/free-solid-svg-icons'; export function ReadingProgress() { const [mounted, setMounted] = useState(false); const [progress, setProgress] = useState(0); useEffect(() => { setMounted(true); }, []); useEffect(() => { if (!mounted) return; const handleScroll = () => { const { scrollTop, scrollHeight, clientHeight } = document.documentElement; const total = scrollHeight - clientHeight; if (total <= 0) { setProgress(0); return; } const value = Math.min(100, Math.max(0, (scrollTop / total) * 100)); setProgress(value); }; handleScroll(); window.addEventListener('scroll', handleScroll, { passive: true }); return () => window.removeEventListener('scroll', handleScroll); }, [mounted]); if (!mounted) return null; return (