import Image from "next/image";
import { cn } from "cn";
import { partners } from "@/content/partners";

/**
 * Figma annotation "auto slider" → infinite logo marquee.
 * The list is rendered twice so it loops seamlessly at -50%; pauses on hover, static with reduced motion.
 */
export function PartnersMarquee({ className }: { className?: string }) {
  const strip = [...partners, ...partners];

  return (
    <div className={cn("group overflow-hidden mask-x-from-90% mask-x-to-100%", className)}>
      <ul className="flex w-max animate-marquee items-center rtl:animate-marquee-rtl group-hover:[animation-play-state:paused] motion-reduce:animate-none">
        {strip.map((p, i) => {
          const isCopy = i >= partners.length;
          return (
            <li
              key={`${p.name}-${i}`}
              aria-hidden={isCopy}
              className="me-[38px] flex h-[46px] w-[150px] shrink-0 items-center justify-center max-md:me-3 max-md:h-[37px] max-md:w-20 md:max-lg:me-[21px]"
            >
              <Image
                src={p.logo}
                alt={isCopy ? "" : p.name}
                width={p.width}
                height={p.height}
                // Phone (Figma 390): logos scaled into 80px slots.
                className="h-auto max-w-full opacity-90 transition hover:opacity-100"
              />
            </li>
          );
        })}
      </ul>
    </div>
  );
}
