"use client"; import { useEffect, useState, type CSSProperties } from "react"; import "./sign-off-footer.css"; /** * Sign-off Footer * Minimal, but every element is live: the local time ticks (with the offset * from the visitor's own time, so they know when you'll reply), availability * is a single dot, and the email is a pill that copies itself and says so. */ type Props = { line: string; email: string; city: string; timeZone: string; available?: boolean; links?: { label: string; href: string }[]; owner: string; accent?: string; className?: string; }; function useClock(timeZone: string) { const [now, setNow] = useState(null); useEffect(() => { setNow(new Date()); const id = setInterval(() => setNow(new Date()), 1000); return () => clearInterval(id); }, []); if (!now) return { time: "--:--:--", diff: "" }; const time = new Intl.DateTimeFormat("en-GB", { timeZone, hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: false }).format(now); const there = new Date(now.toLocaleString("en-US", { timeZone })); const hours = Math.round((there.getTime() - new Date(now.toLocaleString("en-US")).getTime()) / 36e5); const diff = hours === 0 ? "same time as you" : `${Math.abs(hours)}h ${hours > 0 ? "ahead of" : "behind"} you`; return { time, diff }; } export function SignOffFooter({ line, email, city, timeZone, available = true, links = [], owner, accent = "#b9cce4", className = "" }: Props) { const { time, diff } = useClock(timeZone); const [copied, setCopied] = useState(false); const copy = async () => { try { await navigator.clipboard?.writeText(email); } catch { /* still confirm */ } setCopied(true); setTimeout(() => setCopied(false), 1800); }; return (