import { Explain } from "./ui";
import { fundTermTip } from "../lib/fundGlossary";

/** 財報名詞 + ? 說明（沿用全站 Explain，fixed 浮層不撐破版面） */
export function TermHint({ term, tip, className }: { term: string; tip?: string; className?: string }) {
  const text = tip ?? fundTermTip(term);
  if (!text) return <span className={className}>{term}</span>;
  return (
    <span className={`term-label ${className || ""}`.trim()}>
      <span className="term-label-text">{term}</span>
      <Explain tip={{ what: text }} label={term} />
    </span>
  );
}