"use client";
import { ArrowUpRight, Check, Copy, Mail, MessagesSquare, Phone } from "lucide-react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
import { useEffect, useRef, useState, type ReactNode } from "react";
const ease = [0.22, 1, 0.36, 1] as const;
function CopyEmail({ email }: { email: string }) {
const [copied, setCopied] = useState(false);
const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
useEffect(() => () => void (timer.current && clearTimeout(timer.current)), []);
function copy() {
void navigator.clipboard?.writeText(email).catch(() => undefined);
setCopied(true);
timer.current = setTimeout(() => setCopied(false), 1800);
}
return (
<button
type="button"
onClick={copy}
className="flex w-full items-center justify-between gap-3 rounded-xl border border-border bg-background px-4 py-3 text-left font-mono text-sm text-foreground transition-colors hover:border-primary/50"
>
<span className="truncate">{email}</span>
<span className="relative flex size-5 shrink-0 items-center justify-center text-muted-foreground">
<AnimatePresence mode="wait" initial={false}>
<motion.span
key={copied ? "y" : "n"}
initial={{ scale: 0.4, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
exit={{ scale: 0.4, opacity: 0 }}
transition={{ duration: 0.15 }}
className={copied ? "text-emerald-500" : undefined}
>
{copied ? <Check className="size-4" strokeWidth={3} /> : <Copy className="size-4" />}
</motion.span>
</AnimatePresence>
<span className="sr-only">{copied ? "Copied" : "Copy email address"}</span>
</span>
</button>
);
}
function ChatPeek() {
return (
<div className="space-y-2 text-sm">
<p className="w-fit max-w-[85%] rounded-2xl rounded-bl-md bg-muted px-3.5 py-2 text-foreground">
Hi, I am Priya. What are you stuck on?
</p>
<p className="ml-auto w-fit max-w-[85%] rounded-2xl rounded-br-md bg-primary px-3.5 py-2 text-primary-foreground">
Webhooks retry twice?
</p>
<div className="flex w-fit items-center gap-1 rounded-2xl rounded-bl-md bg-muted px-3.5 py-3" aria-label="Priya is typing">
{[0, 1, 2].map((i) => (
<span
key={i}
className="size-1.5 rounded-full bg-muted-foreground motion-reduce:animate-none"
style={{ animation: `pp-contact-cards-channels-dot 1.2s ease-in-out ${i * 0.15}s infinite` }}
/>
))}
</div>
</div>
);
}
function VoiceLevels() {
const reduce = useReducedMotion();
const bars = [0.35, 0.7, 0.5, 0.95, 0.6, 0.8, 0.4, 0.9, 0.55, 0.75, 0.45, 0.85, 0.5, 0.65, 0.3, 0.7, 0.5, 0.9, 0.4, 0.6];
return (
<div className="flex h-[104px] items-center gap-[5px] rounded-xl border border-border bg-background px-4">
{bars.map((h, i) => (
<motion.span
key={i}
className="flex-1 rounded-full bg-primary/70"
initial={{ height: `${h * 60}%` }}
animate={reduce ? undefined : { height: [`${h * 60}%`, `${(1 - h) * 55 + 18}%`, `${h * 60}%`] }}
transition={{ duration: 1.1 + (i % 5) * 0.18, repeat: Infinity, ease: "easeInOut" }}
/>
))}
</div>
);
}
type Channel = { icon: typeof Mail; title: string; meta: string; body: string; cta: string; visual: ReactNode; live?: boolean };
const channels: Channel[] = [
{
icon: Mail,
title: "Email",
meta: "Replies in about 4 hours",
body: "Best for detailed questions, invoices and anything with attachments.",
cta: "Write to us",
visual: <CopyEmail email="[email protected]" />,
},
{
icon: MessagesSquare,
title: "Live chat",
meta: "3 people online now",
body: "Talk to the same support engineers who answer the hard tickets.",
cta: "Start a chat",
visual: <ChatPeek />,
live: true,
},
{
icon: Phone,
title: "Call",
meta: "Mon–Fri, 09:00–18:00 GMT",
body: "Prefer a voice? We pick up in under a minute, with no phone tree.",
cta: "+44 20 4587 0142",
visual: <VoiceLevels />,
},
];
export default function ContactCardsChannels() {
return (
<section className="w-full bg-background px-6 py-20">
<style>{`
@keyframes pp-contact-cards-channels-dot {
0%, 60%, 100% { transform: translateY(0); opacity: .4; }
30% { transform: translateY(-4px); opacity: 1; }
}
`}</style>
<div className="mx-auto max-w-6xl">
<div className="max-w-xl">
<h2 className="text-4xl font-semibold tracking-tight text-foreground sm:text-5xl">Reach a human, your way.</h2>
<p className="mt-4 text-lg text-muted-foreground">
Parcelbird support is seven people in Leeds. Pick whichever channel suits the problem.
</p>
</div>
<motion.div
initial="hidden"
whileInView="shown"
viewport={{ once: true, amount: 0.2 }}
transition={{ staggerChildren: 0.1 }}
className="mt-12 grid gap-5 lg:grid-cols-3"
>
{channels.map(({ icon: Icon, title, meta, body, cta, visual, live }) => (
<motion.article
key={title}
variants={{ hidden: { opacity: 0, y: 28 }, shown: { opacity: 1, y: 0, transition: { duration: 0.7, ease } } }}
whileHover={{ y: -6 }}
className="group flex flex-col rounded-3xl border border-border bg-card p-6 transition-shadow duration-300 hover:shadow-2xl hover:shadow-primary/10"
>
<div className="flex items-center justify-between">
<span className="flex size-11 items-center justify-center rounded-2xl bg-primary/10 text-primary transition-colors duration-300 group-hover:bg-primary group-hover:text-primary-foreground">
<Icon className="size-5" />
</span>
<span className="inline-flex items-center gap-1.5 rounded-full border border-border px-2.5 py-1 text-xs text-muted-foreground">
{live && (
<span className="relative flex size-1.5">
<span className="absolute inset-0 animate-ping rounded-full bg-emerald-500 motion-reduce:animate-none" />
<span className="relative size-1.5 rounded-full bg-emerald-500" />
</span>
)}
{meta}
</span>
</div>
<h3 className="mt-6 text-xl font-semibold tracking-tight text-card-foreground">{title}</h3>
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">{body}</p>
<div className="mt-6 flex flex-1 flex-col justify-end">{visual}</div>
<a
href="#"
className="mt-6 inline-flex items-center justify-between border-t border-border pt-4 text-sm font-medium text-foreground transition-colors hover:text-primary"
>
{cta}
<ArrowUpRight className="size-4 transition-transform duration-300 group-hover:translate-x-0.5 group-hover:-translate-y-0.5" />
</a>
</motion.article>
))}
</motion.div>
</div>
</section>
);
}