{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"halo-treatment-card","type":"registry:component","title":"Halo Treatment Card","description":"A treatment card with a light well: a grained halo in the treatment's own colour rests low, then rises and blooms toward the pointer on hover or focus while the card lifts on a feathered shadow.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/halo-treatment-card.tsx","content":"\"use client\";\n\nimport { useRef } from \"react\";\nimport type { CSSProperties, PointerEvent as ReactPointerEvent } from \"react\";\n\n/**\n * HaloTreatmentCard — a treatment card with a light well.\n *\n * The well holds a grained halo in the treatment's own colour, resting low\n * like a lamp turned down; on hover or focus it rises and blooms, leaning a\n * little toward the pointer (420ms), and the card lifts on a\n * feathered shadow. The name is the card's link, so the whole card is one\n * target, and the focus ring goes round the card.\n *\n * Part of the Diffused Glow kit: a warm bone day (#f6f1e6) and a jade room\n * (#0b120f); soft, grained halos in gold, rose or jade (or any #rrggbb), at\n * most two per view; a serif through var(--font-serif) over Geist. Respects\n * prefers-reduced-motion. No dependencies beyond React. Paste it as its own\n * file: it repeats the kit's small helpers, which would clash in one module.\n * For the serif, load Fraunces with next/font (variable: \"--font-serif\") on a parent.\n */\n\nconst SANS = 'var(--font-sans, \"Geist\", \"Inter\", ui-sans-serif, system-ui, sans-serif)';\n\nconst MONO = 'var(--font-mono, \"Geist Mono\", ui-monospace, \"SFMono-Regular\", Menlo, Consolas, monospace)';\n\nconst SERIF = 'var(--font-serif, \"Fraunces\", \"Iowan Old Style\", \"Palatino Linotype\", Georgia, serif)';\n\nconst EASE = \"cubic-bezier(0.22, 1, 0.36, 1)\";\n\nconst HEX = /^#[0-9a-fA-F]{6}$/;\n\n/** The two grounds the kit is set on: the warm day and the jade room. */\nconst TONES = {\n  day: {\n    ground: \"#f6f1e6\",\n    panel: \"#efe7d6\",\n    raised: \"#fbf8f1\",\n    ink: \"rgba(34,31,26,0.92)\",\n    ink2: \"rgba(34,31,26,0.58)\",\n    ink3: \"rgba(34,31,26,0.4)\",\n    line: \"rgba(34,31,26,0.09)\",\n    line2: \"rgba(34,31,26,0.18)\",\n    shadow: \"0 30px 80px -20px rgba(40,30,10,0.14)\",\n  },\n  jewel: {\n    ground: \"#0b120f\",\n    panel: \"#101c17\",\n    raised: \"#16261f\",\n    ink: \"rgba(243,237,226,0.94)\",\n    ink2: \"rgba(243,237,226,0.63)\",\n    ink3: \"rgba(243,237,226,0.4)\",\n    line: \"rgba(243,237,226,0.08)\",\n    line2: \"rgba(243,237,226,0.16)\",\n    shadow: \"0 40px 100px -24px rgba(0,0,0,0.5)\",\n  },\n} as const;\n\nexport type DgTone = keyof typeof TONES;\n\n/** The bronze accent, used only as light. */\nconst BRONZE = \"#c9a15e\";\n\n/** The one filled action in the kit: booking. */\nconst JADE_FILL = \"#2f6f57\";\n\n/** Halo colours. Gold and rose belong to the jade room; jade is the day's own light. */\nexport const DG_GLOWS = {\n  gold: \"#f5c48c\",\n  rose: \"#f2a39a\",\n  jade: \"#bcd9c8\",\n} as const;\n\nfunction own<T extends object>(map: T, key: string): key is Extract<keyof T, string> {\n  return Object.prototype.hasOwnProperty.call(map, key);\n}\n\n/** A named glow or a #rrggbb; anything else falls back to gold. */\nfunction glowHex(value: string): string {\n  if (own(DG_GLOWS, value)) return DG_GLOWS[value];\n  return HEX.test(value) ? value : DG_GLOWS.gold;\n}\n\nfunction toneOf(value: string) {\n  return own(TONES, value) ? TONES[value] : TONES.day;\n}\n\nfunction rgbOf(hex: string): [number, number, number] {\n  const n = parseInt(hex.slice(1), 16);\n  return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n}\n\nfunction rgba(hex: string, a: number): string {\n  const [r, g, b] = rgbOf(hex);\n  return `rgba(${r},${g},${b},${a})`;\n}\n\n/**\n * Grain as an SVG turbulence tile. It is only ever laid inside a light (masked\n * to the halo's shape), never over the whole page: grain belongs to the glow.\n */\nconst GRAIN_URL = `url(\"data:image/svg+xml,${encodeURIComponent(\n  \"<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.9 0'/></filter><rect width='160' height='160' filter='url(#g)'/></svg>\",\n)}\")`;\n\n/** Links: strip tabs and newlines, refuse backslashes, allow http(s), mailto, tel and same-site paths. */\nfunction safeHref(raw: string): string {\n  const v = raw.replace(/[\\t\\n\\r]/g, \"\").trim();\n  if (!v || v.includes(\"\\\\\")) return \"#\";\n  if (/^(https?:|mailto:|tel:)/i.test(v)) return v;\n  if (/^[/#?]/.test(v) && !/^\\/\\//.test(v)) return v;\n  return \"#\";\n}\n\n// Each part carries only the CSS it needs, so any one of them works on its own.\n// Nothing is interpolated into these sheets; colours arrive as CSS variables.\n// revert-layer keeps an element's own rounded corners when a host page's focus rule flattens them.\nconst FOCUS_CSS = \".dg-scope :focus-visible,.dg-scope:focus-visible{outline:2px solid var(--dg-ring);outline-offset:3px;border-radius:revert-layer}\";\n\n/** The focus ring colour for a ground: bronze light on the jade room, jade on the day. */\nfunction ringVar(tone: string): CSSProperties {\n  return { \"--dg-ring\": tone === \"jewel\" ? BRONZE : JADE_FILL } as CSSProperties;\n}\n\nconst CARD_CSS =\n  \".dg-card{transition:transform 450ms \" + EASE + \",box-shadow 450ms \" + EASE + \"}\" +\n  \".dg-card:hover,.dg-card:focus-within{transform:translateY(-4px)}\" +\n  \".dg-card .dg-well-light{transition:transform 420ms \" + EASE + \",opacity 420ms \" + EASE + \"}\" +\n  \".dg-card:hover .dg-well-light,.dg-card:focus-within .dg-well-light{opacity:1}\" +\n  // The whole card is the target, so the ring goes round the card, not the name inside it.\n  // Only where :has() exists; older engines keep the link's own ring.\n  \"@supports selector(:has(a)){.dg-card a:focus-visible{outline:none!important}.dg-card:has(a:focus-visible){outline:2px solid var(--dg-ring);outline-offset:3px}}\" +\n  \"@media (prefers-reduced-motion: reduce){.dg-card,.dg-card .dg-well-light{transition:none}.dg-card:hover,.dg-card:focus-within{transform:none}}\";\n\nexport type DgTreatment = {\n  name: string;\n  line: string;\n  duration: string;\n  price: string;\n  href: string;\n  /** The treatment's own light: gold, rose, jade or #rrggbb. */\n  glow?: string;\n  /** A short tag in the well, e.g. \"Facial\" or \"Most booked\". */\n  tag?: string;\n};\n\nexport type HaloTreatmentCardProps = DgTreatment & {\n  tone?: DgTone;\n  /** A two-digit index in the well's corner. */\n  index?: number;\n  className?: string;\n};\n\n/**\n * A treatment as a card with a light well. The well holds a soft, grained\n * halo in the treatment's own colour, resting low like a lamp turned down;\n * on hover or focus it rises and blooms (420ms), leaning a little toward the\n * pointer, and the card lifts on a feathered shadow. The\n * name is the card's link, so the whole card is one target.\n */\nexport function HaloTreatmentCard({ name, line, duration, price, href, glow = \"rose\", tag, tone = \"day\", index, className }: HaloTreatmentCardProps) {\n  const t = toneOf(tone);\n  const light = glowHex(glow);\n  const dark = tone === \"jewel\";\n  const lightRef = useRef<HTMLSpanElement>(null);\n\n  const onMove = (e: ReactPointerEvent<HTMLElement>) => {\n    const el = lightRef.current;\n    if (!el) return;\n    const r = e.currentTarget.getBoundingClientRect();\n    const dx = (e.clientX - r.left - r.width / 2) * 0.18;\n    const dy = (e.clientY - r.top - r.height * 0.35) * 0.12;\n    el.style.transform = `translate(${dx.toFixed(1)}px, ${(dy - 18).toFixed(1)}px) scale(1.14)`;\n  };\n  const onLeave = () => {\n    if (lightRef.current) lightRef.current.style.transform = \"\";\n  };\n\n  return (\n    <article\n      onPointerMove={onMove}\n      onPointerLeave={onLeave}\n      className={\"dg-scope dg-card group relative flex flex-col overflow-hidden rounded-[26px]\" + (className ? \" \" + className : \"\")}\n      style={{ ...ringVar(tone), background: t.raised, boxShadow: `inset 0 0 0 1px ${t.line}, ${t.shadow}`, fontFamily: SANS, color: t.ink }}\n    >\n      <style>{FOCUS_CSS + CARD_CSS}</style>\n      <div aria-hidden className=\"relative m-2 aspect-[5/4] overflow-hidden rounded-[20px]\" style={{ background: t.panel }}>\n        <span ref={lightRef} className=\"dg-well-light absolute inset-[-20%] opacity-80\">\n          <span\n            className=\"absolute inset-0\"\n            style={{ background: `radial-gradient(38% 42% at 50% 72%, ${rgba(light, dark ? 0.9 : 0.95)}, ${rgba(light, dark ? 0.28 : 0.4)} 45%, ${rgba(light, 0)} 72%)` }}\n          />\n          <span\n            className=\"absolute inset-0\"\n            style={{\n              backgroundImage: GRAIN_URL,\n              mixBlendMode: \"overlay\",\n              opacity: 0.7,\n              WebkitMaskImage: \"radial-gradient(40% 44% at 50% 72%, #000, transparent 75%)\",\n              maskImage: \"radial-gradient(40% 44% at 50% 72%, #000, transparent 75%)\",\n            }}\n          />\n        </span>\n        {index !== undefined && (\n          <span className=\"absolute left-4 top-3 text-[28px] italic\" style={{ fontFamily: SERIF, fontWeight: 340, color: t.ink3 }}>\n            {String(index).padStart(2, \"0\")}\n          </span>\n        )}\n        {tag && (\n          <span\n            className=\"absolute right-3 top-3 rounded-full px-2.5 py-1 text-[10.5px] uppercase tracking-[0.16em]\"\n            style={{ fontFamily: MONO, color: t.ink2, background: dark ? \"rgba(243,237,226,0.06)\" : \"rgba(251,248,241,0.7)\", boxShadow: `inset 0 0 0 1px ${t.line}` }}\n          >\n            {tag}\n          </span>\n        )}\n      </div>\n      <div className=\"flex flex-1 flex-col px-5 pb-5 pt-3\">\n        <h3 className=\"m-0 text-[26px] leading-[1.1]\" style={{ fontFamily: SERIF, fontWeight: 400, fontVariationSettings: '\"SOFT\" 50' }}>\n          <a href={safeHref(href)} className=\"after:absolute after:inset-0 after:rounded-[26px] after:content-['']\">\n            {name}\n          </a>\n        </h3>\n        <p className=\"mt-2 text-[14.5px] leading-[1.55]\" style={{ color: t.ink2 }}>\n          {line}\n        </p>\n        <div className=\"mt-auto flex items-center justify-between pt-5 text-[13px]\" style={{ color: t.ink2 }}>\n          <span style={{ fontFamily: MONO }}>\n            {duration} · {price}\n          </span>\n          <span aria-hidden className=\"transition-transform duration-300 group-hover:translate-x-1\" style={{ color: t.ink }}>\n            Book →\n          </span>\n        </div>\n      </div>\n    </article>\n  );\n}\n","type":"registry:component","target":"components/viberdy/halo-treatment-card.tsx"}],"meta":{"tier":"free","tags":["card","treatment","service","spa","glow","grain","hover","pointer"],"href":"https://viberdy.dev/library/halo-treatment-card","aiPrompt":"Build a React + Tailwind card, `HaloTreatmentCard({ name, line, duration, price, href, glow, tag, tone, index })`, a treatment card with a light well.\n\nA 26px-radius article (raised surface, inset hairline, feathered shadow). At the top, an 8px-inset well (aspect 5/4, 20px radius, panel colour) holding an oversized span: a radial gradient in the treatment's colour at 50% 72% (strong core, softer by 45%, gone by 72%) and an SVG grain tile in overlay blend masked to the same radial. At rest the light sits low at 80% opacity; on hover or focus-within it goes to full opacity, and pointermove sets its transform to lean toward the pointer (18% of the x offset, 12% of the y, lifted 18px, scale 1.14), transitioned over 420ms; leaving clears it. The card translates -4px on hover and focus. In the well: a serif italic two-digit index and a mono tag pill. Below: the name as an h3 whose link has an after pseudo-element covering the card, a description, and a footer row with duration and price in mono and a Book cue that nudges on hover. The focus ring goes on the card via .dg-card:has(a:focus-visible), with the link's own outline removed.\n\nDiffused Glow grammar: two grounds, a warm bone day (#f6f1e6; panels #efe7d6, raised #fbf8f1; ink #221f1a at 92/58/40%; hairlines at 9% and 18%) and a near-black jade room (#0b120f; panels #101c17 and #16261f; ink #f3ede2 at 94/63/40%). Light is soft and grained: halos in gold #f5c48c, rose #f2a39a and, on the day ground, jade #bcd9c8 (or any #rrggbb validated against /^#[0-9a-fA-F]{6}$/), never more than two per view, each a wide gaussian skirt with a warmer core, and the grain lives inside the light (an SVG feTurbulence tile masked to the halo, or noise in the shader), never as a page overlay. In the jade room light is added (screen blend); on the day ground it pools as colour (the paper takes the tint). One bronze accent #c9a15e used as light and one jade fill #2f6f57 kept for the booking action; one filled action per view. A serif (Fraunces by default, through var(--font-serif, \"Fraunces\", Georgia, serif)) at 340-400 for display with 0.98-1.04 leading and *italic* accents, over Geist for UI and Geist Mono uppercase captions. Radii 24-28px on panels, pills for controls; feathered shadows only. Motion is slow: halos breathe on about 10s, drift on 36s or longer and settle toward the pointer over about 900ms (1 - e^(-3dt)); resolves run 700-1100ms out of a blur on cubic-bezier(0.16, 1, 0.3, 1); hovers under 450ms. Keyframes and a focus ring (a .dg-scope rule with border-radius: revert-layer) live in a small static <style> the component renders itself; nothing is interpolated into it. Respect prefers-reduced-motion. No dependencies beyond React.","license":"https://viberdy.dev/license"}}