import type { ReactNode } from 'react';
import { cx } from './cx';

export interface CardProps {
  title?: string;
  /** Niveau du titre dans la page, pour garder une hiérarchie correcte (WCAG 1.3.1). */
  headingLevel?: 2 | 3 | 4;
  children: ReactNode;
  className?: string;
}

export function Card({ title, headingLevel = 2, children, className }: CardProps) {
  const Titre = `h${headingLevel}` as const;
  return (
    <div
      className={cx(
        'rounded-lg border border-bordure border-t-4 border-t-accent bg-surface p-5',
        className,
      )}
    >
      {title ? <Titre className="mb-2 text-xl font-semibold">{title}</Titre> : null}
      {children}
    </div>
  );
}
