/* Shared viewport hook — exposes window.useViewport() returning the
   current width plus mobile/tablet/desktop booleans. Used across the
   Rust Truck screens to adapt layout. */
(function () {
  function useViewport() {
    const get = () => (typeof window !== 'undefined' ? window.innerWidth : 1280);
    const [w, setW] = React.useState(get());
    React.useEffect(() => {
      let raf = 0;
      const onResize = () => {
        cancelAnimationFrame(raf);
        raf = requestAnimationFrame(() => setW(get()));
      };
      window.addEventListener('resize', onResize);
      return () => { window.removeEventListener('resize', onResize); cancelAnimationFrame(raf); };
    }, []);
    return { w, mobile: w < 680, tablet: w >= 680 && w < 1040, desktop: w >= 1040 };
  }
  window.useViewport = useViewport;
})();
