"use client"; import { useRef } from "react"; import { motion, useInView, useReducedMotion } from "motion/react"; import type { Milestone } from "@/components/roadmap/milestones"; import { blockEase } from "@/lib/block-motion"; import { type } from "@/lib/typography"; import { cn } from "@/lib/utils"; type TimelineItemProps = { milestone: Milestone; index: number; side: "left" | "right"; active: boolean; completed: boolean; itemRef: (element: HTMLElement | null) => void; nodeRef: (element: HTMLDivElement | null) => void; /** Mobile stacked card — used to clip the rail to card bounds */ cardRef: (element: HTMLElement | null) => void; onSelect: () => void; }; const cardSpring = { type: "spring" as const, stiffness: 280, damping: 28, mass: 0.85, }; function TimelineConnector({ side, active, completed, }: { side: "left" | "right"; active: boolean; completed: boolean; }) { const lit = active || completed; return ( ); } function TimelineCard({ milestone, side, active, onSelect, }: { milestone: Milestone; side: "left" | "right"; active: boolean; onSelect: () => void; }) { const cardRef = useRef(null); const reduceMotion = useReducedMotion(); const inView = useInView(cardRef, { once: true, amount: 0.35, margin: "0px 0px -8% 0px", }); const enterX = side === "left" ? -28 : 28; return (
{milestone.numeral}

{milestone.title}

{milestone.description}

); } export function TimelineItem({ milestone, index, side, active, completed, itemRef, nodeRef, cardRef, onSelect, }: TimelineItemProps) { return (
  • {/* Mobile/tablet: stacked — centered node, full-width card over the rail. Desktop (lg+): alternating left/right cards with horizontal connectors. */}
    {/* Desktop — left card */} {/* Center node — centered above card on mobile/tablet; rail column on desktop */}
    {/* Mobile/tablet card (above rail) + desktop right card. Ref stays on the static wrapper so motion transforms don't skew rail math. */}
  • ); }