{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"drift-card","type":"registry:ui","title":"Drift Card","description":"A card whose photo, text and chips drift at different parallax depths as the pointer moves, with a soft tilt and glare.","dependencies":["motion"],"registryDependencies":[],"files":[{"path":"registry/ui/drift-card.tsx","type":"registry:ui","content":"\"use client\";\n\nimport type { PointerEvent, ReactNode } from \"react\";\nimport { motion, useMotionTemplate, useMotionValue, useReducedMotion, useSpring, useTransform } from \"motion/react\";\n\nexport interface DriftCardProps {\n  image: string;\n  title: string;\n  description?: string;\n  /** Small label floating on the top layer. */\n  eyebrow?: string;\n  /** Extra foreground content (e.g. a button), drifts with the text. */\n  children?: ReactNode;\n  /** Max drift of the nearest layer in px. Farther layers drift less. */\n  depth?: number;\n  /** Max card tilt in degrees. */\n  tilt?: number;\n  width?: number;\n  height?: number;\n  className?: string;\n}\n\ntype MV = ReturnType<typeof useSpring>;\nconst useDrift = (sx: MV, sy: MV, px: number) => ({\n  x: useTransform(sx, (v) => v * px * 2),\n  y: useTransform(sy, (v) => v * px * 2),\n});\n\nexport function DriftCard({\n  image,\n  title,\n  description,\n  eyebrow,\n  children,\n  depth = 24,\n  tilt = 8,\n  width = 320,\n  height = 420,\n  className,\n}: DriftCardProps) {\n  const reduce = useReducedMotion();\n  // Pointer position in the card, -0.5..0.5, eased with a spring so layers glide instead of snap.\n  const px = useMotionValue(0);\n  const py = useMotionValue(0);\n  const sx = useSpring(px, { stiffness: 140, damping: 18, mass: 0.6 });\n  const sy = useSpring(py, { stiffness: 140, damping: 18, mass: 0.6 });\n\n  // Each layer drifts by a fraction of `depth`; negative moves against the pointer (far away).\n  const back = useDrift(sx, sy, -0.6 * depth);\n  const mid = useDrift(sx, sy, 0.5 * depth);\n  const front = useDrift(sx, sy, depth);\n  const extra = useDrift(sx, sy, 0.5 * depth); // children ride inside `mid`, this tops them up to `front`\n  const rotateX = useTransform(sy, (v) => -v * tilt * 2);\n  const rotateY = useTransform(sx, (v) => v * tilt * 2);\n  const gx = useTransform(sx, (v) => `${(v + 0.5) * 100}%`);\n  const gy = useTransform(sy, (v) => `${(v + 0.5) * 100}%`);\n  const glare = useMotionTemplate`radial-gradient(circle at ${gx} ${gy}, rgba(255,255,255,.22), transparent 55%)`;\n\n  const onMove = (e: PointerEvent<HTMLDivElement>) => {\n    if (reduce) return;\n    const r = e.currentTarget.getBoundingClientRect();\n    px.set((e.clientX - r.left) / r.width - 0.5);\n    py.set((e.clientY - r.top) / r.height - 0.5);\n  };\n  const onLeave = () => {\n    px.set(0);\n    py.set(0);\n  };\n\n  return (\n    <div style={{ perspective: 1000, width, height }} onPointerMove={onMove} onPointerLeave={onLeave} className={className}>\n      <motion.article\n        className=\"group relative size-full overflow-hidden rounded-3xl border border-border bg-muted shadow-[0_40px_80px_-40px_rgba(0,0,0,.9)]\"\n        style={{ rotateX, rotateY, transformStyle: \"preserve-3d\" }}\n      >\n        <motion.img\n          src={image}\n          alt=\"\"\n          draggable={false}\n          className=\"absolute -inset-[10%] size-[120%] max-w-none object-cover\"\n          style={back}\n        />\n        <div className=\"absolute inset-0 bg-gradient-to-t from-black/85 via-black/20 to-black/10\" />\n\n        {eyebrow && (\n          <motion.span\n            style={front}\n            className=\"absolute left-5 top-5 rounded-full border border-white/20 bg-white/10 px-3 py-1 text-xs font-medium text-white backdrop-blur-md\"\n          >\n            {eyebrow}\n          </motion.span>\n        )}\n\n        <motion.div style={mid} className=\"absolute inset-x-0 bottom-0 p-6 text-white\">\n          <h3 className=\"text-2xl font-semibold tracking-tight\">{title}</h3>\n          {description && <p className=\"mt-2 text-sm leading-relaxed text-white/75\">{description}</p>}\n          {children && <motion.div style={extra} className=\"mt-5\">{children}</motion.div>}\n        </motion.div>\n\n        <motion.div\n          aria-hidden\n          className=\"pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300 group-hover:opacity-100\"\n          style={{ background: glare }}\n        />\n      </motion.article>\n    </div>\n  );\n}\n"}]}