# Handoff — Northline workshop signup site repair (Task 3)

## Deliverables
- `output/site/` — repaired site, ready to run: `index.html`, `style.css`, `app.js`, `server.py`. To run: `cd output/site && python3 server.py`, then open http://127.0.0.1:8765. `PORT` can override the port (inputs/brief.md).
- `output/checks/server_check.py` — repeatable check of the server handler and the price formula.
- `output/checks/cleanup.py` — moved the browser-test `submissions.jsonl` out of the deliverable folder.
- `output/checks/browser_test_submissions.jsonl` — the records the browser tests created (kept as evidence).
- The raw inputs (`site/`, `inputs/`) are unchanged.

## Defects found and fixes (against inputs/brief.md)
| # | Defect in the original `site/` | Fix in `output/site/` |
|---|---|---|
| 1 | `app.js` `calculateTotal` returned `subtotal * discount * 1.12`, so 1 seat showed **CAD 0.00** (seen in the browser at 390 px) and 3+ seats charged only the discount amount. | Now `subtotal * (1 - discount) * 1.12`, rounded to cents, shown as `CAD x.xx`. The 10% discount applies at 3+ seats, and tax is added after the discount. |
| 2 | `fetch('/api/lead')` doesn't match the server route `/api/leads`, so every signup got a 404 and nothing was saved. | The form now posts to `/api/leads`. |
| 3 | The calculator didn't reject bad seat counts: blank and 0 became `Number('')=0`, and fractions and 9+ were priced. | Added `parseSeats()`, which only accepts a whole number from 1 to 8. Anything else shows "Enter a whole number of seats from 1 to 8." in place of a price and sets `aria-invalid`. |
| 4 | There was no check in the browser before sending. Native validation didn't cover a name made only of spaces or the server's email pattern. | The form uses `novalidate` plus JS checks for name (trimmed), email (same pattern as `server.py`) and seats. Each problem shows a visible error and nothing is sent. Server error text from a 400 response is shown if one comes back. The button is disabled while a request is in progress. On success it shows "Thanks! Your workshop request is saved." and resets the form. |
| 5 | Mobile overflow: `.shell{width:1120px}` and a fixed two-column grid. The browser reported `overflow: true` at 390 px. | Changed to `width:100%; max-width:1120px` with `minmax(0,…)` grid columns. Below 760 px it switches to one column with smaller padding and a 30 px h1. Inputs and buttons are at least 48 px tall, and keyboard focus now has a visible outline. |
| 6 | Minor HTML: there were no `<head>` tags. | Added `<head>` tags, plus `name`/`autocomplete` attributes and `inputmode="numeric"` on the inputs. |

What stayed the same: the title "Northline Workshops", all the visible text, the colours (dark blue #152a45, orange #e78136, #edf1f5 background) and the font. `server.py` is byte-for-byte identical to the original (checked by `server_check.py`). No frameworks, dependencies, external services or tracking were added.

## Checks performed (with evidence)
### A. Browser tool (local site, trusted server running the original POST /api/leads; fresh browser each call)
**Before the fix:** the original `site/` at 390 px showed `CAD 0.00` for 1 seat and `overflow: true`.

**Calculator examples on `output/site`** (fill `#seats`, read `#total`):
| Seats | Width | Shown | Brief expects |
|---|---|---|---|
| 1 (default) | 1280 and 390 | CAD 268.80 | 268.80 |
| 2 | 390 | CAD 537.60 | 537.60 |
| 3 | 390 | CAD 725.76 | 725.76 |
| 8 | 1280 | CAD 1935.36 | 1935.36 |
| blank, 0, -1, 9 | 390 | "Enter a whole number of seats from 1 to 8." | reject |
| 2.5 | 1280 | same rejection message | reject |

**Layout:** after the fix, `overflow: false` was reported at both 1280 px and 390 px on every call, including after error messages appeared. All labels (Name, Email, Seats) and the "Request a place" button were present in the visible text and controls.

**Form submissions:**
| Width | Input | Result shown |
|---|---|---|
| 1280 | Ada Tester / ada@example.test / 3 | "Thanks! Your workshop request is saved." The form reset. |
| 390 | Mo Bile / mo@example.test / 1 | "Thanks! Your workshop request is saved." |
| 390 | name of spaces / not-an-email / 9 | "Enter your name. Enter a valid email address. Enter a whole number of seats from 1 to 8." |
| 1280 | Frac Tion / frac@example.test / 2.5 | "Enter a whole number of seats from 1 to 8." |

**Stored records:** after all the browser runs, `output/site/submissions.jsonl` contained exactly 2 lines, for the two valid signups (Ada Tester, 3 seats; Mo Bile, 1 seat). The invalid attempts added no records. That file was then moved to `output/checks/browser_test_submissions.jsonl`, so the delivered site starts with no submissions file.

### B. `python output/checks/server_check.py` (run, exit code 0)
The sandbox blocks network sockets, so the script calls the unmodified `server.py` request handler directly, using a temporary copy. Results:
- 201 for a valid signup, which added 1 record.
- 404 for `/api/lead` (the route the original client used).
- 400 for a name of spaces, a bad email, 0 seats, 9 seats and 2.5 seats. Each added 0 records.
- The Python version of the price formula matches all four examples in the brief.

## Limitations / assumptions
- I did not open http://127.0.0.1:8765 by running `python3 server.py` myself, because sockets aren't allowed in my sandbox. The end-to-end checks went through the provided browser tool's trusted server instead.
- The browser tool returns text, not screenshots. Visual appearance (colours, spacing, how readable it looks) was not checked by eye. "Usable controls" was only inferred from the CSS and from the fill and click actions succeeding.
- I couldn't trigger the code that displays a server 400 error through the UI, because the browser-side checks match the server rules. That path was only reviewed in the code.
- Assumption: "plausible email" means the server's pattern `[^@\s]+@[^@\s]+\.[^@\s]+`, and the browser uses the same rule.
- Assumption: the form is reset after a successful signup, so the total goes back to 1 seat (CAD 268.80).
- Only tested at the two widths in the brief (390 and 1280 px), in one browser engine.

## Estimated human time to finish
About 15–25 minutes (estimate, not measured): run the server locally, look over desktop and mobile in a real browser or with screenshots, try one keyboard-only signup, and delete any test `submissions.jsonl` before going live.
