{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "profile-flip-card",
  "title": "Profile Flip Card",
  "description": "A profile card that flips from a photo front to a bio back on click or hover, with flip Y, flip X, spring, or fade transitions.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/profile-flip-card/profile-flip-card.tsx",
      "content": "\"use client\";\n\nimport * as React from \"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 ProfileFlipCardTransition = \"flipY\" | \"flipX\" | \"spring\" | \"fade\";\n\nexport interface ProfileFlipCardProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\"> {\n  src?: string;\n  name?: string;\n  role?: string;\n  bio?: string;\n  accentColor?: string;\n  bgBack?: string;\n  nameColorFront?: string;\n  nameColorBack?: string;\n  roleColorFront?: string;\n  roleColorBack?: string;\n  bioColor?: string;\n  animationSpeed?: number;\n  tag?: string;\n  tagColor?: string;\n  tagBg?: string;\n  borderRadius?: number;\n  borderColor?: string;\n  flipOnHover?: boolean;\n  flipTransition?: ProfileFlipCardTransition;\n}\n\nfunction useContainerWidth(ref: React.RefObject<HTMLDivElement | null>) {\n  const [width, setWidth] = React.useState(9999);\n  React.useEffect(() => {\n    if (!ref.current) return;\n    const ro = new ResizeObserver(([entry]) => setWidth(entry.contentRect.width));\n    ro.observe(ref.current);\n    return () => ro.disconnect();\n  }, [ref]);\n  return width;\n}\n\nexport function ProfileFlipCard({\n  src,\n  name = \"Takahashi Aya\",\n  role = \"CEO, Pentaclay\",\n  bio = \"I'm focused on growing my brand, improving my products, and finding smarter ways to market and package my work. I'm driven, curious, and committed to turning my design skills into something bigger.\",\n  accentColor = \"#cccccc\",\n  bgBack = \"#ffffff\",\n  nameColorFront = \"#ffffff\",\n  nameColorBack = \"#0a0a0a\",\n  roleColorFront = \"#ffffff\",\n  roleColorBack = \"#0a0a0a\",\n  bioColor = \"#333333\",\n  animationSpeed = 0.7,\n  tag = \"\",\n  tagColor = \"#0a0a0a\",\n  tagBg = \"#ffffff\",\n  borderRadius = 20,\n  borderColor = \"rgba(0,0,0,0.08)\",\n  flipOnHover = false,\n  flipTransition = \"flipY\",\n  className,\n  ...props\n}: ProfileFlipCardProps) {\n  const containerRef = React.useRef<HTMLDivElement>(null);\n  const containerWidth = useContainerWidth(containerRef);\n  const isMobile = containerWidth <= 480;\n\n  // Whether hover flips the card is about input capability, not layout\n  // width — a mouse user viewing this at a narrow width should still get\n  // hover, while a touchscreen shouldn't get \"stuck\" hover from a tap.\n  const [canHover, setCanHover] = React.useState(false);\n  React.useEffect(() => {\n    const mq = window.matchMedia(\"(hover: hover) and (pointer: fine)\");\n    const update = () => setCanHover(mq.matches);\n    update();\n    mq.addEventListener(\"change\", update);\n    return () => mq.removeEventListener(\"change\", update);\n  }, []);\n\n  const [flipped, setFlipped] = React.useState(false);\n  const [hovered, setHovered] = React.useState(false);\n  const touchStartX = React.useRef(0);\n  const touchStartY = React.useRef(0);\n\n  const rNameSizeFront = isMobile ? 22 : 26;\n  const rNameSizeBack = isMobile ? 16 : 18;\n  const rBioSize = isMobile ? 13 : 14;\n\n  const is3D = flipTransition !== \"fade\";\n  const flipAxis = flipTransition === \"flipX\" ? \"rotateX\" : \"rotateY\";\n\n  const flipEasing: Record<string, string> = React.useMemo(\n    () => ({\n      flipY: `transform ${animationSpeed}s cubic-bezier(0.77,0,0.175,1)`,\n      flipX: `transform ${animationSpeed}s cubic-bezier(0.77,0,0.175,1)`,\n      spring: `transform ${animationSpeed * 1.6}s cubic-bezier(0.34,1.56,0.64,1)`,\n    }),\n    [animationSpeed],\n  );\n\n  const frontStyle: React.CSSProperties = is3D\n    ? { position: \"absolute\", inset: 0, borderRadius, overflow: \"hidden\", outline: `1px solid ${borderColor}`, outlineOffset: \"-1px\", backfaceVisibility: \"hidden\" }\n    : {\n        position: \"absolute\",\n        inset: 0,\n        borderRadius,\n        overflow: \"hidden\",\n        outline: `1px solid ${borderColor}`,\n        outlineOffset: \"-1px\",\n        opacity: flipped ? 0 : 1,\n        transition: \"opacity 0.5s ease\",\n        zIndex: 2,\n        pointerEvents: flipped ? \"none\" : \"auto\",\n      };\n\n  const backStyle: React.CSSProperties = is3D\n    ? {\n        position: \"absolute\",\n        inset: 0,\n        borderRadius,\n        overflow: \"hidden\",\n        background: bgBack,\n        outline: `1px solid ${borderColor}`,\n        display: \"flex\",\n        flexDirection: isMobile ? \"column\" : \"row\",\n        backfaceVisibility: \"hidden\",\n        transform: `${flipAxis}(180deg)`,\n      }\n    : {\n        position: \"absolute\",\n        inset: 0,\n        borderRadius,\n        overflow: \"hidden\",\n        background: bgBack,\n        outline: `1px solid ${borderColor}`,\n        display: \"flex\",\n        flexDirection: isMobile ? \"column\" : \"row\",\n        opacity: flipped ? 1 : 0,\n        transition: \"opacity 0.5s ease\",\n        zIndex: 1,\n        pointerEvents: flipped ? \"auto\" : \"none\",\n      };\n\n  // schema.org Person markup (JSON-LD) for search engines, skipped while the placeholder profile shows.\n  const jsonLd = name === \"Takahashi Aya\"\n    ? null\n    : JSON.stringify({\n        \"@context\": \"https://schema.org\",\n        \"@type\": \"Person\",\n        name,\n        ...(role ? { jobTitle: role } : {}),\n        ...(bio ? { description: bio } : {}),\n        ...(src ? { image: src } : {}),\n      }).replace(/</g, \"\\\\u003c\");\n\n  return (\n    <div\n      ref={containerRef}\n      tabIndex={0}\n      onKeyDown={(e) => {\n        if (e.key === \"Escape\" && flipped) setFlipped(false);\n      }}\n      className={cn(\"flex h-full w-full items-stretch gap-3 outline-none\", isMobile ? \"flex-col\" : \"flex-row\", className)}\n      {...props}\n    >\n      {jsonLd && <script type=\"application/ld+json\" dangerouslySetInnerHTML={{ __html: jsonLd }} />}\n      <div\n        className=\"order-1 flex-1 cursor-pointer\"\n        style={{ perspective: is3D ? \"1200px\" : \"none\" }}\n        onClick={() => {\n          if (!canHover) return;\n          if (!flipOnHover) setFlipped((f) => !f);\n        }}\n        onMouseEnter={() => {\n          if (canHover) {\n            setHovered(true);\n            if (flipOnHover) setFlipped(true);\n          }\n        }}\n        onMouseLeave={() => {\n          if (canHover) {\n            setHovered(false);\n            if (flipOnHover) setFlipped(false);\n          }\n        }}\n        onTouchStart={(e) => {\n          touchStartX.current = e.touches[0].clientX;\n          touchStartY.current = e.touches[0].clientY;\n        }}\n        onTouchEnd={(e) => {\n          const dx = e.changedTouches[0].clientX - touchStartX.current;\n          const dy = e.changedTouches[0].clientY - touchStartY.current;\n          if ((Math.abs(dx) > 40 && Math.abs(dy) < 60) || (Math.abs(dx) < 10 && Math.abs(dy) < 10)) setFlipped((f) => !f);\n        }}\n      >\n        <div\n          className=\"relative h-full w-full\"\n          style={{\n            transformStyle: is3D ? \"preserve-3d\" : \"flat\",\n            transform: is3D ? (flipped ? `${flipAxis}(180deg)` : `${flipAxis}(0deg)`) : \"none\",\n            transition: is3D ? flipEasing[flipTransition] || flipEasing.flipY : \"none\",\n          }}\n        >\n          {/* Front */}\n          <div style={{ ...frontStyle, ...(is3D ? { opacity: flipped ? 0 : 1, transition: `opacity 0s ${animationSpeed / 2}s` } : {}) }}>\n            {src && (\n              <img\n                src={src}\n                alt={name}\n                className=\"absolute inset-0 block h-full w-full object-cover\"\n                style={{\n                  transform: hovered && !flipped ? \"scale(1.06)\" : \"scale(1)\",\n                  filter: hovered && !flipped ? \"blur(6px) brightness(0.75)\" : \"blur(0px) brightness(1)\",\n                  transition: \"transform 0.6s ease, filter 0.4s ease\",\n                }}\n              />\n            )}\n            <div className=\"absolute inset-0\" style={{ background: \"linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.2) 50%, transparent 100%)\" }} />\n            {tag && (\n              <div\n                className=\"absolute top-4 left-4 z-10 rounded-full text-[10px] font-semibold tracking-[0.12em] uppercase\"\n                style={{ padding: \"4px 10px\", background: tagBg, color: tagColor }}\n              >\n                {tag}\n              </div>\n            )}\n            <div className=\"absolute top-1/2 right-0 left-0 z-10 flex -translate-y-1/2 flex-col items-center gap-1.5 px-5\">\n              <div className=\"relative flex items-center justify-center\">\n                <span className=\"text-center leading-[1.1] font-extrabold tracking-[0.04em] uppercase\" style={{ fontSize: rNameSizeFront, color: nameColorFront }}>\n                  {name}\n                </span>\n                {!isMobile && (\n                  <svg\n                    width=\"16\"\n                    height=\"16\"\n                    viewBox=\"0 0 18 18\"\n                    fill=\"none\"\n                    className=\"absolute -right-6 transition-[opacity,transform] duration-300\"\n                    style={{ opacity: hovered && !flipped ? 1 : 0, transform: hovered && !flipped ? \"translateX(0)\" : \"translateX(-4px)\" }}\n                  >\n                    <path d=\"M3 9H15M9 3L15 9L9 15\" stroke={nameColorFront} strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                  </svg>\n                )}\n              </div>\n              <span className=\"text-center tracking-[0.01em]\" style={{ fontSize: isMobile ? 12 : 13, color: roleColorFront, opacity: 0.7 }}>\n                {role}\n              </span>\n              {isMobile && !flipped && (\n                <div className=\"mt-2.5 flex items-center gap-1.5 opacity-50\">\n                  <svg width=\"12\" height=\"12\" viewBox=\"0 0 18 18\" fill=\"none\">\n                    <path d=\"M3 9H15M9 3L15 9L9 15\" stroke={nameColorFront} strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                  </svg>\n                  <span className=\"text-[10px] tracking-[0.08em]\" style={{ color: nameColorFront }}>\n                    Tap to flip\n                  </span>\n                </div>\n              )}\n            </div>\n          </div>\n\n          {/* Back */}\n          <div style={{ ...backStyle, ...(is3D ? { opacity: !flipped ? 0 : 1, transition: `opacity 0s ${animationSpeed / 2}s` } : {}) }}>\n            <div\n              className=\"absolute top-4 left-4 z-20 flex h-9 w-9 cursor-pointer items-center justify-center rounded-full transition-transform duration-300\"\n              style={{ background: nameColorBack, transform: hovered && flipped ? \"scale(1.12)\" : \"scale(1)\" }}\n              onClick={(e) => {\n                e.stopPropagation();\n                setFlipped(false);\n              }}\n            >\n              <svg width=\"14\" height=\"14\" viewBox=\"0 0 18 18\" fill=\"none\">\n                <path d=\"M15 9H3M9 3L3 9L9 15\" stroke={bgBack} strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n              </svg>\n            </div>\n\n            <div\n              className=\"relative flex shrink-0 flex-col justify-end overflow-hidden\"\n              style={{ width: isMobile ? \"100%\" : \"42%\", height: isMobile ? \"38%\" : \"100%\", background: accentColor, padding: isMobile ? \"12px 16px\" : \"20px 18px\" }}\n            >\n              {src && (\n                <div className=\"absolute inset-0 opacity-35\">\n                  <img src={src} alt={name} className=\"h-full w-full object-cover\" />\n                </div>\n              )}\n              <div className=\"relative z-[1]\">\n                <div className=\"mb-1 leading-[1.1] font-extrabold tracking-[0.04em] uppercase\" style={{ fontSize: rNameSizeBack, color: nameColorBack }}>\n                  {name}\n                </div>\n                <div className=\"tracking-[0.02em]\" style={{ fontSize: 11, color: roleColorBack, opacity: 0.6 }}>\n                  {role}\n                </div>\n              </div>\n            </div>\n\n            <div className=\"relative min-w-0 flex-1 overflow-hidden\" style={{ background: bgBack, padding: isMobile ? \"14px 16px\" : \"20px 20px 20px 18px\" }}>\n              <div className=\"absolute top-3.5 right-4\">\n                <svg width=\"32\" height=\"26\" viewBox=\"0 0 48 40\" fill=\"none\">\n                  <path d=\"M0 40V24C0 14 4 6 12 0L16 4C10 8 7 14 7 22H14V40H0ZM26 40V24C26 14 30 6 38 0L42 4C36 8 33 14 33 22H40V40H26Z\" fill=\"#e8e8e8\" />\n                </svg>\n              </div>\n              <div\n                className=\"leading-[1.65] tracking-[-0.01em]\"\n                style={{ fontSize: rBioSize, color: bioColor, display: \"-webkit-box\", WebkitLineClamp: isMobile ? 4 : 99, WebkitBoxOrient: \"vertical\", overflow: \"hidden\" }}\n              >\n                {bio}\n              </div>\n            </div>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}