{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"strobe-words","type":"registry:component","title":"Strobe Words","description":"Big words strobe in at a set rhythm over a dark horizon glow, ending on the logo.","dependencies":["remotion","@remotion/google-fonts"],"docs":"Needs a Remotion project. If a frame renders black, the component is drawing on a transparent layer: put a background behind it, e.g. <AbsoluteFill style={{ background: \"#faf9f6\" }}><Component /></AbsoluteFill>.","files":[{"path":"components/kuchi/strobe-words.tsx","type":"registry:component","target":"components/kuchi/strobe-words.tsx","content":"/*! Portions Copyright (c) 2026 Remocn. MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\n\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { loadFont as loadDisplay } from \"@remotion/google-fonts/Sora\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst manrope = loadManrope(\"normal\", {\n  weights: [\"500\", \"600\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: display } = loadDisplay(\"normal\", {\n  weights: [\"500\"],\n  subsets: [\"latin\"],\n});\n\n// gradients.sh \"radial-glow\" palette (bg #020204): #f3f1ff, #9db4ff, #5a46cb, #1d1240.\nconst GLOW = [\"#f3f1ff\", \"#9db4ff\", \"#5a46cb\", \"#1d1240\", \"#020204\"] as const;\n\n// Sora 500 advances (1/1000 em), ASCII 32–126, measured with HarfBuzz.\nconst SORA_500 = [\n  222, 303, 452, 702, 652, 864, 702, 264, 382, 382, 568, 592, 266, 506, 266,\n  365, 750, 423, 623, 620, 652, 630, 668, 585, 647, 668, 266, 266, 592, 590,\n  592, 556, 1124, 765, 684, 797, 788, 598, 560, 832, 803, 320, 641, 703, 549,\n  937, 858, 865, 649, 865, 710, 682, 602, 785, 719, 1052, 705, 654, 652, 382,\n  365, 382, 587, 581, 300, 581, 694, 608, 694, 616, 380, 679, 644, 317, 324,\n  595, 296, 973, 644, 678, 694, 694, 414, 543, 429, 634, 572, 873, 574, 555,\n  493, 382, 375, 382, 511,\n];\nconst TRACK = -0.045;\n\n\n/** Full logo as on acme.dev: R mark (0.76em tall, baseline-aligned) + \"Acme\" in Manrope 600, tracking-tight. */\nfunction KuchiLogo({ fontSize, color }: { fontSize: number; color: string }) {\n  return (\n    <div\n      style={{\n        display: \"flex\",\n        alignItems: \"baseline\",\n        color,\n        fontFamily: manrope.fontFamily,\n        fontWeight: 600,\n        fontSize,\n        letterSpacing: \"-0.025em\",\n        lineHeight: 1,\n      }}\n    >\n      <span>Acme</span>\n    </div>\n  );\n}\n\nexport interface StrobeWordsProps {\n  words?: string[];\n  rhythm?: number[];\n  /** Frames of the first strobe cut when `rhythm` is unset; cuts speed up to half that. */\n  beat?: number;\n  /** Fewest strobe cuts before the poster when `rhythm` is unset. */\n  cuts?: number;\n  logo?: React.ReactNode;\n  accent?: string;\n  /** Typeface for the words. Load it yourself; Sora by default. */\n  fontFamily?: string;\n  /** Film grain over the scene. */\n  grain?: boolean;\n  /** Size of the words and logo, around the frame's center. */\n  scale?: number;\n  /** Frames to hold the first frame before anything moves. */\n  delay?: number;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\nconst CAP = 0.73;\nconst BASE = 0.84;\nconst INK = \"#0A0A0B\";\nconst PAPER = \"#F5F4F0\";\nconst PAPER_INK = \"#121214\";\n\ntype Field = \"accent\" | \"ink\" | \"paper\";\nconst CYCLE: Field[] = [\"accent\", \"ink\", \"paper\"];\n\nfunction widthEm(text: string) {\n  let w = 0;\n  for (const ch of text) {\n    const code = ch.charCodeAt(0);\n    const adv = code >= 32 && code < 127 ? SORA_500[code - 32] : 600;\n    w += adv / 1000 + TRACK;\n  }\n  return Math.max(w, 0.5);\n}\n\nfunction defaultRhythm(count: number, beat: number, cuts: number) {\n  let n = count - 1;\n  while (n < cuts) n += count;\n  return Array.from({ length: n }, (_, i) =>\n    Math.round(beat - ((beat / 2) * i) / Math.max(1, n - 1)),\n  );\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n  const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  return (\n    <svg\n      width=\"100%\"\n      height=\"100%\"\n      style={{ position: \"absolute\", inset: 0, opacity, pointerEvents: \"none\" }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={3}\n          stitchTiles=\"stitch\"\n        />\n        <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\" />\n      </filter>\n      <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n    </svg>\n  );\n}\n\nfunction Word({\n  text,\n  size,\n  color,\n  stop,\n  fill,\n  fontFamily,\n}: {\n  text: string;\n  size: number;\n  color: string;\n  stop: string;\n  fill?: string;\n  fontFamily: string;\n}) {\n  const { height: H } = useVideoConfig();\n  const baseline = H / 2 + (CAP * size) / 2;\n  const tail = text.match(/[.!?]$/) ? text.slice(-1) : \"\";\n  const body = tail ? text.slice(0, -1) : text;\n  return (\n    <div\n      style={{\n        position: \"absolute\",\n        left: 0,\n        right: 0,\n        top: baseline - BASE * size,\n        display: \"flex\",\n        justifyContent: \"center\",\n      }}\n    >\n      <div\n        style={{\n          fontFamily,\n          fontWeight: 500,\n          fontSize: size,\n          lineHeight: 1,\n          letterSpacing: `${TRACK}em`,\n          paddingLeft: `${-TRACK}em`,\n          whiteSpace: \"nowrap\",\n          color,\n        }}\n      >\n        {fill ? (\n          <span\n            style={{\n              color: \"transparent\",\n              backgroundImage: fill,\n              WebkitBackgroundClip: \"text\",\n              backgroundClip: \"text\",\n              paddingRight: \"0.08em\",\n              marginRight: \"-0.08em\",\n            }}\n          >\n            {body}\n          </span>\n        ) : (\n          body\n        )}\n        {tail ? <span style={{ color: stop }}>{tail}</span> : null}\n      </div>\n    </div>\n  );\n}\n\n/** The foreground at `scale`, around the frame's center; nothing extra at 1. */\nfunction ScaleLayer({\n  scale,\n  children,\n}: {\n  scale: number;\n  children: React.ReactNode;\n}) {\n  if (scale === 1) return children;\n  return (\n    <AbsoluteFill style={{ transform: `scale(${scale})` }}>\n      {children}\n    </AbsoluteFill>\n  );\n}\n\nexport function StrobeWords({\n  words = [\"Plan.\", \"Write.\", \"Render.\", \"Ship.\"],\n  rhythm,\n  beat = 6,\n  cuts = 13,\n  logo,\n  accent = \"#3B5BFD\",\n  fontFamily = display,\n  grain = true,\n  scale = 1,\n  delay = 0,\n  theme = \"dark\",\n  speed = 1,\n}: StrobeWordsProps) {\n  const t = Math.max(0, useCurrentFrame() - delay) * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = H / 720;\n  const list = words.length > 0 ? words : [\"Ship.\"];\n  const beats =\n    rhythm && rhythm.length > 0\n      ? rhythm\n      : defaultRhythm(list.length, beat, cuts);\n  const poster: Field = theme === \"light\" ? \"paper\" : \"ink\";\n\n  const offset = (((CYCLE.indexOf(\"accent\") - (beats.length - 1)) % 3) + 3) % 3;\n\n  let index = beats.length;\n  let at = 0;\n  for (let i = 0; i < beats.length; i++) {\n    if (t < at + beats[i]) {\n      index = i;\n      break;\n    }\n    at += beats[i];\n  }\n  const isPoster = index >= beats.length;\n  const field: Field = isPoster ? poster : CYCLE[(index + offset) % 3];\n  const text = isPoster\n    ? list[list.length - 1]\n    : list[\n        (((index - beats.length + list.length - 1) % list.length) +\n          list.length) %\n          list.length\n      ];\n\n  // Each strobe beat on the accent field is a radial-glow ground; the disc\n  // sits in a slightly different place per beat so the cuts read as light.\n  const k = isPoster ? 0 : index;\n  const bx = 50 + ((k * 37) % 5) * 5 - 10;\n  const glowField = [\n    `radial-gradient(52% 64% at ${bx}% 104%, ${GLOW[0]} 0%, color-mix(in oklab, ${GLOW[1]} 85%, transparent) 30%, transparent 72%)`,\n    `radial-gradient(90% 90% at ${100 - bx}% 0%, color-mix(in oklab, ${GLOW[3]} 80%, transparent) 0%, transparent 70%)`,\n    `linear-gradient(180deg, ${GLOW[3]} 0%, ${GLOW[2]} 62%, #7e6fe0 100%)`,\n  ].join(\", \");\n  const rise = interpolate(t - at, [0, 60], [0, 1], {\n    extrapolateLeft: \"clamp\",\n    extrapolateRight: \"clamp\",\n    easing: Easing.bezier(0.22, 1, 0.36, 1),\n  });\n  // Poster: the glow's ring reads as a horizon arc low in frame, rising a\n  // few percent over the hold, under the word rather than around it.\n  const posterGlow = [\n    `radial-gradient(78% 62% at 50% ${142 - 6 * rise}%, color-mix(in oklab, ${GLOW[3]} 90%, transparent) 60%, color-mix(in oklab, ${GLOW[0]} 80%, transparent) 63%, color-mix(in oklab, ${GLOW[1]} 40%, transparent) 67%, transparent 80%)`,\n    `radial-gradient(90% 60% at 50% 120%, color-mix(in oklab, ${GLOW[2]} 45%, transparent) 0%, transparent 70%)`,\n    GLOW[4],\n  ].join(\", \");\n  const bg =\n    field === \"accent\"\n      ? glowField\n      : field === \"ink\"\n        ? isPoster\n          ? posterGlow\n          : INK\n        : PAPER;\n  const fg = field === \"paper\" ? PAPER_INK : \"#F7F7F5\";\n  const stop = field === \"accent\" ? GLOW[0] : accent;\n  const posterFill =\n    isPoster && field === \"paper\"\n      ? `linear-gradient(180deg, ${GLOW[2]} 10%, ${GLOW[3]} 92%)`\n      : undefined;\n\n  const longest = list.reduce((m, w) => Math.max(m, widthEm(w)), 0.5);\n  const strobeSize = Math.min(290 * u, (0.74 * W) / longest);\n  const final = list[list.length - 1];\n  const posterSize = Math.min(340 * u, (0.8 * W) / widthEm(final));\n\n  return (\n    <AbsoluteFill style={{ background: bg, overflow: \"hidden\" }}>\n      <ScaleLayer scale={scale}>\n        <Word\n          text={text}\n          size={isPoster ? posterSize : strobeSize}\n          color={fg}\n          stop={stop}\n          fill={posterFill}\n          fontFamily={fontFamily}\n        />\n        {isPoster ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: 0,\n              right: 0,\n              bottom: 0.085 * H,\n              display: \"flex\",\n              justifyContent: \"center\",\n              alignItems: \"center\",\n              gap: 10 * u,\n              color: fg,\n            }}\n          >\n            {logo ?? <KuchiLogo fontSize={28 * u} color={fg} />}\n          </div>\n        ) : null}\n      </ScaleLayer>\n      {grain ? <Grain opacity={field === \"paper\" ? 0.04 : 0.05} /> : null}\n    </AbsoluteFill>\n  );\n}\n"}]}