"use client";

import { m, LazyMotion, domAnimation } from "framer-motion";
import { pageTransition } from "@/lib/motion";

/**
 * Applies the shared cross-route transition to every page — Sprint 3 Motion System, "page transitions".
 * Sprint 8: mounts the single LazyMotion provider every `m.*` usage site-wide resolves against —
 * this is what makes the `motion` → `m` conversion actually shrink the shipped bundle (loads the
 * `domAnimation` feature set once, lazily, instead of every client component pulling in the full API).
 */
export default function Template({ children }: { children: React.ReactNode }) {
  return (
    <LazyMotion features={domAnimation} strict>
      <m.div initial="hidden" animate="visible" exit="exit" variants={pageTransition}>
        {children}
      </m.div>
    </LazyMotion>
  );
}
