import Link from "next/link";
import { ArrowUpRight, Building2, DraftingCompass, KeyRound, Landmark, Scale, TrendingUp, type LucideIcon } from "lucide-react";
import { localizedPath, type Locale, type ServiceSlug } from "@alterra/shared";
import Reveal from "../Reveal";
import SectionHeading from "../SectionHeading";
import type { HomeCopy } from "@/lib/home";
import type { Menus } from "@/lib/site";

const icons: Record<ServiceSlug, LucideIcon> = {
  "luxury-real-estate": Building2,
  "legal-foreign-investment": Scale,
  "tax-financial-structuring": Landmark,
  "architecture-development": DraftingCompass,
  "investment-opportunities": TrendingUp,
  "property-management-concierge": KeyRound,
};

const slugOf = (path: string) => path.split("/").pop() as ServiceSlug;

export default function Divisions({ copy, lang, services }: { copy: HomeCopy["divisions"]; lang: Locale; services: Menus["services"] }) {
  return (
    <section className="bg-forest py-24 text-cream md:py-32">
      <div className="mx-auto max-w-7xl px-5 md:px-8">
        <SectionHeading eyebrow={copy.eyebrow} title={copy.title} intro={copy.intro} light />

        <div className="mt-16 grid border-t border-cream/15 sm:grid-cols-2 lg:grid-cols-3">
          {services.map((service, i) => {
            const Icon = icons[slugOf(service.path)];
            return (
              <Reveal
                key={service.path}
                delay={(i % 3) * 0.1}
                className="border-b border-cream/15 sm:[&:nth-child(odd)]:border-r lg:[&:nth-child(odd)]:border-r-0 lg:[&:not(:nth-child(3n))]:border-r"
              >
                <Link href={localizedPath(lang, service.path)} className="group flex h-full flex-col py-10 transition-colors hover:bg-moss/50 sm:px-8">
                  <div className="flex items-center justify-between">
                    <Icon size={30} strokeWidth={1.1} className="text-gold-light" />
                    <span className="font-serif text-cream/85">0{i + 1}</span>
                  </div>
                  <h3 className="mt-8 font-serif text-[1.65rem] leading-tight">{service.name}</h3>
                  <p className="mt-4 flex-1 text-[0.95rem] leading-relaxed text-cream/70">{service.line}</p>
                  <span className="eyebrow mt-8 flex items-center gap-2 text-[0.62rem] text-gold-light">
                    {copy.more}
                    <ArrowUpRight size={14} strokeWidth={1.5} className="transition-transform duration-500 group-hover:-translate-y-0.5 group-hover:translate-x-0.5" />
                  </span>
                </Link>
              </Reveal>
            );
          })}
        </div>
      </div>
    </section>
  );
}
