import Image from "next/image";
import type { ReactNode } from "react";
import { buttonVariants } from "@/components/ui/button";
import { Section } from "./section";

/** Classes for the banner's button (white pill; smaller and centred on phones). */
export const ctaBannerActionClass = buttonVariants({
  variant: "white",
  size: "pill-lg",
  className: "text-text-dark max-lg:py-2.5 max-lg:text-sm max-md:self-center",
});

type CtaBannerProps = {
  titleId: string;
  title: string;
  description: string;
  imageAlt: string;
  /** The button (a link or a download), styled with `ctaBannerActionClass`. */
  action: ReactNode;
  className?: string;
};

/**
 * Riyadh-aerial banner with a gradient title, a line of text and one button
 * (Home "Powering Riyadh's Digital Skyline", Career "Don't see the right role").
 */
export function CtaBanner({ titleId, title, description, imageAlt, action, className }: CtaBannerProps) {
  return (
    <Section labelledBy={titleId} className={className ?? "py-0"}>
      <div className="relative isolate overflow-hidden rounded-3xl lg:min-h-80">
        <Image src="/images/home/riyadh-aerial.jpg" alt={imageAlt} fill sizes="100vw" className="-z-20 object-cover opacity-35" />
        <div aria-hidden className="absolute inset-0 -z-10 bg-banner-overlay" />

        {/* Phone & tablet (Figma 390 / 744): stacked, 20px sides, 40px top / 20px bottom. Desktop: side by side. */}
        <div className="flex flex-col items-start gap-8 px-6 py-12 max-lg:gap-5 max-lg:px-5 max-lg:pt-10 max-lg:pb-5 lg:flex-row lg:items-center lg:justify-between lg:px-20 lg:py-[105px]">
          <div className="flex max-w-xl flex-col gap-4">
            <h2 id={titleId} className="text-gradient-brand font-heading text-[32px] leading-[45px] font-black lg:text-4xl">
              {title}
            </h2>
            <p className="text-base leading-6 text-white max-lg:text-xs max-lg:leading-5">{description}</p>
          </div>
          {action}
        </div>
      </div>
    </Section>
  );
}
