# Task 3 handoff — Northline Workshops signup site repair

Deliverable: `output/site/` (working copy; original `site/` inputs untouched).
Run: `python3 server.py` from `output/site/`, open http://127.0.0.1:8765
(`PORT` env var overrides). No dependencies added.

## Fixes made (vs supplied site/)

1. **Wrong API endpoint** — `site/app.js` posted to `/api/lead`; the server
   (`site/server.py`, `do_POST`) only accepts `/api/leads` (inputs/brief.md).
   Fixed to `POST /api/leads` in `output/site/app.js`.
2. **Broken discount math** — original `calculateTotal` returned
   `subtotal * discount * 1.12` (i.e. charged only the discount amount, and 0
   for 1–2 seats). Now `subtotal * (1 - discountRate) * 1.12` with
   `discountRate = 0.10` for 3+ seats, matching inputs/brief.md ("10% off
   subtotal for 3+ seats … add 12% tax AFTER discount").
3. **No seat validation in the calculator** — blank/0/negative/fractional/9+
   values produced `CAD NaN` or wrong totals. Added `parseSeats()` (whole
   digits only, 1–8); invalid input shows "Enter 1–8 seats" in the total
   instead of a price.
4. **No client-side form validation** — whitespace-only names and out-of-range
   seats reached the server (or native validation gave inconsistent behavior).
   Form now uses `novalidate` + JS checks mirroring server.py rules: trimmed
   nonempty name, email regex `^[^@\s]+@[^@\s]+\.[^@\s]+$`, integer seats 1–8.
   Invalid submissions show a specific error in `#status` and send no request.
   Server 400 responses surface the server's error message; network failures
   show a fallback error. Submit button disabled while a request is in flight;
   form resets and total re-renders on success.
5. **Mobile horizontal overflow** — `site/style.css` used fixed
   `.shell{width:1120px}` and a rigid 2-column grid. Now
   `max-width:1120px` with side margins, and a `@media (max-width:820px)`
   block stacks the layout to one column, reduces padding and h1 size.
   Dark-blue `#152a45` / orange `#e78136` palette, fonts, title and all copy
   preserved. Small additions only: error/success status colors, disabled
   button style, `autocomplete`/`inputmode` attributes.
6. **server.py unchanged** — verified byte-identical to the supplied input
   (it already implements the brief's validation and storage rules).

## Checks actually performed

- **Browser (local inspection tool, text observations; full log in
  `output/evidence/browser-checks.md`)** — 18 fresh-browser sessions against
  `output/site/` with the trusted server implementing original `/api/leads`:
  - Load at **1280 px and 390 px**: all content/labels/controls present,
    `overflow: false`, no page errors, in every session.
  - **Calculator examples** displayed in-page: 1→CAD 268.80, 2→CAD 537.60,
    3→CAD 725.76, 8→CAD 1935.36 (all match inputs/brief.md); 3 seats also
    verified at 390 px.
  - **Calculator rejects** blank, 0, -1, 2.5, 9 → "Enter 1–8 seats".
  - **Valid submissions** (Ada Lovelace/3 seats at 1280; Grace Hopper/1 seat
    at 390, both @example.test) → visible "Thanks! Your workshop request is
    saved." and exactly those two records appeared in `submissions.jsonl`
    (copy: `output/evidence/submissions-after-tests.jsonl`).
  - **Invalid submissions** (whitespace name; email `ada@example`; seats 9;
    all-blank form) → specific error shown, **no records created** (file
    contained only the 2 valid lines).
- **Python (stdlib; log in `output/evidence/python-checks.txt`)** — pricing
  formula and seat-parsing logic mirrored from app.js verified against all
  four brief examples and 10 parse cases; `server.py` copy confirmed
  byte-identical to input.

## Limitations / assumptions

- The Python sandbox blocks loopback sockets (`Operation not permitted`), so
  I could **not** run `server.py` itself over HTTP; server-side 400/201
  behavior was observed only via the browser tool's trusted server, which
  states it implements the original `/api/leads` logic. The invalid-HTTP
  cases scripted in `checks/test_server_and_math.py` did not execute.
- Browser evidence is textual (visible text, control values, overflow flag),
  not screenshots; visual polish (exact spacing/colors) was not eyeballed.
- Assumption: "plausible email" = the server's regex; client mirrors it.
  Trimming name/email before sending was chosen as reasonable (server only
  requires nonempty-after-trim name).
- `output/site/submissions.jsonl` ships empty; the two fake test records are
  preserved in `output/evidence/`.
- Intermediate widths between 390 and 1280 and assistive-tech behavior were
  not tested (status uses `role="status"`/`aria-live="polite"` as supplied).

## Output files

- `output/site/index.html`, `output/site/app.js`, `output/site/style.css`,
  `output/site/server.py`, `output/site/submissions.jsonl` (empty)
- `output/handoff.md` (this file)
- `output/evidence/browser-checks.md`, `output/evidence/python-checks.txt`,
  `output/evidence/submissions-after-tests.jsonl`
- `checks/test_server_and_math.py` (working test script, outside deliverable)

## Estimated human finish time

~10–20 minutes (estimate, not measured): run `server.py` locally to confirm
the live 400/201 paths and `submissions.jsonl` writes, eyeball desktop/mobile
rendering, and optionally test a mid-size viewport and keyboard/screen-reader
flow.
