# Build spec — Save My Spells

**Artifact:** `demos/save-my-spells/index.html` (single file, 396,175 bytes, sha256 `60fe0441…21f098`)
**Mirror:** `demos/save-my-spells-mirror/index.html` (byte-identical copy)
**Analysis:** `demos/save-my-spells-analysis.html`
**Source:** `~/Documents/save-my-spells/` (`parts_a.py`–`parts_g.py`, `art.py`, `fig_a.py`, `fig_b.py`, `template.html`, `build.py`, `verify.py`, `verify_paper.py`, `verify_revise.py`, `artcheck.py`)

## What it is

One offline HTML revision site for the Hogwarts curriculum, shaped like Save My Exams: **16 subjects,
71 topic pages, 182 exam questions and 461 marks** of point-by-point mark schemes, plus flashcards, a
paper generator, a redo pile and a "revise next" ranking. No network requests, no image files, no
fonts — every figure and emblem is inline SVG assembled from primitives.

## Hard requirements (do not regress these)

1. **One file, no requests.** The only `http://` string in the output is the SVG namespace. Images are
   inline SVG only. Opens from the Desktop with Wi-Fi off.
2. **The build refuses rather than warns.** `build.py` exits non-zero if a topic has fewer than 3 key
   terms or fewer than 2 questions, a question has an empty scheme or zero marks, a level is not
   `O.W.L.` or `N.E.W.T.`, a subject has no emblem, a `fig` key is unregistered, or two topics share an id.
3. **Book canon, and silence labelled.** Where the books do not say, the note says so instead of inventing.
   Film-only material carries a film label. The 1993 Statute of Secrecy pass, dragon-blood uses, Niffler
   behaviour and the Horcrux count were each corrected against the books during the build.
4. **Progress in `localStorage`** under `sms.v1`, wrapped in try/catch so a blocked store degrades to
   session-only instead of breaking the page.
5. **Mobile at 320 px and print both clean.** Figures sit in `.figscroll` with `main{min-width:0}` so a wide
   SVG scrolls inside its own box rather than pushing the page sideways.

## Content shape

Subject → topics → `notes` (blocks of `p` / `ul` / `table` with an `h` heading), `terms` (≥3), `tip`,
`traps`, and `q` (≥2 questions with `marks`, `q`, `ms`). 47 topics are O.W.L. level, 24 are N.E.W.T.

## Features

- **Paper generator:** tier (mixed / O.W.L. / N.E.W.T.), 10–30 questions, one subject or all, timed or not.
  Draw is round-robin over shuffled subjects so a 30-question paper cannot come from two subjects. The
  clock stores an absolute deadline (leaving the page does not pause it); time is `marks × 1.5` minutes
  rounded to 5.
- **Self-marking:** full / half / missed against the real scheme. Full marks add house points; half and
  missed enter the redo pile.
- **Redo pile:** miss counts increment, marking the same question full later removes it, redo papers take up
  to 10 most-missed-first then shuffle.
- **Revise next:** per-subject score out of 100 = min(40, pile marks × 4) + unopened share × 35 + (1 −
  accuracy) × 25 (flat 12 when nothing is marked), with a Practise drill of 5 questions.
- **Print:** `Print paper` (questions only, name/date lines) and `Print with marks` (answer key, mark
  buttons stripped).

## Regenerating

```bash
cd ~/Documents/save-my-spells
python3 artcheck.py        # figures=19 labels=210 issues=0
python3 build.py           # OK ~/Documents/SaveMySpells.html
python3 verify.py          # 51 assertions
python3 verify_paper.py    # 42 assertions
python3 verify_revise.py   # 20 assertions
cp ~/Documents/SaveMySpells.html ~/Desktop/desktop/portfolio-deploy/demos/save-my-spells/index.html
cp ~/Documents/SaveMySpells.html ~/Desktop/desktop/portfolio-deploy/demos/save-my-spells-mirror/index.html
```

`/demos/save-my-spells` and `/demos/save-my-spells-mirror` are in `SKIP_PREFIX` in `~/scripts/theme-inject.py`,
so the served bytes stay identical to the source (no skin block, no floating theme button over the paper
timer). Verify by sha-256, not by eye.
