import { motion, useReducedMotion } from 'framer-motion';
import RaceImage from '@/components/race-image';

const fallbackImage =
    'https://images.unsplash.com/photo-1504215680853-026ed2a45def?auto=format&fit=crop&w=2200&q=85';

export default function CinematicPageScene({
    eyebrow,
    title,
    description,
    image,
    imageAlt,
    index = '01',
}: {
    eyebrow: string;
    title: string;
    description: string;
    image: string;
    imageAlt: string;
    index?: string;
}) {
    const reduceMotion = useReducedMotion();

    return (
        <motion.section
            aria-label={`${eyebrow}: ${title}`}
            initial={reduceMotion ? false : { opacity: 0, y: 18 }}
            whileInView={{ opacity: 1, y: 0 }}
            viewport={{ once: true, amount: 0.16 }}
            transition={{ duration: 0.55, ease: 'easeOut' }}
            className="public-cinematic-scene relative isolate flex min-h-[250px] items-end overflow-hidden bg-[#111718] text-white sm:min-h-[290px] lg:min-h-[330px]"
        >
            <RaceImage
                src={image}
                fallbackSrc={fallbackImage}
                alt={imageAlt}
                className="absolute inset-0 -z-20 size-full object-cover object-center"
            />
            <div
                aria-hidden="true"
                className="absolute inset-0 -z-10 bg-[linear-gradient(90deg,rgba(10,14,15,.9)_0%,rgba(10,14,15,.67)_46%,rgba(10,14,15,.12)_100%),linear-gradient(0deg,rgba(10,14,15,.5),transparent_58%)]"
            />
            <div
                aria-hidden="true"
                className="absolute inset-y-0 left-0 -z-10 w-[5px] bg-[#cf3829]"
            />
            <div className="mx-auto grid w-full max-w-[1440px] gap-6 px-5 py-8 sm:px-8 sm:py-10 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end lg:px-12 lg:py-12">
                <div className="max-w-3xl">
                    <p className="flex items-center gap-3 text-[10px] font-black tracking-[.22em] text-[#f3ca58] uppercase sm:text-xs">
                        <span className="font-mono text-white/60">{index}</span>
                        <span
                            aria-hidden="true"
                            className="h-px w-8 bg-[#e8493a]"
                        />
                        {eyebrow}
                    </p>
                    <h2 className="mt-3 text-3xl leading-[.95] font-black tracking-[-.065em] sm:text-4xl lg:text-5xl">
                        {title}
                    </h2>
                    <p className="mt-3 max-w-2xl text-sm leading-6 text-white/75 sm:text-base sm:leading-7">
                        {description}
                    </p>
                </div>
                <p className="hidden pb-1 text-[9px] font-bold tracking-[.18em] text-white/50 uppercase lg:block">
                    Placeholder photography · Unsplash
                </p>
            </div>
        </motion.section>
    );
}
