import React, { useEffect, useMemo, useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; const EMAIL_TO = "ns@soulcorridor.ai"; // Put the image file in /public/eye-corridor.jpg for Next.js to serve at /eye-corridor.jpg const BACKGROUND_URL = "/eye-corridor.jpg"; const QUESTIONS = [ "What do you think humanity has forgotten?", "What still brings you a sense of wonder?", "When do you feel most like yourself?", ]; export default function SoulCorridorOnePager() { useEffect(() => { // Fonts const link = document.createElement("link"); link.href = "https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=Inter:wght@300;400;600&display=swap"; link.rel = "stylesheet"; document.head.appendChild(link); // Preload background for iOS Safari first paint const preload = document.createElement("link"); preload.rel = "preload"; preload.as = "image"; preload.href = BACKGROUND_URL; document.head.appendChild(preload); return () => { document.head.removeChild(link); document.head.removeChild(preload); }; }, []); const [email, setEmail] = useState(""); const [started, setStarted] = useState(false); const [answers, setAnswers] = useState(["", "", ""]); const [currentIndex, setCurrentIndex] = useState(0); const [note, setNote] = useState(""); const [status, setStatus] = useState<"idle" | "sending" | "sent" | "error">("idle"); const [errorMsg, setErrorMsg] = useState(null); const startFlow = () => { if (!/.+@.+\..+/.test(email)) return; setStarted(true); }; const goNext = () => setCurrentIndex((i) => Math.min(i + 1, QUESTIONS.length - 1)); const goPrev = () => setCurrentIndex((i) => Math.max(i - 1, 0)); const updateAnswer = (value: string) => { setAnswers((prev) => { const copy = [...prev]; copy[currentIndex] = value; return copy; }); }; const canSend = useMemo(() => { const emailOk = /.+@.+\..+/.test(email); const haveAny = answers.some((a) => a.trim().length > 0) || note.trim().length > 0; return emailOk && haveAny; }, [email, answers, note]); const handleSubmit = async () => { if (!canSend) return; setStatus("sending"); setErrorMsg(null); const payload = { email, answers: QUESTIONS.map((q, i) => ({ question: q, answer: answers[i] || "" })), note: note.trim(), to: EMAIL_TO, pageTag: "SoulCorridorOnePager", ts: new Date().toISOString(), }; try { const res = await fetch("/api/submit", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload), }); if (res.ok) { setStatus("sent"); } else { throw new Error(`Server responded ${res.status}`); } } catch (err) { console.error(err); try { const subject = encodeURIComponent("Soul Corridor — New Entry"); const body = encodeURIComponent(JSON.stringify(payload, null, 2)); window.location.href = `mailto:${EMAIL_TO}?subject=${subject}&body=${body}`; setStatus("sent"); } catch (e) { setStatus("error"); setErrorMsg("Could not send. Please try again or email us directly."); } } }; return (
{/* Floating faded background */} {/* Radial dark veil to keep copy readable */}
{!started ? ( <> If you have been wandering too long, sit.
setEmail(e.target.value)} onKeyDown={(e) => e.key === "Enter" && startFlow()} placeholder="Whatever Email" className="w-full rounded-xl border border-[#C3A35D]/50 bg-transparent px-4 py-3 text-center text-[#F5F5F5] placeholder:text-[#C3A35D]/80 focus:outline-none focus:ring-2 focus:ring-[#C3A35D]/40" style={{ fontFamily: "Inter, system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial" }} />
) : status === "sent" ? (

Received.

Your light has entered the corridor.

) : (
{QUESTIONS.map((_, i) => (

{QUESTIONS[currentIndex]}