# Prepare Episode Brief (Standalone)

You are preparing an episode for a video production pipeline. This creates the episode's `brief.txt` that the per-episode orchestrator will use. The brief must be SELF-CONTAINED — downstream stages cannot access any other files.

## Content Rating

This is an adaptation of a classic public domain science fiction story for a general audience. The tone is **heroic adventure**. Any peril or danger should be portrayed tastefully — focus on courage and determination. Keep all descriptions suitable for a PG/12+ audience.

## Read These Files

- `source.txt` — the original story. Read lines {source_lines} for this episode.
- `{bible_path}` — story bible with characters, world, themes
- `{style_path}` — visual style guide with color palettes
- `{episodes_path}` — episode breakdown with scene beats
- Check `references/people/` for character descriptions (description.md files)

## Episode to Prepare

**Episode {episode_number}**: "{episode_title}"

{continuity_section}

## Character References

{character_references_section}

## Brief Format

Format brief.txt EXACTLY like this (use plain text blocks, NOT markdown tables):

```
EPISODE {episode_number}: {episode_title_upper}
============================
Series: [series title] | Grid: [grid] | Clips: [duration] | Total: [total]

STORY SUMMARY
-------------
[2-3 sentence summary from episodes.json]

SOURCE TEXT (Lines {source_lines})
----------------------------------
[VERBATIM copy from source.txt — every word, every paragraph, exactly as written. Do NOT summarize.]

VISUAL STYLE
------------
[Style, rendering, lighting from style.json. Include hex color codes.]

CHARACTERS IN THIS EPISODE
---------------------------

CHARACTER_NAME (role)
- Appearance: [full description from bible + references/people/*/description.md]
- Clothing: [what they wear]
- Voice: [voice signature: age, gender, timbre, default tone, pacing]
- Episode state: [condition/arc in this episode]
- Reference: [path to portrait/sheet]

LOCATIONS IN THIS EPISODE
--------------------------

LOCATION_NAME
- [description]
- Palette: [hex codes from style.json]

DIALOGUE
--------

Scene N:
SPEAKER: character_id
LINE: "exact dialogue"
VOICE: He/She says in the voice of a [AGE] [GENDER], [TIMBRE], [TONE], [PACING]: "line"

SCENE BREAKDOWN (N scenes, Xs each)
====================================

SCENE 1: [Shot Type] — [Title]
Visual: [what we see in frame]
Location: [location_id]
Characters: [who is visible]
Action: [what happens, camera movement]
Mood: [mood_name — #hex1 (name), #hex2 (name), #hex3 (name)]
Dialogue: [if any, with voice prompt, or "None"]
Duration: Xs

[repeat for ALL scenes]

CONTINUITY NOTES
----------------
[what to establish, what carries forward to next episodes]
[track physical progression: injuries, clothing degradation, etc.]

TITLE CARD
----------
Text: "Episode N: Title"
[visual direction for title card matching series style]

END OF EPISODE BRIEF
```

## Important Rules

1. Source text MUST be verbatim — copy every word from the specified lines
2. Do NOT use markdown tables — use the block format shown above
3. Each scene needs a Mood line with palette name AND hex codes from style.json
4. Include per-scene color mood mapping (adventure_hope, tension_danger, desolation_thirst, etc.)
5. Voice prompts format: "He/She says in the voice of a [AGE] [GENDER], [TIMBRE], [TONE], [PACING]: ..."
6. Character voice signatures (age + gender + timbre) must be CONSTANT across episodes

## Output Files

Write to `{output_dir}/`:

1. **brief.txt** — Complete episode brief as formatted above
2. **nanobanana_title_card.txt** — NanoBanana image prompt for episode title card (9:16 aspect ratio, match series visual style)
3. **user_message.txt** — Brief 2-3 sentence summary
4. **corpus_refs.json** — If corpus references were provided, write updated file
   with scene_assignments: {"1": "refs/01_filename.jpg", "3": "refs/04_filename.jpg", ...}
   Not every scene needs a corpus ref — only assign where a strong match exists.
