import Image from "next/image";
import type { CSSProperties } from "react";
import type { Mockup } from "@/content/catalog";
import { DetailsMockup } from "./details-mockup";

type DetailsHeroSectionProps = {
  badge: string;
  title: string;
  paragraphs: string[];
  featuresLabel: string;
  features: string[];
  /** Badge and chip color (a CSS color, e.g. a token var). */
  accent: string;
  background: string;
  mockup: Mockup;
  mockupAlt: string;
};

/**
 * Project / product details (Figma "Motakamel" & co.): faded project photo, a colored badge, the name, the description,
 * the device card and the feature chips.
 * Desktop (1440): text on the start side, the card (320×384) on the end side, centred in 880px.
 * Tablet (744) and phone (390): one column — badge, name, text, card (full width), features.
 * data-figma-small-text: 10px chips on phones come from the Figma phone frame.
 */
export function DetailsHeroSection(props: DetailsHeroSectionProps) {
  return (
    <section
      aria-labelledby="details-title"
      data-figma-small-text
      style={{ "--accent": props.accent } as CSSProperties}
      className="relative isolate overflow-hidden py-[120px] lg:flex lg:min-h-[880px] lg:items-center lg:py-32"
    >
      <div aria-hidden className="absolute inset-x-0 top-0 -z-10 h-[880px]">
        <Image src={props.background} alt="" fill priority sizes="100vw" className="object-cover opacity-50" />
        <div className="absolute inset-0 bg-career-hero-overlay" />
      </div>

      <div className="container-site">
        <div className="grid items-center gap-5 lg:grid-cols-[minmax(0,1fr)_320px] lg:gap-x-10 lg:gap-y-7 lg:px-20">
          <p className="flex h-[38px] w-fit items-center justify-center rounded-[20px] border border-(--accent)/20 bg-(--accent)/20 px-4 font-mono text-xs leading-4 font-bold text-(--accent) uppercase backdrop-blur-[10px] md:w-[270px] md:text-sm">
            {props.badge}
          </p>
          <h1 id="details-title" className="font-heading text-2xl leading-none font-black tracking-[-1.7px] text-white md:text-[32px] lg:text-[68px]">
            {props.title}
          </h1>
          <div className="text-xs leading-5 text-default md:text-sm md:leading-[22px] lg:max-w-lg lg:text-lg lg:leading-[29.25px]">
            {props.paragraphs.map((p) => (
              <p key={p.slice(0, 24)}>{p}</p>
            ))}
          </div>
          <DetailsMockup mockup={props.mockup} alt={props.mockupAlt} className="lg:col-start-2 lg:row-span-4 lg:row-start-1" />
          <div className="flex flex-col gap-2.5 lg:gap-3">
            <h2 className="text-sm leading-[29.25px] font-bold text-default md:text-lg">{props.featuresLabel}</h2>
            <ul className="flex flex-wrap gap-3">
              {props.features.map((feature) => (
                <li key={feature} className="rounded-full border border-(--accent) px-3 py-2 text-[10px] leading-4 font-semibold text-(--accent) md:text-sm">
                  {feature}
                </li>
              ))}
            </ul>
          </div>
        </div>
      </div>
    </section>
  );
}
