"use client"; import { useEffect, useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { ArrowUpRight } from "lucide-react"; import { useLanguage } from "@/components/LanguageContext"; import { useSplitFlapAudio } from "@/components/ui/split-flap-text"; export function FloatingCTA() { const { t } = useLanguage(); const audio = useSplitFlapAudio(); const [isVisible, setIsVisible] = useState(false); useEffect(() => { const handleScroll = () => { // Show button when user scrolls down more than 600px if (window.scrollY > 600) { setIsVisible(true); } else { setIsVisible(false); } }; window.addEventListener("scroll", handleScroll, { passive: true }); return () => { window.removeEventListener("scroll", handleScroll); }; }, []); const handleClick = () => { // Play satisfying mechanical click sound if (audio && !audio.isMuted) { audio.playClick(); } // Smooth scroll back to top to the waitlist input const inputElement = document.getElementById("email-input"); if (inputElement) { inputElement.scrollIntoView({ behavior: "smooth", block: "center" }); setTimeout(() => { inputElement.focus(); }, 850); } else { window.scrollTo({ top: 0, behavior: "smooth" }); } }; return ( {isVisible && ( {t("accessHubapi")} )} ); }