import { cn } from "cn";
import { StepNumber } from "./step-number";

type Step = { title: string; description: string };

/** Desktop: numbers joined by a line, text centered under each one. */
export function ProcessTimeline({ steps, className }: { steps: Step[]; className?: string }) {
  return (
    <ol className={cn("grid-cols-5", className)}>
      {steps.map((step, i) => (
        <li key={step.title} className="relative flex flex-col items-center gap-6 text-center">
          {i > 0 && (
            // Connector from the previous number to this one (44px = 20px radius + 24px gap on each side).
            <span aria-hidden className="absolute top-5 end-[calc(50%+44px)] h-px w-[calc(100%-88px)] bg-subtle/50" />
          )}
          <StepNumber n={i + 1} />
          <div className="flex max-w-60 flex-col gap-2 font-display leading-[1.66] tracking-[0.4px]">
            <h3 className="text-base font-bold text-default">{step.title}</h3>
            <p className="text-sm text-soft">{step.description}</p>
          </div>
        </li>
      ))}
    </ol>
  );
}
