import Link from "next/link";
import { InteractiveContainer } from "@/app/components/InteractiveContainer";
import Image, { StaticImageData } from "next/image";
import { Container } from "@/app/components/layout/Container";
import { popularProductsData } from "../_data/home-data";
import Heading from "@/app/components/ui/Heading";

function PopularProductCard({
  img,
  title,
  href,
}: {
  img: StaticImageData;
  title: string;
  href: string;
}) {
  return (
    <InteractiveContainer step={4} boundry={12} className="w-full">
      <div className="relative group rounded-lg overflow-y-hidden">
        <Image
          src={img}
          alt={
            title === "Basmati Rice"
              ? "Premium branded sack of export Basmati rice"
              : "Raw brown Basmati rice grains close-up"
          }
          placeholder="blur"
          className="w-full h-auto object-cover"
        />
        <Link
          href={href}
          className="z-10 h-full w-full rounded-lg absolute top-0 flex items-center justify-center bg-primary/75 transform duration-1000 ease-in-out -translate-y-full group-hover:translate-y-0"
        >
          <Heading as="h4" variant="card" className="text-white text-center">
            {title}
          </Heading>
        </Link>
      </div>
    </InteractiveContainer>
  );
}

export function PopularProducts() {
  return (
    <section className="mt-32 flex items-center justify-center">
      <Container>
        <div className="flex flex-col gap-8 lg:gap-16">
          <div className="flex flex-col gap-2">
            <Heading
              as="h2"
              variant="section"
              className="text-primary text-center"
            >
              Popular Products for Export
            </Heading>
            <div className="mx-auto w-full lg:w-4/5">
              <p className="text-center text-gray-600">
                We offer a diverse range of basmati rice varieties, each
                renowned for its quality and flavor. These popular choices are
                known for their exceptional quality and consistency, making them
                ideal for export.
              </p>
            </div>
          </div>
          <div className="flex flex-col gap-4">
            <div className="flex flex-col lg:flex-row gap-6 lg:gap-14">
              {popularProductsData.map((p, index) => (
                <PopularProductCard
                  key={index}
                  title={p.title}
                  img={p.img}
                  href={p.href}
                />
              ))}
            </div>
            <div className="flex justify-center">
              <Link
                href="/get-a-quote"
                className="mt-4 block w-fit bg-accent hover:bg-primary transition-all duration-500 px-8 py-4 text-white font-medium rounded-full"
              >
                Explore more
              </Link>
            </div>
          </div>
        </div>
      </Container>
    </section>
  );
}
