# Landmark Shell

## Objective

Give every page the same navigable regions so people can jump straight to the content.

A reusable application shell providing labelled banner, navigation, main, complementary, and contentinfo regions on every route.

## 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. Find the layouts the app already renders and identify what each region actually is — the top bar, the primary navigation, the page body, any inspector or sidebar, the footer — then express them as landmarks once in the shell rather than per page.
2. Give the shell exactly one main region per rendered page, and make it the target of a skip link that is the first focusable thing in the document.
3. Label every landmark that appears more than once so they can be told apart — primary navigation, breadcrumb, pagination — using a short distinct name rather than the word navigation repeated.
4. Move focus to the main region's heading on route change so keyboard and screen reader users start at the new content rather than back at the top of the navigation, and keep the announcement itself in Live Region Manager rather than adding a second mechanism here.
5. Do not achieve the visual arrangement by reordering with layout properties while leaving the source order wrong. Tab order and reading order follow the source, so a sidebar that reads before the main content in source but sits to the right on screen will confuse everyone who does not use a mouse.

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

- There must be exactly one main region at any moment. A nested layout that renders its own main inside the shell's produces two, and assistive technology then offers the user a meaningless choice.
- Multiple navigation regions without distinct labels are indistinguishable in a landmark list; every repeated landmark type needs its own accessible name, and those names must not duplicate each other.
- Visual order and source order must agree. Where a responsive layout moves a region, the source must move with it rather than being repositioned visually only.
- Route changes that mount a new shell alongside the old one during a transition will briefly duplicate every landmark id and label; ensure the outgoing tree is removed before the incoming one is announced, and generate ids that cannot collide across two mounted instances.
- Modals and fullscreen surfaces must hide the rest of the shell from assistive technology while open, or the user can arrow out of the dialog into the page behind it.
- A page with no sidebar or no footer must omit that landmark entirely rather than render an empty labelled region.
- The skip link must actually move focus, not merely scroll — a hash change that leaves focus at the top of the document does nothing for keyboard users.

## 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 route renders exactly one main landmark, wrapped by the shared shell.
- [ ] Banner, navigation, main, complementary, and contentinfo regions are present where they apply and absent where they do not.
- [ ] Repeated landmark types each carry a distinct accessible name.
- [ ] A skip link is the first focusable element and moves focus into main.
- [ ] Source order matches visual order at every breakpoint.
- [ ] No duplicate ids or duplicate landmarks exist at any point during a route transition.
- [ ] An open modal hides the shell from assistive technology until it closes.
- [ ] 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.
