{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"holo-ticket-card","type":"registry:component","title":"Holo Ticket Card","description":"A tour date as a notched, perforated ticket whose stub carries the date in chrome numerals on a strip of holographic foil; it tilts toward the pointer while the foil's colour slides and a glare follows.","dependencies":[],"registryDependencies":[],"files":[{"path":"components/viberdy/holo-ticket-card.tsx","content":"\"use client\";\n\nimport { useRef, useSyncExternalStore } from \"react\";\nimport type { CSSProperties, PointerEvent as ReactPointerEvent } from \"react\";\n\n/**\n * HoloTicketCard — a tour date as a ticket with a holographic stub.\n *\n * Notched and perforated where the stub tears, the date set in heavy\n * chrome numerals on a strip of foil. Under the pointer the ticket tilts\n * toward you, the foil's colour slides along its thin-film series, fine\n * diffraction lines shimmer and a glare follows the pointer; keyboard\n * focus tilts it too. Sold-out dates dim and lose their link. Dates are\n * ISO strings, printed in UTC so server and browser agree.\n *\n * Part of the Liquid Chrome kit: a graphite room, a four-band chrome ramp\n * (#08090b, #4b4f58, #c9ced6, #ffffff) multiplied by a finish (chrome, gold,\n * rose, cobalt or any #rrggbb), foil colour only as a thin film. Fonts come\n * from CSS variables with Archivo and Geist fallbacks. 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 */\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 DISPLAY = 'var(--font-display, \"Archivo\", \"Helvetica Neue\", Arial, sans-serif)';\n\nconst PANEL = \"#141519\";\n\nconst RAISED = \"#1b1c21\";\n\nconst INK = \"rgba(244,245,247,0.94)\";\n\nconst INK_2 = \"rgba(244,245,247,0.62)\";\n\nconst INK_3 = \"rgba(244,245,247,0.4)\";\n\nconst LINE_2 = \"rgba(255,255,255,0.16)\";\n\nconst EASE = \"cubic-bezier(0.22, 1, 0.36, 1)\";\n\n/** The reflected room, darkest to hottest. Every chrome surface in the kit reflects these four bands. */\nconst RAMP = [\"#08090b\", \"#4b4f58\", \"#c9ced6\", \"#ffffff\"] as const;\n\n/** Thin-film colour (Newton's series): silver, champagne, magenta, cyan, green, gold, violet, silver. Unevenly spaced on purpose. */\nconst FOIL: [string, number][] = [\n  [\"#d8dce2\", 0],\n  [\"#eadfc4\", 0.12],\n  [\"#d68fc7\", 0.3],\n  [\"#8fd6d1\", 0.47],\n  [\"#a8d68f\", 0.6],\n  [\"#d6b98f\", 0.72],\n  [\"#b48fd6\", 0.86],\n  [\"#d8dce2\", 1],\n];\n\n/** Metal finishes: the colour the room is multiplied by. */\nexport const LC_FINISHES = {\n  chrome: \"#ffffff\",\n  gold: \"#f2cf92\",\n  rose: \"#f1bcb4\",\n  cobalt: \"#b9cbff\",\n} as const;\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\n/** A ramp colour multiplied by the finish, as rgb(). */\nfunction tinted(hex: string, tint: string): string {\n  const a = rgbOf(hex);\n  const b = rgbOf(tint);\n  return `rgb(${Math.round((a[0] * b[0]) / 255)} ${Math.round((a[1] * b[1]) / 255)} ${Math.round((a[2] * b[2]) / 255)})`;\n}\n\n/** The finished ramp as the CSS variables every chrome gradient and the focus ring read. */\nfunction finishVars(tint: string): CSSProperties {\n  return {\n    \"--lc-0\": tinted(RAMP[0], tint),\n    \"--lc-1\": tinted(RAMP[1], tint),\n    \"--lc-2\": tinted(RAMP[2], tint),\n    \"--lc-3\": tinted(RAMP[3], tint),\n  } as CSSProperties;\n}\n\n/** The foil ramp as a CSS gradient list, stretched over `span` of the gradient. */\nfunction foilStops(alpha = 1): string {\n  return FOIL.map(([hex, at]) => {\n    const [r, g, b] = rgbOf(hex);\n    return `rgba(${r},${g},${b},${alpha}) ${(at * 100).toFixed(1)}%`;\n  }).join(\", \");\n}\n\n/**\n * Chrome as a CSS gradient: bright sky, a hard dark horizon, a lit floor.\n * `--lc-h` moves the horizon (0-100), so a surface can turn in the room.\n */\nconst CHROME_BG =\n  \"linear-gradient(180deg, var(--lc-3) 0%, var(--lc-2) calc(var(--lc-h, 50) * 1% - 16%), var(--lc-1) calc(var(--lc-h, 50) * 1% - 2%), var(--lc-0) calc(var(--lc-h, 50) * 1%), var(--lc-1) calc(var(--lc-h, 50) * 1% + 14%), var(--lc-2) calc(var(--lc-h, 50) * 1% + 34%), var(--lc-3) 100%)\";\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\nfunction subscribeMotion(cb: () => void) {\n  const m = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n  m.addEventListener(\"change\", cb);\n  return () => m.removeEventListener(\"change\", cb);\n}\n\n/** True when the visitor asked for reduced motion. False on the server. */\nfunction useReducedMotion(): boolean {\n  return useSyncExternalStore(\n    subscribeMotion,\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\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 = \".lc-scope :focus-visible,.lc-scope:focus-visible{outline:2px solid var(--lc-2);outline-offset:3px;border-radius:revert-layer}\";\n\nexport type LcShow = {\n  /** ISO date, \"2026-11-14\". */\n  date: string;\n  city: string;\n  venue: string;\n  status?: \"on-sale\" | \"few-left\" | \"sold-out\";\n  href?: string;\n};\n\nconst TICKET_DAY = new Intl.DateTimeFormat(\"en-GB\", { day: \"2-digit\", timeZone: \"UTC\" });\n\nconst TICKET_MONTH = new Intl.DateTimeFormat(\"en-GB\", { month: \"short\", timeZone: \"UTC\" });\n\nconst TICKET_WEEKDAY = new Intl.DateTimeFormat(\"en-GB\", { weekday: \"short\", timeZone: \"UTC\" });\n\nexport type HoloTicketCardProps = LcShow & {\n  /** The link's label while tickets are on sale. */\n  label?: string;\n  className?: string;\n};\n\n/**\n * A tour date as a ticket with a holographic stub. The ticket is notched and\n * perforated where the stub tears off, and the stub carries the date in heavy\n * chrome numerals on a strip of foil. Under the pointer the ticket tilts\n * toward you, the foil's colour slides along its thin-film series as the\n * angle changes, fine diffraction lines shimmer, and a glare follows the\n * pointer. Keyboard focus tilts it too. Sold-out dates dim and lose their\n * link.\n */\nexport function HoloTicketCard({ date, city, venue, status = \"on-sale\", href = \"#\", label = \"Tickets\", className }: HoloTicketCardProps) {\n  const reduced = useReducedMotion();\n  const ref = useRef<HTMLDivElement>(null);\n  const d = new Date(date + \"T00:00:00Z\");\n  const valid = !Number.isNaN(d.getTime());\n  const day = valid ? TICKET_DAY.format(d) : \"--\";\n  const month = valid ? TICKET_MONTH.format(d) : \"\";\n  const weekday = valid ? TICKET_WEEKDAY.format(d) : \"\";\n  const sold = status === \"sold-out\";\n\n  const pose = (x: number, y: number, on: boolean) => {\n    const el = ref.current;\n    if (!el) return;\n    const tilt = on && !reduced;\n    el.style.setProperty(\"--rx\", `${tilt ? ((0.5 - y) * 10).toFixed(2) : 0}deg`);\n    el.style.setProperty(\"--ry\", `${tilt ? ((x - 0.5) * 12).toFixed(2) : 0}deg`);\n    el.style.setProperty(\"--fx\", `${(x * 100).toFixed(1)}%`);\n    el.style.setProperty(\"--fy\", `${(y * 100).toFixed(1)}%`);\n    el.style.setProperty(\"--glare\", on ? \"1\" : \"0\");\n  };\n  const onMove = (e: ReactPointerEvent<HTMLDivElement>) => {\n    const r = e.currentTarget.getBoundingClientRect();\n    pose((e.clientX - r.left) / (r.width || 1), (e.clientY - r.top) / (r.height || 1), true);\n  };\n\n  const cut = \"calc(100% - 112px)\";\n  return (\n    <div\n      className={\"lc-scope\" + (className ? \" \" + className : \"\")}\n      style={{ perspective: 900, filter: \"drop-shadow(0 18px 26px rgba(0,0,0,0.55))\", fontFamily: SANS }}\n      onPointerMove={onMove}\n      onPointerLeave={() => pose(0.5, 0.5, false)}\n      onFocus={() => pose(0.35, 0.3, true)}\n      onBlur={() => pose(0.5, 0.5, false)}\n    >\n      <style>{FOCUS_CSS}</style>\n      <div\n        ref={ref}\n        className=\"relative flex h-[168px] overflow-hidden rounded-[26px]\"\n        style={\n          {\n            ...finishVars(LC_FINISHES.chrome),\n            \"--rx\": \"0deg\",\n            \"--ry\": \"0deg\",\n            \"--fx\": \"50%\",\n            \"--fy\": \"50%\",\n            \"--glare\": \"0\",\n            transform: \"rotateX(var(--rx)) rotateY(var(--ry))\",\n            transition: reduced ? \"none\" : `transform 260ms ${EASE}`,\n            background: `linear-gradient(160deg, ${RAISED}, ${PANEL})`,\n            boxShadow: `inset 0 0 0 1px ${LINE_2}, inset 0 1px 0 rgba(255,255,255,0.08)`,\n            opacity: sold ? 0.62 : 1,\n            // The notches where the stub tears: one bite from the top edge, one from the bottom.\n            WebkitMask: `radial-gradient(circle 11px at ${cut} 0, transparent 10.5px, #000 11px) top / 100% 51% no-repeat, radial-gradient(circle 11px at ${cut} 100%, transparent 10.5px, #000 11px) bottom / 100% 51% no-repeat`,\n            mask: `radial-gradient(circle 11px at ${cut} 0, transparent 10.5px, #000 11px) top / 100% 51% no-repeat, radial-gradient(circle 11px at ${cut} 100%, transparent 10.5px, #000 11px) bottom / 100% 51% no-repeat`,\n          } as CSSProperties\n        }\n      >\n        {/* A faint film over the whole ticket. */}\n        <span\n          aria-hidden\n          className=\"pointer-events-none absolute inset-0\"\n          style={{ backgroundImage: `linear-gradient(115deg, ${foilStops(0.1)})`, backgroundSize: \"300% 300%\", backgroundPosition: \"var(--fx) var(--fy)\", mixBlendMode: \"screen\" }}\n        />\n        <div className=\"relative flex min-w-0 flex-1 flex-col justify-between p-5 pr-4\">\n          <div className=\"min-w-0\">\n            <p className=\"truncate text-[26px] leading-none\" style={{ fontFamily: DISPLAY, fontWeight: 800, fontStretch: \"125%\", letterSpacing: \"-0.02em\", color: INK }}>\n              {city}\n            </p>\n            <p className=\"mt-2 truncate text-[14px]\" style={{ color: INK_2 }}>\n              {venue}\n            </p>\n          </div>\n          <div className=\"flex items-center justify-between gap-3\">\n            <span className=\"text-[11px] uppercase tracking-[0.16em]\" style={{ fontFamily: MONO, color: status === \"few-left\" ? \"#eadfc4\" : INK_3, textDecoration: sold ? \"line-through\" : \"none\" }}>\n              {sold ? \"Sold out\" : status === \"few-left\" ? \"Few left\" : \"On sale\"}\n            </span>\n            {sold ? (\n              <span className=\"text-[13px]\" style={{ color: INK_3 }}>\n                No tickets\n              </span>\n            ) : (\n              <a\n                href={safeHref(href)}\n                className=\"rounded-full px-3.5 py-1.5 text-[13px] font-medium transition-colors hover:text-white\"\n                style={{ color: INK, boxShadow: `inset 0 0 0 1px ${LINE_2}` }}\n                aria-label={`${label}: ${city}, ${venue}`}\n              >\n                {label} →\n              </a>\n            )}\n          </div>\n        </div>\n        {/* Perforation. */}\n        <span aria-hidden className=\"absolute bottom-3 top-3 w-px\" style={{ left: cut, backgroundImage: `linear-gradient(${LINE_2} 50%, transparent 50%)`, backgroundSize: \"1px 7px\" }} />\n        {/* The stub: chrome numerals on a strip of foil. */}\n        <div className=\"relative flex w-[112px] shrink-0 flex-col items-center justify-center overflow-hidden\">\n          <span\n            aria-hidden\n            className=\"absolute inset-0\"\n            style={{\n              backgroundImage: `repeating-linear-gradient(115deg, rgba(255,255,255,0.14) 0 1px, rgba(255,255,255,0) 1px 4px), linear-gradient(115deg, ${foilStops(0.55)})`,\n              backgroundSize: \"auto, 300% 300%\",\n              backgroundPosition: \"0 0, var(--fx) var(--fy)\",\n              opacity: sold ? 0.3 : 0.9,\n            }}\n          />\n          <span aria-hidden className=\"absolute inset-0\" style={{ background: \"linear-gradient(180deg, rgba(12,13,16,0.25), rgba(12,13,16,0.6))\" }} />\n          <time dateTime={date} className=\"relative flex flex-col items-center\">\n            <span className=\"text-[11px] uppercase tracking-[0.2em]\" style={{ fontFamily: MONO, color: \"rgba(255,255,255,0.8)\" }}>\n              {weekday}\n            </span>\n            <span\n              className=\"text-[46px] leading-[1.02]\"\n              style={{ fontFamily: DISPLAY, fontWeight: 800, fontStretch: \"125%\", letterSpacing: \"-0.04em\", color: \"transparent\", backgroundImage: CHROME_BG, WebkitBackgroundClip: \"text\", backgroundClip: \"text\" }}\n            >\n              {day}\n            </span>\n            <span className=\"text-[12px] uppercase tracking-[0.2em]\" style={{ fontFamily: MONO, color: \"rgba(255,255,255,0.9)\" }}>\n              {month}\n            </span>\n          </time>\n        </div>\n        {/* Glare. */}\n        <span\n          aria-hidden\n          className=\"pointer-events-none absolute inset-0\"\n          style={{ background: \"radial-gradient(circle at var(--fx) var(--fy), rgba(255,255,255,0.16), rgba(255,255,255,0) 45%)\", opacity: \"var(--glare)\", transition: \"opacity 300ms ease\" }}\n        />\n      </div>\n    </div>\n  );\n}\n","type":"registry:component","target":"components/viberdy/holo-ticket-card.tsx"}],"meta":{"tier":"free","tags":["card","ticket","tour","event","holographic","foil","tilt","pointer","music"],"href":"https://viberdy.dev/library/holo-ticket-card","aiPrompt":"Build a React + Tailwind card, `HoloTicketCard({ date, city, venue, status, href, label })`: a tour date as a ticket with a holographic stub.\n\nA 168px-tall row with a 26px radius, graphite gradient and an inset hairline, masked with two radial gradients (each covering half the height) that bite 11px notches from the top and bottom edges at the stub line, 112px from the right. The main area: the city in Archivo 800 expanded at 26px, the venue, and a footer row with the status in mono (Few left in champagne #eadfc4, Sold out struck through) and a hairline pill link (aria-label with city and venue) or \"No tickets\" when sold out. A dotted perforation (a 1x7px repeating gradient) at the stub line. The stub: a strip of foil (a 115-degree Newton-series gradient at 300% size positioned by the pointer, under fine repeating diffraction lines), a dark wash, and a time element with the weekday, the day in chrome numerals (background-clip text) and the month, formatted with Intl in UTC.\n\nOn pointermove over the wrapper set --rx and --ry (up to 10 and 12 degrees, transitioned 260ms), --fx and --fy (the foil and glare position) and --glare; on focus pose it toward the top left. A drop-shadow filter on the outer wrapper follows the notches. Sold out dims the ticket to 62%. Reduced motion: no tilt.\n\nLiquid Chrome grammar: a graphite room (ground #0c0d10, panels #141519 and #1b1c21, hairlines white 7% and 16% drawn as inset box-shadows or SVG strokes, never border colours), ink #f4f5f7 at 94/62/40%. Chrome is a reflected room, never a flat grey gradient: four bands (#08090b, #4b4f58, #c9ced6, #ffffff) arranged as a bright sky over a hard dark horizon over a lit floor, multiplied by a finish (chrome #ffffff, gold #f2cf92, rose #f1bcb4, cobalt #b9cbff, or any #rrggbb validated against /^#[0-9a-fA-F]{6}$/) and handed to CSS as --lc-0 to --lc-3 with the horizon position in --lc-h. Colour appears only as a thin film on Newton's series (silver #d8dce2, champagne #eadfc4, magenta #d68fc7, cyan #8fd6d1, green #a8d68f, gold #d6b98f, violet #b48fd6, unevenly spaced), never a hue-rotate rainbow. Chrome goes only on heavy, curved forms (display type, pills, discs), never on hairlines. Display type is Archivo at 800 with font-stretch 125% and -0.02em tracking through var(--font-display, \"Archivo\", ...); UI in Geist; captions in Geist Mono, uppercase. Pills and 26px radii. The room eases toward the pointer in about 220ms, ambient drift runs 40s or slower, presses squash about 4% in 130ms. Keyframes and a focus ring (a .lc-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"}}