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

316 lines
15 KiB
TypeScript
Raw Normal View History

'use client';
import React, { useRef, useState, useEffect } from 'react';
import Link from 'next/link';
import { Sparkles, ArrowRight, Smartphone } from 'lucide-react';
import { Cinematic3DComparison } from '@/components/ui/Cinematic3DComparison';
interface ShowcaseCard {
id: string;
index: string;
category: string;
model: string;
latency: string;
title: string;
tagline: string;
description: string;
toolSlug: string;
appSlug: string;
appName: string;
beforeUrl: string;
afterUrl: string;
specs: string[];
}
const showcaseCards: ShowcaseCard[] = [
{
id: 'matting',
index: '01 / 03',
category: 'ALPHA MATTING ARCHIVE',
model: 'P3M-Net Dual-Stream Alpha',
latency: '< 520ms Stream',
title: 'Hair-Strand Matting & Alpha Isolation',
tagline: 'Sub-pixel edge detection with microscopic flyaway hair preservation.',
description: 'Trained on high-resolution studio portraits, P3M-Net isolates individual flyaway hair strands, fur, and translucent fabrics without halo artifacts or jagged edges. Streams transparent alpha PNGs in real-time.',
toolSlug: 'background-remover',
appSlug: 'bg-cleaner-app',
appName: 'Magic Cutout Studio',
beforeUrl: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=800&auto=format&fit=crop&q=80',
afterUrl: 'https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=800&auto=format&fit=crop&q=80',
specs: ['Sub-pixel flyaway detection', 'Lossless alpha PNG export', 'Zero edge halo bleeding'],
},
{
id: 'retouch',
index: '02 / 03',
category: 'DERMAL RESTORATION',
model: 'RetouchGAN v2.1 Micro-Pore',
latency: '< 380ms Stream',
title: 'Sub-Pore Skin Retouching & Blemish Removal',
tagline: 'Authentic microscopic texture preservation without plastic smoothing.',
description: 'Unlike standard beauty filters that smear your face into plastic, RetouchGAN operates at the dermal level—erasing acne, blemishes, and under-eye redness while reconstructing microscopic skin pore geometry.',
toolSlug: 'blemish-remover',
appSlug: 'portrait-app',
appName: 'Portrait Studio AI',
beforeUrl: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=800&auto=format&fit=crop&q=80',
afterUrl: 'https://images.unsplash.com/photo-1517841905240-472988babdf9?w=800&auto=format&fit=crop&q=80',
specs: ['Microscopic pore geometry', 'Instant scar & redness repair', 'True-to-life dermal tones'],
},
{
id: 'enhancer',
index: '03 / 03',
category: '4K SUPER-RESOLUTION',
model: 'GFPGAN + RealESRGAN Ultra',
latency: '< 460ms Stream',
title: '4K Super-Resolution & Facial Deblurring',
tagline: 'Transform low-resolution snapshots into crystal-clear 4K portraits.',
description: 'Deep neural priors restore authentic iris sharpness, eyelash detail, and facial contours on blurry, out-of-focus, or highly compressed photos, yielding gallery-ready clarity with zero guesswork.',
toolSlug: 'photo-enhancer',
appSlug: 'photo-enhancer-pro',
appName: 'Enhance Ultra AI',
beforeUrl: 'https://images.unsplash.com/photo-1544005313-94ddf0286df2?w=800&auto=format&fit=crop&q=80',
afterUrl: 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=800&auto=format&fit=crop&q=80',
specs: ['Iris & eyelash synthesis', '400% lossless super-resolution', 'Studio-grade crispness'],
},
];
export function CinematicHorizontalScrollSection() {
const containerRef = useRef<HTMLDivElement>(null);
const trackRef = useRef<HTMLDivElement>(null);
const bgTextRef = useRef<HTMLDivElement>(null);
const progressBarRef = useRef<HTMLDivElement>(null);
const progressTextRef = useRef<HTMLSpanElement>(null);
useEffect(() => {
let rafId: number;
let targetX = 0;
let currentX = 0;
let isTracking = true;
// High-precision lerp animation loop (eliminates CSS transition conflicts for butter-smooth 120 FPS glide)
const updateMotion = () => {
if (!isTracking) return;
if (containerRef.current && trackRef.current) {
const rect = containerRef.current.getBoundingClientRect();
const totalScrollable = containerRef.current.offsetHeight - window.innerHeight;
if (totalScrollable > 0) {
const rawProgress = Math.min(Math.max(-rect.top / totalScrollable, 0), 1);
const maxTranslate = trackRef.current.scrollWidth - window.innerWidth;
if (maxTranslate > 0) {
targetX = rawProgress * maxTranslate;
}
// Smooth exponential damping (lerp factor 0.085)
currentX += (targetX - currentX) * 0.085;
// Apply 100% GPU compositor transform without CSS transition lag
trackRef.current.style.transform = `translate3d(-${currentX.toFixed(2)}px, 0, 0)`;
// Parallax 3D background typography ribbon drifting in opposite perspective
if (bgTextRef.current) {
bgTextRef.current.style.transform = `translate3d(-${(currentX * 0.4).toFixed(2)}px, 0, 0) rotateX(10deg)`;
}
// Update Progress Indicator directly in DOM (zero React re-renders)
const liveProgress = Math.min(Math.max(currentX / (maxTranslate || 1), 0), 1);
if (progressBarRef.current) {
progressBarRef.current.style.width = `${Math.max(liveProgress * 100, 4).toFixed(1)}%`;
}
if (progressTextRef.current) {
progressTextRef.current.textContent = `PROGRESS ${Math.round(liveProgress * 100)}%`;
}
// 3D Perspective rotational offset on individual cards
const cards = trackRef.current.children;
const screenCenter = window.innerWidth / 2;
for (let i = 0; i < cards.length; i++) {
const card = cards[i] as HTMLElement;
const cardRect = card.getBoundingClientRect();
const cardCenter = cardRect.left + cardRect.width / 2;
const dist = (cardCenter - screenCenter) / (window.innerWidth * 0.6);
const rotY = Math.max(Math.min(dist * -8, 14), -14);
const scale = Math.max(1 - Math.abs(dist) * 0.04, 0.94);
card.style.transform = `perspective(1200px) rotateY(${rotY.toFixed(2)}deg) scale3d(${scale.toFixed(3)}, ${scale.toFixed(3)}, 1)`;
}
}
}
rafId = requestAnimationFrame(updateMotion);
};
rafId = requestAnimationFrame(updateMotion);
return () => {
isTracking = false;
cancelAnimationFrame(rafId);
};
}, []);
return (
<section
id="flagship-models"
ref={containerRef}
className="relative h-[290vh] sm:h-[350vh] bg-[#FAF8F5] border-t border-slate-900/[0.08] overflow-visible"
>
{/* Sticky Fullscreen Camera Viewport */}
<div className="sticky top-0 h-screen w-full overflow-hidden flex flex-col justify-between py-10 sm:py-14 select-none">
{/* Massive 3D Kinetic Background Typography Ribbon (Parallax Drift) */}
<div
ref={bgTextRef}
className="absolute top-1/2 -translate-y-1/2 left-0 w-max whitespace-nowrap pointer-events-none -z-10 opacity-30 select-none preserve-3d"
aria-hidden="true"
>
<span className="font-display font-black text-[13vw] uppercase tracking-tighter text-transparent bg-clip-text bg-gradient-to-r from-slate-900/10 via-blue-900/15 to-amber-900/10 block leading-none">
01 ALPHA MATTING // 02 DERMAL RETOUCH // 03 4K SUPER-RES // STUDIO ARCHIVE //
</span>
</div>
{/* Ambient Subtle Gradients */}
<div className="absolute top-1/4 left-1/3 w-[500px] h-[500px] bg-blue-500/[0.035] rounded-full blur-3xl pointer-events-none -z-10" />
<div className="absolute bottom-1/4 right-1/4 w-[450px] h-[450px] bg-amber-500/[0.03] rounded-full blur-3xl pointer-events-none -z-10" />
{/* Section Top Header & Navigation Telemetry with 3D Depth */}
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 w-full z-10 flex flex-col sm:flex-row sm:items-end justify-between gap-4">
<div className="preserve-3d">
<div className="badge-3d inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-blue-50/90 border border-blue-200/80 text-[11px] font-mono font-semibold text-blue-700 mb-2 shadow-sm">
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
<span>HORIZONTAL 3D CINEMATIC ARCHIVE</span>
</div>
<h2 className="text-2xl sm:text-4xl lg:text-5xl font-display font-black text-slate-900 tracking-tight text-3d-chiseled">
Flagship Transformations <span className="text-transparent bg-clip-text bg-gradient-to-r from-blue-700 via-indigo-600 to-amber-600 text-3d-gradient">In Real-Time</span>
</h2>
</div>
<div className="flex items-center gap-3">
<span className="text-xs font-mono font-bold text-slate-500 uppercase tracking-widest hidden sm:inline">
SCROLL DOWN TO PAN HORIZONTALLY
</span>
<div className="flex items-center gap-1.5 px-3 py-1 rounded-lg bg-white/80 backdrop-blur-sm border border-slate-900/[0.06] text-xs font-mono font-bold text-slate-700 shadow-sm">
<span className="w-2 h-2 rounded-full bg-blue-600 animate-ping inline-block" />
<span ref={progressTextRef}>PROGRESS 0%</span>
</div>
</div>
</div>
{/* Horizontal Sliding Filmstrip Track (Zero CSS transition conflicts, 100% hardware GPU translation) */}
<div className="relative w-full my-auto overflow-visible py-4">
<div
ref={trackRef}
className="flex items-center gap-8 sm:gap-14 px-6 sm:px-12 lg:px-20 w-max will-change-transform preserve-3d"
>
{showcaseCards.map((card) => (
<div
key={card.id}
className="w-[85vw] sm:w-[620px] lg:w-[740px] shrink-0 bg-white/95 backdrop-blur-xl rounded-3xl p-5 sm:p-8 border border-slate-900/[0.08] shadow-cinematic-3d hover:shadow-cinematic-hover transition-shadow duration-300 preserve-3d group"
>
{/* Card Top Metadata Bar (translateZ 30px) */}
<div
className="flex items-center justify-between pb-4 border-b border-slate-900/[0.06] mb-5 preserve-3d"
style={{ transform: 'translateZ(30px)' }}
>
<div className="flex items-center gap-3">
<span className="font-mono text-xs font-black text-blue-700 tracking-wider">
{card.index}
</span>
<span className="h-3 w-px bg-slate-300" />
<span className="font-mono text-[10px] sm:text-xs font-bold text-slate-500 uppercase tracking-widest">
{card.category}
</span>
</div>
<div className="flex items-center gap-2">
<span className="px-2.5 py-1 rounded-md bg-amber-50 border border-amber-200/60 text-[10px] font-mono font-semibold text-amber-800">
{card.latency}
</span>
</div>
</div>
{/* 3D Cinematic Comparison Viewport */}
<div className="mb-6 relative z-10">
<Cinematic3DComparison
beforeUrl={card.beforeUrl}
afterUrl={card.afterUrl}
beforeLabel="RAW SOURCE"
afterLabel={card.model}
aspectRatio="aspect-[16/10]"
/>
</div>
{/* Card 3D Stereoscopic Typography Stack */}
<div className="space-y-3 preserve-3d">
{/* Headline at translateZ 45px with 3D Chiseled Extrusion */}
<h3
className="text-xl sm:text-2xl font-display font-bold text-slate-900 tracking-tight preserve-3d text-3d-chiseled"
style={{ transform: 'translateZ(45px)' }}
>
{card.title}
</h3>
{/* Description at translateZ 25px */}
<p
className="text-sm text-slate-600 leading-relaxed font-normal preserve-3d"
style={{ transform: 'translateZ(25px)' }}
>
{card.description}
</p>
{/* Specs Chips at translateZ 35px */}
<div
className="flex flex-wrap gap-2 pt-2 preserve-3d"
style={{ transform: 'translateZ(35px)' }}
>
{card.specs.map((spec, i) => (
<span
key={i}
className="px-2.5 py-1 rounded-lg bg-slate-100 text-slate-700 text-xs font-mono font-medium border border-slate-200/60"
>
✓ {spec}
</span>
))}
</div>
{/* Actions at translateZ 50px */}
<div
className="pt-4 flex flex-wrap items-center justify-between gap-3 border-t border-slate-900/[0.06] preserve-3d"
style={{ transform: 'translateZ(50px)' }}
>
<Link
href={`/tools/${card.toolSlug}`}
className="inline-flex items-center gap-2 text-xs font-bold text-blue-700 hover:text-blue-900 group/link"
>
<span>Launch Interactive Studio</span>
<ArrowRight className="w-3.5 h-3.5 group-hover/link:translate-x-1 transition-transform" />
</Link>
<Link
href={`/apps/${card.appSlug}`}
className="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-slate-900 text-white text-xs font-bold hover:bg-blue-700 transition-colors shadow-sm"
>
<Smartphone className="w-3.5 h-3.5" />
<span>{card.appName}</span>
</Link>
</div>
</div>
</div>
))}
</div>
</div>
{/* Section Bottom Progress Indicator Bar */}
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 w-full z-10">
<div className="w-full bg-slate-200/80 h-1.5 rounded-full overflow-hidden shadow-inner">
<div
ref={progressBarRef}
className="h-full bg-gradient-to-r from-blue-600 via-indigo-600 to-amber-500 rounded-full will-change-transform"
style={{ width: '4%' }}
/>
</div>
</div>
</div>
</section>
);
}