# Handoff — Task 3: Northline Workshops signup site repair

## Deliverables

| File | Status |
|---|---|
| `output/site/index.html` | changed (markup attributes + empty error placeholders only; visible text identical) |
| `output/site/style.css` | changed (responsive layout, error/focus states) |
| `output/site/app.js` | changed (endpoint, calculator, validation, messages) |
| `output/site/server.py` | **byte-identical** to `site/server.py` (SHA-256 `319965872ca2…` on both) |
| `output/evidence/browser_test_submissions.jsonl` | records the test server stored during my browser runs |
| `output/evidence/server_check.py` | script used for the static and server-handler checks (run from the workspace root) |
| `output/handoff.md` | this file |

Run: `cd output/site && python3 server.py`, then open http://127.0.0.1:8765 (`PORT` overrides), per `inputs/brief.md`.
The raw `site/` inputs were not modified.

## Defects found and fixes

| # | Defect in supplied `site/` | Evidence | Fix |
|---|---|---|---|
| 1 | Form posted to `/api/lead`; server only accepts `/api/leads` (`site/server.py`, `do_POST`) so every signup got a 404 and nothing was stored | `site/app.js` fetch call; handler check below returns 404 for `/api/lead` | `app.js` now posts to `/api/leads` |
| 2 | Calculator returned `subtotal * discount * 1.12` → CAD 0.00 for 1–2 seats, and 10% *of* the subtotal for 3+ | Browser on original site at 390 px showed `CAD 0.00` for 1 seat | Total = (subtotal − discount) × 1.12, computed in integer cents; 10% discount at 3+ seats, tax applied after discount (`inputs/brief.md`, "Calculator") |
| 3 | Calculator accepted blank/0/negative/fractional/9+ seats and showed a number | `site/app.js` used `Number(value)` unchecked | `parseSeats()` accepts only whole numbers 1–8; otherwise total shows `CAD —` plus "Enter a whole number of seats from 1 to 8." |
| 4 | Fixed `.shell{width:1120px}` and a fixed two-column grid caused horizontal overflow on mobile | Browser on original site at 390 px: `overflow: true` | Fluid shell (`max-width:1120px`), single-column layout ≤760 px, smaller heading/padding on mobile, 48 px minimum control height |
| 5 | Invalid submissions had no visible in-page error (relied on native browser bubbles; a fractional/whitespace-only value could reach the server with only a generic message) | `site/index.html`, `site/app.js` | Form is `novalidate`; JS validates name (non-blank after trim), email (same pattern the server uses) and seats before sending. Per-field messages + status line "Signup not sent…"; nothing is sent when invalid. Server 400 text is shown if the server rejects. |
| 6 | Minor | — | Name/email trimmed before sending; submit button disabled while sending; name/email cleared after success; `autocomplete`, `aria-invalid`, `aria-describedby`, visible focus outline added |

Kept: title "Northline Workshops", all page text (programmatic comparison of tag-stripped text: identical), colours `#152a45` / `#e78136` / `#edf1f5`. No framework, dependency, external URL or tracking added (regex scan of html/css/js for `http(s)://`: none).

The success message keeps the original sentence and appends a summary, e.g. "Thanks! Your workshop request is saved. 3 seats, CAD 725.76 including tax."

## Checks actually performed

### A. Browser tool (text/controls/overflow output, fresh browser per call, test server implementing the original `POST /api/leads`)

Layout
| Site | Width | Overflow reported |
|---|---|---|
| original `site/` | 390 | **true** (baseline) |
| `output/site` | 390 | false (every run below at 390) |
| `output/site` | 1280 | false (every run below at 1280) |

No JavaScript errors were reported in any run (`errors: []`).

Calculator (value typed into Seats, text read from the total)
| Seats | Width | Displayed | Brief expects |
|---|---|---|---|
| 1 (default) | 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 | 390 | `CAD —` + seats error | reject |
| 0 | 390 | `CAD —` + seats error | reject |
| -1 | 1280 | `CAD —` + seats error | reject |
| 1.5 | 1280 | `CAD —` + seats error | reject |
| 9 | 390 | `CAD —` + seats error | reject |

Form submissions
| Case | Width | Visible result | Record stored? |
|---|---|---|---|
| Avery Test / avery@example.test / 3 | 1280 | "Thanks! Your workshop request is saved. 3 seats, CAD 725.76 including tax." | yes |
| Mobile Tester / mobile@example.test / 1 | 390 | "Thanks! … 1 seat, CAD 268.80 including tax." | yes |
| "Server Reject" / ab@example.test / 2 | 390 | "Thanks! … 2 seats, CAD 537.60 including tax." | yes (see note) |
| all fields empty, seats 1 | 390 | "Enter your name." + "Enter a valid email address…" + "Signup not sent…" | no |
| email `not-an-email` | 1280 | email error + "Signup not sent…" | no |
| seats 9 | 390 | seats error + "Signup not sent…" | no |
| name whitespace only, seats 1.5 | 1280 | name error + seats error + "Signup not sent…" | no |

Stored-record evidence: after all seven submissions the test server's `submissions.jsonl` contained exactly the three valid records and none of the four invalid ones (copy at `output/evidence/browser_test_submissions.jsonl`). I moved that file out of `output/site/` so the delivered site starts with no test data.

Note: the third record is named "Server Reject" because I tried to provoke a server-side 400 with a control character in the email; the character was not delivered, so it was simply another valid signup. It is not evidence of the server-rejection path.

### B. Python checks (`output/evidence/server_check.py`, exit code 0)

- `server.py` SHA-256 identical to the input; visible text of `index.html` unchanged; title and three palette colours present; no external URLs; old `/api/lead` endpoint absent.
- Python mirror of the pricing rule: 1→268.80, 2→537.60, 3→725.76, 8→1935.36 (all match the brief).
- Supplied `Handler` class run in-process against a throwaway copy (fake socket, no network): valid 3-seat and 8-seat payloads → 201 and one record each; `/api/lead` → 404; blank name, bad email, seats 0, 9, 1.5 → 400; record count unchanged for all six non-201 cases ("ALL HANDLER CASES OK").

## Limitations (not checked or not resolved)

1. **No visual inspection.** The browser tool returns text, control state and an overflow flag, not screenshots. Colours, spacing, label legibility and tap-target size were set in CSS but not viewed.
2. **`python3 server.py` was not run over a real socket by me.** The sandbox refuses socket binds from Python (`PermissionError`). End-to-end storage was verified through the browser tool's test server, and the supplied handler logic in-process.
3. **Not exercised in the browser:** the message shown when the server itself returns 400, the network-failure message, non-numeric text in Seats, seats 4–7, and keyboard-only/screen-reader use. The JS was not unit-tested outside the browser (Node is not installed).
4. **Privacy risk in the supplied server, left unchanged.** `site/server.py` serves its whole directory as static files, and `submissions.jsonl` is written into that directory, so by reading the code a `GET /submissions.jsonl` would return stored names and emails (not confirmed over HTTP, see 2). It binds to 127.0.0.1 only. I did not alter the server because the task says to use the supplied one; this needs a decision before any non-local use.
5. The server does not de-duplicate; submitting the same details twice stores two records.

## Assumptions

- Seats input such as `03` is accepted as 3; `1e0`, `3.0` and anything not made only of digits is rejected as not a whole number.
- Adding error-message text and the seat/total summary on the success line is within "keep the existing content", since the original copy is untouched.

## Estimated human time to finish

About 15–20 minutes (an estimate, not a measurement): run `python3 server.py` locally, view the page at phone and desktop widths, submit one valid and one invalid signup, and decide on limitation 4.
