{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "marquee",
  "title": "Marquee",
  "description": "A band of words that drifts through a clipped frame. Scroll takes over; a small pause word lets it rest.",
  "registryDependencies": [
    "https://thedirectors.agency/ui/r/0nlytype.json"
  ],
  "files": [
    {
      "path": "registry/0nlytype/ui/marquee.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { useComposedRefs } from \"@/lib/0nlytype/refs\"\nimport { cn } from \"@/lib/utils\"\n\ntype MarqueeProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n  /** The words: each child is one word or phrase in the band. */\n  children: React.ReactNode\n  /**\n   * band: display words, each closed by a full stop, cropped by the frame's ends.\n   * ticker: small capitals running between two hairlines.\n   * counter: two rows of the band cropped against each other, running opposite ways.\n   */\n  variant?: \"band\" | \"ticker\" | \"counter\"\n  /** How far the words travel for each pixel the page scrolls. */\n  speed?: number\n  /** Travel towards the start as you scroll down, instead of reading along towards the end. */\n  reverse?: boolean\n  /** Names the list of words for readers. */\n  label?: string\n  /** Drift between interactions. Reduced motion always keeps the band still. */\n  autoplay?: boolean\n  /** Start with the visible play control, awaiting the person's choice. */\n  defaultPaused?: boolean\n  pauseLabel?: string\n  playLabel?: string\n  \"data-force\"?: string\n}\n\n/**\n * A band of words that drifts, with a visible pause control. Scroll takes over and keeps step with smooth scrolling.\n * The first run of words is the list readers get; the copies that fill the band are hidden from them.\n */\nfunction Marquee({ children, variant = \"band\", speed = 0.4, reverse = false, label, autoplay = true, defaultPaused = false, pauseLabel = \"pause\", playLabel = \"play\", \"data-force\": force, className, ref: forwardedRef, ...props }: MarqueeProps) {\n  const ref = React.useRef<HTMLDivElement>(null)\n  const composedRef = useComposedRefs(ref, forwardedRef)\n  const [paused, setPaused] = React.useState(defaultPaused)\n  const drift = React.useRef<(delta: number) => void>(() => {})\n  const [copies, setCopies] = React.useState(2)\n  const words = React.Children.toArray(children)\n\n  React.useEffect(() => {\n    const el = ref.current\n    const run = el?.querySelector<HTMLElement>(\".ot-marquee-words\")\n    if (!el || !run) return\n    const reduced = matchMedia(\"(prefers-reduced-motion: reduce)\")\n    let period = 0, frame = 0, carried = 0\n    // How far the band has risen through the view, times the speed, wrapped to one run of words. Read from the real\n    // layout in a frame asked for by the scroll event, which runs after a smooth scroller's own frame.\n    const read = () => {\n      if (!period || reduced.matches || force?.split(\" \").includes(\"reduced\")) return\n      const travelled = carried + (innerHeight - el.getBoundingClientRect().top) * speed\n      el.style.setProperty(\"--o\", `${((travelled % period) + period) % period}px`)\n    }\n    const measure = () => {\n      period = run.offsetWidth // one run, its trailing gap included: a new face or size changes it\n      el.style.setProperty(\"--period\", `${period}px`)\n      if (period) setCopies(Math.max(2, Math.ceil(el.clientWidth / period) + 1))\n      read()\n    }\n    drift.current = (delta) => {\n      carried = period ? (carried + delta * 0.024) % period : 0\n      read()\n    }\n    const onScroll = () => {\n      cancelAnimationFrame(frame)\n      frame = requestAnimationFrame(read)\n    }\n    const resized = new ResizeObserver(measure)\n    resized.observe(el)\n    resized.observe(run)\n    reduced.addEventListener(\"change\", measure)\n    addEventListener(\"scroll\", onScroll, { passive: true })\n    return () => {\n      cancelAnimationFrame(frame)\n      resized.disconnect()\n      reduced.removeEventListener(\"change\", measure)\n      drift.current = () => {}\n      removeEventListener(\"scroll\", onScroll)\n    }\n  }, [speed, force])\n\n  // A single clock for idle motion. Every pause cancels it; resuming starts with a fresh delta.\n  React.useEffect(() => {\n    const root = ref.current\n    if (!root) return\n    const reduced = matchMedia(\"(prefers-reduced-motion: reduce)\")\n    let running = false, held = false, visible = false, hovered = root.matches(\":hover\"), frame = 0, last = 0, timer = 0, restUntil = 0\n    const forced = force?.split(\" \") ?? []\n    const tick = (time: number) => {\n      if (!running) return\n      const delta = last ? Math.min(time - last, 64) : 0\n      last = time\n      drift.current(delta)\n      if (running) frame = requestAnimationFrame(tick)\n    }\n    const sync = () => {\n      running = false\n      cancelAnimationFrame(frame)\n      clearTimeout(timer)\n      last = 0\n      const resting = performance.now() < restUntil\n      const stopped = !autoplay || paused || reduced.matches || forced.includes(\"reduced\") || forced.includes(\"hover\") || forced.includes(\"focus\") || !visible || hovered || held || root.contains(document.activeElement) || document.hidden\n      root.dataset.autoplay = stopped || resting ? \"paused\" : \"playing\"\n      if (stopped) return\n      if (resting) timer = window.setTimeout(sync, restUntil - performance.now())\n      else { running = true; frame = requestAnimationFrame(tick) }\n    }\n    const rest = () => {\n      restUntil = performance.now() + 1600\n      sync()\n    }\n    const enter = (event: PointerEvent) => {\n      if (event.pointerType === \"touch\") return\n      hovered = true\n      rest()\n    }\n    const leave = () => { hovered = false; rest() }\n    const down = () => { held = true; rest() }\n    const up = () => { if (held) { held = false; rest() } }\n    const seen = new IntersectionObserver(([entry]) => { visible = entry.isIntersecting; sync() })\n    seen.observe(root)\n    root.addEventListener(\"pointerenter\", enter)\n    root.addEventListener(\"pointerleave\", leave)\n    root.addEventListener(\"pointerdown\", down)\n    addEventListener(\"pointerup\", up)\n    addEventListener(\"pointercancel\", up)\n    root.addEventListener(\"keydown\", rest)\n    root.addEventListener(\"focusin\", rest)\n    root.addEventListener(\"focusout\", rest)\n    addEventListener(\"scroll\", rest, { passive: true })\n    document.addEventListener(\"visibilitychange\", sync)\n    reduced.addEventListener(\"change\", sync)\n    sync()\n    return () => {\n      running = false\n      cancelAnimationFrame(frame)\n      clearTimeout(timer)\n      seen.disconnect()\n      root.removeEventListener(\"pointerenter\", enter)\n      root.removeEventListener(\"pointerleave\", leave)\n      root.removeEventListener(\"pointerdown\", down)\n      removeEventListener(\"pointerup\", up)\n      removeEventListener(\"pointercancel\", up)\n      root.removeEventListener(\"keydown\", rest)\n      root.removeEventListener(\"focusin\", rest)\n      root.removeEventListener(\"focusout\", rest)\n      removeEventListener(\"scroll\", rest)\n      document.removeEventListener(\"visibilitychange\", sync)\n      reduced.removeEventListener(\"change\", sync)\n    }\n  }, [autoplay, paused, force])\n\n  const rows = variant === \"counter\" ? 2 : 1\n  return (\n    <div ref={composedRef} data-slot=\"marquee\" data-force={force} data-variant={variant === \"band\" ? undefined : variant} className={cn(\"ot-marquee\", className)} {...props}>\n      <div className=\"ot-marquee-frame\">\n        {Array.from({ length: rows }, (_, row) => (\n          <div key={row} className=\"ot-marquee-row\" data-back={reverse !== (row === 1) || undefined}>\n            <div className=\"ot-marquee-track\">\n              {Array.from({ length: copies }, (_, copy) => {\n                const read = row === 0 && copy === 0\n                return (\n                  <ul key={copy} className=\"ot-marquee-words\" aria-label={read ? label : undefined} aria-hidden={read ? undefined : true} inert={!read}>\n                    {words.map((word, i) => (\n                      <li key={i}>{word}</li>\n                    ))}\n                  </ul>\n                )\n              })}\n            </div>\n          </div>\n        ))}\n      </div>\n      {autoplay && <button type=\"button\" className=\"ot-marquee-pause\" onClick={() => setPaused((value) => !value)}>{paused ? playLabel : pauseLabel}</button>}\n    </div>\n  )\n}\n\nexport { Marquee, type MarqueeProps }\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/0nlytype/styles/marquee.css",
      "content": "@layer components {\n  /* ── ot-marquee ── --o wraps the drift and the scroll to one run (--period). The frame clips every copy;\n     its minimum width is zero, so a max-content track can never widen its containing grid or the page. */\n  .ot-marquee { --ot-marquee-dir: 1; --ot-marquee-gap: 0.32em; --o: 0px; --period: 0px; display: grid; grid-template-columns: minmax(0, 1fr); min-inline-size: 0; max-inline-size: 100%; font-weight: 300; color: var(--ot-ink); }\n  .ot-marquee-frame { min-inline-size: 0; overflow: clip; }\n  .ot-marquee:is([dir=\"rtl\"], [dir=\"rtl\"] *) { --ot-marquee-dir: -1; } /* reading along runs the other way */\n  .ot-marquee-row { overflow: clip; }\n  .ot-marquee-track { display: flex; inline-size: max-content; translate: calc(var(--o) * -1 * var(--ot-marquee-dir)) 0; }\n  .ot-marquee-row[data-back] .ot-marquee-track { translate: calc((var(--o) - var(--period)) * var(--ot-marquee-dir)) 0; }\n  .ot-marquee-words { display: flex; gap: var(--ot-marquee-gap); margin: 0; padding: 0 var(--ot-marquee-gap) 0 0; list-style: none; white-space: nowrap; }\n  .ot-marquee-words:is([dir=\"rtl\"] *) { padding: 0 0 0 var(--ot-marquee-gap); }\n  .ot-marquee-words > li { margin: 0; }\n  /* band: after \"Renaissance.\" and \"Less is more.\", every word a statement closed by its full stop. */\n  .ot-marquee:not([data-variant=\"ticker\"]) .ot-marquee-words > li::after { content: \".\"; }\n\n  /* ticker: small capitals running between two hairlines, after the Renaissance poster's top row and the frame row of\n     SHAPES / GRADIENTS. */\n  .ot-marquee[data-variant=\"ticker\"] {\n    --ot-marquee-gap: var(--ot-space-7);\n    font: 500 var(--ot-pp) / var(--ot-pp-lh) var(--ot-voice); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ot-graphite);\n  }\n  .ot-marquee[data-variant=\"ticker\"] .ot-marquee-frame { border-block: var(--ot-hairline) solid var(--ot-rule); padding-block: var(--ot-space-3); }\n\n  /* counter: SPECTRA's two rows, the upper cut at its head and the lower at its feet, facing each other across one\n     hairline and running opposite ways. Each word's box is trimmed to its cap height and baseline, so the cuts fall\n     on the letters themselves in every face: into the capitals above, along the baseline below (the full stops stay). */\n  .ot-marquee[data-variant=\"counter\"] .ot-marquee-row { overflow: visible; }\n  .ot-marquee[data-variant=\"counter\"] .ot-marquee-words > li { text-box: trim-both cap alphabetic; }\n  .ot-marquee[data-variant=\"counter\"] .ot-marquee-row:first-child { clip-path: inset(0 0 -1em 0); padding-block-end: 0.28em; }\n  .ot-marquee[data-variant=\"counter\"] .ot-marquee-row:first-child .ot-marquee-track { margin-block-start: -0.16em; }\n  .ot-marquee[data-variant=\"counter\"] .ot-marquee-row + .ot-marquee-row { clip-path: inset(-1em 0 0 0); padding-block-start: 0.14em; border-block-start: var(--ot-hairline) solid var(--ot-rule-strong); }\n\n  /* Reduced motion: the words stand still and wrap, whole, as one list. */\n  @media (prefers-reduced-motion: reduce) {\n    .ot-marquee-track { inline-size: auto; translate: none; }\n    .ot-marquee-row[data-back] .ot-marquee-track { translate: none; }\n    .ot-marquee-words { flex-wrap: wrap; white-space: normal; padding: 0; }\n    .ot-marquee-words + .ot-marquee-words, .ot-marquee-row + .ot-marquee-row { display: none; }\n    .ot-marquee-words { row-gap: 0; }\n    .ot-marquee[data-variant=\"counter\"] .ot-marquee-row:first-child { clip-path: none; padding: 0; }\n    .ot-marquee[data-variant=\"counter\"] .ot-marquee-row:first-child .ot-marquee-track { margin-block: 0; }\n    .ot-marquee[data-variant=\"counter\"] .ot-marquee-words > li { text-box: normal; }\n  }\n  /* The same small word beneath each autoplaying phrase; the parentheses are its only frame. */\n  .ot-marquee-pause {\n    display: block; justify-self: start; appearance: none; border: 0; background: none; margin: 0; margin-block-start: var(--ot-space-3); padding: var(--ot-space-1) 0;\n    min-block-size: var(--ot-space-5); color: var(--ot-pencil); font: 400 var(--ot-pp) / var(--ot-pp-lh) var(--ot-voice); letter-spacing: 0; text-transform: none; cursor: pointer;\n  }\n  .ot-marquee-pause::before { content: \"( \"; }\n  .ot-marquee-pause::after { content: \" )\"; }\n  .ot-marquee-pause:hover { color: var(--ot-ink); }\n  .ot-marquee-pause:focus-visible { outline: var(--ot-stroke) solid var(--ot-accent); outline-offset: var(--ot-space-1); }\n  .ot-marquee-pause:disabled { color: var(--ot-pencil); cursor: not-allowed; }\n  .ot-marquee[data-force~=\"reduced\"] .ot-marquee-pause { display: none; }\n  @media (prefers-reduced-motion: reduce) {\n    .ot-marquee-pause { display: none; }\n  }\n  @media (forced-colors: active) {\n    .ot-marquee-pause { color: ButtonText; }\n    .ot-marquee-pause:focus-visible { outline-color: Highlight; }\n  }\n\n  .ot-marquee[data-force~=\"reduced\"] .ot-marquee-track { inline-size: auto; translate: none; }\n  .ot-marquee[data-force~=\"reduced\"] .ot-marquee-row[data-back] .ot-marquee-track { translate: none; }\n  .ot-marquee[data-force~=\"reduced\"] .ot-marquee-words { flex-wrap: wrap; white-space: normal; padding: 0; }\n  .ot-marquee[data-force~=\"reduced\"] .ot-marquee-words + .ot-marquee-words, .ot-marquee[data-force~=\"reduced\"] .ot-marquee-row + .ot-marquee-row { display: none; }\n  .ot-marquee[data-force~=\"reduced\"] .ot-marquee-words { row-gap: 0; }\n  .ot-marquee[data-force~=\"reduced\"][data-variant=\"counter\"] .ot-marquee-row:first-child { clip-path: none; padding: 0; }\n  .ot-marquee[data-force~=\"reduced\"][data-variant=\"counter\"] .ot-marquee-row:first-child .ot-marquee-track { margin-block: 0; }\n  .ot-marquee[data-force~=\"reduced\"][data-variant=\"counter\"] .ot-marquee-words > li { text-box: normal; }\n\n}\n",
      "type": "registry:file",
      "target": "styles/0nlytype/marquee.css"
    }
  ],
  "css": {
    "@import \"../styles/0nlytype/marquee.css\"": {}
  },
  "meta": {
    "movement": "II",
    "underneath": "hook",
    "contract": "ot-marquee"
  },
  "type": "registry:ui"
}
