/**
 * The four parts of an environment, as data.
 *
 * This is the site's one transferable piece of explanation. The landing strip
 * (`DefinitionStrip`) and every demo page's four boxes (`EnvAnatomy`) both read
 * these strings, so a visitor who learns the labels on the word game reads the
 * fraud screen as "same machine, different grader". That only works if the
 * four labels never change between surfaces — which is why they live here and
 * nowhere else. Do not paraphrase them in a page.
 *
 * `key` is the field name on `DemoModule.anatomy`, so a demo's own text for
 * each part is looked up with it.
 */

import type { DemoModule } from '@/lib/demo-kit/types';

export type AnatomyKey = keyof DemoModule['anatomy'];

export interface AnatomyTerm {
  key: AnatomyKey;
  /** Zero-padded ordinal, rendered in mono: `01`–`04`. */
  index: string;
  /** The label. Sans, 600. The same four words on every surface. */
  kicker: string;
  /** One line, for the landing strip. A sentence, not a fragment. */
  gloss: string;
  /** The question the box answers, for the full `EnvAnatomy`. */
  question: string;
}

export const ANATOMY: readonly AnatomyTerm[] = [
  {
    key: 'task',
    index: '01',
    kicker: 'The task',
    gloss: 'What the agent is asked to do.',
    question: 'What is the agent asked to do?',
  },
  {
    key: 'actions',
    index: '02',
    kicker: 'Legal actions',
    gloss: 'What it is allowed to do.',
    question: 'What is it allowed to do?',
  },
  {
    key: 'grader',
    index: '03',
    kicker: 'The grader',
    gloss: 'Code that computes, never a judge.',
    question: 'Who decides whether it was good?',
  },
  {
    key: 'score',
    index: '04',
    kicker: 'The score that moves',
    gloss: 'The number you train against.',
    question: 'What number does that produce?',
  },
];

/** One term by its key. Throws at build time rather than rendering a blank box. */
export function anatomyTerm(key: AnatomyKey): AnatomyTerm {
  const term = ANATOMY.find((t) => t.key === key);
  if (!term) throw new Error(`No anatomy term "${key}".`);
  return term;
}
