Files
webb/src/components/sections/HowItWorks3DSection.tsx
T

541 lines
27 KiB
TypeScript
Raw Normal View History

'use client';
import React, { useState, useEffect, useRef } from 'react';
import {
Sparkles,
Wand2,
Download,
Heart,
ArrowRight,
PartyPopper,
CheckCircle2,
Play,
Pause,
ArrowDown,
Camera,
Check
} from 'lucide-react';
import { TextAnimate } from '@/components/magicui/text-animate';
interface HowItWorksSectionProps {
title?: string;
badge?: string;
subtitle?: string;
}
export function HowItWorks3DSection({
title = 'Making Photo Magic is Super Simple',
badge = 'SUPER EASY AS 1-2-3',
subtitle = 'No complicated buttons or confusing settings. Just three friendly steps from your photo to pure magic!',
}: HowItWorksSectionProps) {
const [activeStep, setActiveStep] = useState<1 | 2 | 3>(1);
const [isPaused, setIsPaused] = useState(false);
const sectionRef = useRef<HTMLDivElement>(null);
// Auto-advance travelling image through cards with smart offscreen pause
// 100% safe on device battery and thermals: zero work when offscreen or tab hidden
useEffect(() => {
if (isPaused) return;
const section = sectionRef.current;
let isVisible = false;
let timer: any = null;
const runTimer = () => {
if (timer) clearInterval(timer);
timer = setInterval(() => {
if (isVisible && !document.hidden && !isPaused) {
setActiveStep((prev) => (prev === 3 ? 1 : ((prev + 1) as 1 | 2 | 3)));
}
}, 4500);
};
const observer = new IntersectionObserver(
([entry]) => {
isVisible = entry.isIntersecting;
if (isVisible) {
runTimer();
} else if (timer) {
clearInterval(timer);
timer = null;
}
},
{ threshold: 0.15 }
);
if (section) observer.observe(section);
const handleVisibility = () => {
if (document.hidden && timer) {
clearInterval(timer);
timer = null;
} else if (isVisible && !isPaused) {
runTimer();
}
};
document.addEventListener('visibilitychange', handleVisibility);
return () => {
if (timer) clearInterval(timer);
observer.disconnect();
document.removeEventListener('visibilitychange', handleVisibility);
};
}, [isPaused]);
return (
<section
id="how-it-works"
ref={sectionRef}
className="py-16 sm:py-24 px-4 sm:px-6 md:px-8 lg:px-10 bg-[#FAF8F5] relative overflow-hidden border-t border-slate-900/[0.06]"
>
{/* Playful Ambient Background Highlights */}
<div
className="absolute inset-0 pointer-events-none -z-10"
style={{
background: 'radial-gradient(circle at 50% 30%, rgba(254,240,138,0.12) 0%, rgba(199,210,254,0.1) 40%, transparent 70%)',
}}
/>
<div className="max-w-[1640px] mx-auto space-y-10 sm:space-y-12">
{/* Playful & Warm Section Header with Quick Controls */}
<div className="text-center max-w-3xl mx-auto space-y-4">
<div className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-xs font-display font-bold tracking-wider uppercase text-amber-900 bg-amber-100/80 border border-amber-300 shadow-sm">
<Sparkles className="w-4 h-4 text-amber-600" />
<span>{badge}</span>
</div>
<h2 className="text-3xl sm:text-5xl font-display font-black text-slate-900 tracking-tight text-balance">
<TextAnimate animation="slideLeft" by="word">
{title}
</TextAnimate>
</h2>
<p className="text-base sm:text-lg text-slate-600 font-sans text-pretty">
<TextAnimate animation="fadeIn" by="word" delay={0.08}>
{subtitle}
</TextAnimate>
</p>
{/* Step Selector Pills & Auto-Play Toggle */}
<div className="pt-2 flex items-center justify-center flex-wrap gap-2 text-xs font-display font-bold">
<button
type="button"
onClick={() => setActiveStep(1)}
className={`flex items-center gap-1.5 px-4 py-2 rounded-full transition-all duration-300 ${
activeStep === 1
? 'bg-blue-600 text-white shadow-md shadow-blue-500/25 scale-105'
: 'bg-white text-slate-700 hover:bg-slate-100 border border-slate-200 shadow-xs'
}`}
>
<span>📸 1. Pick Photo</span>
</button>
<button
type="button"
onClick={() => setActiveStep(2)}
className={`flex items-center gap-1.5 px-4 py-2 rounded-full transition-all duration-300 ${
activeStep === 2
? 'bg-amber-500 text-white shadow-md shadow-amber-500/25 scale-105'
: 'bg-white text-slate-700 hover:bg-slate-100 border border-slate-200 shadow-xs'
}`}
>
<span>🪄 2. AI Magic</span>
</button>
<button
type="button"
onClick={() => setActiveStep(3)}
className={`flex items-center gap-1.5 px-4 py-2 rounded-full transition-all duration-300 ${
activeStep === 3
? 'bg-emerald-600 text-white shadow-md shadow-emerald-500/25 scale-105'
: 'bg-white text-slate-700 hover:bg-slate-100 border border-slate-200 shadow-xs'
}`}
>
<span>🎉 3. Masterpiece</span>
</button>
<button
type="button"
onClick={() => setIsPaused(!isPaused)}
className="p-2 rounded-full bg-white hover:bg-slate-100 border border-slate-200 text-slate-700 transition-colors shadow-xs ml-1"
title={isPaused ? 'Resume auto-advance' : 'Pause auto-advance'}
aria-label={isPaused ? 'Resume auto-advance' : 'Pause auto-advance'}
>
{isPaused ? <Play className="w-3.5 h-3.5" /> : <Pause className="w-3.5 h-3.5" />}
</button>
</div>
</div>
{/* -------------------------------------------------------------
Three Connected Cards with Travelling Photo Journey Integrated Directly Within
------------------------------------------------------------- */}
<div className="relative">
{/* Desktop Connecting Conveyor Tracks Between the Cards */}
<div className="hidden lg:block absolute top-[138px] inset-x-[15%] h-1 bg-slate-200/80 rounded-full pointer-events-none -z-0">
{/* Travelling Active Pulse Energy Beam */}
<div
className="h-full bg-gradient-to-r from-blue-500 via-amber-400 to-emerald-500 rounded-full transition-all duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] shadow-[0_0_8px_rgba(59,130,246,0.5)]"
style={{
width: activeStep === 1 ? '0%' : activeStep === 2 ? '50%' : '100%'
}}
/>
</div>
{/* Desktop Floating Transfer Arrow Cues */}
<div className="hidden lg:flex absolute top-[138px] left-[33.33%] -translate-x-1/2 -translate-y-1/2 z-20 pointer-events-none">
<div className={`w-8 h-8 rounded-full border flex items-center justify-center transition-all duration-500 ${
activeStep >= 2
? 'bg-amber-500 border-amber-300 text-white shadow-md scale-110'
: 'bg-white border-slate-200 text-slate-400'
}`}>
<ArrowRight className="w-4 h-4" />
</div>
</div>
<div className="hidden lg:flex absolute top-[138px] left-[66.66%] -translate-x-1/2 -translate-y-1/2 z-20 pointer-events-none">
<div className={`w-8 h-8 rounded-full border flex items-center justify-center transition-all duration-500 ${
activeStep === 3
? 'bg-emerald-600 border-emerald-300 text-white shadow-md scale-110'
: 'bg-white border-slate-200 text-slate-400'
}`}>
<ArrowRight className="w-4 h-4" />
</div>
</div>
{/* 3 Step Cards Grid */}
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6 sm:gap-8 items-stretch relative z-10">
{/* =========================================================
CARD 1: Pick Any Picture (Origin Dock)
========================================================= */}
<div
onClick={() => setActiveStep(1)}
className={`group relative flex flex-col justify-between rounded-[36px] bg-white border p-6 sm:p-7 shadow-cream-sm transition-all duration-500 cursor-pointer ${
activeStep === 1
? 'border-blue-500 ring-4 ring-blue-500/20 shadow-cream-lg -translate-y-1.5'
: 'border-slate-200/90 hover:border-blue-300 hover:shadow-cream-md'
}`}
>
<div>
{/* Step Badge */}
<div className="flex items-center justify-between mb-4">
<div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-blue-50 border border-blue-200 text-blue-700 text-xs font-display font-bold uppercase tracking-wider">
{activeStep === 1 && <span className="w-2 h-2 rounded-full bg-blue-600 inline-block animate-ping" />}
<span>STEP 01</span>
</div>
<span className="text-xl">📸</span>
</div>
{/* VISUAL DOCK 1: Raw Photo Drop & Origin Departure */}
<div className="relative w-full h-[220px] rounded-3xl bg-gradient-to-b from-blue-50/70 to-indigo-50/40 border border-blue-100 overflow-hidden flex flex-col items-center justify-center p-3 select-none">
{/* Photo Frame with Transition */}
<div className={`relative w-44 h-32 rounded-2xl bg-white shadow-xl border-2 border-white overflow-hidden p-1.5 transition-all duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] transform-gpu ${
activeStep === 1
? 'scale-100 rotate-[-1deg] opacity-100'
: 'scale-90 rotate-[0deg] opacity-40 translate-x-4'
}`}>
<img
src="/management/pages/home/sections/how-it-works/media/before.jpg"
alt="Your Photo"
className="w-full h-full object-cover rounded-xl"
/>
{/* Tag badge */}
<div className="absolute bottom-2 left-2 right-2 flex items-center justify-between pointer-events-none">
<span className="px-2 py-0.5 rounded-full text-[9px] font-mono font-bold uppercase tracking-wider bg-blue-600/90 text-white shadow-xs">
Raw Photo
</span>
{activeStep === 1 && (
<span className="text-xs">👇</span>
)}
</div>
</div>
{/* Flow cues */}
<div className="absolute top-2.5 left-3 px-2.5 py-0.5 rounded-full bg-white/95 shadow-xs border border-blue-100 text-[10px] font-bold text-blue-700 flex items-center gap-1">
<span>{activeStep === 1 ? 'Photo Loaded' : 'Sent to Step 2'}</span>
{activeStep > 1 && <Check className="w-3 h-3 text-emerald-600" />}
</div>
{activeStep === 1 && (
<div className="absolute bottom-2.5 right-3 px-2.5 py-0.5 rounded-full bg-blue-600 text-white shadow-xs text-[10px] font-bold flex items-center gap-1 animate-pulse">
<span>Travelling Next</span>
<ArrowRight className="w-3 h-3" />
</div>
)}
</div>
{/* Text Content */}
<h3 className="mt-5 text-xl sm:text-2xl font-display font-black text-slate-900 group-hover:text-blue-600 transition-colors">
1. Pick Any Picture
</h3>
<p className="mt-2 text-xs sm:text-sm text-slate-600 leading-relaxed font-sans">
Grab any photo from your phone or laptop. Selfies, family portraits, vintage prints, or vacation snaps—everything transforms in seconds!
</p>
{/* Feature checkmarks */}
<ul className="mt-4 space-y-1.5 text-xs font-medium text-slate-600 border-t border-slate-100 pt-3">
<li className="flex items-center gap-2">
<CheckCircle2 className="w-3.5 h-3.5 text-emerald-500 shrink-0" />
<span>One-tap upload or drag & drop</span>
</li>
<li className="flex items-center gap-2">
<CheckCircle2 className="w-3.5 h-3.5 text-emerald-500 shrink-0" />
<span>No sign-up or credit card required</span>
</li>
</ul>
</div>
<div className="mt-5 pt-3 border-t border-slate-100 text-xs font-display font-bold text-blue-600 flex items-center justify-between">
<span>Instant upload</span>
<span>⚡ Easy & Private</span>
</div>
</div>
{/* Mobile Vertical Flow Arrow 1 -> 2 */}
<div className="flex lg:hidden justify-center -my-3 z-20 pointer-events-none">
<div className={`w-8 h-8 rounded-full border flex items-center justify-center transition-all ${
activeStep >= 2 ? 'bg-amber-500 border-amber-300 text-white shadow-md' : 'bg-white border-slate-200 text-slate-400'
}`}>
<ArrowDown className="w-4 h-4" />
</div>
</div>
{/* =========================================================
CARD 2: Some Magic Happens! (Transformation Dock)
========================================================= */}
<div
onClick={() => setActiveStep(2)}
className={`group relative flex flex-col justify-between rounded-[36px] bg-white border p-6 sm:p-7 shadow-cream-sm transition-all duration-500 cursor-pointer ${
activeStep === 2
? 'border-amber-500 ring-4 ring-amber-500/20 shadow-cream-lg -translate-y-1.5'
: 'border-slate-200/90 hover:border-amber-300 hover:shadow-cream-md'
}`}
>
<div>
{/* Step Badge */}
<div className="flex items-center justify-between mb-4">
<div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-amber-50 border border-amber-200 text-amber-800 text-xs font-display font-bold uppercase tracking-wider">
{activeStep === 2 && <span className="w-2 h-2 rounded-full bg-amber-500 inline-block animate-ping" />}
<span>STEP 02</span>
</div>
<span className="text-xl">🪄</span>
</div>
{/* VISUAL DOCK 2: In-Card Arrival, Laser Scan & Neural Crossfade */}
<div className="relative w-full h-[220px] rounded-3xl bg-gradient-to-b from-amber-50/80 via-purple-50/40 to-pink-50/50 border border-amber-200/80 overflow-hidden flex flex-col items-center justify-center p-3 select-none">
{/* Photo Frame Docked in Card 2 with Real-Time Crossfade */}
<div className={`relative w-44 h-32 rounded-2xl bg-white shadow-xl border-2 transition-all duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] overflow-hidden p-1.5 transform-gpu ${
activeStep === 2
? 'scale-105 border-amber-400 shadow-amber-500/25 rotate-[0deg] opacity-100'
: activeStep === 3
? 'scale-90 border-slate-200 opacity-40 translate-x-4'
: 'scale-90 border-slate-200 opacity-30 -translate-x-4'
}`}>
{/* Before Image */}
<img
src="/management/pages/home/sections/how-it-works/media/before.jpg"
alt="Raw Photo Transforming"
className={`absolute inset-1.5 w-[calc(100%-12px)] h-[calc(100%-12px)] object-cover rounded-xl transition-opacity duration-700 ${
activeStep === 2 ? 'opacity-0' : 'opacity-100'
}`}
/>
{/* Transformed After Image */}
<img
src="/management/pages/home/sections/how-it-works/media/after.jpg"
alt="Transformed AI Image"
className={`absolute inset-1.5 w-[calc(100%-12px)] h-[calc(100%-12px)] object-cover rounded-xl transition-opacity duration-700 ${
activeStep >= 2 ? 'opacity-100' : 'opacity-0'
}`}
/>
{/* Neural Laser Scanner Beam during Step 2 */}
{activeStep === 2 && (
<div className="absolute inset-y-1.5 w-8 bg-gradient-to-r from-transparent via-cyan-400 to-transparent animate-laser-scan pointer-events-none z-20" />
)}
{/* Tag badge */}
<div className="absolute bottom-2 left-2 right-2 flex items-center justify-between pointer-events-none z-30">
<span className={`px-2 py-0.5 rounded-full text-[9px] font-mono font-bold uppercase tracking-wider text-white shadow-xs ${
activeStep === 2 ? 'bg-amber-600/95' : 'bg-slate-700/80'
}`}>
{activeStep === 2 ? 'AI Magic...' : activeStep === 3 ? 'Enhanced' : 'Awaiting'}
</span>
{activeStep === 2 && <span className="text-xs">✨</span>}
</div>
</div>
{/* Flow cues */}
<div className="absolute top-2.5 left-3 px-2.5 py-0.5 rounded-full bg-white/95 shadow-xs border border-amber-200 text-[10px] font-bold text-amber-900 flex items-center gap-1">
<span>{activeStep === 2 ? 'Pixels Processing' : activeStep === 3 ? 'Magic Applied' : 'Dock Ready'}</span>
{activeStep === 3 && <Check className="w-3 h-3 text-emerald-600" />}
</div>
{activeStep === 2 && (
<div className="absolute bottom-2.5 right-3 px-2.5 py-0.5 rounded-full bg-amber-500 text-white shadow-xs text-[10px] font-bold flex items-center gap-1 animate-pulse">
<span>Moving to 4K</span>
<ArrowRight className="w-3 h-3" />
</div>
)}
</div>
{/* Text Content */}
<h3 className="mt-5 text-xl sm:text-2xl font-display font-black text-slate-900 group-hover:text-amber-600 transition-colors">
2. Some Magic Happens!
</h3>
<p className="mt-2 text-xs sm:text-sm text-slate-600 leading-relaxed font-sans">
Our neural AI waves its magic wand—dusting away marks, clarifying pupils, restoring crisp textures, and balancing vibrant colors in under a second!
</p>
{/* Feature checkmarks */}
<ul className="mt-4 space-y-1.5 text-xs font-medium text-slate-600 border-t border-slate-100 pt-3">
<li className="flex items-center gap-2">
<CheckCircle2 className="w-3.5 h-3.5 text-amber-500 shrink-0" />
<span>Preserves real pores & authentic facial features</span>
</li>
<li className="flex items-center gap-2">
<CheckCircle2 className="w-3.5 h-3.5 text-amber-500 shrink-0" />
<span>Automated neural enhancement with zero guesswork</span>
</li>
</ul>
</div>
<div className="mt-5 pt-3 border-t border-slate-100 text-xs font-display font-bold text-amber-700 flex items-center justify-between">
<span>Under 0.8 seconds</span>
<span>🪄 Neural Engine</span>
</div>
</div>
{/* Mobile Vertical Flow Arrow 2 -> 3 */}
<div className="flex lg:hidden justify-center -my-3 z-20 pointer-events-none">
<div className={`w-8 h-8 rounded-full border flex items-center justify-center transition-all ${
activeStep === 3 ? 'bg-emerald-600 border-emerald-300 text-white shadow-md' : 'bg-white border-slate-200 text-slate-400'
}`}>
<ArrowDown className="w-4 h-4" />
</div>
</div>
{/* =========================================================
CARD 3: Tada! Ready to Love (Arrival Masterpiece Dock)
========================================================= */}
<div
onClick={() => setActiveStep(3)}
className={`group relative flex flex-col justify-between rounded-[36px] bg-white border p-6 sm:p-7 shadow-cream-sm transition-all duration-500 cursor-pointer ${
activeStep === 3
? 'border-emerald-500 ring-4 ring-emerald-500/20 shadow-cream-lg -translate-y-1.5'
: 'border-slate-200/90 hover:border-emerald-300 hover:shadow-cream-md'
}`}
>
<div>
{/* Step Badge */}
<div className="flex items-center justify-between mb-4">
<div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-emerald-50 border border-emerald-200 text-emerald-800 text-xs font-display font-bold uppercase tracking-wider">
{activeStep === 3 && <span className="w-2 h-2 rounded-full bg-emerald-500 inline-block animate-ping" />}
<span>STEP 03</span>
</div>
<span className="text-xl">🎉</span>
</div>
{/* VISUAL DOCK 3: Finished 4K Arrival & Download State */}
<div className="relative w-full h-[220px] rounded-3xl bg-gradient-to-b from-emerald-50/80 via-teal-50/40 to-cyan-50/50 border border-emerald-200/80 overflow-hidden flex flex-col items-center justify-center p-3 select-none">
{/* Masterpiece Photo Frame in Card 3 */}
<div className={`relative w-44 h-32 rounded-2xl bg-white shadow-xl border-2 transition-all duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] overflow-hidden p-1.5 transform-gpu ${
activeStep === 3
? 'scale-105 border-emerald-400 shadow-emerald-500/25 rotate-[1deg] opacity-100'
: 'scale-90 border-slate-200 opacity-30 -translate-x-4'
}`}>
<img
src="/management/pages/home/sections/how-it-works/media/after.jpg"
alt="Finished 4K Masterpiece"
className="w-full h-full object-cover rounded-xl"
/>
{/* Celebration badges */}
<div className="absolute top-2 left-2 z-20">
<span className="px-2 py-0.5 rounded-full bg-emerald-600 text-white text-[9px] font-mono font-bold uppercase tracking-wider shadow-sm flex items-center gap-1">
<PartyPopper className="w-2.5 h-2.5" />
<span>Tada! Masterpiece</span>
</span>
</div>
<div className="absolute bottom-2 right-2 z-20">
<span className="px-2 py-0.5 rounded-full bg-white/95 text-slate-900 text-[9px] font-mono font-bold shadow-xs border border-slate-200 flex items-center gap-1">
<Download className="w-2.5 h-2.5 text-emerald-600" />
<span>4K Ready</span>
</span>
</div>
</div>
{/* Flow cues */}
<div className="absolute top-2.5 left-3 px-2.5 py-0.5 rounded-full bg-white/95 shadow-xs border border-emerald-200 text-[10px] font-bold text-emerald-900 flex items-center gap-1">
<span>{activeStep === 3 ? 'Masterpiece Ready!' : 'Waiting for Arrival'}</span>
{activeStep === 3 && <PartyPopper className="w-3 h-3 text-emerald-600" />}
</div>
{activeStep === 3 && (
<div className="absolute bottom-2.5 right-3 px-2.5 py-0.5 rounded-full bg-emerald-600 text-white shadow-xs text-[10px] font-bold flex items-center gap-1">
<span>Ready to Save</span>
<span>🎉</span>
</div>
)}
</div>
{/* Text Content */}
<h3 className="mt-5 text-xl sm:text-2xl font-display font-black text-slate-900 group-hover:text-emerald-600 transition-colors">
3. Tada! Ready to Love
</h3>
<p className="mt-2 text-xs sm:text-sm text-slate-600 leading-relaxed font-sans">
One tap to download your gorgeous new picture in crystal 4K resolution! No annoying watermarks, no compression artifacts, ready to share proudly.
</p>
{/* Feature checkmarks */}
<ul className="mt-4 space-y-1.5 text-xs font-medium text-slate-600 border-t border-slate-100 pt-3">
<li className="flex items-center gap-2">
<CheckCircle2 className="w-3.5 h-3.5 text-emerald-500 shrink-0" />
<span>Crisp high-definition 4K image export</span>
</li>
<li className="flex items-center gap-2">
<CheckCircle2 className="w-3.5 h-3.5 text-emerald-500 shrink-0" />
<span>Zero watermarks or hidden payment traps</span>
</li>
</ul>
</div>
<div className="mt-5 pt-3 border-t border-slate-100 text-xs font-display font-bold text-emerald-700 flex items-center justify-between">
<span>Instant Download</span>
<span>🎉 All Yours</span>
</div>
</div>
</div>
</div>
{/* Cheerful Bottom Reassurance Banner */}
<div className="rounded-3xl bg-gradient-to-r from-amber-50 via-white to-blue-50 border border-amber-200/80 p-5 sm:p-6 shadow-sm flex flex-col md:flex-row items-center justify-between gap-4 text-center md:text-left">
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-2xl bg-amber-400 text-amber-950 flex items-center justify-center font-bold text-lg shadow-sm shrink-0">
🎈
</div>
<div>
<h4 className="font-display font-bold text-slate-900 text-sm">
100% Free Trial • No Credit Card • No Sign-Up Needed
</h4>
<p className="text-xs text-slate-600 mt-0.5 font-sans">
Anyone can do it in seconds. Your photos stay completely private on your own device and are never stored.
</p>
</div>
</div>
<a
href="#our-tools"
className="inline-flex items-center gap-2 px-6 py-3 rounded-full text-xs font-bold text-slate-900 bg-amber-400 hover:bg-amber-300 shadow-md transition-all hover:scale-105 active:scale-95 shrink-0"
>
<span>Try It Yourself Now</span>
<ArrowRight className="w-4 h-4" />
</a>
</div>
</div>
</section>
);
}