# Product Quick View

## Objective

Let shoppers preview a product and add it to the cart without leaving the listing.

An overlay panel opened from a product card showing images, variants, price, and an add-to-cart control.

## 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. Show only what decides a purchase: images, price, variant choices, stock status, and the add-to-cart control. Everything longer belongs on the full product page, and a link to it must always be present.
2. Build the panel on the app's existing modal or drawer behaviour rather than introducing a second overlay implementation. Focus trapping, escape handling, and scroll locking are already solved there.
3. Fetch the product detail when the panel opens and show a skeleton matching the panel's real layout, so the overlay never appears empty.
4. Reuse the app's existing Image Lightbox for full-size image viewing instead of nesting a second image viewer inside the panel.
5. Do not make quick view the only path to the product. Every card must still link to the real page, and that page must remain crawlable and shareable.

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

- Closing the panel must return focus to the card that opened it and leave the listing at the same scroll position. Dumping the shopper at the top of the page after a close is the failure people notice most.
- The listing behind the panel must not scroll underneath it, and locking that scroll must not shift the layout when the scrollbar disappears.
- Details load lazily, so a slow request needs a skeleton with reserved dimensions and a failure needs a message with a link to the full page rather than an empty panel that stays empty.
- On small screens an overlay squeezing a gallery, variant picker, and buy button into a phone viewport is worse than the real thing. Navigate to the full product page instead of opening the panel.
- A variant chosen in the preview must carry through when the shopper opens the full product page, otherwise the selection is silently lost and they choose again.
- Adding to cart from the panel must update the cart indicator and either confirm in place or close deliberately. Doing nothing visible reads as a failed click and produces duplicate additions.
- Out-of-stock and unavailable variants must be reflected in the panel with the add control disabled, not discovered at checkout.
- Opening a quick view must not push a history entry that makes the back button close the panel and the second press leave the site unpredictably. Decide the behaviour and apply it consistently.

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

- [ ] The panel opens from a card with product images, price, variants, and add to cart.
- [ ] Closing restores focus to the originating card and the listing's scroll position.
- [ ] The page behind the panel does not scroll or shift while it is open.
- [ ] A loading panel shows a shape-matched skeleton and a failed load offers the full product page.
- [ ] Small screens go to the full product page instead of opening the overlay.
- [ ] A variant selected in the preview is preselected on the full product page.
- [ ] The panel reuses the app's existing modal and lightbox behaviour rather than duplicating it.
- [ ] 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.
