"use client";

import Link from "next/link";
import {
  TAG_BACKGROUNDS,
  TAG_TEXT_COLORS,
} from "@/features/opportunities/components/learnServeDetailsTypes";

/**
 * One interest chip on a detail page, linking to that tag's filtered list.
 *
 * Both detail screens rendered this as a `<span onClick={() => router.push(…)}>`,
 * which is a navigation dressed as decoration: no keyboard access, nothing
 * announced, no middle-click, no "open in new tab", and nothing for a crawler to
 * follow into the filtered list. `next/link` gives all of that back and keeps
 * the client-side transition.
 *
 * The colour rotates by position, which is why the index is a prop — the palette
 * has four entries and a list of five chips starts over, as before.
 */
export default function TagChipLink({
  label,
  href,
  index,
}: {
  label: string;
  href: string;
  index: number;
}) {
  return (
    <Link
      href={href}
      style={{ backgroundColor: TAG_BACKGROUNDS[index % TAG_BACKGROUNDS.length] }}
      className={`text-sm py-[13px] rounded-[20px] xss:py-2 xss:px-4 xss:text-xs px-8 ${
        TAG_TEXT_COLORS[index % TAG_TEXT_COLORS.length]
      } cursor-pointer hover:opacity-80 transition-opacity`}
    >
      {label}
    </Link>
  );
}
