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

544 lines
27 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
import React, { useState, useEffect, useRef, useCallback } from 'react';
import Image from 'next/image';
import {
UploadCloud,
Cpu,
Download,
ArrowRight,
Check,
ShieldCheck,
Sparkles,
Zap,
Lock,
CheckCircle2
} from 'lucide-react';
import { InteractiveHoverButton } from '@/components/magicui/interactive-hover-button';
import { KineticText } from '@/components/magicui/kinetic-text';
import { AnimatedShinyText } from '@/components/magicui/animated-shiny-text';
interface HowItWorksSectionProps {
title?: string;
badge?: string;
subtitle?: string;
}
export function HowItWorks3DSection({
title = 'How the process works',
badge = 'Neural pipeline',
subtitle = 'Synchronous GPU inference in volatile memory, returning studio-quality exports in seconds.',
}: HowItWorksSectionProps) {
const [activeStep, setActiveStep] = useState<1 | 2 | 3>(1);
const [isPaused, setIsPaused] = useState<boolean>(false);
const [isInView, setIsInView] = useState<boolean>(false);
const sectionRef = useRef<HTMLElement>(null);
const cardsContainerRef = useRef<HTMLDivElement>(null);
const card1Ref = useRef<HTMLDivElement>(null);
const card2Ref = useRef<HTMLDivElement>(null);
const card3Ref = useRef<HTMLDivElement>(null);
const scrollTimeoutRef = useRef<NodeJS.Timeout | null>(null);
// Auto-scroll active card into view on mobile screens when activeStep changes
useEffect(() => {
if (typeof window === 'undefined' || window.innerWidth >= 768) return;
const targetRef = activeStep === 1 ? card1Ref.current : activeStep === 2 ? card2Ref.current : card3Ref.current;
if (targetRef && cardsContainerRef.current) {
targetRef.scrollIntoView({ behavior: 'smooth', inline: 'center', block: 'nearest' });
}
}, [activeStep]);
// Sync active step when user swipes horizontally on mobile
const handleMobileScroll = useCallback(() => {
if (typeof window === 'undefined' || window.innerWidth >= 768) return;
if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);
scrollTimeoutRef.current = setTimeout(() => {
const container = cardsContainerRef.current;
if (!container) return;
const scrollLeft = container.scrollLeft;
const cardWidth = container.clientWidth * 0.85;
const newStep = Math.round(scrollLeft / cardWidth) + 1;
const clamped = Math.max(1, Math.min(3, newStep)) as 1 | 2 | 3;
if (clamped !== activeStep) {
setActiveStep(clamped);
}
}, 80);
}, [activeStep]);
useEffect(() => {
return () => {
if (scrollTimeoutRef.current) clearTimeout(scrollTimeoutRef.current);
};
}, []);
// Only run auto-advance interval when section is visible in viewport (0% CPU offscreen)
useEffect(() => {
const el = sectionRef.current;
if (!el) return;
const observer = new IntersectionObserver(
([entry]) => {
setIsInView(entry.isIntersecting);
},
{ threshold: 0.08 }
);
observer.observe(el);
return () => observer.disconnect();
}, []);
// Auto-advance traveling pipeline every 4.2 seconds only when visible
useEffect(() => {
if (!isInView || isPaused) return;
const interval = setInterval(() => {
setActiveStep((prev) => (prev === 3 ? 1 : ((prev + 1) as 1 | 2 | 3)));
}, 4200);
return () => clearInterval(interval);
}, [isInView, isPaused]);
return (
<section
ref={sectionRef}
id="how-it-works"
className="py-16 sm:py-24 px-4 sm:px-6 md:px-8 lg:px-10 bg-paper border-b border-rule relative overflow-hidden"
onMouseEnter={() => setIsPaused(true)}
onMouseLeave={() => setIsPaused(false)}
>
{/* Studio Background Ambient Lighting */}
<div
className="pointer-events-none absolute top-0 left-1/4 w-[600px] h-[400px] [background:radial-gradient(circle_at_center,color-mix(in_oklab,var(--color-accent)_10%,transparent)_0%,transparent_70%)]"
aria-hidden="true"
/>
<div
className="pointer-events-none absolute inset-0 opacity-20 studio-proof-grid"
aria-hidden="true"
/>
<div className="max-w-container mx-auto space-y-12 relative z-10">
{/* Section Header */}
<div className="max-w-2xl space-y-2 border-b border-rule pb-5">
<div className="flex items-center gap-2">
<span className="w-2 h-2 rounded-full bg-accent animate-pulse" aria-hidden="true" />
<span className="text-xs font-semibold text-accent font-body">
{badge}
</span>
</div>
<h2 className="text-3xl sm:text-4xl font-display font-bold text-ink tracking-tight">
<KineticText>{title}</KineticText>
</h2>
<p className="text-sm sm:text-base text-ink-2 font-body text-pretty">
{subtitle}
</p>
{/* Interactive Step Selector Pills */}
<div className="pt-3 flex flex-wrap items-center gap-2 text-xs font-body">
<button
type="button"
onClick={() => setActiveStep(1)}
className={`px-3.5 py-1.5 rounded-full transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-accent active:bg-paper-3 disabled:opacity-50 flex items-center gap-1.5 ${
activeStep === 1
? 'bg-ink text-paper-hi font-medium shadow-sm ring-1 ring-ink'
: 'bg-paper-2 text-ink-2 hover:bg-paper-3 border border-rule'
}`}
>
<UploadCloud className="w-3.5 h-3.5 text-accent" aria-hidden="true" />
<span>1. Upload photograph</span>
</button>
<button
type="button"
onClick={() => setActiveStep(2)}
className={`px-3.5 py-1.5 rounded-full transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-accent active:bg-paper-3 disabled:opacity-50 flex items-center gap-1.5 ${
activeStep === 2
? 'bg-ink text-paper-hi font-medium shadow-sm ring-1 ring-ink'
: 'bg-paper-2 text-ink-2 hover:bg-paper-3 border border-rule'
}`}
>
<Cpu className="w-3.5 h-3.5 text-accent" aria-hidden="true" />
<span>2. Neural processing</span>
</button>
<button
type="button"
onClick={() => setActiveStep(3)}
className={`px-3.5 py-1.5 rounded-full transition-colors duration-150 focus-visible:ring-2 focus-visible:ring-accent active:bg-paper-3 disabled:opacity-50 flex items-center gap-1.5 ${
activeStep === 3
? 'bg-ink text-paper-hi font-medium shadow-sm ring-1 ring-ink'
: 'bg-paper-2 text-ink-2 hover:bg-paper-3 border border-rule'
}`}
>
<Download className="w-3.5 h-3.5 text-accent" aria-hidden="true" />
<span>3. Studio export</span>
</button>
</div>
</div>
{/* 3 Step Process Cards with Visual Travelling Image Specimen */}
{/* Mobile: Sleek horizontal swipe snap carousel (NO long vertical stacking). Desktop: 3-column connected grid. */}
<div
ref={cardsContainerRef}
onScroll={handleMobileScroll}
className="relative flex md:grid md:grid-cols-3 gap-4 sm:gap-6 overflow-x-auto md:overflow-visible snap-x snap-mandatory pb-3 md:pb-0 -mx-4 px-4 sm:mx-0 sm:px-0 no-scrollbar"
>
{/* Connecting Traveling Data Conduits (Desktop between cards) */}
<div className="hidden md:block absolute top-[115px] left-[32%] w-[4%] h-[2px] bg-gradient-to-r from-rule via-accent/40 to-rule overflow-hidden z-20 pointer-events-none">
<div className="w-8 h-full bg-accent animate-beam-pulse rounded-full shadow-glow" />
</div>
<div className="hidden md:block absolute top-[115px] left-[65%] w-[4%] h-[2px] bg-gradient-to-r from-rule via-accent/40 to-rule overflow-hidden z-20 pointer-events-none">
<div className="w-8 h-full bg-accent animate-beam-pulse rounded-full shadow-glow" />
</div>
{/* ================= STEP 1: UPLOAD PHOTOGRAPH ================= */}
<div
ref={card1Ref}
onClick={() => setActiveStep(1)}
className={`w-[85vw] sm:w-[350px] md:w-auto shrink-0 md:shrink snap-center cursor-pointer studio-sheet p-5 sm:p-6 rounded-3xl bg-paper-hi border shadow-sheet flex flex-col justify-between motion-safe:transition-[border-color,box-shadow,transform] duration-200 relative overflow-hidden ${
activeStep === 1
? 'border-accent shadow-glow ring-2 ring-accent/20 scale-[1.01]'
: 'border-rule hover:border-accent/60 opacity-90'
}`}
>
{/* Active Step Progress Indicator Bar */}
<div className="absolute top-0 inset-x-0 h-1 bg-paper-2 overflow-hidden">
{activeStep === 1 && (
<div className="h-full bg-accent transition-opacity duration-300 w-full animate-pulse" />
)}
</div>
<div className="space-y-4">
{/* Header: Step number & Icon */}
<div className="flex items-center justify-between border-b border-rule pb-3">
<div className="flex items-center gap-2">
<span className="w-6 h-6 rounded-full bg-accent/10 text-accent font-bold text-xs flex items-center justify-center font-mono">
01
</span>
<span className="text-xs font-semibold text-accent font-body">
Capture & validate
</span>
</div>
<div className="w-8 h-8 rounded-full bg-paper-2 border border-rule flex items-center justify-center text-accent">
<UploadCloud className="w-4 h-4" aria-hidden="true" />
</div>
</div>
{/* VISUAL IMAGE SPECIMEN 1: Raw Studio Input Viewfinder */}
<div className="relative w-full h-44 sm:h-48 rounded-2xl overflow-hidden bg-paper-2 border border-rule shadow-inner">
<Image
src="/management/pages/tools/photo-enhancer/media/before.jpg"
alt="Raw photograph specimen"
fill
className="object-cover object-top opacity-90"
sizes="(max-width: 768px) 100vw, 33vw"
/>
{/* Viewfinder Crop Corner Brackets */}
<div className="pointer-events-none absolute inset-2.5 flex flex-col justify-between" aria-hidden="true">
<div className="flex justify-between">
<div className="w-3.5 h-3.5 border-t-2 border-l-2 border-white" />
<div className="w-3.5 h-3.5 border-t-2 border-r-2 border-white" />
</div>
{/* Center Autofocus Reticle */}
<div className="self-center w-7 h-7 rounded-full border border-white/60 flex items-center justify-center">
<div className="w-1.5 h-1.5 rounded-full bg-accent animate-ping" />
</div>
<div className="flex justify-between">
<div className="w-3.5 h-3.5 border-b-2 border-l-2 border-white" />
<div className="w-3.5 h-3.5 border-b-2 border-r-2 border-white" />
</div>
</div>
{/* Specimen Tag Overlays */}
<div className="absolute top-2 left-2 px-2.5 py-0.5 rounded-full bg-ink/80 text-[10px] font-body text-paper-hi border border-white/20 flex items-center gap-1.5">
<span className="w-1.5 h-1.5 rounded-full bg-emerald-400" />
<span>Raw specimen</span>
</div>
<div className="absolute bottom-2 inset-x-2 flex items-center justify-between text-[10px] font-body text-paper-hi px-2.5 py-1 rounded-xl bg-ink/80 border border-white/20">
<span>24.2 MP · 6000×4000</span>
<span className="text-accent font-semibold flex items-center gap-1">
Ready to stream <ArrowRight className="w-2.5 h-2.5" />
</span>
</div>
</div>
{/* Text Info */}
<div>
<h3 className="text-base sm:text-lg font-body font-bold text-ink">
<AnimatedShinyText>Select your source photo</AnimatedShinyText>
</h3>
<p className="mt-1 text-xs text-muted leading-relaxed font-body">
Drop any portrait, archival print, or product image into the studio. Validates JPEG, PNG, and WebP signatures client-side in milliseconds.
</p>
</div>
{/* Bullet Points */}
<ul className="space-y-1.5 text-xs text-ink-2 pt-2 border-t border-rule font-body">
<li className="flex items-center gap-2">
<Check className="w-3.5 h-3.5 text-accent shrink-0" aria-hidden="true" />
<span>Up to 12MB input resolution</span>
</li>
<li className="flex items-center gap-2">
<Check className="w-3.5 h-3.5 text-accent shrink-0" aria-hidden="true" />
<span>Zero sign-up or email required</span>
</li>
</ul>
</div>
<div className="mt-5 pt-3 border-t border-rule flex items-center justify-between text-xs text-muted font-body">
<span className="flex items-center gap-1 text-emerald-600 font-medium">
<CheckCircle2 className="w-3.5 h-3.5" /> Client validation passed
</span>
<span className="text-[11px] font-body text-accent">Stage 1 of 3</span>
</div>
</div>
{/* ================= STEP 2: NEURAL INFERENCE (ACTIVE SCANNING LASER) ================= */}
<div
ref={card2Ref}
onClick={() => setActiveStep(2)}
className={`w-[85vw] sm:w-[350px] md:w-auto shrink-0 md:shrink snap-center cursor-pointer studio-sheet p-5 sm:p-6 rounded-3xl bg-paper-hi border shadow-sheet flex flex-col justify-between motion-safe:transition-[border-color,box-shadow,transform] duration-200 relative overflow-hidden ${
activeStep === 2
? 'border-accent shadow-glow ring-2 ring-accent/20 scale-[1.01]'
: 'border-rule hover:border-accent/60 opacity-90'
}`}
>
{/* Active Step Progress Indicator Bar */}
<div className="absolute top-0 inset-x-0 h-1 bg-paper-2 overflow-hidden">
{activeStep === 2 && (
<div className="h-full bg-accent transition-opacity duration-300 w-full animate-pulse" />
)}
</div>
<div className="space-y-4">
{/* Header: Step number & Icon */}
<div className="flex items-center justify-between border-b border-rule pb-3">
<div className="flex items-center gap-2">
<span className="w-6 h-6 rounded-full bg-accent/10 text-accent font-bold text-xs flex items-center justify-center font-mono">
02
</span>
<span className="text-xs font-semibold text-accent font-body">
Volatile inference
</span>
</div>
<div className="w-8 h-8 rounded-full bg-paper-2 border border-rule flex items-center justify-center text-accent">
<Cpu className="w-4 h-4" aria-hidden="true" />
</div>
</div>
{/* VISUAL IMAGE SPECIMEN 2: Animated Neural Processing Scanner */}
<div className="relative w-full h-44 sm:h-48 rounded-2xl overflow-hidden bg-paper-2 border border-rule shadow-inner">
<Image
src="/management/pages/tools/photo-enhancer/media/before.jpg"
alt="Neural processing specimen"
fill
className="object-cover object-top opacity-80 filter hue-rotate-15"
sizes="(max-width: 768px) 100vw, 33vw"
/>
{/* Fine Dot Matrix Overlay */}
<div
className="pointer-events-none absolute inset-0 opacity-25 studio-proof-grid"
aria-hidden="true"
/>
{/* Animated Scanning Laser Line Sweeping Up & Down */}
<div
className="pointer-events-none absolute inset-x-0 h-[2px] bg-accent shadow-glow animate-scanline z-10"
aria-hidden="true"
/>
{/* Status Badges */}
<div className="absolute top-2 left-2 px-2.5 py-0.5 rounded-full bg-ink/80 text-[10px] font-body text-cyan-300 border border-white/20 flex items-center gap-1.5 z-10">
<span className="w-1.5 h-1.5 rounded-full bg-cyan-400 animate-ping" />
<span>GPU tensor active</span>
</div>
<div className="absolute top-2 right-2 px-2.5 py-0.5 rounded-full bg-ink/80 text-[10px] font-body text-emerald-400 border border-white/20 flex items-center gap-1 z-10">
<Lock className="w-2.5 h-2.5" />
<span>Volatile RAM</span>
</div>
<div className="absolute bottom-2 inset-x-2 flex items-center justify-between text-[10px] font-body text-paper-hi px-2.5 py-1 rounded-xl bg-ink/80 border border-white/20 z-10">
<span className="flex items-center gap-1">
<Zap className="w-3 h-3 text-cyan-400 animate-pulse" /> 120 TFLOPS · 0.42s
</span>
<span className="text-amber-300 font-semibold flex items-center gap-1">
Synthesizing <ArrowRight className="w-2.5 h-2.5" />
</span>
</div>
</div>
{/* Text Info */}
<div>
<h3 className="text-base sm:text-lg font-body font-bold text-ink">
<AnimatedShinyText>Synchronous neural inference</AnimatedShinyText>
</h3>
<p className="mt-1 text-xs text-muted leading-relaxed font-body">
Inference executes inside isolated volatile GPU memory. The model separates alpha strands, clears blemishes, or interpolates sub-pixel details.
</p>
</div>
{/* Bullet Points */}
<ul className="space-y-1.5 text-xs text-ink-2 pt-2 border-t border-rule font-body">
<li className="flex items-center gap-2">
<Check className="w-3.5 h-3.5 text-accent shrink-0" aria-hidden="true" />
<span>Zero disk storage retention policy</span>
</li>
<li className="flex items-center gap-2">
<Check className="w-3.5 h-3.5 text-accent shrink-0" aria-hidden="true" />
<span>Sub-second GPU turnaround time</span>
</li>
</ul>
</div>
<div className="mt-5 pt-3 border-t border-rule flex items-center justify-between text-xs text-muted font-body">
<span className="flex items-center gap-1 text-accent font-medium">
<Zap className="w-3.5 h-3.5" /> Volatile GPU stream
</span>
<span className="text-[11px] font-body text-accent">Stage 2 of 3</span>
</div>
</div>
{/* ================= STEP 3: LOSSLESS STUDIO EXPORT ================= */}
<div
ref={card3Ref}
onClick={() => setActiveStep(3)}
className={`w-[85vw] sm:w-[350px] md:w-auto shrink-0 md:shrink snap-center cursor-pointer studio-sheet p-5 sm:p-6 rounded-3xl bg-paper-hi border shadow-sheet flex flex-col justify-between motion-safe:transition-[border-color,box-shadow,transform] duration-200 relative overflow-hidden ${
activeStep === 3
? 'border-accent shadow-glow ring-2 ring-accent/20 scale-[1.01]'
: 'border-rule hover:border-accent/60 opacity-90'
}`}
>
{/* Active Step Progress Indicator Bar */}
<div className="absolute top-0 inset-x-0 h-1 bg-paper-2 overflow-hidden">
{activeStep === 3 && (
<div className="h-full bg-accent transition-opacity duration-300 w-full animate-pulse" />
)}
</div>
<div className="space-y-4">
{/* Header: Step number & Icon */}
<div className="flex items-center justify-between border-b border-rule pb-3">
<div className="flex items-center gap-2">
<span className="w-6 h-6 rounded-full bg-accent/10 text-accent font-bold text-xs flex items-center justify-center font-mono">
03
</span>
<span className="text-xs font-semibold text-accent font-body">
Studio export
</span>
</div>
<div className="w-8 h-8 rounded-full bg-paper-2 border border-rule flex items-center justify-center text-accent">
<Download className="w-4 h-4" aria-hidden="true" />
</div>
</div>
{/* VISUAL IMAGE SPECIMEN 3: Pristine 4K Enhanced Studio Master */}
<div className="relative w-full h-44 sm:h-48 rounded-2xl overflow-hidden bg-paper-2 border border-rule shadow-inner">
<Image
src="/management/pages/tools/photo-enhancer/media/after.jpg"
alt="Enhanced studio output specimen"
fill
className="object-cover object-top opacity-100 filter brightness-105"
sizes="(max-width: 768px) 100vw, 33vw"
/>
{/* 4K UHD Master Badge */}
<div className="pointer-events-none absolute top-2 right-2 px-2.5 py-0.5 rounded-full bg-amber-500 text-stone-950 font-bold text-[10px] font-body shadow-sm flex items-center gap-1 z-10">
<Sparkles className="w-3 h-3 fill-stone-950" />
<span>4K UHD master</span>
</div>
{/* Before/After Split Line Indicator */}
<div className="pointer-events-none absolute inset-y-0 left-1/2 w-[2px] bg-white shadow-sm z-10">
<div className="absolute top-1/2 -translate-y-1/2 -left-3 w-6 h-6 rounded-full bg-white text-ink text-[10px] font-bold flex items-center justify-center shadow-md">
⇄
</div>
</div>
<div className="absolute bottom-2 inset-x-2 flex items-center justify-between text-[10px] font-body text-paper-hi px-2.5 py-1 rounded-xl bg-ink/80 border border-white/20 z-10">
<span className="flex items-center gap-1 text-emerald-300">
<CheckCircle2 className="w-3 h-3 text-emerald-400" /> Lossless PNG
</span>
<span className="text-amber-300 font-semibold flex items-center gap-1">
Download ready <Download className="w-2.5 h-2.5" />
</span>
</div>
</div>
{/* Text Info */}
<div>
<h3 className="text-base sm:text-lg font-body font-bold text-ink">
<AnimatedShinyText>Inspect & download result</AnimatedShinyText>
</h3>
<p className="mt-1 text-xs text-muted leading-relaxed font-body">
Compare the output against the original with the interactive slider. Download the high-definition result directly or hand off to mobile for batch 4K.
</p>
</div>
{/* Bullet Points */}
<ul className="space-y-1.5 text-xs text-ink-2 pt-2 border-t border-rule font-body">
<li className="flex items-center gap-2">
<Check className="w-3.5 h-3.5 text-accent shrink-0" aria-hidden="true" />
<span>Full fidelity download in browser</span>
</li>
<li className="flex items-center gap-2">
<Check className="w-3.5 h-3.5 text-accent shrink-0" aria-hidden="true" />
<span>Direct QR handoff to native apps</span>
</li>
</ul>
</div>
<div className="mt-5 pt-3 border-t border-rule flex items-center justify-between text-xs text-muted font-body">
<span className="flex items-center gap-1 text-emerald-600 font-medium">
<CheckCircle2 className="w-3.5 h-3.5" /> Production ready export
</span>
<span className="text-[11px] font-body text-accent">Stage 3 of 3</span>
</div>
</div>
</div>
{/* Mobile Step Indicators & Swipe Guidance (Phone screens only) */}
<div className="flex md:hidden items-center justify-between px-1 text-xs text-muted font-body">
<div className="flex items-center gap-1.5" role="tablist" aria-label="Process steps">
{[1, 2, 3].map((step) => (
<button
key={step}
type="button"
onClick={() => setActiveStep(step as 1 | 2 | 3)}
className={`h-1.5 rounded-full transition-all duration-300 ${
activeStep === step ? 'w-7 bg-accent' : 'w-2 bg-rule hover:bg-muted'
}`}
aria-label={`Go to step ${step}`}
/>
))}
</div>
<span className="text-[11px] text-muted flex items-center gap-1 font-body">
<span>Swipe steps</span>
<ArrowRight className="w-3 h-3 text-accent inline" />
</span>
</div>
{/* Clean Privacy Reassurance Strip */}
<div className="studio-sheet rounded-3xl p-5 sm:p-6 flex flex-col sm:flex-row items-center justify-between gap-5 border border-rule bg-gradient-to-r from-paper-hi via-paper-2 to-paper-hi">
<div className="flex items-center gap-3.5">
<div className="w-11 h-11 rounded-2xl bg-accent/10 text-accent flex items-center justify-center shrink-0 border border-accent/20">
<ShieldCheck className="w-6 h-6" aria-hidden="true" />
</div>
<div>
<h4 className="font-body font-semibold text-ink text-sm sm:text-base">
Zero photo retention and free daily browser trials
</h4>
<p className="text-xs text-muted mt-0.5 font-body">
All photos are processed exclusively in volatile GPU memory and immediately purged upon stream completion.
</p>
</div>
</div>
<InteractiveHoverButton
text="Try our tools now"
href="#our-tools"
className="w-full sm:w-auto shrink-0 min-h-[48px]"
/>
</div>
</div>
</section>
);
}