/* 共通フック & ヘルパー */

// scroll-reveal via React state (survives re-renders; parent gets .revealed)
function useInView(opts) {
  const ref = React.useRef(null);
  const [seen, setSeen] = React.useState(false);
  React.useEffect(() => {
    if (seen) return;
    const el = ref.current;
    if (!el) return;
    const io = new IntersectionObserver((entries) => {
      entries.forEach((e) => {
        if (e.isIntersecting) { setSeen(true); io.disconnect(); }
      });
    }, { threshold: (opts && opts.threshold) || 0.15 });
    io.observe(el);
    return () => io.disconnect();
  }, [seen]);
  return [ref, seen];
}

function yen(n) { return "¥" + n.toLocaleString("ja-JP"); }
function pts(n) { return n.toLocaleString("ja-JP"); }

Object.assign(window, { useInView, yen, pts });
