'use client'; import { useEffect, useRef, useState } from 'react'; import { Play, X } from 'lucide-react'; import { sendGAEvent } from '@/app/utils/analytics'; import { MARKETING_FILM, filmSrc, formatTime } from './media'; /** * The marketing film as the hero centrepiece. It shows the film's poster * until someone presses play, then plays from R2 in place; closing it * returns to the still. The frame tilts back in perspective and stands up as the page scrolls. */ export default function HeroFilm() { const stageRef = useRef(null); const [watching, setWatching] = useState(false); // Scroll-linked tilt: --tilt goes 1 → 0 as the frame rises into view. useEffect(() => { const stage = stageRef.current; if (!stage || window.matchMedia('(prefers-reduced-motion: reduce)').matches) { stage?.style.setProperty('--tilt', '0'); return; } let frame = 0; const update = () => { frame = 0; const rect = stage.getBoundingClientRect(); const viewport = window.innerHeight; const progress = Math.min(1, Math.max(0, (viewport - rect.top) / (viewport * 0.75))); stage.style.setProperty('--tilt', (1 - progress).toFixed(4)); }; const onScroll = () => { if (!frame) frame = requestAnimationFrame(update); }; update(); window.addEventListener('scroll', onScroll, { passive: true }); window.addEventListener('resize', onScroll); return () => { cancelAnimationFrame(frame); window.removeEventListener('scroll', onScroll); window.removeEventListener('resize', onScroll); }; }, []); const watch = () => { setWatching(true); sendGAEvent('film_play_sound', { film: 'marketing' }); }; return (
); }