How it works
The effect combines three layered techniques. First, pointer tracking: a pointermove listener computes the cursor position relative to the card center and normalizes it to a -1 to 1 range on both axes. Second, perspective rotation: those values drive rotateX and rotateY transforms, capped at around 12 degrees so the card reads as tilt rather than spin. A parent container with CSS perspective (typically 800 to 1000px) is what makes the rotation render as true 3D depth. Third, the glow layer: a radial-gradient positioned at the same pointer coordinates is composited on top of the card, simulating a reflective sheen that follows your hand.
The polish lives in the exit animation. Naive implementations zero the rotation the moment the pointer leaves, which looks robotic. Here the release values are handed to a spring simulation (or a CSS transition with an overshooting cubic-bezier) so the card swings slightly past flat and settles, the same way a physical object would. Using requestAnimationFrame for the tracking loop and keeping all motion on transform properties ensures the animation stays on the GPU compositor and never triggers layout work, which is why it holds 60fps even on mid-range phones.
How to use this prompt
Copy the prompt and paste it into your AI coding tool with the component you want to enhance. If you use React or Vue, mention that in the same message so the assistant wraps the logic in a component hook instead of inline listeners. For touch devices, ask the AI to duplicate the behavior with touch events - the prompt already hints at pointer support, but being explicit about mobile gets you a result that works everywhere on the first try.
Tips for better results
Keep the max angle between 8 and 15 degrees; anything steeper starts to distort text readability. If the card contains interactive children like buttons, ask the AI to preserve their click targets by tilting the inner wrapper instead of the card itself. And on low-end hardware, disable the glow layer via prefers-reduced-motion to respect users who opt out of decorative animation.