# Age Verification Gate

## Objective

Ask visitors to confirm their age before restricted content, and remember the answer.

An interstitial on age-restricted pages that records a confirmation and does not ask again on every visit.

## 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. Apply the gate only to the pages that genuinely need it. Gating an entire site, including its help and legal pages, drives away visitors who were never going to see the restricted content.
2. Store the decision the same way the app already stores Consent and Cookie Preferences, and put the age confirmation in that same preference record rather than inventing a second cookie with its own expiry rules.
3. Give a refusal a real destination: an explanation page, or the site the visitor most likely came from. A blank screen or an infinite redirect loop reads as a broken site, not a policy.
4. Build the gate on the app's existing Accessible Modal and Drawer Behaviour or Focus Containment Primitive so focus is trapped, Escape has a defined meaning, and the whole thing is reachable by keyboard.
5. Do not treat this as identity verification. A self-declared checkbox is a legal formality, and building a date-of-birth capture or an ID upload on the back of it creates a data protection obligation nobody asked for.

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

- Remember the decision so a returning visitor is not gated on every page load, but do not let the gate hide the page from search engine crawlers and link previews. Serve the underlying content to crawlers and gate the rendered experience.
- A visitor who declines needs somewhere to go. Send them to a page that explains why, and make sure that page is not itself behind the gate.
- The minimum age differs by jurisdiction. Derive it from the visitor's region where the app already knows it, default to the strictest applicable age when it does not, and let the value be configured rather than hardcoded.
- The gate must be fully operable from the keyboard, with focus moved into it on open, contained while it is open, and returned to a sensible place on close. A mouse-only gate blocks the page for anyone who cannot use one.
- Do not collect a date of birth when a confirmation is enough. If a birth date genuinely is required, store the derived answer and discard the date rather than keeping a piece of personal data you have no use for.
- The gate must not flash the restricted content before it appears. Decide server-side or before first paint, not after the page has rendered.
- Deep links from social media and search results land directly on restricted pages. The gate must handle that entry point and return the visitor to the page they asked for after confirming.
- The stored decision must be resettable, and clearing site data must clear it. Persisting a confirmation the visitor cannot revoke is not defensible.

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

- [ ] Only age-restricted pages are gated; the rest of the site is reachable.
- [ ] A confirmed visitor is not asked again within the retention period, and the decision lives alongside the app's other consent preferences.
- [ ] Declining leads to a real explanatory destination with no redirect loop.
- [ ] The minimum age is configurable and varies by visitor region, defaulting to the strictest applicable value.
- [ ] The gate traps focus, is fully keyboard operable, and restores focus on close.
- [ ] Restricted content is never visible before the gate resolves.
- [ ] No date of birth is stored when a confirmation would do, and the decision can be cleared by the visitor.
- [ ] 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.
