{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "holographic-flip-card",
  "type": "registry:ui",
  "title": "Holographic Flip Card",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Dual-sided 3D interactive card combining spring-damped perspective tilt, specular foil glare tracking, and a 180-degree Y-axis kinetic flip.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/holographic-flip-card.tsx",
      "content": "\"use client\";\n\nimport React, { useRef, useState } from \"react\";\nimport {\n  motion,\n  useMotionTemplate,\n  useMotionValue,\n  useSpring,\n  useReducedMotion,\n} from \"framer-motion\";\nimport { RotateCw, Sparkles, Terminal } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface HolographicFlipCardProps {\n  /** Custom front face content */\n  front?: React.ReactNode;\n  /** Custom back face content */\n  back?: React.ReactNode;\n  /** Peak 3D perspective tilt angle in degrees on pointer hover. Default: 12 */\n  maxTilt?: number;\n  /** Hooke's Law spring stiffness coefficient for 3D rotation. Default: 220 */\n  stiffness?: number;\n  /** Spring damping coefficient for 3D rotation. Default: 22 */\n  damping?: number;\n  className?: string;\n}\n\nexport function HolographicFlipCard({\n  front,\n  back,\n  maxTilt = 12,\n  stiffness = 220,\n  damping = 22,\n  className,\n}: HolographicFlipCardProps) {\n  const cardRef = useRef<HTMLDivElement | null>(null);\n  const shouldReduceMotion = useReducedMotion() ?? false;\n  const [isFlipped, setIsFlipped] = useState(false);\n  const [isHovered, setIsHovered] = useState(false);\n\n  const tiltX = useMotionValue(0);\n  const tiltY = useMotionValue(0);\n  const glareX = useMotionValue(50);\n  const glareY = useMotionValue(50);\n\n  const springRotateX = useSpring(tiltX, { stiffness, damping });\n  const springRotateY = useSpring(tiltY, { stiffness, damping });\n  const springGlareX = useSpring(glareX, { stiffness: 280, damping: 28 });\n  const springGlareY = useSpring(glareY, { stiffness: 280, damping: 28 });\n\n  const glareBackground = useMotionTemplate`radial-gradient(260px circle at ${springGlareX}% ${springGlareY}%, rgba(255, 255, 255, 0.22), rgba(160, 160, 160, 0.08) 45%, transparent 80%)`;\n\n  const toggleFlip = () => {\n    const nextFlipped = !isFlipped;\n    setIsFlipped(nextFlipped);\n    tiltY.set(nextFlipped ? 180 : 0);\n    tiltX.set(0);\n  };\n\n  const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {\n    const el = cardRef.current;\n    if (!el || shouldReduceMotion) return;\n    const rect = el.getBoundingClientRect();\n    const x = e.clientX - rect.left;\n    const y = e.clientY - rect.top;\n\n    const pctX = (x / rect.width - 0.5) * 2;\n    const pctY = (y / rect.height - 0.5) * 2;\n\n    const baseFlipAngle = isFlipped ? 180 : 0;\n    tiltX.set(-pctY * maxTilt);\n    tiltY.set(baseFlipAngle + pctX * maxTilt);\n\n    glareX.set((x / rect.width) * 100);\n    glareY.set((y / rect.height) * 100);\n  };\n\n  const handleMouseLeave = () => {\n    setIsHovered(false);\n    tiltX.set(0);\n    tiltY.set(isFlipped ? 180 : 0);\n  };\n\n  const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === \"Enter\" || e.key === \" \") {\n      e.preventDefault();\n      toggleFlip();\n    }\n  };\n\n  return (\n    <div\n      style={{ perspective: \"1200px\" }}\n      className={cn(\"w-full max-w-sm select-none\", className)}\n    >\n      <motion.div\n        ref={cardRef}\n        role=\"button\"\n        tabIndex={0}\n        aria-pressed={isFlipped}\n        aria-label={\n          isFlipped\n            ? \"Holographic card showing back face. Press Enter or Space to flip to front.\"\n            : \"Holographic card showing front face. Press Enter or Space to flip to back.\"\n        }\n        onClick={toggleFlip}\n        onKeyDown={handleKeyDown}\n        onMouseMove={handleMouseMove}\n        onMouseEnter={() => setIsHovered(true)}\n        onMouseLeave={handleMouseLeave}\n        style={{\n          rotateX: shouldReduceMotion ? 0 : springRotateX,\n          rotateY: shouldReduceMotion ? (isFlipped ? 180 : 0) : springRotateY,\n          transformStyle: \"preserve-3d\",\n        }}\n        className=\"group relative min-h-[210px] w-full cursor-pointer rounded-2xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black dark:focus-visible:ring-white\"\n      >\n        {/* Front Face */}\n        <div\n          style={{ backfaceVisibility: \"hidden\" }}\n          className=\"relative flex min-h-[210px] flex-col justify-between overflow-hidden rounded-2xl border border-neutral-200 bg-white p-6 shadow-sm transition-colors group-hover:border-neutral-400 dark:border-[#222222] dark:bg-[#0A0A0A] dark:group-hover:border-[#383838]\"\n        >\n          <motion.div\n            aria-hidden=\"true\"\n            style={{\n              background: glareBackground,\n              opacity: isHovered && !isFlipped ? 1 : 0,\n            }}\n            className=\"pointer-events-none absolute inset-0 transition-opacity duration-300\"\n          />\n\n          {front || (\n            <>\n              <div className=\"relative z-10 flex items-center justify-between\">\n                <span className=\"inline-flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2.5 py-1 text-[10px] font-semibold uppercase tracking-wider text-black dark:border-[#262626] dark:bg-[#141414] dark:text-white\">\n                  <Sparkles className=\"h-3 w-3\" />\n                  3D Specular Surface\n                </span>\n                <RotateCw className=\"h-4 w-4 text-neutral-400 transition-transform group-hover:rotate-45 group-hover:text-black dark:group-hover:text-white\" />\n              </div>\n\n              <div className=\"relative z-10 mt-6\">\n                <div className=\"text-base font-semibold text-black dark:text-white\">\n                  Holographic Flip Card\n                </div>\n                <p className=\"mt-1 text-xs leading-relaxed text-neutral-500 dark:text-neutral-400\">\n                  Hover for coupled 3D perspective tilt &amp; foil sheen. Click or\n                  press Enter to flip 180° around the Y-axis.\n                </p>\n              </div>\n            </>\n          )}\n        </div>\n\n        {/* Back Face */}\n        <div\n          style={{\n            backfaceVisibility: \"hidden\",\n            transform: \"rotateY(180deg)\",\n          }}\n          className=\"absolute inset-0 flex min-h-[210px] flex-col justify-between overflow-hidden rounded-2xl border border-neutral-800 bg-neutral-950 p-6 text-white shadow-sm dark:border-neutral-200 dark:bg-white dark:text-black\"\n        >\n          {back || (\n            <>\n              <div className=\"flex items-center justify-between\">\n                <span className=\"inline-flex items-center gap-1.5 font-mono text-[11px] font-semibold text-neutral-300 dark:text-neutral-600\">\n                  <Terminal className=\"h-3.5 w-3.5\" />\n                  SPRING_TELEMETRY\n                </span>\n                <RotateCw className=\"h-4 w-4 text-neutral-400\" />\n              </div>\n\n              <div className=\"my-auto space-y-2 font-mono text-xs\">\n                <div className=\"flex justify-between border-b border-white/10 pb-1.5 dark:border-black/10\">\n                  <span className=\"text-neutral-400 dark:text-neutral-500\">\n                    stiffness:\n                  </span>\n                  <span className=\"font-semibold\">{stiffness} N/m</span>\n                </div>\n                <div className=\"flex justify-between border-b border-white/10 pb-1.5 dark:border-black/10\">\n                  <span className=\"text-neutral-400 dark:text-neutral-500\">\n                    damping:\n                  </span>\n                  <span className=\"font-semibold\">{damping} Ns/m</span>\n                </div>\n                <div className=\"flex justify-between\">\n                  <span className=\"text-neutral-400 dark:text-neutral-500\">\n                    maxTilt:\n                  </span>\n                  <span className=\"font-semibold\">±{maxTilt}°</span>\n                </div>\n              </div>\n\n              <div className=\"text-[11px] text-neutral-400 dark:text-neutral-500\">\n                Click or press Space to return to front\n              </div>\n            </>\n          )}\n        </div>\n      </motion.div>\n    </div>\n  );\n}\n\nexport default HolographicFlipCard;\n",
      "type": "registry:ui",
      "target": "components/ui/holographic-flip-card.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
