{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"ghosted-chat","type":"registry:block","title":"Ghosted Chat","description":"Unanswered chat messages marked as read, with a thumbs-down reply on hover","dependencies":[],"files":[{"path":"illustrations/ghosted-chat/ghosted-chat.tsx","type":"registry:block","content":"\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\n\n/*\n * Ghosted Chat – a small card illustration, in a single self-contained file.\n * Three unanswered outgoing messages, the last one with a red shine and a soft glow, marked \"Read\".\n * On hover a thumbs-down reply pops in.\n * The scene is laid out on a 360 × 240 artboard and scaled to the width of its container.\n */\n\nconst W = 360;\n\nexport type GhostedChatProps = {\n  className?: string;\n  /** Accessible description of the scene */\n  label?: string;\n};\n\nexport function GhostedChat({\n  className,\n  label = \"A chat with three unanswered messages marked as read\",\n}: GhostedChatProps) {\n  const root = useRef<HTMLDivElement>(null);\n  const [scale, setScale] = useState(0);\n  // The messages arrive one by one once the scene scrolls into view\n  const [play, setPlay] = useState(false);\n\n  useEffect(() => {\n    const el = root.current;\n    if (!el) return;\n    const observer = new IntersectionObserver(\n      ([entry]) => {\n        if (entry.isIntersecting) {\n          setPlay(true);\n          observer.disconnect();\n        }\n      },\n      { threshold: 0.35 },\n    );\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, []);\n\n  // Scale the artboard to the container width\n  useEffect(() => {\n    const el = root.current;\n    if (!el) return;\n    const fit = () => setScale(el.clientWidth / W);\n    fit();\n    const observer = new ResizeObserver(fit);\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, []);\n\n  return (\n    <div ref={root} className={[\"ui-gc\", className].filter(Boolean).join(\" \")} role=\"img\" aria-label={label}>\n      {/* React 19 hoists this into <head> once, no matter how many instances render */}\n      <style href=\"ui-ghosted-chat\" precedence=\"default\">\n        {css}\n      </style>\n      <div\n        className=\"ui-gc-stage\"\n        aria-hidden=\"true\"\n        data-play={play || undefined}\n        style={{ transform: `scale(${scale})`, visibility: scale > 0 ? \"visible\" : \"hidden\" }}\n      >\n        <div className=\"ui-gc-content\">\n          <span className=\"ui-gc-status\">No new messages</span>\n          <div className=\"ui-gc-bubbles\">\n            <div className=\"ui-gc-bubble\">\n              <span>Hi team!</span>\n            </div>\n            <div className=\"ui-gc-bubble\">\n              <span>Are you by any chance looking for a recruiter?</span>\n            </div>\n            <div className=\"ui-gc-bubble ui-gc-bubble-last\">\n              <span className=\"ui-gc-alert\">Hello?</span>\n            </div>\n            <span className=\"ui-gc-read\">Read</span>\n          </div>\n          <div className=\"ui-gc-bubble ui-gc-reply\">\n            <span>👎</span>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n\n/* ---------- Styles ---------- */\n\nconst css = /* css */ `\n.ui-gc {\n  --ui-gc-bubble: #FFFFFF;\n  --ui-gc-bubble-border: #EDEDED;\n  --ui-gc-bubble-shadow: 0 2px 6px rgba(28, 29, 31, 0.08), 0 1px 2px rgba(28, 29, 31, 0.05);\n  --ui-gc-text: #4A4C52;\n  --ui-gc-ink: #202020;\n  --ui-gc-status: #9A9DA3;\n  --ui-gc-read: #A8ABB1;\n  position: relative;\n  width: 100%;\n  aspect-ratio: 3 / 2;\n  overflow: hidden;\n  font-family: \"Inter\", ui-sans-serif, system-ui, -apple-system, sans-serif;\n}\n.ui-gc *, .ui-gc *::before, .ui-gc *::after { box-sizing: border-box; margin: 0; }\n\n/* Fixed 360 × 240 artboard, scaled from the top-left corner */\n.ui-gc-stage {\n  position: absolute;\n  left: 0;\n  top: 0;\n  z-index: 1;\n  width: 360px;\n  height: 240px;\n  padding: 22px 22px 0;\n  transform-origin: 0 0;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 14px;\n}\n/* A touch smaller than the frame, so the chat has room to breathe */\n.ui-gc-content {\n  position: relative;\n  width: 100%;\n  height: 100%;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 14px;\n  transform: scale(0.86);\n  transform-origin: 50% 45%;\n}\n\n/* Arrival: everything waits hidden, then fades in one after another */\n.ui-gc-status,\n.ui-gc-bubbles > * {\n  opacity: 0;\n}\n.ui-gc-stage[data-play] .ui-gc-status {\n  animation: ui-gc-fade 500ms ease-out 100ms both;\n}\n.ui-gc-stage[data-play] .ui-gc-bubbles > .ui-gc-bubble {\n  animation: ui-gc-arrive 620ms cubic-bezier(0.22, 1, 0.36, 1) both;\n}\n.ui-gc-stage[data-play] .ui-gc-bubbles > .ui-gc-bubble:nth-child(1) { animation-delay: 500ms; }\n.ui-gc-stage[data-play] .ui-gc-bubbles > .ui-gc-bubble:nth-child(2) { animation-delay: 1300ms; }\n.ui-gc-stage[data-play] .ui-gc-bubbles > .ui-gc-bubble:nth-child(3) { animation-delay: 2300ms; }\n.ui-gc-stage[data-play] .ui-gc-read {\n  animation: ui-gc-fade 500ms ease-out 3200ms both;\n}\n@keyframes ui-gc-arrive {\n  from { opacity: 0; transform: translateY(10px) scale(0.92); filter: blur(2px); }\n  to { opacity: 1; transform: none; filter: none; }\n}\n@keyframes ui-gc-fade {\n  from { opacity: 0; }\n  to { opacity: 1; }\n}\n.ui-gc-bubbles > .ui-gc-bubble { transform-origin: 100% 100%; }\n\n.ui-gc-status {\n  font-size: 11px;\n  line-height: 1.4;\n  color: var(--ui-gc-status);\n  letter-spacing: 0.01em;\n  transition: color 0.3s ease;\n}\n.ui-gc-bubbles {\n  width: 100%;\n  padding-right: 14px;\n  display: flex;\n  flex-direction: column;\n  align-items: flex-end;\n  gap: 5px;\n  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);\n}\n.ui-gc-bubble {\n  max-width: min(68%, 26ch);\n  width: fit-content;\n  padding: 7px 12px;\n  background: var(--ui-gc-bubble);\n  border: 1px solid var(--ui-gc-bubble-border);\n  border-radius: 14px 14px 4px 14px;\n  box-shadow: var(--ui-gc-bubble-shadow);\n  font-size: 12.5px;\n  line-height: 1.3;\n  font-weight: 500;\n  color: var(--ui-gc-text);\n}\n\n/* \"Hello?\" – a red shine sweeps through the text */\n.ui-gc-alert {\n  display: inline-block;\n  font-weight: 500;\n  background-image: linear-gradient(90deg, var(--ui-gc-ink) 0%, var(--ui-gc-ink) 38%, #FF4D47 50%, var(--ui-gc-ink) 62%, var(--ui-gc-ink) 100%);\n  background-size: 300% 100%;\n  background-position: 100% 0;\n  background-repeat: no-repeat;\n  -webkit-background-clip: text;\n  background-clip: text;\n  -webkit-text-fill-color: transparent;\n  color: transparent;\n  animation: ui-gc-shine 4.5s ease-in-out infinite;\n}\n@keyframes ui-gc-shine {\n  0% { background-position: 100% 0; }\n  35%, 100% { background-position: 0% 0; }\n}\n\n/* Last bubble: soft colored glow underneath */\n.ui-gc-bubble-last {\n  position: relative;\n  isolation: isolate;\n  padding: 6px 11px;\n  margin-bottom: 6px;\n  /* The surface moves to ::before so the glow can sit behind it */\n  background: transparent;\n  border-color: transparent;\n  box-shadow: none;\n}\n.ui-gc-bubble-last::before {\n  content: \"\";\n  position: absolute;\n  inset: -1px;\n  z-index: -1;\n  background: var(--ui-gc-bubble);\n  border: 1px solid var(--ui-gc-bubble-border);\n  border-radius: inherit;\n  box-shadow: var(--ui-gc-bubble-shadow);\n}\n.ui-gc-bubble-last::after {\n  content: \"\";\n  position: absolute;\n  left: 50%;\n  bottom: -6px;\n  transform: translateX(-50%);\n  width: 100%;\n  height: 22px;\n  background: linear-gradient(90deg, #FFA0AB 0%, #FFB89E 33%, #C8A8E5 66%, #A8B5FF 100%);\n  opacity: 0.6;\n  filter: blur(12px);\n  border-radius: 50%;\n  pointer-events: none;\n  z-index: -2;\n}\n.ui-gc-read {\n  font-size: 10.5px;\n  line-height: 1.4;\n  color: var(--ui-gc-read);\n  margin-top: 2px;\n  transition: color 0.3s ease;\n}\n\n/* Thumbs-down reply – hidden, pops in on hover */\n.ui-gc-reply {\n  position: absolute;\n  left: 64px; /* from the padded chat column */\n  bottom: 68px;\n  max-width: none;\n  width: auto;\n  padding: 6px 12px;\n  background: #155EEF;\n  border: 1px solid #155EEF;\n  border-radius: 14px 14px 14px 4px;\n  color: #FFFFFF;\n  font-size: 15px;\n  line-height: 1.1;\n  box-shadow: 0 4px 12px rgba(21, 94, 239, 0.22), 0 1px 2px rgba(21, 94, 239, 0.18);\n  opacity: 0;\n  transform: translateY(14px) scale(0.92);\n  transform-origin: bottom left;\n  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);\n  pointer-events: none;\n}\n/* Hover hides the status texts via their color, so the arrival animation (opacity) is left alone */\n.ui-gc:hover .ui-gc-status,\n.ui-gc:hover .ui-gc-read { color: transparent; }\n.ui-gc:hover .ui-gc-bubbles { transform: translateY(-12px); }\n.ui-gc:hover .ui-gc-reply { opacity: 1; transform: translateY(0) scale(1); }\n\n@media (prefers-reduced-motion: reduce) {\n  .ui-gc-alert { animation: none; background-position: 0% 0; }\n  .ui-gc-status, .ui-gc-bubbles, .ui-gc-read, .ui-gc-reply { transition: none; }\n  .ui-gc-status, .ui-gc-bubbles > * { opacity: 1; animation: none !important; }\n}\n\n/* Dark mode: follows a .dark class or data-theme=\"dark\" on any ancestor, e.g. <html> */\n:where(.dark, [data-theme=\"dark\"]) .ui-gc {\n  --ui-gc-bubble: #232326;\n  --ui-gc-bubble-border: rgba(255, 255, 255, 0.08);\n  --ui-gc-bubble-shadow: 0 2px 6px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.4);\n  --ui-gc-text: #c4c4c4;\n  --ui-gc-ink: #ededed;\n  --ui-gc-status: #8f8f8f;\n  --ui-gc-read: #8f8f8f;\n}\n:where(.dark, [data-theme=\"dark\"]) .ui-gc-bubble-last::after { opacity: 0.45; }\n:where(.dark, [data-theme=\"dark\"]) .ui-gc-reply {\n  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.4);\n}\n`;\n"}]}