---
description: Create a new math worksheet document (JSON config + HTML + PDF)
allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion]
---

You are creating a new math worksheet document. Follow these steps:

## Step 1: Gather requirements

Use AskUserQuestion to ask the user (ask all at once, not one by one):

1. **Theme** — what visual theme? (space, forest, ocean, etc.). Currently only "space" theme with `space-base` template is available.
2. **Pages** — how many pages and what math task for each page? E.g. "Page 1: addition A+B where A 1-20, B 1-10. Page 2: multiplication A×B where A,B 1-5"
3. **Texts** — title, subtitle, and footer bubble text (or use defaults from theme)
4. **Document name** — filename for the output (used as `tasks/<name>.json` and `output/html/<name>.html`)

## Step 2: Create JSON task config

Read `tasks/space-exploration-1.json` as a format reference.

Create a new JSON file in `tasks/<name>.json` with:
- Unique `id` matching the filename
- `labels` with title/subtitle/footerBubble from user input
- `theme` matching the chosen visual theme
- `layout` with columns and problemsPerPage
- `pages` array — one entry per page with:
  - `task`: free-text description of the math problems
  - `problemCount`: number of problems (typically 20)
  - `heroImage`: pick from available hero images (for space: `assets/hero-images/spaceship{1-6}.jpeg`)
  - `footerImage`: pick from available footer images (for space: `assets/footers/planet{1-6}.jpeg`)
  - `heroDirection`: alternate between `row` and `row-reverse` across pages

Use different hero/footer images for each page.

## Step 3: Generate HTML

1. Read `src/templates/space-base.html` (structure reference)
2. Read `src/examples/space-worksheet.html` (finished output reference)
3. Read the JSON config you just created

Generate the HTML file at `output/html/<name>.html`:
- For each page, generate concrete math problems based on the `task` text
- Assign unique icons from `assets/icons/pack1/` — no icon should repeat across the entire document. Shuffle minerals and plants together randomly
- Randomize problem card alignment (justify-start, justify-center, justify-end) — no visible pattern
- Use `break-after: page` between pages (not on the last page)
- Do NOT use `overflow-hidden` on the footer container (causes PDF hairline artifact)

## Step 4: Generate PDF

Run: `npm run pdf -- output/html/<name>.html`

## Step 5: Report

Tell the user:
- Path to JSON config
- Path to HTML file
- Path to PDF file
- Summary of what was generated (pages, problem types)
