{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion-skew-marquee",
  "type": "registry:component",
  "title": "Motion Skew Marquee",
  "description": "Two marquee rows that react to scroll speed: the big outlined words lean, stretch and fill with light as you scroll faster, and both rows flip direction with the scroll. A speed gauge reads the velocity live.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "motion",
    "marquee",
    "scroll",
    "velocity",
    "skew",
    "ticker",
    "agency"
  ],
  "docs": "https://hyperblur.dev/effects/motion-skew-marquee",
  "files": [
    {
      "path": "registry/hyperblur/motion-skew-marquee.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/motion-skew-marquee.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface MotionSkewMarqueeProps extends React.HTMLAttributes<HTMLDivElement> {\n  words?: string[];\n  chips?: string[];\n  speed?: number;\n  skew?: number;\n  sensitivity?: number;\n  showMeter?: boolean;\n  accent?: string;\n  progress?: number;\n  autoPlay?: boolean;\n  duration?: number;\n}\n\nconst defaultWords = [\"Strategy\", \"Identity\", \"Motion\", \"Product\", \"Launch\"];\nconst defaultChips = [\n  \"Brand systems\",\n  \"Design ops\",\n  \"Web platforms\",\n  \"Campaign film\",\n  \"Type design\",\n  \"Packaging\",\n  \"Prototyping\",\n  \"Art direction\",\n];\n\nconst css = `\n.hb-wh3 {\n  --hb-wh3-a: #2f7bff;\n  --hb-wh3-s: 0;\n  position: relative;\n  width: 100%;\n  overflow: hidden;\n  color: #ededed;\n  font-family: inherit;\n  container-type: inline-size;\n  padding: clamp(10px, 2.6cqw, 28px) 0;\n}\n.hb-wh3 *, .hb-wh3 *::before, .hb-wh3 *::after { box-sizing: border-box; }\n.hb-wh3-meter {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 1em;\n  padding: 0 clamp(12px, 3cqw, 32px) clamp(6px, 1.6cqw, 18px);\n  font-family: var(--font-mono, ui-monospace, monospace);\n  font-size: clamp(9px, 1.3cqw, 12px);\n  letter-spacing: 0.12em;\n  text-transform: uppercase;\n  color: #7a7a7a;\n}\n.hb-wh3-gauge { display: inline-flex; align-items: center; gap: 0.7em; font-variant-numeric: tabular-nums; }\n.hb-wh3-gauge b { min-width: 3.4em; font-weight: 500; text-align: right; color: #ededed; }\n.hb-wh3-ticks { display: inline-flex; gap: 2px; }\n.hb-wh3-ticks i {\n  width: 3px;\n  height: 9px;\n  border-radius: 1px;\n  background: #2a2a2a;\n  transition: background 0.12s linear;\n}\n.hb-wh3-ticks i[data-on=\"true\"] { background: var(--hb-wh3-a); box-shadow: 0 0 6px color-mix(in srgb, var(--hb-wh3-a) 60%, transparent); }\n.hb-wh3-row {\n  position: relative;\n  overflow: hidden;\n  -webkit-mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);\n  mask-image: linear-gradient(90deg, transparent, #000 9%, #000 91%, transparent);\n}\n.hb-wh3-track {\n  display: flex;\n  width: max-content;\n  will-change: transform;\n  transform-origin: 50% 60%;\n}\n.hb-wh3-group { display: flex; align-items: center; flex: none; }\n.hb-wh3-word {\n  position: relative;\n  display: inline-block;\n  padding: 0 0.22em;\n  font-family: var(--font-grotesk, var(--font-sans, system-ui));\n  font-size: clamp(30px, 11cqw, 150px);\n  font-weight: 700;\n  line-height: 1.05;\n  letter-spacing: -0.04em;\n  white-space: nowrap;\n  color: transparent;\n  -webkit-text-stroke: 1px #4d4d4d;\n}\n.hb-wh3-word::after {\n  content: attr(data-t);\n  position: absolute;\n  inset: 0;\n  padding: inherit;\n  color: #f4f4f4;\n  -webkit-text-stroke: 0;\n  background: linear-gradient(100deg, #f4f4f4 30%, color-mix(in srgb, var(--hb-wh3-a) 70%, #fff));\n  -webkit-background-clip: text;\n  background-clip: text;\n  -webkit-text-fill-color: transparent;\n  opacity: var(--hb-wh3-s);\n}\n.hb-wh3-star {\n  flex: none;\n  width: clamp(14px, 3.6cqw, 46px);\n  height: clamp(14px, 3.6cqw, 46px);\n  margin: 0 0.4em;\n  color: var(--hb-wh3-a);\n  transform: rotate(calc(var(--hb-wh3-s) * 90deg));\n}\n.hb-wh3-row-b { margin-top: clamp(6px, 1.6cqw, 18px); }\n.hb-wh3-chip {\n  flex: none;\n  display: inline-flex;\n  align-items: center;\n  gap: 0.55em;\n  margin-right: 0.6em;\n  padding: 0.5em 0.95em;\n  border-radius: 999px;\n  border: 1px solid #262626;\n  background: linear-gradient(180deg, #161616, #101010);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);\n  font-size: clamp(10px, 1.7cqw, 16px);\n  font-weight: 500;\n  white-space: nowrap;\n  color: #cfcfcf;\n}\n.hb-wh3-chip::before {\n  content: \"\";\n  width: 0.45em;\n  height: 0.45em;\n  border-radius: 50%;\n  background: color-mix(in srgb, var(--hb-wh3-a) 80%, #fff);\n  opacity: calc(0.35 + var(--hb-wh3-s) * 0.65);\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-wh3-track { will-change: auto; }\n  .hb-wh3-ticks i { transition: none; }\n}\n`;\n\nfunction Star() {\n  return (\n    <svg className=\"hb-wh3-star\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n      <path d=\"M12 1.5c.5 5.6 4.9 10 10.5 10.5-5.6.5-10 4.9-10.5 10.5-.5-5.6-4.9-10-10.5-10.5C7.1 11.5 11.5 7.1 12 1.5z\" fill=\"currentColor\" />\n    </svg>\n  );\n}\n\nfunction findScroller(el: HTMLElement): HTMLElement | null {\n  let node = el.parentElement;\n  while (node && node !== document.body && node !== document.documentElement) {\n    const oy = getComputedStyle(node).overflowY;\n    if ((oy === \"auto\" || oy === \"scroll\" || oy === \"overlay\") && node.scrollHeight > node.clientHeight + 1) return node;\n    node = node.parentElement;\n  }\n  return null;\n}\n\nfunction burst(ms: number, duration: number) {\n  const d = Math.max(1.5, duration) * 1000;\n  const ph = (ms % d) / d;\n  if (ph < 0.22) return Math.sin((Math.PI * ph) / 0.22) * 2.4;\n  if (ph > 0.5 && ph < 0.66) return -Math.sin((Math.PI * (ph - 0.5)) / 0.16) * 1.7;\n  return 0;\n}\n\nconst TICKS = 12;\nconst COPIES = 4;\n\nexport function MotionSkewMarquee({\n  words = defaultWords,\n  chips = defaultChips,\n  speed = 60,\n  skew = 14,\n  sensitivity = 1,\n  showMeter = true,\n  accent = \"#2f7bff\",\n  progress,\n  autoPlay = false,\n  duration = 5,\n  className,\n  style,\n  ...rest\n}: MotionSkewMarqueeProps) {\n  const ref = React.useRef<HTMLDivElement>(null);\n  const trackA = React.useRef<HTMLDivElement>(null);\n  const trackB = React.useRef<HTMLDivElement>(null);\n  const readout = React.useRef<HTMLElement>(null);\n  const ticks = React.useRef<HTMLSpanElement>(null);\n  const progressRef = React.useRef(progress);\n\n  React.useEffect(() => {\n    progressRef.current = progress;\n  }, [progress]);\n\n  const controlled = typeof progress === \"number\";\n\n  React.useEffect(() => {\n    const root = ref.current;\n    const a = trackA.current;\n    const b = trackB.current;\n    if (!root || !a || !b) return;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) return;\n    const sc = findScroller(root);\n    const readScroll = () => (sc ? sc.scrollTop : window.scrollY);\n    let lastScroll = readScroll();\n    let lastP = progressRef.current ?? 0;\n    let raf = 0;\n    let last = 0;\n    let t = 0;\n    let vs = 0;\n    let xa = 0;\n    let xb = 0;\n    let dir = 1;\n    let visible = true;\n    let shownTicks = -1;\n    const io = new IntersectionObserver((entries) => {\n      visible = entries[0]?.isIntersecting ?? true;\n    });\n    io.observe(root);\n    const tick = (now: number) => {\n      raf = requestAnimationFrame(tick);\n      const dt = last ? Math.min(50, now - last) : 16;\n      last = now;\n      if (!visible) return;\n      t += dt;\n      let v = 0;\n      if (controlled) {\n        const p = progressRef.current ?? 0;\n        v = ((p - lastP) / dt) * 1000 * 3;\n        lastP = p;\n      } else if (autoPlay) {\n        v = burst(t, duration);\n      } else {\n        const s = readScroll();\n        v = ((s - lastScroll) / dt) * 1000 / 900;\n        lastScroll = s;\n      }\n      v *= sensitivity;\n      vs += (v - vs) * Math.min(1, dt * 0.009);\n      if (Math.abs(vs) > 0.05) dir = vs < 0 ? -1 : 1;\n      const mag = Math.min(3, Math.abs(vs));\n      const step = (dt / 1000) * speed * (1 + mag * 4) * dir;\n      const wa = (a.firstElementChild as HTMLElement | null)?.offsetWidth || 1;\n      const wb = (b.firstElementChild as HTMLElement | null)?.offsetWidth || 1;\n      xa = (((xa + step) % wa) + wa) % wa;\n      xb = (((xb + step * 0.8) % wb) + wb) % wb;\n      const k = Math.max(-1, Math.min(1, vs / 1.6));\n      const sk = (-k * skew).toFixed(2);\n      const sx = (1 + Math.abs(k) * 0.06).toFixed(3);\n      a.style.transform = `translate3d(${(-xa).toFixed(1)}px,0,0) skewX(${sk}deg) scaleX(${sx})`;\n      b.style.transform = `translate3d(${(xb - wb).toFixed(1)}px,0,0) skewX(${(-Number(sk) * 0.6).toFixed(2)}deg)`;\n      root.style.setProperty(\"--hb-wh3-s\", Math.min(1, mag / 1.5).toFixed(3));\n      if (readout.current) readout.current.textContent = `${(1 + mag * 4).toFixed(1)}x`;\n      const on = Math.round(Math.min(1, mag / 2.2) * TICKS);\n      if (on !== shownTicks && ticks.current) {\n        shownTicks = on;\n        Array.from(ticks.current.children).forEach((el, i) => el.setAttribute(\"data-on\", i < on ? \"true\" : \"false\"));\n      }\n    };\n    raf = requestAnimationFrame(tick);\n    return () => {\n      cancelAnimationFrame(raf);\n      io.disconnect();\n    };\n  }, [controlled, autoPlay, duration, speed, skew, sensitivity]);\n\n  const groupA = (key: number) => (\n    <div className=\"hb-wh3-group\" key={key} aria-hidden={key > 0 ? \"true\" : undefined}>\n      {words.map((w, i) => (\n        <React.Fragment key={`${w}-${i}`}>\n          <span className=\"hb-wh3-word\" data-t={w}>\n            {w}\n          </span>\n          <Star />\n        </React.Fragment>\n      ))}\n    </div>\n  );\n\n  const groupB = (key: number) => (\n    <div className=\"hb-wh3-group\" key={key} aria-hidden={key > 0 ? \"true\" : undefined}>\n      {chips.map((c, i) => (\n        <span className=\"hb-wh3-chip\" key={`${c}-${i}`}>\n          {c}\n        </span>\n      ))}\n    </div>\n  );\n\n  return (\n    <div\n      ref={ref}\n      className={[\"hb-wh3\", className].filter(Boolean).join(\" \")}\n      style={{ \"--hb-wh3-a\": accent, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-motion-skew-marquee\" precedence=\"default\">{css}</style>\n      {showMeter ? (\n        <div className=\"hb-wh3-meter\" aria-hidden=\"true\">\n          <span>Scroll speed</span>\n          <span className=\"hb-wh3-gauge\">\n            <span className=\"hb-wh3-ticks\" ref={ticks}>\n              {Array.from({ length: TICKS }, (_, i) => (\n                <i key={i} data-on=\"false\" />\n              ))}\n            </span>\n            <b ref={readout}>1.0x</b>\n          </span>\n        </div>\n      ) : null}\n      <div className=\"hb-wh3-row\">\n        <div className=\"hb-wh3-track\" ref={trackA}>\n          {Array.from({ length: COPIES }, (_, i) => groupA(i))}\n        </div>\n      </div>\n      <div className=\"hb-wh3-row hb-wh3-row-b\">\n        <div className=\"hb-wh3-track\" ref={trackB}>\n          {Array.from({ length: COPIES }, (_, i) => groupB(i))}\n        </div>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}