{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "italic-speed",
  "title": "Italic Speed",
  "description": "A slanted caps word rides in on speed strips with a serif italic subtitle under an underline.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/italic-speed/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Archivo\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  spring,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: display } = loadFont(\"italic\", {\n  weights: [\"500\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: serif } = loadSerif(\"italic\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\n\nexport interface ItalicSpeedProps {\n  /** The word that rides in on the strips. Set in caps. */\n  title?: string;\n  /** Second line, set smaller under the underline. Pass \"\" to hide. */\n  subtitle?: string;\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\n// Archivo Italic 500, per 1000 em, chars 32–126 then ’ “ ” … – — (harfbuzz):\n// advance, left and right side bearing, and the caps/punctuation kerning pairs.\nconst ADV = [\n  205, 282, 407, 582, 524, 958, 710, 227, 356, 356, 407, 630, 288, 333, 288,\n  296, 574, 547, 571, 575, 566, 573, 575, 564, 575, 574, 315, 315, 630, 630,\n  630, 595, 1002, 695, 702, 725, 731, 674, 611, 795, 734, 274, 571, 677, 552,\n  846, 734, 785, 667, 785, 722, 670, 612, 728, 659, 938, 683, 666, 635, 316,\n  296, 316, 630, 495, 189, 573, 579, 532, 579, 554, 293, 573, 573, 238, 236,\n  528, 238, 860, 573, 583, 579, 579, 346, 524, 305, 572, 516, 740, 529, 516,\n  503, 372, 245, 373, 630, 258, 435, 435, 901, 500, 1000,\n];\nconst LSB = [\n  0, 39, 104, 37, 27, 130, 36, 104, 58, -22, 71, 70, 2, 33, 42, -55, 47, 14, -2,\n  27, 16, 32, 45, 95, 28, 48, 55, 17, 56, 51, 43, 104, 55, -35, 35, 54, 35, 36,\n  36, 54, 36, 35, 20, 36, 36, 36, 36, 54, 36, 54, 35, 29, 80, 72, 87, 87, -34,\n  85, -17, 25, 83, -55, 113, -71, 81, 24, 21, 34, 34, 34, -79, 8, 21, 21, -101,\n  21, 21, 21, 21, 32, -10, 31, 21, 13, 51, 39, 58, 54, -35, -26, -17, 45, 83,\n  -25, 27, 89, 103, 89, 42, -4, -4,\n];\nconst RSB = [\n  205, 5, -16, 11, 17, 101, 15, -16, -32, 48, -15, 72, 117, 31, 114, -83, 19,\n  85, 12, 15, 33, 10, 26, -36, 20, 21, 56, 58, 45, 53, 58, 22, 40, 57, 17, 7,\n  26, -14, -35, 42, 6, 6, 2, -55, 45, 7, 6, 24, -16, 24, 19, 26, -52, 3, -62,\n  -64, -37, -65, -26, -64, 55, 17, 102, 58, -58, 24, 32, 21, -14, 31, -83, 19,\n  42, -13, -13, -20, -14, 41, 42, 33, 34, 21, -36, 31, -26, 21, -36, -37, -23,\n  -36, -3, -34, 80, 37, 70, 1, -13, 1, 114, -8, -8,\n];\nconst KERN = new Map(\n  [\n    \"AC-14 AG-14 AO-14 AQ-14 AT-86 AU-15 AV-31 AW-31 AX-24 AY-78 A?-30\",\n    \"A'-98 BV-10 BW-10 BX-10 BY-14 CT-20 CV-4 CW-4 CX-8 CY-8 DA-14 DT-24\",\n    \"DV-14 DW-14 DX-14 DY-14 DZ-10 D,-32 D:-10 D'-8 D…-32 EJ-20 FA-55\",\n    \"FJ-78 FX-28 FY-28 FZ-42 F,-60 F:-12 F--20 F…-60 F–-20 F—-20 GV-5 GW-5\",\n    \"KA-50 KC-44 KG-44 KJ-30 KO-44 KQ-44 KT-30 KV-54 KW-54 KX-20 KY-54\",\n    \"KZ-10 K--60 K'-18 K–-60 K—-60 LC-30 LG-30 LJ-20 LO-30 LQ-30 LT-85\",\n    \"LU-35 LV-92 LW-92 LX-148 LY-121 LZ-20 L?-50 L--80 L'-100 L’-100 L–-80\",\n    \"L—-80 OA-14 OT-24 OV-14 OW-14 OX-14 OY-14 OZ-10 O,-32 O:-10 O'-8\",\n    \"O…-32 PA-50 PJ-70 PT-20 PX-28 PY-18 PZ-30 P,-90 P…-90 QA-14 QT-24\",\n    \"QV-14 QW-14 QX-14 QY-14 QZ-10 Q,-32 Q:-10 Q'-8 Q…-32 RC-10 RG-10\",\n    \"RJ-30 RO-10 RQ-10 RT-22 RU-14 RV-10 RW-10 RX-19 RY-21 SY-35 TA-86\",\n    \"TC-24 TG-24 TJ-108 TO-24 TQ-24 TX-20 TY-20 TZ-20 T,-50 T:-20 T…-50\",\n    \"UA-15 VA-31 VC-14 VG-14 VJ-88 VO-14 VQ-14 VX-20 VY-20 V,-145 V:-10\",\n    \"V--50 V…-145 V–-50 V—-50 WA-31 WC-14 WG-14 WJ-88 WO-14 WQ-14 WX-20\",\n    \"WY-20 W,-145 W:-10 W--50 W…-145 W–-50 W—-50 XA-24 XC-14 XG-14 XO-14\",\n    \"XQ-14 XT-20 XV-20 XW-20 XY-30 XZ-20 X--50 X–-50 X—-50 YA-78 YC-14\",\n    \"YG-14 YJ-130 YO-14 YQ-14 YS-35 YT-20 YV-20 YW-20 YX-30 Y,-198 Y:-48\",\n    \"Y--135 Y…-198 Y–-135 Y—-135 ZC-10 ZG-10 ZO-10 ZQ-10 ZT-20 ZX-20 Z--95\",\n    \"Z–-95 Z—-95 0-40 0'7 0–40 0—40 1-40 1'-9 1–40 1—40 2-10 2–10 2—10\",\n    \"3-40 3–40 3—40 4-40 4–40 4—40 5-40 5–40 5—40 6-20 6–20 6—20 77-10\",\n    \"7,-120 7--40 7…-120 7–-40 7—-40 8-30 8–30 8—30 9-40 9–40 9—40 -V-50\",\n    \"-W-50 -X-50 -Y-135 -040 -140 -240 -340 -440 -540 -640 -830 -920 'A-98\",\n    \"'J-100 '4-12 ',-50 '…-50 ’A-98 –V-50 –W-50 –X-50 –Y-135 –040 –140\",\n    \"–240 –340 –440 –540 –640 –830 –920 —V-50 —W-50 —X-50 —Y-135 —040 —140\",\n    \"—240 —340 —440 —540 —640 —830 —920\",\n  ]\n    .join(\" \")\n    .split(\" \")\n    .map((p) => [p.slice(0, 2), Number(p.slice(2)) / 1000] as const),\n);\nconst CAP = 0.686;\n\n// Beat sheet (30fps, speed 1):\n//  0–12    horizontal speed strips shoot in from the left edge, already moving\n//          on frame 0, each with its own length and weight\n//  3–19    the word rides in on them at high skew, leading letter first; the\n//          trailing letters catch up, so the word arrives stretched\n//  13–24   each letter brakes and its skew snaps to the resting slant with a\n//          small overshoot (leans back a hair, then settles)\n//  18–33   the strips retract: left ends race in, they fold down onto one thin\n//          accent underline under the word\n//  32–43   the second line slides up out from under the underline\n//  43–     poster hold\nconst ARRIVE = 13;\nconst TRAVEL = 11;\nconst STAGGER = 1.2;\nconst LEAN = 34;\nconst RETRACT_AT = 18;\nconst RETRACT_LEN = 11;\nconst SUB_AT = 32;\nconst SUB_LEN = 11;\n\nconst RIDE = Easing.bezier(0.16, 0.8, 0.25, 1);\nconst STRIP_IN = Easing.bezier(0.2, 0.7, 0.3, 1);\nconst RETRACT = Easing.bezier(0.6, 0, 0.2, 1);\nconst SUB = Easing.bezier(0.2, 0.85, 0.3, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    stage: \"#0A0A0B\",\n    ink: \"#F3F2EF\",\n    strip: \"#2E2E34\",\n    sub: \"#B9B8B3\",\n    // gradients.sh \"beam\": tail fades into the stage, head burns white-blue.\n    beam: [\"#1A1660\", \"#3D5BFF\", \"#8FB4FF\", \"#F4F7FF\"],\n  },\n  light: {\n    stage: \"#F5F4F0\",\n    ink: \"#121214\",\n    strip: \"#D6D4CD\",\n    sub: \"#55545A\",\n    beam: [\"#C9D4FF\", \"#8FB4FF\", \"#3D5BFF\", \"#1A1660\"],\n  },\n} as const;\n\n// Strips: vertical position (0 = cap top, 1 = baseline), thickness (× cap),\n// right-end overhang past the word (× word width), whether it takes the\n// accent, and how far across the frame it already is on frame 0.\nconst STRIPS = [\n  { y: -0.06, h: 0.035, over: 0.08, accent: false, head: 0.55 },\n  { y: 0.1, h: 0.09, over: -0.18, accent: true, head: 0.35 },\n  { y: 0.24, h: 0.03, over: 0.14, accent: false, head: 0.7 },\n  { y: 0.37, h: 0.13, over: -0.3, accent: false, head: 0.25 },\n  { y: 0.52, h: 0.05, over: 0.03, accent: true, head: 0.6 },\n  { y: 0.64, h: 0.025, over: 0.2, accent: false, head: 0.45 },\n  { y: 0.76, h: 0.08, over: -0.08, accent: false, head: 0.3 },\n  { y: 0.9, h: 0.04, over: 0.1, accent: true, head: 0.65 },\n  { y: 1.06, h: 0.06, over: -0.22, accent: false, head: 0.4 },\n];\n\nconst EXTRA = \"’“”…–—\";\nfunction code(ch: string) {\n  const c = ch.charCodeAt(0);\n  if (c >= 32 && c < 127) return c - 32;\n  const x = EXTRA.indexOf(ch);\n  return x >= 0 ? 95 + x : 46;\n}\n\n/** Pen offset of each glyph plus the total advance, in em, kerned. */\nfunction layout(text: string) {\n  const pens: number[] = [];\n  let pen = 0;\n  for (let i = 0; i < text.length; i++) {\n    if (i > 0) pen += KERN.get(text[i - 1] + text[i]) ?? 0;\n    pens.push(pen);\n    pen += ADV[code(text[i])] / 1000;\n  }\n  return { pens, advance: pen };\n}\n\nexport function ItalicSpeed({\n  title = \"FASTER\",\n  subtitle = \"Ship at race pace.\",\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: ItalicSpeedProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H, fps } = useVideoConfig();\n  const c = THEMES[theme];\n  const uid = useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n\n  const text = title.trim().toUpperCase() || \"GO\";\n  const { pens, advance } = layout(text);\n  const lsb = LSB[code(text[0])] / 1000;\n  const rsb = RSB[code(text[text.length - 1])] / 1000;\n  const inkEm = Math.max(0.5, advance - lsb - rsb);\n  const fs = Math.min((0.78 * W) / inkEm, (0.36 * H) / CAP);\n  const cap = CAP * fs;\n  const inkW = inkEm * fs;\n\n  const sub = subtitle.trim();\n  const subFs = Math.max(0.44 * fs, 0.06 * W);\n  const ruleGap = 0.13 * cap;\n  const ruleH = Math.max(3, 0.0085 * H);\n  const subGap = 0.3 * subFs;\n  const blockH = cap + ruleGap + ruleH + (sub ? subGap + subFs * CAP * 1.3 : 0);\n  const baseline = (H - blockH) / 2 + cap;\n  const left = (W - inkW) / 2 - 0.02 * W;\n  const penX = left - lsb * fs;\n  const ruleY = baseline + ruleGap;\n  // Italic: at the baseline the ink starts a little left of the cap-top ink.\n  const ruleL = left - 0.02 * fs;\n  const ruleR = left + inkW - 0.1 * fs;\n\n  // Letters: the last one leads; each trails the next by STAGGER frames.\n  const n = text.length;\n  const letters = text.split(\"\").map((ch, i) => {\n    const arrive = ARRIVE + (n - 1 - i) * STAGGER;\n    const ride = RIDE(interpolate(t, [arrive - TRAVEL, arrive], [0, 1], CLAMP));\n    const dx = -(1.05 * W) * (1 - ride);\n    const snap = spring({\n      frame: t - (arrive - 2),\n      fps,\n      config: { damping: 11, stiffness: 320, mass: 0.55 },\n    });\n    const lean = -LEAN * (1 - snap);\n    const x = penX + pens[i] * fs + dx;\n    const pivot = x + (ADV[code(ch)] / 2000) * fs;\n    return { ch, x, lean, pivot, visible: ride > 0 };\n  });\n  const lead = letters[n - 1];\n  const leadRight = lead.x + (ADV[code(lead.ch)] / 1000) * fs;\n\n  const strips = STRIPS.map((s, k) => {\n    const color = s.accent ? `url(#${uid}-beam)` : c.strip;\n    const enter = STRIP_IN(\n      interpolate(t, [-TRAVEL * s.head, ARRIVE - 2 + k * 0.5], [0, 1], CLAMP),\n    );\n    const restR = ruleR + s.over * inkW;\n    // The strip head never falls behind the leading letter it pulls along.\n    const headX = Math.max(-0.02 * W + (restR + 0.02 * W) * enter, leadRight);\n    const r0 = Math.min(headX, restR + 0.6 * W);\n    const ret = RETRACT(\n      interpolate(\n        t,\n        [RETRACT_AT + k * 0.5, RETRACT_AT + k * 0.5 + RETRACT_LEN],\n        [0, 1],\n        CLAMP,\n      ),\n    );\n    const y0 = baseline - cap + s.y * cap - (s.h * cap * 1.4) / 2;\n    const h0 = s.h * cap * 1.4;\n    const l = -0.05 * W + (ruleL + 0.05 * W) * ret;\n    const r = r0 + (ruleR - r0) * ret;\n    const y = y0 + (ruleY - y0) * ret;\n    const h = h0 + (ruleH - h0) * ret;\n    return { key: k, l, r, y, h, color, accent: s.accent, ret };\n  });\n  const done = strips.every((s) => s.ret >= 1);\n\n  const subP = SUB(interpolate(t, [SUB_AT, SUB_AT + SUB_LEN], [0, 1], CLAMP));\n  const subLean = -14 * (1 - subP);\n  const subBase = ruleY + ruleH + subGap + subFs * CAP;\n  const subDy = -(subFs * 1.2) * (1 - subP);\n  const subX = ruleL + 0.004 * W;\n\n  return (\n    <AbsoluteFill style={{ background: c.stage }}>\n      <svg\n        width={W}\n        height={H}\n        viewBox={`0 0 ${W} ${H}`}\n        style={{ position: \"absolute\", inset: 0 }}\n        role=\"img\"\n        aria-label={sub ? `${text}. ${sub}` : text}\n      >\n        <defs>\n          <linearGradient id={`${uid}-beam`} x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\">\n            <stop offset=\"0\" stopColor={c.beam[0]} stopOpacity={0} />\n            <stop offset=\"0.35\" stopColor={c.beam[0]} />\n            <stop offset=\"0.7\" stopColor={c.beam[1]} />\n            <stop offset=\"0.92\" stopColor={c.beam[2]} />\n            <stop offset=\"1\" stopColor={c.beam[3]} />\n          </linearGradient>\n          <linearGradient id={`${uid}-rule`} x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\">\n            <stop offset=\"0\" stopColor={accent} />\n            <stop offset=\"0.75\" stopColor={c.beam[1]} />\n            <stop offset=\"1\" stopColor={c.beam[2]} />\n          </linearGradient>\n          <clipPath id={`${uid}-sub`}>\n            <rect x={0} y={ruleY + ruleH} width={W} height={H} />\n          </clipPath>\n        </defs>\n        {done ? (\n          <rect\n            x={ruleL}\n            y={ruleY}\n            width={ruleR - ruleL}\n            height={ruleH}\n            fill={`url(#${uid}-rule)`}\n          />\n        ) : (\n          [\n            ...strips.filter((s) => !s.accent),\n            ...strips.filter((s) => s.accent),\n          ]\n            .filter((s) => s.r > s.l)\n            .map((s) => (\n              <rect\n                key={s.key}\n                x={s.l}\n                y={s.y}\n                width={s.r - s.l}\n                height={s.h}\n                fill={s.color}\n              />\n            ))\n        )}\n        {letters.map((g, i) =>\n          g.visible && g.ch !== \" \" ? (\n            <text\n              key={i}\n              x={g.x}\n              y={baseline}\n              transform={`translate(${g.pivot} ${baseline}) skewX(${g.lean}) translate(${-g.pivot} ${-baseline})`}\n              fill={c.ink}\n              fontFamily={display}\n              fontStyle=\"italic\"\n              fontWeight={500}\n              fontSize={fs}\n              style={{ fontKerning: \"none\" }}\n            >\n              {g.ch}\n            </text>\n          ) : null,\n        )}\n        {sub && subP > 0 ? (\n          <g clipPath={`url(#${uid}-sub)`}>\n            <text\n              x={subX}\n              y={subBase + subDy}\n              transform={`translate(${subX} ${subBase}) skewX(${subLean}) translate(${-subX} ${-subBase})`}\n              fill={c.sub}\n              fontFamily={serif}\n              fontStyle=\"italic\"\n              fontWeight={400}\n              fontSize={subFs}\n              style={{ letterSpacing: \"-0.01em\" }}\n            >\n              {sub}\n            </text>\n          </g>\n        ) : null}\n      </svg>\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/italic-speed.tsx"
    }
  ],
  "type": "registry:component"
}
