/**
 * =============================================================================
 * QWHPI — Quebec Weekly Housing Price Index
 * Author  : Simon-Pierre Boucher
 * Contact : contact@spboucher.ai
 * File    : web/components/ReliabilityBadge.tsx
 * Purpose : Reliability grade badge (A–E) — icon + label, never color alone.
 * =============================================================================
 */

const DESCRIPTIONS: Record<string, string> = {
  A: "Very strong — high liquidity, tight confidence band",
  B: "Strong — reliable weekly signal",
  C: "Moderate — partial shrinkage toward parent trend",
  D: "Thin — heavy shrinkage, interpret levels not weeks",
  E: "Model-implied — published for transparency only",
};

export default function ReliabilityBadge({ grade }: { grade: string }) {
  const good = grade === "A" || grade === "B";
  const weak = grade === "D" || grade === "E";
  return (
    <span className="badge" title={DESCRIPTIONS[grade] ?? ""}>
      <span
        className="dot"
        style={{
          background: good
            ? "var(--good)"
            : weak
              ? "var(--serious)"
              : "var(--series-4)",
        }}
      />
      Reliability {grade}
      {weak ? " ⚠" : ""}
    </span>
  );
}
