import type { ReactNode } from "react";
import { cn } from "cn";

/** Small mono label with a leading line, e.g. "— WHAT WE OFFER". */
export function SectionLabel({ children, className }: { children: ReactNode; className?: string }) {
  return (
    <p className={cn("flex items-center gap-3 font-mono text-xs leading-4 font-bold tracking-[1.44px] text-default uppercase", className)}>
      <span aria-hidden className="h-px w-6 bg-default" />
      {children}
    </p>
  );
}

type SectionHeadingProps = {
  label: string;
  title: string;
  /** Rendered at the end of the row (e.g. "See All"). */
  action?: ReactNode;
  id?: string;
};

export function SectionHeading({ label, title, action, id }: SectionHeadingProps) {
  return (
    <div className="flex flex-wrap items-end justify-between gap-4">
      <div>
        <SectionLabel>{label}</SectionLabel>
        <h2 id={id} className="pt-3 font-heading text-[32px] leading-10 font-black text-default lg:text-5xl lg:leading-12">
          {title}
        </h2>
      </div>
      {action}
    </div>
  );
}
