# Required Field Indicator

## Objective

Make it obvious which fields must be filled in and which may be left alone.

A consistent marking of required and optional fields across every form in the app.

## 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. Count the required and optional fields across the app's forms and pick the convention that marks the minority — if most fields are required, mark the optional ones instead.
2. Apply the chosen convention to every form without exception, and state the convention once at the top of each form so the marker means something to a first-time reader.
3. Expose the requirement to assistive technology as well as visually, so the control itself reports that it is required rather than relying on a symbol beside the label.
4. Recompute the marking when requirements change at runtime — a field that becomes mandatory once a plan or a country is selected must gain its marker and its announcement immediately.
5. Do not mark a read-only, disabled, or system-populated field as required. It tells the user to act on something they cannot touch, and it makes the marker untrustworthy everywhere else.

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

- A bare asterisk carries no meaning to a screen reader and is often skipped entirely; the requirement must be on the control, not only in the label's punctuation.
- The form-level legend explaining the convention must match what the fields actually do, and a form that mixes required-marking with optional-marking teaches the user nothing.
- Requirements that change mid-form must update the marker, the accessible state, and the validation rule together — a field that validates as required but shows no marker looks like a bug.
- A field that is required by the server but not marked in the interface produces an error the user could not have anticipated; the marking must reflect the actual validation.
- A field required only in one branch of a conditional flow must lose its marker when that branch is not active, rather than staying marked and blocking submission invisibly.
- The marker must not be conveyed by colour alone, and it must survive at compact density without colliding with a long label.
- How the marker is placed in the label and linked to the control is owned by Form Field Shell; this entry owns which fields are marked and what the convention is.

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

- [ ] One convention — marking required or marking optional — is used across every form.
- [ ] Each form states its convention once, visibly.
- [ ] Requirements are exposed programmatically on the control, not only as a visual symbol.
- [ ] Marking matches the validation actually enforced on submission.
- [ ] Requirements that change at runtime update the marker and the accessible state together.
- [ ] Read-only, disabled, and system-populated fields are never marked required.
- [ ] 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.
