# Handoff: Northline workshop signup site repair

The repaired site is in `output/site/`. Signups now save through the supplied server, the calculator matches all four examples in the brief, and the page no longer overflows at 390 px.

Run it as the brief describes: `cd output/site && python3 server.py`, then open http://127.0.0.1:8765 (`PORT` overrides the port). I could not start it that way myself, because the sandbox blocks opening sockets. Page checks went through the provided browser tool and its trusted `/api/leads` server instead.

## What was wrong and what changed

| # | Defect in `site/` | Fix in `output/site/` |
|---|---|---|
| 1 | `app.js` posted to `/api/lead`, but `server.py` only accepts `/api/leads`, so every signup got a 404. | `app.js` posts to `/api/leads`. |
| 2 | `calculateTotal` multiplied the subtotal by the discount rate, giving CAD 0.00 for 1–2 seats and CAD 80.64 for 3. | The total is now subtotal, less 10% for 3+ seats, plus 12% tax after the discount (`inputs/brief.md`, "Calculator"). It is computed in whole cents and shown as `CAD 0.00`-style with two decimals. |
| 3 | Blank, 0, negative, fractional or 9+ seats still produced a total, and nothing on the page explained a rejected entry. | Seats must be a whole number 1–8. Otherwise the total shows "—" and the message "Enter a whole number of seats from 1 to 8." appears under the field. |
| 4 | A whitespace-only name or an email like `cy@example` passed the browser's own checks and was only rejected by the server with a generic message. | `app.js` checks name, email (same pattern as `server.py`) and seats before posting. Invalid input shows a message per field plus "Signup not sent…", and nothing is posted. Name and email are trimmed. |
| 5 | `.shell{width:1120px}` with a fixed two-column grid overflowed horizontally at 390 px. | `style.css` uses `max-width:1120px` and a single column at 760 px and below, with smaller padding and heading on mobile. |
| 6 | No styling for errors, success or keyboard focus. | Added error and success styles, an orange focus outline, bold labels and 48 px minimum control height, within the existing dark-blue/orange palette. |

- **Unchanged:** `server.py` is a byte-identical copy (same SHA-256 as the original). The title, all existing page text, colours and font are kept, and the original `site/` was not written to.
- **Added to `index.html`:** `name`, `autocomplete`, `inputmode` and `aria-describedby` attributes, plus three empty error slots under the fields.
- **Not added:** frameworks, dependencies, external requests or tracking.

## Checks performed

### Before the fix (original `site/`)
- **390 px load:** overflow was reported and the total read "CAD 0.00".
- **1280 px valid submit (Ada Test, 3 seats):** the page showed "Signup failed. Please check your details and try again." and a total of "CAD 80.64".

### Layout (repaired site)
- **390 px and 1280 px:** no horizontal overflow on any load or interaction below; all original text and the Name, Email and Seats labels were present.
- **Not seen:** the browser tool returns text, control state and an overflow flag, not screenshots. I did not visually confirm colours, spacing or tap-target size.

### Calculator examples (typed into the Seats field)

| Seats | Width | Displayed | Brief expects |
|---|---|---|---|
| 1 | 390 and 1280 | CAD 268.80 | 268.80 |
| 2 | 1280 | CAD 537.60 | 537.60 |
| 3 | 1280 | CAD 725.76 | 725.76 |
| 8 | 390 | CAD 1935.36 | 1935.36 |

Blank and 0 (at 390 px) and -2, 2.5 and 9 (at 1280 px) each showed "—" and the seats message.

### Form submissions through the browser tool's trusted server

| Width | Name / email / seats | Result on page |
|---|---|---|
| 1280 | Ada Test / ada@example.test / 3 | "Thanks! Your workshop request is saved. 3 seats, CAD 725.76." |
| 390 | Ben Test / ben@example.test / 1 | "Thanks! Your workshop request is saved. 1 seat, CAD 268.80." |
| 390 | Cy Test / `bad` / 2, then corrected to cy@example.test / 8 and resubmitted | "Thanks! Your workshop request is saved. 8 seats, CAD 1935.36." after the correction |
| 390 | all blank / 1 | "Enter your name.", "Enter a valid email address, like name@example.test." and "Signup not sent. Please fix the highlighted fields and try again." |
| 1280 | three spaces / cy@example.test / 2 | "Enter your name." and "Signup not sent…" |
| 390 | Cy Test / not-an-email / 2 | email message and "Signup not sent…" |
| 1280 | Cy Test / cy@example / 2 | email message and "Signup not sent…" |
| 390 | Cy Test / cy@example.test / 9 | seats message and "Signup not sent…" |
| 1280 | Cy Test / cy@example.test / 2.5 | seats message and "Signup not sent…" |
| 390 | Cy Test / cy@example.test / 0 | seats message and "Signup not sent…" |

After these runs the trusted server had written exactly three records, one per successful submission and none for the eight invalid attempts:

```
{"name":"Ada Test","email":"ada@example.test","seats":3}
{"name":"Ben Test","email":"ben@example.test","seats":1}
{"name":"Cy Test","email":"cy@example.test","seats":8}
```

I moved that file to `output/evidence/submissions_from_browser_checks.jsonl` so the delivered site starts with no test records.

### Server handler, in-process
`output/evidence/server_handler_check.py` drives the `Handler` class from the delivered `server.py` with a fake socket and a temporary copy of the site.
- **Static files:** `index.html`, `style.css` and `app.js` were each served with 200 and matched the delivered files.
- **Old endpoint:** POST `/api/lead` returned 404 and wrote no record.
- **Valid payloads:** two POSTs to `/api/leads` returned 201 and added one record each.
- **Invalid payloads:** blank name, bad email, and seats of 0, 9, 2.5 and -1 each returned 400 and added no record.

To rerun it, start it from the workspace root; it also re-copies `site/server.py` into `output/site/`.

## Assumptions
- **Form after success:** the fields are not cleared, as in the original, so the total panel still matches the confirmation. The button is disabled while a request is in flight.
- **Seats format:** only plain digits are accepted, so "1.0" and "1e0" are rejected as not whole numbers.
- **Amount format:** no thousands separator, matching the brief's "1935.36".
- **New wording:** the error messages and the seats/total suffix on the success message are new text; the brief did not supply any.

## Limitations
- **No real HTTP run of `python3 server.py`:** the sandbox refused to bind a socket (PermissionError).
- **No visual check:** appearance on a real phone or desktop browser is unconfirmed.
- **Untested paths in `app.js`:** the server-400 message and the network-failure message were never triggered, because client validation stops every invalid input I tried before it is posted. The disabled-button guard against double clicks was also not exercised.
- **No JavaScript unit tests:** Node is not installed, so the pricing functions were checked only through the page.
- **One browser engine:** only the provided browser tool was used.

## Files
- `output/site/index.html`
- `output/site/style.css`
- `output/site/app.js`
- `output/site/server.py`
- `output/evidence/submissions_from_browser_checks.jsonl`
- `output/evidence/server_handler_check.py`
- `output/handoff.md`

Estimated human time to finish: about 10–15 minutes (an estimate, not measured), to run `python3 server.py` and look at the page on a phone-width and a desktop browser.
