/* Glossary — definitions for the technical terms surfaced via <Term>.
   Source of truth: methodology page + V2.0 white paper. Update here when
   definitions evolve and every tooltip on the site stays in sync. */
const GLOSSARY = {
  'shared-value': {
    term: 'Shared Value',
    definition: 'Activities that produce a measurable business benefit AND a social or environmental benefit, with an explicit causal link between them and measurable evidence of outcomes. Kestrel only classifies a passage as Shared Value when all four criteria are met.',
  },
  'transactional': {
    term: 'Transactional',
    definition: 'Initiative type — one-sided benefit. The disclosure shows business OR social value, not both.',
  },
  'transitional': {
    term: 'Transitional',
    definition: 'Initiative type — both benefits implied, but the causal linkage between business and social value is weak or unverified.',
  },
  'transformational': {
    term: 'Transformational',
    definition: 'Initiative type — clear dual benefit with a demonstrated, measurable impact on both business and social outcomes.',
  },
  'csv-pillar': {
    term: 'CSV pillar',
    definition: 'One of three Porter & Kramer pillars used to categorise initiatives: products & markets, value-chain productivity, or local cluster development.',
  },
  'fleiss-kappa': {
    term: "Fleiss' κ",
    definition: "A statistical measure of agreement between multiple raters classifying items into categories. Kestrel reports Fleiss' κ across five independent classification runs per passage; 0.60–0.80 is substantial agreement and 0.80+ is almost perfect.",
  },
  'linkage-strength': {
    term: 'Linkage strength',
    definition: 'Disclosure metadata field — how clearly the report establishes a causal connection between the business activity and its social or environmental outcome.',
  },
  'evidence-strength': {
    term: 'Evidence strength',
    definition: 'Disclosure metadata field — the rigour of the supporting evidence (figures, baselines, methods) provided in the passage, on an ordinal scale.',
  },
  'beneficiary-scope': {
    term: 'Beneficiary scope',
    definition: 'Disclosure metadata field — the breadth of the population or ecosystem benefiting from the initiative (e.g. workforce, local communities, broader region).',
  },
  'initiative-type': {
    term: 'Initiative type',
    definition: 'Porter & Kramer taxonomy applied to each passage: no initiative, transactional, transitional, or transformational.',
  },
  'remediation-flag': {
    term: 'Remediation flag',
    definition: 'Disclosure metadata field — flags whether the initiative is reactive remediation or harm reduction (responding to a problem) rather than proactive value creation.',
  },
};

const Term = ({ name, children }) => {
  const entry = GLOSSARY[name];
  if (!entry) return <React.Fragment>{children}</React.Fragment>;
  const label = children != null ? children : entry.term;
  return (
    <span className="glossary-term" tabIndex={0} aria-label={`${entry.term}: ${entry.definition}`}>
      <span className="glossary-term-label">{label}</span>
      <span className="glossary-tip" role="tooltip" aria-hidden="true">
        <span className="glossary-tip-term">{entry.term}</span>
        <span className="glossary-tip-def">{entry.definition}</span>
      </span>
    </span>
  );
};

window.GLOSSARY = GLOSSARY;
window.Term = Term;
