# Touch Target Checker

## Objective

Find the controls that are too small or too crowded to hit reliably on a phone.

A development-time audit reporting the measured hit area and neighbour spacing of every interactive element.

## Before You Begin

This feature is being added to an application that already exists and already
works. Do not scaffold a new project, and do not assume a blank slate.

Inspect the codebase first and establish:

- The existing application structure and where code of this kind already lives.
- The framework and version in use.
- The existing design system — colours, spacing, typography, and component conventions.
- Existing UI components you can reuse instead of writing new ones.
- The existing database structure, if this feature needs to persist anything.
- The existing authentication and authorization system, if this feature is user-scoped.
- Dependencies already installed, so you don't add a library that duplicates one.
- The existing test setup and conventions.

Only start writing code once you understand the above. If the application
already implements part of this feature, extend it rather than replacing it.

## Implementation Instructions

1. Measure the element's actual activation area — the region that responds to a tap — rather than the icon or glyph drawn inside it, since padding and pseudo-element extensions frequently make a small icon a perfectly adequate target.
2. Check the gap between adjacent targets as well as their size. Two comfortable buttons sitting flush against each other still produce mis-taps, and the report must say which of the two problems it found.
3. Report the offending elements with enough context to locate them — the route, the component, and a way to highlight the element on the page — rather than a count of failures.
4. Evaluate at touch-capable viewport sizes and pointer modes. Desktop layouts are allowed to be denser, and flagging every compact desktop toolbar produces a report nobody reads.
5. Do not flag decorative or non-interactive elements, and do not flag controls that are duplicated by a larger target covering the same action. A checker that reports hundreds of false positives gets switched off within a week.

## UI and UX Requirements

Match the application's existing design system exactly. Reuse its components,
spacing, and typography. This feature should look like it was always there.

## Responsive Requirements

Works on mobile, tablet, and desktop. Touch targets are large enough to hit on a
phone, and nothing overflows horizontally at 320px.

## Accessibility Requirements

- Fully keyboard navigable.
- Correct semantic elements and ARIA roles.
- Visible focus states.
- Meets WCAG AA contrast.
- Dynamic changes are announced to screen readers.
- Respects prefers-reduced-motion.

## Edge Cases

- The measurement must be of the real hit area including padding and any invisible extension, not the rendered icon, or every well-built icon button is reported as a failure.
- Spacing between neighbouring targets is a separate failure from insufficient size, and conflating them hides the cases where the fix is a gap rather than a bigger button.
- Denser desktop layouts are legitimate, so the checker must apply the touch thresholds only where touch input is plausible and must not push mobile sizes onto desktop toolbars.
- Decorative elements, disabled controls that cannot be activated, and elements whose action is duplicated by a larger surrounding target should be excluded from the report.
- Elements hidden behind a collapsed menu, an inactive tab, or a closed drawer are never measured unless the audit opens them, which is where the smallest controls usually hide.
- Overlapping targets that fully or partially cover one another are worse than small ones and need their own finding.
- This feature reports; Display Density owns whether the app has a compact mode and what it is allowed to shrink. Compact mode must reduce padding and line height without dropping below the audit's thresholds.

## Testing

Exercise the feature end to end in the running application. Cover every edge case
above, then run the existing test suite and confirm nothing regressed.

## Acceptance Criteria

- [ ] The audit measures the activation area rather than the visual glyph.
- [ ] Insufficient size and insufficient spacing are reported as distinct findings.
- [ ] Touch thresholds apply only at touch-capable viewports and pointer types.
- [ ] Decorative, disabled, and duplicated controls are excluded.
- [ ] Each finding identifies the route and component and can highlight the element in place.
- [ ] Controls inside collapsed menus, drawers, and inactive tabs are included in the audit.
- [ ] Overlapping interactive areas are reported separately.
- [ ] The feature matches the existing design system.
- [ ] No existing functionality is broken.

## Adaptation Rules

- Match the existing design system. Do not introduce a new colour palette,
  spacing scale, or component library.
- Reuse existing components and utilities wherever they fit.
- Follow the naming, file layout, and code style already present.
- Do not upgrade, replace, or remove existing dependencies to make this
  feature fit. Adapt the feature to the app, not the app to the feature.
- Do not break existing functionality. If a change is genuinely required in
  existing code, make the smallest one that works and say so.
- If something in these instructions conflicts with how the application is
  built, follow the application and explain the deviation.

## Final Verification

Before you report the work as done:

1. Re-read the acceptance criteria above and check each one against what you
   actually built.
2. Run the application and exercise the feature end to end.
3. Run the existing test suite and confirm you have broken nothing.
4. Check the feature on mobile, tablet, and desktop widths.
5. Check keyboard navigation and focus handling.
6. Summarize what changed: files added, files modified, and anything you
   deliberately did differently because of how this application is built.

If any acceptance criterion is unmet, fix it before reporting completion.
