"use client";

import type { IconViewProps } from "./Icon.types";

export function IconView({
  icon,
  title,
  description,
  className,
  interactive,
  layoutTitleId,
  onClick,
  onKeyDown,
}: IconViewProps) {
  const interactionClass = interactive
    ? "cursor-pointer transition-shadow duration-200 hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-content-default-brand-primary)] focus:ring-offset-2"
    : "cursor-default";

  return (
    <div
      data-figma-node="22084-859659"
      className={`relative flex h-[350px] w-full min-w-[240px] max-w-[480px] flex-col items-start justify-between border border-solid border-[var(--color-border-default-secondary)] bg-transparent p-[var(--measures-spacing-020)] ${interactionClass} ${className}`}
      tabIndex={interactive ? 0 : undefined}
      role={interactive ? "button" : "article"}
      aria-label={interactive ? `${title}: ${description}` : undefined}
      aria-labelledby={interactive ? undefined : layoutTitleId}
      onClick={interactive ? onClick : undefined}
      onKeyDown={interactive ? onKeyDown : undefined}
    >
      {/* Icon */}
      <div className="flex h-9 w-9 shrink-0 items-center justify-center">
        {icon}
      </div>

      {/* Title — Figma XX Large / Label (32 / 36) */}
      <h3
        id={interactive ? undefined : layoutTitleId}
        className="w-full text-left text-xx-large-label text-[var(--color-content-default-primary)]"
      >
        {title}
      </h3>

      {/* Body: X Small / Paragraph (12/16) per Figma; 14/20 on md–<lg only (Section 22084-859062) */}
      <p className="w-full text-left text-x-small-paragraph text-[var(--color-content-default-primary)] md:text-small-paragraph lg:text-x-small-paragraph">
        {description}
      </p>
    </div>
  );
}
