import { motion, useReducedMotion } from "framer-motion";
import type { ReactNode } from "react";

export function ScaleIn({
  children,
  from = 0.95,
  delay = 0,
  duration = 0.7,
  className,
}: {
  children: ReactNode;
  from?: number;
  delay?: number;
  duration?: number;
  className?: string;
}) {
  const reduce = useReducedMotion();
  return (
    <motion.div
      className={className}
      initial={{ opacity: 0, scale: reduce ? 1 : from }}
      whileInView={{ opacity: 1, scale: 1 }}
      viewport={{ once: true, margin: "-80px" }}
      transition={{ duration, delay, ease: [0.22, 1, 0.36, 1] }}
    >
      {children}
    </motion.div>
  );
}
