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

Requirements source: `inputs/brief.md` ("Workshop site acceptance brief"). I left the raw `site/` untouched and made all fixes in `output/site/`.

## Deliverables
- `output/site/index.html`, `style.css`, `app.js`: the repaired files.
- `output/site/server.py`: an unchanged copy of `site/server.py`. A Python comparison confirmed it is byte-for-byte identical. To run it: `cd output/site && python3 server.py`, then open http://127.0.0.1:8765. The `PORT` environment variable overrides the port.
- `output/test-evidence-submissions.jsonl`: the `submissions.jsonl` the trusted server wrote during my browser tests. I moved it out of `output/site/` so the delivered site starts with no records.
- `output/handoff.md`: this file.

## Defects found and fixes
| # | Defect in original `site/` | Evidence (browser, original site) | Fix |
|---|---|---|---|
| 1 | `app.js` posted to `/api/lead`, but the server only accepts `/api/leads` (`server.py` `do_POST`) | A valid signup (Ada Test, ada@example.test, 3 seats) at 390 px showed "Signup failed. Please check your details and try again." | Fetch URL changed to `/api/leads` |
| 2 | `calculateTotal` returned `subtotal * discount * 1.12`, so 1–2 seats gave 0 and 3 seats gave the discount amount only | 3 seats displayed **CAD 80.64** (expected 725.76) | Now `subtotal * (1 - discount) * 1.12`, rounded to cents, shown with `toFixed(2)` |
| 3 | The seat count was never validated in JS. `Number('')` gives 0, and fractional or out-of-range values went into the total | — | `parseSeats()` accepts only the digit strings 1–8. Otherwise the total shows "—" and a visible error appears on input and on submit |
| 4 | The browser's own validation could block a submit with no visible text message. Whitespace-only names passed `required` | — | Added `novalidate` to the form. JS validation matches the server rules (trimmed name not empty; email matches the same regex as `server.py`; integer seats 1–8) and puts error text in `#status`. Invalid fields get `aria-invalid` and a red border |
| 5 | Error responses from the server were not shown | — | The server's `error` JSON message is shown if the server returns 400 |
| 6 | `.shell{width:1120px}` and a fixed 2-column grid caused horizontal overflow on mobile | The browser reported `overflow: true` at 390 px | Shell is now `width:min(1120px, calc(100% - 32px))`. Grid columns use `minmax(0,…)`. Below 760 px there is one column, less padding and a 30 px h1 |
| 7 | Usability touches | — | Bold labels, controls at least 48 px tall, orange focus outline, button disabled while sending, `autocomplete` and `inputmode` attributes |

All titles, copy, colours (#152a45 dark blue, #e78136 orange, #edf1f5 background) and fonts are unchanged. I added no framework, dependencies, external requests or tracking.

## Checks performed (browser tool, repaired `output/site/`, fresh browser for each run)
**Layout / overflow**
- 1280 px initial load: `overflow: false`, total CAD 268.80.
- 390 px initial load: `overflow: false`, total CAD 268.80.
- Every later run listed below also reported `overflow: false` at its width.

**Calculator examples (from the brief)**
| Seats | Expected | Displayed | Width |
|---|---|---|---|
| 1 | 268.80 | CAD 268.80 | 390 & 1280 (initial load) |
| 2 | 537.60 | CAD 537.60 | 390 |
| 3 | 725.76 | CAD 725.76 | 390 |
| 8 | 1935.36 | CAD 1935.36 | 1280 |

Arithmetic: 3 seats = 720 × 0.90 = 648 × 1.12 = 725.76; 8 seats = 1920 × 0.90 = 1728 × 1.12 = 1935.36.

**Valid submissions (all succeeded with a visible confirmation)**
- 390 px: Ada Test / ada@example.test / 3 seats → "Thanks, Ada Test! Your workshop request for 3 seats is saved."
- 1280 px: Ben Test / ben@example.test / 8 seats → "Thanks, Ben Test! … for 8 seats is saved."
- 390 px (after the final app.js edit): Dee Test / dee@example.test / 1 seat → "Thanks, Dee Test! … for 1 seat is saved."

**Invalid submissions (each showed an error)**
- 390 px: name "   ", email "not-an-email", seats blank → "Please enter your name. Please enter a valid email address. Seats must be a whole number from 1 to 8." Total showed "—".
- 390 px: seats 0 → seats error.
- 1280 px: seats -2 → seats error.
- 1280 px: seats 2.5 → seats error.
- 390 px: seats 9 → seats error.
- 1280 px (after the final edit): email "eve@example" → "Please enter a valid email address."
- 390 px (after the final edit): typing 9 into seats, without submitting, showed the seats error straight away and the total showed "—".

**Stored records:** after all of the above, `submissions.jsonl` held exactly 3 lines: Ada/3, Ben/8 and Dee/1. That is one per valid submission and none for the invalid ones. It is now saved as `output/test-evidence-submissions.jsonl`.

## Limitations / assumptions
- The seat 0/-2/2.5/9/blank and bad-email runs were done before the last `app.js` edit, which only added the live error while typing and moved code around. The validation logic was the same. After that edit I re-ran 9 seats (live), one valid signup and one invalid email, but not the full invalid set.
- Invalid input is blocked in the browser before any request is sent, so the browser tests did not exercise the server's own 400 rejection. I tried to test `server.py` directly from Python, but it could not bind a local port ("PermissionError: Operation not permitted"), so I have no direct server-level test results.
- The browser tool returns text, not screenshots. Layout checks cover horizontal overflow and visible text only, not visual appearance or contrast. I did not test real mobile devices, other browsers or keyboard-only use.
- Assumption: after a successful signup the form resets, so the total goes back to the 1-seat price (CAD 268.80) while the confirmation stays visible. Keeping the values instead is a one-line change if preferred.
- Email checking deliberately matches the server's regex (`[^@\s]+@[^@\s]+\.[^@\s]+`), which only checks that an address looks plausible.

## Estimated human time to finish
About 20–30 minutes (an estimate, not measured): look over the layout in real browsers and phones, test the server directly with curl for invalid payloads, and decide whether the form should reset after success.
