# Icon System

## Objective

Draw every icon from one set, at one set of sizes, with one rule for accessible naming.

A single icon interface with a fixed size ladder, stable names, predictable alignment, and defined accessible behaviour.

## 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. Inventory every icon currently rendered in the app — inline vector markup, sprites, image files, icon fonts, glyphs pasted into labels — and route all of them through one interface so a size or colour change is made in one place.
2. Fix a small size ladder, three or four steps, tied to the type scale, and make every icon align to the text it sits beside rather than to the box that contains it.
3. Decide per usage whether an icon is decorative or meaningful. Decorative icons must be hidden from assistive technology; meaningful ones need an accessible name that says what the control does, not what the picture is.
4. Make icons inherit colour from their context so a single icon works in a button, a menu, a warning, and a disabled control without a per-instance override.
5. Do not leave a second icon library in place while migrating. Two sets of the same concept drift apart, and the day someone reaches for the wrong chevron is the day the app has two visual languages. Icon Stroke Normalization owns the drawing weight of the icons themselves; this entry owns the interface, sizing, naming, and accessibility around them.

## 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

- More than one icon library in the same codebase produces two versions of the same concept at different weights and different optical sizes. Pick one source, migrate the rest, and remove the abandoned dependency rather than leaving it available.
- An icon that carries meaning on its own — a status dot, an error mark, a delete control with no text — needs a name announced to assistive technology. An icon beside a visible label is decoration and must be hidden, or screen reader users hear the same word twice.
- Icons drawn on different canvases occupy different proportions of their box, so a set nominally at one size will look mismatched. Normalize the optical size so a square and a circle read as equally weighted at the same step.
- Fill and stroke behaviour has to survive a theme change. An icon that relies on a light background will disappear or invert badly in dark mode unless its colour comes from the theme rather than being baked in.
- Directional icons — arrows, chevrons, undo, next and previous — must mirror in right-to-left locales, while icons for time, media playback, and brand marks must not.
- A name that does not exist in the set must fail visibly during development rather than rendering an empty box in production.
- Icons used as the only content of a control still need a minimum touch target, which is larger than the icon itself.

## 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

- [ ] Every icon in the app is rendered through one interface, and no second icon library remains installed.
- [ ] Icon sizes come from a fixed ladder and align optically with adjacent text.
- [ ] Decorative icons are hidden from assistive technology and meaningful ones carry an accessible name describing the action.
- [ ] Icons inherit colour from their surroundings and remain legible in every theme.
- [ ] Directional icons mirror in right-to-left locales and non-directional ones do not.
- [ ] An unknown icon name produces a clear failure during development.
- [ ] Icon-only controls meet the minimum touch target regardless of the icon's size.
- [ ] 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.
