import { cn } from "cn";
import type { Dictionary } from "@/i18n/get-dictionary";
import { aboutHighlights } from "@/content/catalog";
import { HighlightedTitle } from "@/components/shared/highlighted-title";
import { SectionLabel } from "@/components/shared/section-heading";
import { AboutHighlight } from "./about-highlight";

type AboutCopyProps = {
  t: Dictionary["home"]["about"];
  features: Dictionary["home"]["features"];
  titleId: string;
  className?: string;
};

export function AboutCopy({ t, features, titleId, className }: AboutCopyProps) {
  return (
    // Spacing per Figma: desktop 24px between everything; phone/tablet 20px, the label sits right on
    // the title and the two paragraphs are 10px apart.
    <div className={cn("flex flex-col gap-5 lg:gap-6", className)}>
      <div className="flex flex-col lg:gap-6">
        <SectionLabel className="pb-3">{t.label}</SectionLabel>
        <HighlightedTitle
          id={titleId}
          start={t.titleStart}
          highlight={t.titleHighlight}
          end={t.titleEnd}
          // 40px from 390px up (Figma); scales down below that so "Transformation" fits a 320px screen.
          className="text-[min(40px,10.25vw)] leading-[50px] lg:text-5xl lg:leading-[60px]"
          // Tablet (Figma 744): "Pioneering Digital / Transformation in Saudi Arabia" on two lines.
          secondBreakClassName="md:max-lg:hidden"
        />
      </div>
      <div className="flex flex-col gap-2.5 lg:gap-6">
        {t.paragraphs.map((p) => (
          <p key={p.slice(0, 24)} className="text-xs leading-5 text-soft lg:text-base lg:leading-[26px]">
            {p}
          </p>
        ))}
      </div>
      <ul className="grid gap-5 md:grid-cols-2 lg:gap-0">
        {aboutHighlights.map(({ id, icon }) => (
          <AboutHighlight key={id} icon={icon} title={features[id].title} description={features[id].description} />
        ))}
      </ul>
    </div>
  );
}
