{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "depth-card",
  "title": "Depth Card",
  "author": "VenusUI",
  "description": "A card that tilts toward the pointer while its layers rise off the surface, each to its own depth.",
  "files": [
    {
      "path": "registry/default/ui/depth-card.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ninterface DepthCardProps extends React.ComponentProps<\"div\"> {\n  /** Largest tilt in degrees as the pointer moves across the card. */\n  max?: number\n  /** Distance to the viewer in px. Smaller values exaggerate the depth. */\n  perspective?: number\n  /** Class for the outer element that holds the perspective, e.g. for layout. */\n  containerClassName?: string\n}\n\n/**\n * A card that tilts toward the pointer while the `DepthCardItem`s inside it\n * rise off the surface, each to its own depth. Keyboard focus inside the card\n * lifts the items too (without tilting). Touch users and anyone who prefers\n * reduced motion see a flat card.\n */\nfunction DepthCard({ max = 12, perspective = 1000, className, containerClassName, style, children, ...props }: DepthCardProps) {\n  const ref = React.useRef<HTMLDivElement>(null)\n  const frame = React.useRef(0)\n\n  React.useEffect(() => () => cancelAnimationFrame(frame.current), [])\n\n  const reduced = () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n\n  const setActive = (active: boolean) => {\n    const card = ref.current\n    if (!card) return\n    if (active && !reduced()) card.setAttribute(\"data-active\", \"\")\n    else card.removeAttribute(\"data-active\")\n  }\n\n  const resetTilt = () => {\n    cancelAnimationFrame(frame.current)\n    ref.current?.style.setProperty(\"--rx\", \"0deg\")\n    ref.current?.style.setProperty(\"--ry\", \"0deg\")\n  }\n\n  return (\n    <div\n      className={cn(\"perspective-(--depth-card-perspective)\", containerClassName)}\n      style={{ \"--depth-card-perspective\": `${perspective}px` } as React.CSSProperties}\n    >\n      <div\n        ref={ref}\n        data-slot=\"depth-card\"\n        onPointerEnter={(event) => event.pointerType !== \"touch\" && setActive(true)}\n        onPointerMove={(event) => {\n          if (event.pointerType === \"touch\" || reduced()) return\n          const card = ref.current\n          if (!card) return\n          const { clientX, clientY } = event\n          cancelAnimationFrame(frame.current)\n          frame.current = requestAnimationFrame(() => {\n            const rect = card.getBoundingClientRect()\n            const px = (clientX - rect.left) / rect.width\n            const py = (clientY - rect.top) / rect.height\n            card.style.setProperty(\"--rx\", `${(0.5 - py) * max * 2}deg`)\n            card.style.setProperty(\"--ry\", `${(px - 0.5) * max * 2}deg`)\n          })\n        }}\n        onPointerLeave={() => {\n          resetTilt()\n          if (!ref.current?.contains(document.activeElement)) setActive(false)\n        }}\n        onFocus={() => setActive(true)}\n        onBlur={(event) => {\n          if (!event.currentTarget.contains(event.relatedTarget) && !event.currentTarget.matches(\":hover\")) setActive(false)\n        }}\n        className={cn(\n          \"group/depth-card relative transform-3d\",\n          \"[transform:rotateX(var(--rx,0deg))_rotateY(var(--ry,0deg))] transition-transform duration-200 ease-out will-change-transform\",\n          className\n        )}\n        style={style}\n        {...props}\n      >\n        {children}\n      </div>\n    </div>\n  )\n}\n\ninterface DepthCardItemProps extends React.ComponentProps<\"div\"> {\n  /** How far the item rises toward the viewer while the card is active, in px. */\n  depth?: number\n  /** Sideways and vertical shift while active, in px. */\n  x?: number\n  y?: number\n  /** Extra rotation while active, in degrees. */\n  rotateX?: number\n  rotateY?: number\n  rotateZ?: number\n}\n\n/**\n * A layer inside a `DepthCard`. It sits flat until the card is hovered or\n * focused, then rises to `depth` (and moves or turns by the other props).\n * Items can be nested; anything between an item and the card must keep 3D\n * (`transform-3d`) and must not clip (`overflow-hidden` flattens the effect).\n */\nfunction DepthCardItem({ depth = 0, x = 0, y = 0, rotateX = 0, rotateY = 0, rotateZ = 0, className, style, ...props }: DepthCardItemProps) {\n  return (\n    <div\n      data-slot=\"depth-card-item\"\n      className={cn(\n        \"transform-3d transition-transform duration-500 ease-out\",\n        \"[transform:translate3d(0,0,0)]\",\n        \"group-data-active/depth-card:[transform:translate3d(var(--dx),var(--dy),var(--dz))_rotateX(var(--drx))_rotateY(var(--dry))_rotateZ(var(--drz))]\",\n        className\n      )}\n      style={\n        {\n          \"--dx\": `${x}px`,\n          \"--dy\": `${y}px`,\n          \"--dz\": `${depth}px`,\n          \"--drx\": `${rotateX}deg`,\n          \"--dry\": `${rotateY}deg`,\n          \"--drz\": `${rotateZ}deg`,\n          ...style,\n        } as React.CSSProperties\n      }\n      {...props}\n    />\n  )\n}\n\nexport { DepthCard, DepthCardItem }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "cards",
    "interactive",
    "3d"
  ],
  "type": "registry:ui"
}