# Hover Zoom Magnifier

## Objective

Show a magnified detail of an image on hover, the way product photos do.

A hover magnifier that reveals a high-resolution detail of an image under the pointer without opening a dialog.

## 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 this only where detail genuinely matters — product photography, scans, diagrams — and not to every image in the app. A magnifier on an avatar is noise.
2. Treat it as an enhancement over the app's existing Image Lightbox rather than a replacement. Hovering magnifies, clicking still opens the lightbox, and the two must share the same image sources and the same alt text.
3. Require a source meaningfully larger than the displayed size. If the only available file is the one already on screen, skip the effect entirely instead of magnifying a blurry upscale.
4. Load the high-resolution source on first pointer entry and hold it, so the magnifier does not open onto a blank panel and does not re-fetch on every pass.
5. Do not intercept the pointer with an overlay that swallows clicks. Links, buttons, and text selection underneath the image must keep working exactly as they did.

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

- Touch devices have no hover. Detect a coarse pointer and fall back to tap-to-open full view rather than firing the magnifier on a tap and trapping the user in it.
- Without a source larger than the rendered image there is nothing to magnify. Detect the missing high-resolution rendition and disable the effect quietly rather than showing an upscaled smear.
- Near the right or bottom edge of the window the magnified panel would be clipped. Flip it to the other side of the cursor and keep it fully inside the viewport.
- Preload the zoom source when the pointer first enters the image, so the first magnification shows content rather than an empty box while the file arrives.
- The magnifier must not block text selection or clicks on links and buttons layered over or beside the image.
- The effect must not be the only way to see detail. Keyboard users and screen reader users need the full view reachable without a pointer.
- Fast pointer movement across a grid of images must not queue a stack of high-resolution downloads; cancel loads for images the pointer has already left.
- Suppress the follow animation when reduced motion is requested and simply place the panel.

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

- [ ] Hovering a qualifying image shows a magnified detail tracking the pointer.
- [ ] Images without a higher-resolution source do not show the effect at all.
- [ ] Touch and coarse-pointer devices fall back to opening the existing lightbox.
- [ ] The magnified panel stays fully within the viewport at every screen edge.
- [ ] Links, buttons, and text selection under the image continue to work.
- [ ] The high-resolution source is fetched once and the first hover is never blank.
- [ ] The full-size view is reachable by keyboard without hovering.
- [ ] 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.
