# Plan Comparison

## Objective

Show what each plan includes and what would actually change for this account.

A side-by-side plan table driven by real entitlements, marking the current plan and the transitions this account can make.

## 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. Build every comparison row from the live entitlement definitions. Hard-coded marketing copy drifts from what the app actually enforces, and the table becomes a lie.
2. Mark the current plan unmistakably, and render only the transitions this account is eligible for. A disabled button with no explanation is worse than no button.
3. Show limits as numbers with the account's current usage against them, so a downgrade that would break something is visible before it is chosen.
4. Cover interval (monthly versus annual), add-ons, and whether displayed prices include tax. A price that changes at checkout destroys trust.
5. Do NOT build the contextual single-feature upsell — that is owned by Upgrade Modal. Subscription state and payment methods are owned by Billing Portal, and the money delta of a change is owned by Proration Preview. Link to them; do not duplicate 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

- A grandfathered plan may not appear in the current lineup at all. Show it as the current plan anyway, with what would be lost by moving off it.
- Custom or negotiated plans must not be flattened into the nearest public tier. Show the real entitlements or defer to a contact route.
- A downgrade that would exceed the target plan's limits must warn with specifics — which items, how many over — before the user commits.
- Currency and tax vary by region. Show the account's own currency rather than a converted approximation.
- Annual and monthly rows are not comparable at a glance. Show the interval explicitly rather than relying on a toggle the user may not notice.
- A plan the account cannot buy — region-restricted, sales-only, deprecated — must be hidden or labelled, not shown as an option that fails at checkout.
- Rows must be honest about degree. 'Included' versus 'included up to 5' versus 'paid add-on' are three different answers and a tick mark gives all three the same one.

## 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 row is generated from live entitlement data, not static copy.
- [ ] The current plan is clearly marked and only eligible transitions are offered.
- [ ] Limits show the account's current usage alongside each plan's allowance.
- [ ] Billing interval, add-ons, currency, and tax treatment are stated on the table.
- [ ] Grandfathered and custom plans render correctly rather than being mapped to a public tier.
- [ ] A downgrade that would breach a limit warns with specifics before confirmation.
- [ ] The table links to the upgrade, billing, and proration surfaces instead of reimplementing them.
- [ ] 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.
