import type { ReactNode } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "cn";

/** Round icon holder used across sections (Figma: 36/40/48px circles). */
const iconBadgeVariants = cva("flex shrink-0 items-center justify-center rounded-full", {
  variants: {
    size: {
      sm: "size-9 [&_svg]:size-4", // About highlights, hero "Client Growth"
      md: "size-10 [&_svg]:size-[18px]", // Why-us strip, contact details, process steps
      lg: "size-12 [&_svg]:size-[22px]", // Service cards
    },
    tone: {
      /** Purple fill, white icon. */
      primary: "bg-primary/20 text-white",
      /** Purple fill + border, white icon. */
      "primary-outline": "border border-primary/40 bg-primary/20 text-white",
      /** Purple fill + soft border, purple icon. */
      "primary-ghost": "border border-primary/30 bg-primary/20 text-primary",
      /** Indigo fill, orchid icon. */
      indigo: "bg-indigo/20 text-orchid-light",
      /** Uses the `--accent` CSS variable set by the parent (service cards). */
      accent: "border border-(--accent)/19 bg-(--accent)/9 text-(--accent)",
    },
  },
  defaultVariants: { size: "md", tone: "primary-outline" },
});

type IconBadgeProps = VariantProps<typeof iconBadgeVariants> & { children: ReactNode; className?: string };

export function IconBadge({ size, tone, className, children }: IconBadgeProps) {
  return <span className={cn(iconBadgeVariants({ size, tone }), className)}>{children}</span>;
}
