"use client";
import { Check, LoaderCircle, Mic, Sparkles } from "lucide-react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
import { useEffect, useState, type ReactNode } from "react";
import { cn } from "@/lib/utils";
const ease = [0.22, 1, 0.36, 1] as const;
/** Counts 0…max on an interval, rests for `rest` ticks at the end, then loops. */
function useLoop(max: number, ms: number, rest: number) {
const reduce = useReducedMotion();
const [tick, setTick] = useState(0);
useEffect(() => {
if (reduce) return;
const id = setInterval(() => setTick((t) => (t + 1) % (max + rest)), ms);
return () => clearInterval(id);
}, [reduce, max, ms, rest]);
return reduce ? max : Math.min(tick, max);
}
function Tile({ className, children }: { className?: string; children: ReactNode }) {
return (
<motion.div
variants={{ hidden: { opacity: 0, y: 24, scale: 0.98 }, shown: { opacity: 1, y: 0, scale: 1, transition: { duration: 0.7, ease } } }}
className={cn("relative flex flex-col overflow-hidden rounded-3xl border border-border bg-card p-6", className)}
>
<div aria-hidden className="absolute inset-x-8 top-0 h-px bg-gradient-to-r from-transparent via-primary/60 to-transparent" />
{children}
</motion.div>
);
}
function Caption({ title, body }: { title: string; body: string }) {
return (
<div className="mt-auto pt-6">
<h3 className="font-medium text-card-foreground">{title}</h3>
<p className="mt-1 text-sm text-muted-foreground">{body}</p>
</div>
);
}
const answer =
"Yes. Your Kestrel Pro plan includes two free returns per order. I have emailed a prepaid label for order 4821, and the refund of $148.00 will reach your card within three business days of the scan.".split(" ");
function Streaming() {
const shown = useLoop(answer.length, 70, 45);
const done = shown >= answer.length;
return (
<div className="space-y-3 text-sm">
<p className="ml-auto w-fit max-w-[80%] rounded-2xl rounded-br-md bg-muted px-4 py-2.5 text-foreground">
Can I return the boots I ordered last week?
</p>
<div className="flex gap-3">
<span className="flex size-7 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground">
<Sparkles className="size-3.5" />
</span>
<div className="min-h-28">
<p className="leading-relaxed text-card-foreground">
{answer.slice(0, shown).join(" ")}
{!done && <span className="ml-1 inline-block size-2 animate-pulse rounded-full bg-primary align-middle" />}
</p>
<div className={cn("mt-3 flex flex-wrap gap-2 transition-all duration-500", done ? "opacity-100" : "translate-y-1 opacity-0")}>
{["Returns policy §2", "Order 4821", "Plan: Kestrel Pro"].map((c, i) => (
<span key={c} className="rounded-full border border-border bg-background px-2.5 py-1 text-xs text-muted-foreground">
<span className="mr-1 font-mono text-primary">{i + 1}</span>
{c}
</span>
))}
</div>
</div>
</div>
</div>
);
}
const agentSteps = ["Read the ticket and 4 past replies", "Looked up order 4821", "Checked returns policy", "Issued prepaid label", "Drafted reply for review"];
function Agent() {
const at = useLoop(agentSteps.length, 900, 3);
return (
<ol className="relative space-y-4">
<span aria-hidden className="absolute top-3 bottom-3 left-[11px] w-px bg-border" />
{agentSteps.map((s, i) => (
<li key={s} className="relative flex items-center gap-3 text-sm">
<span
className={cn(
"flex size-6 shrink-0 items-center justify-center rounded-full border transition-colors duration-300",
i < at ? "border-primary bg-primary text-primary-foreground" : "border-border bg-card text-muted-foreground",
)}
>
{i < at ? <Check className="size-3.5" strokeWidth={3} /> : i === at ? <LoaderCircle className="size-3.5 animate-spin" /> : null}
</span>
<span className={cn("transition-colors duration-300", i <= at ? "text-card-foreground" : "text-muted-foreground/60")}>{s}</span>
</li>
))}
</ol>
);
}
const bars = [0.35, 0.6, 0.9, 0.5, 0.75, 1, 0.55, 0.8, 0.4, 0.7, 0.95, 0.5, 0.65, 0.85, 0.45, 0.6, 0.3, 0.7, 0.5, 0.4];
function Voice() {
return (
<div className="flex items-center gap-4">
<span className="flex size-11 shrink-0 items-center justify-center rounded-full bg-primary/10 text-primary">
<Mic className="size-5" />
</span>
<div className="flex h-14 flex-1 items-center gap-[3px]">
{bars.map((b, i) => (
<span
key={i}
className="flex-1 rounded-full bg-primary motion-reduce:animate-none"
style={{
height: `${b * 100}%`,
opacity: 0.35 + b * 0.65,
animation: `pp-bento-ai-capabilities-wave ${0.9 + (i % 5) * 0.14}s ease-in-out ${-(i % 7) * 0.13}s infinite alternate`,
}}
/>
))}
</div>
</div>
);
}
const replies = [
["English", "Your refund is on its way."],
["Deutsch", "Ihre Rückerstattung ist unterwegs."],
["Español", "Tu reembolso está en camino."],
["Français", "Votre remboursement est en route."],
];
function Translate() {
const at = useLoop(replies.length * 4 - 1, 600, 1);
const [lang, text] = replies[Math.floor(at / 4) % replies.length];
return (
<div>
<div className="flex gap-1.5">
{replies.map(([l]) => (
<span
key={l}
className={cn("rounded-full px-2.5 py-1 text-xs transition-colors duration-300", l === lang ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground")}
>
{l.slice(0, 2).toUpperCase()}
</span>
))}
</div>
<div className="relative mt-4 h-14">
<AnimatePresence mode="wait" initial={false}>
<motion.p
key={lang}
initial={{ opacity: 0, y: 8, filter: "blur(6px)" }}
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
exit={{ opacity: 0, y: -8, filter: "blur(6px)" }}
transition={{ duration: 0.3 }}
className="absolute inset-0 font-serif text-xl leading-snug text-card-foreground"
>
{text}
</motion.p>
</AnimatePresence>
</div>
</div>
);
}
export default function BentoAiCapabilities() {
return (
<section className="w-full bg-background px-6 py-20 sm:py-24">
<style>{`@keyframes pp-bento-ai-capabilities-wave { from { transform: scaleY(0.3); } to { transform: scaleY(1); } }`}</style>
<div className="mx-auto max-w-6xl">
<div className="mx-auto max-w-2xl text-center">
<p className="inline-flex items-center gap-1.5 rounded-full bg-primary/10 px-3 py-1 text-xs font-medium text-primary">
<Sparkles className="size-3.5" /> Solace Assist
</p>
<h2 className="mt-4 text-4xl font-semibold tracking-tight text-balance text-foreground sm:text-5xl">
A support teammate that reads the whole thread first
</h2>
</div>
<motion.div
initial="hidden"
whileInView="shown"
viewport={{ once: true, amount: 0.15 }}
transition={{ staggerChildren: 0.08 }}
className="mt-12 grid gap-4 md:grid-cols-3"
>
<Tile className="md:col-span-2">
<Streaming />
<Caption title="Answers grounded in your policies" body="Every claim links to the document or order it came from." />
</Tile>
<Tile className="md:row-span-2">
<p className="mb-5 text-xs font-medium tracking-wide text-muted-foreground uppercase">Agent run · 6.2s</p>
<Agent />
<Caption title="Takes the action, not just the note" body="Refunds, labels and plan changes run through the tools you already approved." />
</Tile>
<Tile>
<Voice />
<Caption title="Voice in 180 ms" body="Low-latency speech for phone queues, with live transcripts." />
</Tile>
<Tile>
<Translate />
<Caption title="Fluent in 42 languages" body="Replies in the customer's language, in your tone." />
</Tile>
</motion.div>
<p className="mt-8 text-center text-sm text-muted-foreground">
<span className="font-medium text-foreground">68%</span> of conversations resolved without a handoff across 310 support teams
</p>
</div>
</section>
);
}