"use client";

import { AiImage } from "@/components/AiImage";

type Props = {
  images: string[];
  title?: string;
};

export function HappyMoments({ images, title = "Happy moments" }: Props) {
  const strip = [...images, ...images];

  return (
    <section className="bg-white pb-16">
      <div className="mx-auto mb-8 w-[min(1100px,calc(100%-2rem))]">
        <h2 className="text-center font-[family-name:var(--font-display)] text-3xl font-semibold text-brand-deep">
          {title}
        </h2>
      </div>

      <div className="happy-marquee group relative overflow-hidden">
        <div className="pointer-events-none absolute inset-y-0 left-0 z-10 w-12 bg-gradient-to-r from-white to-transparent sm:w-20" />
        <div className="pointer-events-none absolute inset-y-0 right-0 z-10 w-12 bg-gradient-to-l from-white to-transparent sm:w-20" />

        <div className="happy-marquee__track flex w-max gap-3 py-1 group-hover:[animation-play-state:paused] sm:gap-4">
          {strip.map((src, i) => (
            <div
              key={`${src}-${i}`}
              className="w-[220px] shrink-0 overflow-hidden rounded-2xl sm:w-[260px] md:w-[300px]"
            >
              <AiImage
                src={src}
                alt="Happy travel moment"
                className="aspect-[4/3] w-full transition duration-500 hover:scale-105"
              />
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}
