import { cn } from "cn";

type HighlightedTitleProps = {
  as?: "h1" | "h2";
  id?: string;
  start: string;
  highlight: string;
  end: string;
  /** Size / line-height classes; color and weight are set here. */
  className?: string;
  /** Classes for the break after the highlight, e.g. "md:max-lg:hidden" to join the last two lines. */
  secondBreakClassName?: string;
};

/**
 * Three-line heading with a gradient middle line, e.g.
 * "Towards a / Smarter Future / Together." and "Pioneering Digital / Transformation / in Saudi Arabia".
 */
export function HighlightedTitle({ as: Heading = "h2", id, start, highlight, end, className, secondBreakClassName }: HighlightedTitleProps) {
  return (
    <Heading id={id} className={cn("font-heading font-black text-heading", className)}>
      {start}
      <br />
      <span className="text-gradient-brand">{highlight}</span>
      <br className={secondBreakClassName} />
      {secondBreakClassName && " "}
      {end}
    </Heading>
  );
}
