{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"card-flip","type":"registry:ui","title":"Card Flip","description":"A 3D card that springs over to reveal its back on hover or click, with Enter/Space to toggle.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/card-flip.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useState, type KeyboardEvent, type ReactNode } from \"react\";\n\nexport interface CardFlipProps {\n  front: ReactNode;\n  back: ReactNode;\n  /** Flip on hover (and focus) or on click. Enter/Space always toggle. */\n  trigger?: \"hover\" | \"click\";\n  /** Axis to flip around. */\n  direction?: \"horizontal\" | \"vertical\";\n  /** Flip duration in ms. */\n  duration?: number;\n  /** Card width in px. */\n  width?: number;\n  /** Card height in px. */\n  height?: number;\n  /** Accessible name for the toggle. Defaults to the visible face text. */\n  label?: string;\n  className?: string;\n}\n\nexport function CardFlip({\n  front,\n  back,\n  trigger = \"hover\",\n  direction = \"horizontal\",\n  duration = 700,\n  width = 280,\n  height = 380,\n  label,\n  className,\n}: CardFlipProps) {\n  const [flipped, setFlipped] = useState(false);\n  const [hover, setHover] = useState(false);\n  const on = trigger === \"hover\" ? hover !== flipped : flipped;\n  const axis = direction === \"horizontal\" ? \"rotateY\" : \"rotateX\";\n\n  const onKey = (e: KeyboardEvent) => {\n    if (e.key === \"Enter\" || e.key === \" \") {\n      e.preventDefault();\n      setFlipped((f) => !f);\n    }\n  };\n\n  const face = \"absolute inset-0 overflow-hidden rounded-[inherit] [backface-visibility:hidden] [-webkit-backface-visibility:hidden]\";\n\n  return (\n    <div\n      role=\"button\"\n      tabIndex={0}\n      aria-pressed={on}\n      aria-label={label}\n      onClick={trigger === \"click\" ? () => setFlipped((f) => !f) : undefined}\n      onKeyDown={onKey}\n      onPointerEnter={trigger === \"hover\" ? () => setHover(true) : undefined}\n      onPointerLeave={trigger === \"hover\" ? () => setHover(false) : undefined}\n      className={`group relative cursor-pointer rounded-2xl outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-background ${className ?? \"\"}`}\n      style={{ width, height, perspective: 1200 }}\n    >\n      <div\n        className=\"relative size-full rounded-[inherit] motion-reduce:!transition-none\"\n        style={{\n          transformStyle: \"preserve-3d\",\n          transform: `${axis}(${on ? 180 : 0}deg)`,\n          transition: `transform ${duration}ms cubic-bezier(.3,1.35,.45,1)`,\n        }}\n      >\n        <div className={face} aria-hidden={on}>\n          {front}\n        </div>\n        <div className={face} aria-hidden={!on} style={{ transform: `${axis}(180deg)` }}>\n          {back}\n        </div>\n      </div>\n    </div>\n  );\n}\n"}]}