{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tilt-card",
  "title": "Tilt Card",
  "description": "3D tilt card that rotates toward the cursor on spring physics, with an optional glare reflection.",
  "dependencies": ["motion"],
  "registryDependencies": ["utils"],
  "files": [
    {
      "path": "registry/primitives/effects/tilt-card/index.tsx",
      "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport {\n  motion,\n  useMotionTemplate,\n  useMotionValue,\n  useReducedMotion,\n  useSpring,\n  useTransform,\n} from \"motion/react\";\nimport type { MotionStyle, SpringOptions } from \"motion/react\";\nimport type { MouseEvent, ReactNode, Ref } from \"react\";\n\nconst DEFAULT_ROTATION_FACTOR = 15;\nconst DEFAULT_PERSPECTIVE = 1000;\nconst DEFAULT_SCALE_ON_HOVER = 1;\nconst DEFAULT_GLARE_MAX_OPACITY = 0.05;\nconst DEFAULT_SPRING_OPTIONS: SpringOptions = {\n  stiffness: 150,\n  damping: 20,\n  mass: 1,\n};\n\nexport interface TiltCardProps {\n  children?: ReactNode;\n  /** Additional class names merged onto the tilting card element. */\n  className?: string;\n  /** Render a light reflection that sweeps across the card as it tilts. @default false */\n  glare?: boolean;\n  /** Peak opacity of the glare reflection while hovered. @default 0.05 */\n  glareMaxOpacity?: number;\n  /** Reverse the tilt direction: the hovered corner dips down (pressed) instead of lifting toward the cursor. @default false */\n  isReverse?: boolean;\n  /** Virtual camera distance in pixels — smaller values exaggerate the 3D effect. @default 1000 */\n  perspective?: number;\n  ref?: Ref<HTMLDivElement>;\n  /** Maximum tilt angle in degrees. @default 15 */\n  rotationFactor?: number;\n  /** Scale applied to the card while hovered. @default 1 (no scale) */\n  scaleOnHover?: number;\n  /** Spring options for the tilt/scale motion. @default { stiffness: 150, damping: 20, mass: 1 } */\n  springOptions?: SpringOptions;\n  /** Inline motion styles merged onto the tilting card element. */\n  style?: MotionStyle;\n}\n\nexport function TiltCard({\n  children,\n  className,\n  glare = false,\n  glareMaxOpacity = DEFAULT_GLARE_MAX_OPACITY,\n  isReverse = false,\n  perspective = DEFAULT_PERSPECTIVE,\n  ref,\n  rotationFactor = DEFAULT_ROTATION_FACTOR,\n  scaleOnHover = DEFAULT_SCALE_ON_HOVER,\n  springOptions = DEFAULT_SPRING_OPTIONS,\n  style,\n}: TiltCardProps) {\n  const prefersReducedMotion = useReducedMotion();\n\n  // Normalized mouse position within the card, [-0.5, 0.5] on both axes.\n  const x = useMotionValue(0);\n  const y = useMotionValue(0);\n\n  // Default direction faces the card toward the cursor (hovered corner\n  // lifts up); isReverse makes it dip down instead, like being pressed.\n  const rotateX = useSpring(\n    useTransform(\n      y,\n      [-0.5, 0.5],\n      isReverse\n        ? [rotationFactor, -rotationFactor]\n        : [-rotationFactor, rotationFactor]\n    ),\n    springOptions\n  );\n  const rotateY = useSpring(\n    useTransform(\n      x,\n      [-0.5, 0.5],\n      isReverse\n        ? [-rotationFactor, rotationFactor]\n        : [rotationFactor, -rotationFactor]\n    ),\n    springOptions\n  );\n  const scale = useSpring(1, springOptions);\n  const glareOpacity = useSpring(0, springOptions);\n\n  const glareX = useTransform(x, [-0.5, 0.5], [0, 100]);\n  const glareY = useTransform(y, [-0.5, 0.5], [0, 100]);\n  const glareBackground = useMotionTemplate`radial-gradient(circle at ${glareX}% ${glareY}%, rgb(255 255 255), transparent 65%)`;\n\n  const handleMouseMove = (event: MouseEvent<HTMLDivElement>) => {\n    if (prefersReducedMotion) {\n      return;\n    }\n    const rect = event.currentTarget.getBoundingClientRect();\n    x.set((event.clientX - rect.left) / rect.width - 0.5);\n    y.set((event.clientY - rect.top) / rect.height - 0.5);\n  };\n\n  const handleMouseEnter = () => {\n    if (prefersReducedMotion) {\n      return;\n    }\n    scale.set(scaleOnHover);\n    glareOpacity.set(glareMaxOpacity);\n  };\n\n  const handleMouseLeave = () => {\n    x.set(0);\n    y.set(0);\n    scale.set(1);\n    glareOpacity.set(0);\n  };\n\n  return (\n    <div style={{ perspective }}>\n      <motion.div\n        className={cn(\"relative\", className)}\n        data-slot=\"tilt-card\"\n        onMouseEnter={handleMouseEnter}\n        onMouseLeave={handleMouseLeave}\n        onMouseMove={handleMouseMove}\n        ref={ref}\n        style={{\n          transformStyle: \"preserve-3d\",\n          ...style,\n          rotateX,\n          rotateY,\n          scale,\n          willChange: \"transform\",\n        }}\n      >\n        {children}\n        {/* Always rendered when enabled (never gated on reduced motion, which\n            is unknown during SSR and would mismatch on hydration) — the\n            handlers keep its opacity at 0 when reduced motion is preferred. */}\n        {glare ? (\n          <motion.div\n            aria-hidden\n            className=\"pointer-events-none absolute inset-0 rounded-[inherit]\"\n            data-slot=\"tilt-card-glare\"\n            style={{\n              backgroundImage: glareBackground,\n              opacity: glareOpacity,\n            }}\n          />\n        ) : null}\n      </motion.div>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/sora-ui/effects/tilt-card.tsx"
    }
  ],
  "meta": {
    "inspiration": {
      "type": "inspired",
      "label": "motion-primitives",
      "url": "https://motion-primitives.com/docs/tilt"
    },
    "demoProps": {
      "TiltCard": {
        "rotationFactor": {
          "value": 15,
          "min": 5,
          "max": 30,
          "step": 1
        },
        "glare": {
          "value": true
        },
        "isReverse": {
          "value": false
        },
        "scaleOnHover": {
          "value": 1.02,
          "min": 1,
          "max": 1.15,
          "step": 0.01
        }
      }
    }
  },
  "type": "registry:ui"
}
