'use client';

import * as m from 'motion/react-m';
import type { ReactNode } from 'react';
import { ease } from './presets';

type RevealProps = {
  children: ReactNode;
  className?: string;
  delay?: number;
  y?: number;
};

/**
 * Viewport entrance: opacity + vertical translate only (RTL-safe).
 * Reduced-motion and no-JS fallbacks live in globals.css / the layout <noscript>.
 */
export function Reveal({ children, className, delay = 0, y = 28 }: RevealProps) {
  return (
    <m.div
      data-reveal
      className={className}
      initial={{ opacity: 0, y }}
      whileInView={{ opacity: 1, y: 0 }}
      viewport={{ once: true, margin: '0px 0px -10% 0px' }}
      transition={{ duration: 0.9, ease, delay }}
    >
      {children}
    </m.div>
  );
}
