{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tooltip-warm",
  "type": "registry:component",
  "title": "Warm Tooltip",
  "description": "A cream tooltip with a soft amber glow that springs out of its trigger with a small arrow wobble. Opens after a delay on hover and at once on keyboard focus.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "micro",
    "tooltip",
    "hint",
    "spring",
    "focus",
    "popover",
    "glow"
  ],
  "docs": "https://hyperblur.dev/effects/tooltip-warm",
  "files": [
    {
      "path": "registry/hyperblur/tooltip-warm.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/tooltip-warm.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface TooltipWarmProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, \"content\"> {\n  content: React.ReactNode;\n  children: React.ReactNode;\n  placement?: \"auto\" | \"top\" | \"bottom\" | \"left\" | \"right\";\n  delay?: number;\n  offset?: number;\n  accent?: string;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n}\n\nconst css = `\n.hb-qr8 {\n  position: relative;\n  display: inline-flex;\n  font-family: inherit;\n}\n.hb-qr8-t {\n  position: absolute;\n  left: 0;\n  top: 0;\n  z-index: 60;\n  width: max-content;\n  max-width: min(240px, calc(100vw - 16px));\n  box-sizing: border-box;\n  isolation: isolate;\n  pointer-events: none;\n  visibility: hidden;\n}\n.hb-qr8-t[data-ready=\"true\"] {\n  visibility: visible;\n  animation-duration: 0.55s;\n  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);\n  animation-fill-mode: backwards;\n}\n.hb-qr8-t[data-ready=\"true\"][data-p=\"top\"] { animation-name: hb-qr8-top; }\n.hb-qr8-t[data-ready=\"true\"][data-p=\"bottom\"] { animation-name: hb-qr8-bottom; }\n.hb-qr8-t[data-ready=\"true\"][data-p=\"left\"] { animation-name: hb-qr8-left; }\n.hb-qr8-t[data-ready=\"true\"][data-p=\"right\"] { animation-name: hb-qr8-right; }\n.hb-qr8-t::before {\n  content: \"\";\n  position: absolute;\n  inset: -4px;\n  z-index: -1;\n  border-radius: 16px;\n  background: var(--hb-qr8-a);\n  filter: blur(14px);\n  opacity: 0.32;\n  animation: hb-qr8-glow 2.4s ease-in-out infinite alternate;\n}\n.hb-qr8-b {\n  display: block;\n  box-sizing: border-box;\n  padding: 8px 12px;\n  border: 1px solid color-mix(in srgb, var(--hb-qr8-a) 60%, transparent);\n  border-radius: 12px;\n  background: #fff4e4;\n  color: #3a2312;\n  font-size: 13px;\n  font-weight: 500;\n  line-height: 1.35;\n  text-align: left;\n  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--hb-qr8-a) 60%, transparent);\n}\n.hb-qr8-r {\n  position: absolute;\n  z-index: 1;\n  width: 10px;\n  height: 10px;\n  box-sizing: border-box;\n  border-radius: 2px;\n  background: #fff4e4;\n  border: 1px solid color-mix(in srgb, var(--hb-qr8-a) 60%, transparent);\n  transform: rotate(45deg);\n}\n.hb-qr8-t[data-p=\"top\"] .hb-qr8-r { bottom: -6px; left: calc(var(--hb-qr8-x) - 5px); border-top: 0; border-left: 0; }\n.hb-qr8-t[data-p=\"bottom\"] .hb-qr8-r { top: -6px; left: calc(var(--hb-qr8-x) - 5px); border-bottom: 0; border-right: 0; }\n.hb-qr8-t[data-p=\"left\"] .hb-qr8-r { right: -6px; top: calc(var(--hb-qr8-y) - 5px); border-bottom: 0; border-left: 0; }\n.hb-qr8-t[data-p=\"right\"] .hb-qr8-r { left: -6px; top: calc(var(--hb-qr8-y) - 5px); border-top: 0; border-right: 0; }\n.hb-qr8-t[data-ready=\"true\"] .hb-qr8-r { animation: hb-qr8-wobble 0.8s cubic-bezier(0.3, 0.9, 0.3, 1) 0.12s backwards; }\n@keyframes hb-qr8-top {\n  0% { opacity: 0; transform: translateY(8px) scale(0.5); }\n  55% { opacity: 1; transform: translateY(-2px) scale(1.07); }\n  78% { transform: translateY(0.5px) scale(0.98); }\n  100% { transform: none; }\n}\n@keyframes hb-qr8-bottom {\n  0% { opacity: 0; transform: translateY(-8px) scale(0.5); }\n  55% { opacity: 1; transform: translateY(2px) scale(1.07); }\n  78% { transform: translateY(-0.5px) scale(0.98); }\n  100% { transform: none; }\n}\n@keyframes hb-qr8-left {\n  0% { opacity: 0; transform: translateX(8px) scale(0.5); }\n  55% { opacity: 1; transform: translateX(-2px) scale(1.07); }\n  78% { transform: translateX(0.5px) scale(0.98); }\n  100% { transform: none; }\n}\n@keyframes hb-qr8-right {\n  0% { opacity: 0; transform: translateX(-8px) scale(0.5); }\n  55% { opacity: 1; transform: translateX(2px) scale(1.07); }\n  78% { transform: translateX(-0.5px) scale(0.98); }\n  100% { transform: none; }\n}\n@keyframes hb-qr8-wobble {\n  0% { transform: rotate(45deg) scale(0.2); }\n  35% { transform: rotate(78deg) scale(1.2); }\n  60% { transform: rotate(32deg) scale(0.95); }\n  80% { transform: rotate(50deg) scale(1.02); }\n  100% { transform: rotate(45deg) scale(1); }\n}\n@keyframes hb-qr8-glow {\n  from { opacity: 0.22; }\n  to { opacity: 0.4; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qr8-t[data-ready=\"true\"],\n  .hb-qr8-t[data-ready=\"true\"] .hb-qr8-r,\n  .hb-qr8-t::before { animation: none; }\n}\n`;\n\nconst useIsoLayoutEffect = typeof window === \"undefined\" ? React.useEffect : React.useLayoutEffect;\n\ntype Side = \"top\" | \"bottom\" | \"left\" | \"right\";\n\nconst opposite: Record<Side, Side> = { top: \"bottom\", bottom: \"top\", left: \"right\", right: \"left\" };\n\nexport function TooltipWarm({\n  content,\n  children,\n  placement = \"auto\",\n  delay = 250,\n  offset = 12,\n  accent = \"#ffa94d\",\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  className = \"\",\n  style,\n  onPointerEnter,\n  onPointerLeave,\n  onFocus,\n  onBlur,\n  ...rest\n}: TooltipWarmProps) {\n  const id = React.useId();\n  const wrapRef = React.useRef<HTMLSpanElement>(null);\n  const tipRef = React.useRef<HTMLSpanElement>(null);\n  const timer = React.useRef(0);\n  const [inner, setInner] = React.useState(defaultOpen);\n  const controlled = open !== undefined;\n  const isOpen = controlled ? open : inner;\n  const latest = React.useRef({ controlled, isOpen, onOpenChange });\n\n  React.useEffect(() => {\n    latest.current = { controlled, isOpen, onOpenChange };\n  });\n\n  const setOpen = React.useCallback((next: boolean) => {\n    const cur = latest.current;\n    if (!cur.controlled) setInner(next);\n    if (next !== cur.isOpen) cur.onOpenChange?.(next);\n  }, []);\n\n  const show = (immediate: boolean) => {\n    window.clearTimeout(timer.current);\n    if (immediate || delay <= 0) setOpen(true);\n    else timer.current = window.setTimeout(() => setOpen(true), delay);\n  };\n\n  const hide = () => {\n    window.clearTimeout(timer.current);\n    setOpen(false);\n  };\n\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  React.useEffect(() => {\n    if (!isOpen) return;\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        window.clearTimeout(timer.current);\n        setOpen(false);\n      }\n    };\n    document.addEventListener(\"keydown\", onKey);\n    return () => document.removeEventListener(\"keydown\", onKey);\n  }, [isOpen, setOpen]);\n\n  useIsoLayoutEffect(() => {\n    const wrap = wrapRef.current;\n    const tip = tipRef.current;\n    if (!isOpen || !wrap || !tip) return;\n    const compute = () => {\n      const wr = wrap.getBoundingClientRect();\n      const tw = tip.offsetWidth;\n      const th = tip.offsetHeight;\n      const vw = window.innerWidth;\n      const vh = window.innerHeight;\n      const room = offset + 6;\n      const fits: Record<Side, boolean> = {\n        top: wr.top >= th + room,\n        bottom: vh - wr.bottom >= th + room,\n        left: wr.left >= tw + room,\n        right: vw - wr.right >= tw + room,\n      };\n      let side: Side = placement === \"auto\" ? \"top\" : placement;\n      if (!fits[side] && fits[opposite[side]]) side = opposite[side];\n      let x = 0;\n      let y = 0;\n      if (side === \"top\" || side === \"bottom\") {\n        x = wr.width / 2 - tw / 2;\n        y = side === \"top\" ? -th - offset : wr.height + offset;\n        const abs = wr.left + x;\n        x += Math.min(Math.max(abs, 8), Math.max(8, vw - tw - 8)) - abs;\n      } else {\n        y = wr.height / 2 - th / 2;\n        x = side === \"left\" ? -tw - offset : wr.width + offset;\n        const abs = wr.top + y;\n        y += Math.min(Math.max(abs, 8), Math.max(8, vh - th - 8)) - abs;\n      }\n      const ax = Math.min(Math.max(wr.width / 2 - x, 16), Math.max(16, tw - 16));\n      const ay = Math.min(Math.max(wr.height / 2 - y, 14), Math.max(14, th - 14));\n      tip.style.left = `${x.toFixed(1)}px`;\n      tip.style.top = `${y.toFixed(1)}px`;\n      tip.style.setProperty(\"--hb-qr8-x\", `${ax.toFixed(1)}px`);\n      tip.style.setProperty(\"--hb-qr8-y\", `${ay.toFixed(1)}px`);\n      tip.style.transformOrigin =\n        side === \"top\"\n          ? `${ax}px 100%`\n          : side === \"bottom\"\n            ? `${ax}px 0`\n            : side === \"left\"\n              ? `100% ${ay}px`\n              : `0 ${ay}px`;\n      tip.dataset.p = side;\n      tip.dataset.ready = \"true\";\n    };\n    compute();\n    window.addEventListener(\"resize\", compute);\n    return () => window.removeEventListener(\"resize\", compute);\n  }, [isOpen, placement, offset, content]);\n\n  const trigger =\n    React.isValidElement<{ \"aria-describedby\"?: string }>(children) && isOpen\n      ? React.cloneElement(children, {\n          \"aria-describedby\": [children.props[\"aria-describedby\"], id].filter(Boolean).join(\" \"),\n        })\n      : children;\n\n  return (\n    <span\n      ref={wrapRef}\n      className={`hb-qr8 ${className}`.trim()}\n      style={{ [\"--hb-qr8-a\" as string]: accent, ...style } as React.CSSProperties}\n      onPointerEnter={(e) => {\n        onPointerEnter?.(e);\n        if (e.pointerType !== \"touch\") show(false);\n      }}\n      onPointerLeave={(e) => {\n        onPointerLeave?.(e);\n        hide();\n      }}\n      onFocus={(e) => {\n        onFocus?.(e);\n        show(true);\n      }}\n      onBlur={(e) => {\n        onBlur?.(e);\n        if (!e.currentTarget.contains(e.relatedTarget as Node | null)) hide();\n      }}\n      {...rest}\n    >\n      <style href=\"hb-tooltip-warm\" precedence=\"default\">\n        {css}\n      </style>\n      {trigger}\n      {isOpen ? (\n        <span ref={tipRef} id={id} role=\"tooltip\" className=\"hb-qr8-t\">\n          <span className=\"hb-qr8-b\">{content}</span>\n          <span className=\"hb-qr8-r\" />\n        </span>\n      ) : null}\n    </span>\n  );\n}\n"
    }
  ]
}