infrastructure/accessibility_standards.md

8.2 KiB

CutTheCard Accessibility Standards (project file)

Last Updated: 2026-10-11

Standing rule — applies to every human and every AI that touches this project: nothing ships to QA or Production unless it meets WCAG 2.2 Level AA. This is a release requirement, not a polish item. When asked to build any page, modal, form, email, blog template or export, build it to this document by default without being asked.

Why this standard: WCAG 2.x AA is the benchmark courts, the U.S. DOJ (ADA Titles II/III), Section 508, and state laws (e.g. California Unruh Act, New York, Florida) use in practice. No automated tool or document can guarantee legal compliance; this file defines our engineering standard and evidence trail. Legal questions go to counsel.

1. What is built in (do not undo)

Piece File Purpose
Accessibility stylesheet static/a11y.css Focus rings, skip link, 24px targets, reduced motion, forced-colours, 320px reflow, link underlines
Runtime layer static/a11y.js Skip link, <main>, names for controls, keyboard access for click handlers, dialog focus trap/Esc/restore, live regions, table headers, new-tab notice, deA11y.announce()
Design tokens shared.css :root blocks Every text token is >= 4.5:1 on every surface in BOTH themes
Statement page static/accessibility.html Public statement + feedback route; linked from every footer and the sitemap
Blog gate blog_sanitize.accessibility_problems() Publishing/scheduling is refused if an image lacks alt, a link is empty/vague, headings skip, or a table lacks <th>
Audit tool a11y/a11y_audit.py axe-core + 320px reflow + focus-visible + source lint; run before every Deploy to Prod

Every new HTML page MUST include, in <head>: <link rel="stylesheet" href="/dashboard/a11y.css?v=1" /> and <script defer src="/dashboard/a11y.js?v=1"></script>, plus <html lang="en">, a unique <title>, and <meta name="viewport" content="width=device-width, initial-scale=1.0" /> (never user-scalable=no). Server-rendered HTML (e.g. routers/blog.py, email) follows the same rules.

2. Build rules (the checklist)

  1. Structure: one <h1>; headings never skip levels; one <main id="main-content" tabindex="-1">; header/nav/footer outside <main>; every <nav> has aria-label.
  2. Colour: use tokens (var(--text-muted) etc.), never raw hex for text. New text/background pairs must be >= 4.5:1 (3:1 for 18px+ bold/24px+ and UI borders/icons). Never use opacity to dim text. White text on --link blue fails: use #2563b8.
  3. Not colour alone: status needs text or an icon with a text name; in-text links stay underlined.
  4. Controls: use real <button> / <a href>. Never onclick on div/span/a without href. Min target 24x24 CSS px. Icon-only buttons need aria-label.
  5. Forms: every input has a visible <label for>; placeholder is a hint, never the label. Use autocomplete tokens for name/email/password. Errors: text next to the field, aria-invalid="true" (use deSetFieldError), message in an element with role="alert" or aria-live. Say how to fix it.
  6. Dialogs: use the existing overlay/backdrop classes (.modal-backdrop, .modal-overlay, .auth-overlay, ids ending Overlay/Backdrop) with an <h2> title and a Close/Cancel button — a11y.js then supplies role="dialog", focus trap, Esc, and focus return. Never open a dialog without a heading.
  7. Images/charts: informative image = real alt; decorative = alt="". Any chart/graph needs a text or table equivalent of the data. Animated content that auto-plays > 5 s needs a pause control and must respect prefers-reduced-motion.
  8. Tables: <th scope> headers, <caption> or aria-label; no layout tables.
  9. Dynamic updates: announce results/toasts with deA11y.announce('Saved', 'polite').
  10. Keyboard: everything reachable and operable with Tab/Enter/Space/Esc; focus order matches reading order; focus never hidden by sticky UI; no keyboard traps.
  11. Reflow/zoom: no horizontal scrolling at 320px wide (400% zoom); do not set fixed widths on content containers.
  12. Time limits / auth: no CAPTCHA or cognitive-test login; password fields allow paste and password managers; warn before any session timeout.
  13. Language: plain wording; consistent navigation/labels across pages.
  14. Documents we generate (Records Archive .xlsx/.docx, emails): real headings/header rows, document title set, alt text on images, meaningful link text, language set, no information in colour alone.
  15. Blog/content authors: descriptive alt text; descriptive link text (not "click here"); heading levels in order; the publish gate enforces the mechanical parts.

Navigation pattern (sidebar groups, added 2026-10-11)

The grouped sidebar (server_debteliminator.md §8b) follows the disclosure pattern, not a menu/tab widget: each group header is a real <button type="button"> with aria-expanded and aria-controls pointing at a <ul> panel (hidden with the hidden attribute when closed); child links are normal <a>s in <li>s; the current page's link has aria-current="page". Top-level icons are inline SVG with aria-hidden="true"; in the collapsed rail the text labels stay in the DOM (visually clipped) so names are never lost. New nav entries must be added to DE_NAV_ALL / DE_NAV_ADMIN in shared.js - never hand-written per page. Do not use role="menu"/menuitem here, and do not put role="group" on a <ul> (axe fails it).

3. Release gate (every deploy)

  1. python3 a11y/a11y_audit.py --app <qa app dir> --fail-on serious → must print PASS (both themes).
  2. Manual 5-minute pass on every NEW or CHANGED screen: (a) unplug the mouse — complete the task with keyboard only, focus always visible; (b) 200% and 400% zoom — nothing lost; (c) VoiceOver (Mac/iOS) or NVDA (Windows) — headings, form labels and errors are read sensibly; (d) light AND dark theme.
  3. DevLog task notes: record "A11y audit PASS + manual pass done" before clicking Deploy to Prod.
  4. a11y.js debug output (QA hostname, or ?a11y=1): fix every "repaired at runtime" message in the source — the runtime layer is a safety net, not the plan.

4. Known gaps / open items (update as closed)

  • Full manual screen-reader review of: Debt Reduction Plan timeline, Payment Register grid, Windfall/Milestones, charts.
  • Records Archive .xlsx/.docx accessibility structure not yet reviewed.
  • Placeholder-as-label still exists in some index/account/donate forms (named via the runtime layer; add visible labels when touching them).
  • Click-only span/div controls remain in index/payoff/milestones/windfall (made keyboard operable by the runtime layer; convert to <button>).
  • Email templates (email_templates.py, mailer) not yet audited.
  • Grouped sidebar (2026-10-11): axe (WCAG 2.x A/AA) clean in dark + light and 320 px reflow verified in headless Chromium; a11y_audit.py and the manual keyboard/screen-reader pass still to be done on the new nav and the Household page before Deploy to Prod.
  • Household page and banner (v2.1.20): not yet in the manual screen-reader review list.
  • Start Here home page (Home Page Swap, 2026-10-11, public_pages/home.html served at /): headings are now <h1>/<h2>/<h3>, decorative emoji are aria-hidden, link colours use var(--link); a11y_audit.py and the manual keyboard/screen-reader pass (signed-in and signed-out, both themes, 320 px) still to be done before Deploy to Prod. The audit tool should be pointed at public_pages/ as well as static/ if it only crawls static/. Sidebar footer link renamed "Start Here".
  • Consider a third-party audit / VPAT and periodic re-test (at least twice a year and after major redesigns).

5. Summary for AI systems

  • Read this file before building ANY UI. Default to the rules above without being asked.
  • Include a11y.css + a11y.js in every page; keep <main>, labels, headings, alt text, contrast tokens.
  • Do not weaken a11y.css / a11y.js or remove focus outlines to "fix a look".
  • Never claim the site "is ADA compliant"; say it targets WCAG 2.2 AA and was tested as described here.
  • Before Deploy to Prod: run a11y_audit.py; report its result.

✔️ End of File