# Name Pronunciation Recording

## Objective

Let people record how their name is pronounced and play it back from their profile.

A short self-recorded audio clip of a person's name on their profile, with a phonetic text spelling alongside it.

## 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. Add the recorder to the existing profile editing form, next to the name fields, and store the clip through the app's existing file storage and Avatar Upload path rather than a new one.
2. Keep the interaction to record, listen back, keep or re-record. Anything longer than that is a studio, and people will abandon it.
3. Add a short phonetic spelling field beside the recording, so the name is still readable when audio is unavailable, muted, or blocked.
4. Show the play control anywhere the person's name appears prominently, using the same visibility rules as the rest of their profile, and reuse the app's existing avatar and name components rather than adding a parallel one.
5. Do not require a microphone. Someone who declines the permission, or has no microphone, must still be able to fill in the phonetic spelling and save their profile.

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

- Cap the clip at a few seconds and stop recording automatically at the cap. Without a hard limit this field becomes a voice memo, and the play control on a member list starts a two-minute monologue.
- Re-recording and deletion must remove the previous file rather than leaving orphaned audio in storage. Apply the app's existing retention rules so a deleted clip is actually deleted.
- The phonetic spelling is the fallback whenever audio cannot play: no permission to autoplay, an unsupported format, a blocked storage host, or a silent-mode device. Always show it if it is present.
- The recording follows the person's profile visibility. A clip on a private profile must not be readable by an unauthenticated request to the file, so serve it through the same authorisation as the rest of the profile.
- The play control must be reachable by keyboard, must state whose name it will pronounce, and must not be an unlabelled icon sitting next to an avatar.
- Enforce duration, size, and content type on the server, not only in the browser, and run the clip through the app's existing upload scanning.
- Only one clip may play at a time. Starting a second must stop the first, or a directory page becomes a chorus.
- A recording that fails to upload must leave the previous clip in place and say so, rather than clearing the field and losing what was there.

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

- [ ] A person can record, play back, re-record, and delete a name clip from their existing profile form.
- [ ] Recording stops automatically at the length cap, and the cap is enforced server-side.
- [ ] Deleting or replacing a clip removes the previous file from storage.
- [ ] A phonetic spelling is stored and shown wherever the audio cannot play.
- [ ] The clip is only readable by people allowed to see the profile.
- [ ] The play control is keyboard reachable and clearly labelled with whose name it plays.
- [ ] Declining microphone permission still allows the profile to be saved.
- [ ] 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.
