{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "glare-card",
  "title": "Glare Card",
  "description": "A 3D tilt card that reacts to the cursor with animated conic-gradient reflections, diamond, holographic or aurora reflex styles.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/glare-card/glare-card.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, useMotionValue, useSpring, useTransform } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type GlareCardReflexMode = \"diamond\" | \"holographic\" | \"aurora\";\n\nexport interface GlareCardProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"title\"> {\n  title?: string;\n  subtitle?: string;\n  image?: string;\n  tiltIntensity?: number;\n  reflexMode?: GlareCardReflexMode;\n  reflexIntensity?: number;\n  spotRadius?: number;\n  showText?: boolean;\n  borderRadius?: number;\n}\n\nconst SPRING = { stiffness: 180, damping: 24, mass: 0.6 };\n\nexport function GlareCard({\n  title = \"Glare Card\",\n  subtitle = \"Dynamic tilt motion with animated conic gradient overlays and cinematic reflections.\",\n  image,\n  tiltIntensity = 18,\n  reflexMode = \"diamond\",\n  reflexIntensity = 0.75,\n  spotRadius = 140,\n  showText = true,\n  borderRadius = 20,\n  className,\n  ...props\n}: GlareCardProps) {\n\n  const wrapRef = React.useRef<HTMLDivElement>(null);\n  const rectRef = React.useRef<DOMRect | null>(null);\n\n  const rawX = useMotionValue(0);\n  const rawY = useMotionValue(0);\n  const rotateX = useSpring(useTransform(rawY, (v) => -v), SPRING);\n  const rotateY = useSpring(rawX, SPRING);\n  const scale = useSpring(1, SPRING);\n\n  const conicBg = useMotionValue(\"none\");\n  const conicBg2 = useMotionValue(\"none\");\n  const starOp = useMotionValue(0);\n  const starBg = useMotionValue(\"none\");\n  const spotBg = useMotionValue(\"none\");\n  const reflexOp = useMotionValue(0);\n  const spotOp = useMotionValue(0);\n  const glareOp = useMotionValue(0);\n  const glareBg = useMotionValue(\"none\");\n  const shX = useMotionValue(0);\n  const shY = useMotionValue(0);\n\n  const boxShadow = useTransform(\n    [shX, shY],\n    ([sx, sy]) => `${sx}px ${Number(sy) + 30}px 60px rgba(0,0,0,0.3), 0 8px 20px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.08)`,\n  );\n\n  React.useEffect(() => {\n    const el = wrapRef.current;\n    if (!el) return;\n    rectRef.current = el.getBoundingClientRect();\n    const observer = new ResizeObserver(() => {\n      rectRef.current = el.getBoundingClientRect();\n    });\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, []);\n\n  const onMove = React.useCallback(\n    (e: React.MouseEvent<HTMLDivElement>) => {\n      const rect = rectRef.current;\n      if (!rect) return;\n      const x = e.clientX - rect.left;\n      const y = e.clientY - rect.top;\n      const cx = rect.width / 2;\n      const cy = rect.height / 2;\n      const nx = (x - cx) / cx;\n      const ny = (y - cy) / cy;\n\n      rawX.set(nx * tiltIntensity);\n      rawY.set(ny * tiltIntensity * 0.78);\n\n      const angle = Math.atan2(y - cy, x - cx) * (180 / Math.PI) + 180;\n      const dist = Math.sqrt(nx * nx + ny * ny);\n      const intensity = Math.min(dist * 0.7, reflexIntensity);\n      const px = (x / rect.width) * 100;\n      const py = (y / rect.height) * 100;\n      const iv = intensity * reflexIntensity;\n\n      if (reflexMode === \"diamond\") {\n        conicBg.set(\n          `conic-gradient(from ${angle - 1}deg at ${px}% ${py}%,rgba(255,255,255,0) 0deg,rgba(255,255,255,${iv * 1.0}) 0.6deg,rgba(255,255,255,${iv * 0.7}) 1.5deg,rgba(255,255,255,0) 4deg,rgba(255,255,255,${iv * 0.15}) 25deg,rgba(255,255,255,0) 48deg,rgba(255,255,255,${iv * 0.8}) 49deg,rgba(255,255,255,${iv * 0.55}) 50.5deg,rgba(255,255,255,0) 53deg,rgba(255,255,255,${iv * 0.1}) 85deg,rgba(255,255,255,0) 118deg,rgba(255,255,255,${iv * 0.65}) 119deg,rgba(255,255,255,${iv * 0.45}) 120.5deg,rgba(255,255,255,0) 123deg,rgba(255,255,255,${iv * 0.08}) 160deg,rgba(255,255,255,0) 178deg,rgba(255,255,255,${iv * 0.55}) 179deg,rgba(255,255,255,${iv * 0.38}) 180.5deg,rgba(255,255,255,0) 183deg,rgba(255,255,255,${iv * 0.07}) 220deg,rgba(255,255,255,0) 248deg,rgba(255,255,255,${iv * 0.45}) 249deg,rgba(255,255,255,${iv * 0.3}) 250.5deg,rgba(255,255,255,0) 253deg,rgba(255,255,255,${iv * 0.05}) 300deg,rgba(255,255,255,0) 358deg,rgba(255,255,255,0) 360deg)`,\n        );\n        conicBg2.set(\n          `conic-gradient(from ${angle + 22}deg at ${px}% ${py}%,rgba(255,255,255,0) 0deg,rgba(255,255,255,${iv * 0.5}) 0.8deg,rgba(255,255,255,${iv * 0.35}) 2deg,rgba(255,255,255,0) 5deg,rgba(255,255,255,0) 68deg,rgba(255,255,255,${iv * 0.4}) 69deg,rgba(255,255,255,${iv * 0.28}) 70.5deg,rgba(255,255,255,0) 73deg,rgba(255,255,255,0) 158deg,rgba(255,255,255,${iv * 0.35}) 159deg,rgba(255,255,255,${iv * 0.22}) 160.5deg,rgba(255,255,255,0) 163deg,rgba(255,255,255,0) 248deg,rgba(255,255,255,${iv * 0.28}) 249deg,rgba(255,255,255,${iv * 0.18}) 250.5deg,rgba(255,255,255,0) 253deg,rgba(255,255,255,0) 360deg)`,\n        );\n        starOp.set(Math.min(intensity * 1.2, 1) * reflexIntensity);\n        starBg.set(\n          `conic-gradient(from 0deg at ${px}% ${py}%,rgba(255,255,255,0) 0deg,rgba(255,255,255,0.9) 0.4deg,rgba(255,255,255,0) 1.8deg,rgba(255,255,255,0) 44deg,rgba(255,255,255,0.75) 45deg,rgba(255,255,255,0) 46.5deg,rgba(255,255,255,0) 89deg,rgba(255,255,255,0.80) 90deg,rgba(255,255,255,0) 91.5deg,rgba(255,255,255,0) 134deg,rgba(255,255,255,0.65) 135deg,rgba(255,255,255,0) 136.5deg,rgba(255,255,255,0) 179deg,rgba(255,255,255,0.70) 180deg,rgba(255,255,255,0) 181.5deg,rgba(255,255,255,0) 224deg,rgba(255,255,255,0.60) 225deg,rgba(255,255,255,0) 226.5deg,rgba(255,255,255,0) 269deg,rgba(255,255,255,0.65) 270deg,rgba(255,255,255,0) 271.5deg,rgba(255,255,255,0) 314deg,rgba(255,255,255,0.55) 315deg,rgba(255,255,255,0) 316.5deg,rgba(255,255,255,0) 360deg)`,\n        );\n      } else if (reflexMode === \"holographic\") {\n        const hue1 = (angle * 1.2) % 360;\n        const hue2 = (hue1 + 60) % 360;\n        const hue3 = (hue1 + 120) % 360;\n        const hue4 = (hue1 + 200) % 360;\n        const hue5 = (hue1 + 280) % 360;\n        conicBg.set(\n          `conic-gradient(from ${angle}deg at ${px}% ${py}%,hsla(${hue1},100%,70%,0) 0deg,hsla(${hue1},100%,70%,${iv * 0.55}) 15deg,hsla(${hue2},100%,65%,${iv * 0.45}) 40deg,hsla(${hue3},100%,70%,${iv * 0.5}) 80deg,hsla(${hue4},100%,65%,${iv * 0.4}) 130deg,hsla(${hue5},100%,70%,${iv * 0.45}) 190deg,hsla(${hue1},100%,65%,${iv * 0.35}) 250deg,hsla(${hue2},100%,70%,${iv * 0.3}) 310deg,hsla(${hue1},100%,70%,0) 360deg)`,\n        );\n        conicBg2.set(\n          `conic-gradient(from ${angle + 40}deg at ${px}% ${py}%,transparent 0deg,rgba(255,255,255,${iv * 0.35}) 1deg,transparent 3deg,transparent 88deg,rgba(255,255,255,${iv * 0.25}) 90deg,transparent 92deg,transparent 178deg,rgba(255,255,255,${iv * 0.3}) 180deg,transparent 182deg,transparent 268deg,rgba(255,255,255,${iv * 0.2}) 270deg,transparent 272deg,transparent 360deg)`,\n        );\n        starOp.set(0);\n      } else {\n        const a1 = (angle * 0.8) % 360;\n        conicBg.set(\n          `conic-gradient(from ${a1}deg at ${px}% ${py}%,rgba(120,40,200,0) 0deg,rgba(120,40,200,${iv * 0.35}) 20deg,rgba(60,180,200,${iv * 0.4}) 60deg,rgba(40,220,140,${iv * 0.35}) 100deg,rgba(80,100,240,${iv * 0.3}) 150deg,rgba(180,60,220,${iv * 0.35}) 210deg,rgba(60,200,180,${iv * 0.3}) 270deg,rgba(40,180,100,${iv * 0.25}) 320deg,rgba(120,40,200,0) 360deg)`,\n        );\n        conicBg2.set(\n          `conic-gradient(from ${(a1 + 30) % 360}deg at ${px}% ${py}%,rgba(255,255,255,0) 0deg,rgba(180,255,220,${iv * 0.2}) 25deg,rgba(140,180,255,${iv * 0.18}) 85deg,rgba(220,140,255,${iv * 0.2}) 155deg,rgba(140,255,200,${iv * 0.15}) 225deg,rgba(200,160,255,${iv * 0.18}) 295deg,rgba(255,255,255,0) 360deg)`,\n        );\n        starOp.set(0);\n      }\n      reflexOp.set(1);\n\n      spotBg.set(\n        `radial-gradient(circle ${spotRadius}px at ${px}% ${py}%,rgba(255,255,255,${0.55 * intensity + 0.1}) 0%,rgba(255,255,255,${0.35 * intensity}) 8%,rgba(255,255,255,${0.25 * intensity}) 30%,rgba(255,255,255,${0.08 * intensity}) 55%,transparent 75%)`,\n      );\n      spotOp.set(Math.min(intensity * 2.5, 1));\n\n      const gi = intensity * reflexIntensity;\n      glareBg.set(`linear-gradient(${angle + 90}deg, rgba(255,255,255,${gi * 0.45}) 0%, rgba(255,255,255,${gi * 0.2}) 35%, transparent 65%)`);\n      glareOp.set(gi * 0.9);\n\n      shX.set(nx * -20);\n      shY.set(ny * -20);\n    },\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n    [tiltIntensity, reflexMode, reflexIntensity, spotRadius],\n  );\n\n  const onEnter = React.useCallback(() => {\n    // Re-measure on entry: the rect cached at mount goes stale once the page scrolls, which threw\n    // the tilt and glare off towards the wrong corner.\n    if (wrapRef.current) rectRef.current = wrapRef.current.getBoundingClientRect();\n    scale.set(1.03);\n  }, [scale]);\n  const onLeave = React.useCallback(() => {\n    rawX.set(0);\n    rawY.set(0);\n    scale.set(1);\n    reflexOp.set(0);\n    spotOp.set(0);\n    glareOp.set(0);\n    starOp.set(0);\n    conicBg.set(\"none\");\n    conicBg2.set(\"none\");\n    starBg.set(\"none\");\n    shX.set(0);\n    shY.set(0);\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  const bgImage = image ? `url(${image})` : \"linear-gradient(135deg, #1a1a2e 0%, #16213e 30%, #0f3460 60%, #533483 100%)\";\n\n  return (\n    <div ref={wrapRef} className={cn(\"relative h-full w-full\", className)} style={{ perspective: 1000, perspectiveOrigin: \"50% 50%\" }} {...props}>\n      <motion.div\n        onMouseMove={onMove}\n        onMouseEnter={onEnter}\n        onMouseLeave={onLeave}\n        className=\"relative h-full w-full cursor-pointer\"\n        style={{\n          borderRadius,\n          transformStyle: \"preserve-3d\",\n          rotateX,\n          rotateY,\n          scale,\n          boxShadow,\n          clipPath: `inset(0 round ${borderRadius}px)`,\n          willChange: \"transform\",\n        }}\n      >\n        <div className=\"absolute inset-0\" style={{ backgroundImage: bgImage, backgroundSize: \"cover\", backgroundPosition: \"center\" }} />\n        <motion.div className=\"pointer-events-none absolute inset-0 mix-blend-screen\" style={{ background: conicBg, opacity: reflexOp }} />\n        <motion.div className=\"pointer-events-none absolute inset-0 mix-blend-screen\" style={{ background: conicBg2, opacity: reflexOp }} />\n        <motion.div className=\"pointer-events-none absolute inset-0 mix-blend-screen\" style={{ background: starBg, opacity: starOp }} />\n        <motion.div className=\"pointer-events-none absolute inset-0\" style={{ background: spotBg, opacity: spotOp }} />\n        <motion.div className=\"pointer-events-none absolute inset-0 border border-white/15\" style={{ background: glareBg, opacity: glareOp }} />\n        {showText && (\n          <div\n            className=\"absolute inset-0 flex flex-col justify-end p-6\"\n            style={{ background: \"linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 60%)\" }}\n          >\n            <h2 className=\"m-0 mb-1.5 text-[22px] font-medium leading-tight text-white\">{title}</h2>\n            <p className=\"m-0 text-[13px] leading-[1.5] text-white/55\">{subtitle}</p>\n          </div>\n        )}\n      </motion.div>\n\n          </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}