"use client";

import { useState, useEffect } from "react";

export function useStaggerReveal(count: number, baseDelay = 80) {
  const [visible, setVisible] = useState<Set<number>>(new Set());

  useEffect(() => {
    const timers: ReturnType<typeof setTimeout>[] = [];
    for (let i = 0; i < count; i++) {
      timers.push(
        setTimeout(
          () => setVisible((prev) => new Set(prev).add(i)),
          baseDelay * (i + 1) + 200
        )
      );
    }
    return () => timers.forEach(clearTimeout);
  }, [count, baseDelay]);

  return visible;
}

export function useMountTransition(delay = 50) {
  const [mounted, setMounted] = useState(false);

  useEffect(() => {
    const t = setTimeout(() => setMounted(true), delay);
    return () => clearTimeout(t);
  }, [delay]);

  return mounted;
}
