'use client'; import { useEffect, useRef } from 'react'; import Image from 'next/image'; /** * CSS device frames that hold real Jotley screenshots and screen recordings. * Proportions follow the actual hardware so the app UI is shown at true aspect. */ type ScreenMedia = { image: string; video?: string }; /** A muted looping clip that only plays while on screen (and never with reduced motion). */ function ScreenClip({ video, poster }: { video: string; poster: string }) { const ref = useRef(null); useEffect(() => { const element = ref.current; if (!element) return; const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches; if (reducedMotion) return; const observer = new IntersectionObserver( ([entry]) => { if (entry.isIntersecting) { if (!element.src) element.src = video; void element.play().catch(() => undefined); } else { element.pause(); } }, { rootMargin: '120px 0px' } ); observer.observe(element); return () => { observer.disconnect(); element.pause(); }; }, [video]); return