{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "macro-pan",
  "title": "Macro Pan",
  "description": "A serif headline is revealed by a close-up pan across its glyphs, ending on a gradient.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/macro-pan/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Fraunces\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { useId, useMemo } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: display } = loadFont(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: brand } = loadManrope(\"normal\", {\n  weights: [\"500\", \"600\"],\n  subsets: [\"latin\"],\n});\n\nexport interface MacroPanProps {\n  /** One-line headline. A closing period or other punctuation takes the accent. */\n  title?: string;\n  /** Running label in the corner. \"remocn\" is set as the real logo. */\n  label?: string;\n  /** Number set before the label, like a reel or chapter. */\n  index?: string;\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\n/** Fraunces 400 advance widths (per mille) for ASCII 32–126. */\nconst ADV = [\n  203, 314, 346, 644, 577, 730, 704, 167, 364, 360, 620, 550, 240, 386, 233,\n  450, 648, 433, 588, 533, 566, 554, 592, 520, 564, 592, 282, 293, 512, 556,\n  512, 484, 880, 640, 661, 645, 748, 626, 600, 702, 786, 376, 365, 710, 558,\n  847, 707, 766, 654, 766, 685, 572, 586, 704, 624, 952, 650, 585, 606, 372,\n  430, 372, 460, 456, 228, 548, 552, 455, 560, 485, 320, 519, 576, 315, 304,\n  550, 313, 848, 590, 527, 548, 536, 468, 434, 372, 587, 489, 745, 582, 510,\n  495, 400, 320, 398, 622,\n];\n/** Fraunces 400 kerning: \"AT46\" = A then T, -46/1000 em (\"+\" widens). */\nconst KERN = new Map<string, number>();\nfor (const tok of [\n  \"AT46 AU29 AV40 AW40 AY43 BT23 BU22 BV31 BW31 BY26 DA25 DT36 DU20 DV32\",\n  \"DW32 DX30 DY33 DZ24 FA50 F.50 F,50 JA30 J.42 J,42 Kv34 Kw34 Ky34 LT42\",\n  \"LU31 LV40 LW40 LY32 Lv20 Lw20 Ly20 NT+24 Nb+20 Nh+20 Nk+20 Nl+20\",\n  \"OA25 OT36 OU20 OV32 OW32 OX30 OY33 OZ24 PA54 PB24 PD24 PE24 PF24 PH24\",\n  \"PI24 PK24 PL24 PN21 PP24 PR24 PX29 PZ24 P.66 P,66 QA25 QT36 QU20 QV32\",\n  \"QW32 QX30 QY33 QZ24 RU22 RV35 RW35 RY24 SU22 Sv20 Sw20 Sy20 S.20 S,20\",\n  \"TA60 TC22 TG22 TO22 TQ22 TT+34 TV+38 TW+38 TX+26 Ta41 Tb+20 Tc46 Td46\",\n  \"Te46 Tg41 Th+20 Ti25 Tk+20 Tl+20 Tm35 Tn35 To46 Tq46 Tr35 Ts41 Tu41\",\n  \"Tv42 Tw42 Tx22 Ty42 Tz22 T.68 T,68 UA46 Ua21 Ui24 Um24 Un24 Ur24 Ux21\",\n  \"U.52 U,52 VA74 Va50 Vc44 Vd44 Ve44 Vg50 Vo44 Vq44 Vs38 Vv25 Vw25 Vy25\",\n  \"V.94 V,94 WA74 Wa50 Wc44 Wd44 We44 Wg50 Wo44 Wq44 Ws38 Wv25 Ww25 Wy25\",\n  \"W.94 W,94 Xv24 Xw24 Xy24 YA54 YT+31 Ya46 Yb+20 Yc44 Yd44 Ye44 Yg26\",\n  \"Yh+20 Yi28 Yk+20 Yl+20 Ym28 Yn28 Yo44 Yq44 Yr28 Ys38 Yu31 Yv36 Yw36\",\n  \"Yx21 Yy36 Y.76 Y,76 bb20 bh20 bk20 bl20 bx20 cT58 cU26 cV53 cW53 cY64\",\n  \"eJ20 eT60 eU32 eV58 eW58 eY73 eb21 eh21 ek21 el21 fa21 ob20 oh20 ok20\",\n  \"ol20 ox20 pb20 ph20 pk20 pl20 px20 qj+35 ra26 rg22 rx20 ya22 yg20 yx27\",\n  \"y.35 y,35 .T64 .U27 .V67 .W67 .Y49 ,T64 ,U27 ,V67 ,W67 ,Y49\",\n]\n  .join(\" \")\n  .split(\" \")) {\n  const m = /^(.)(.)(\\+?)(\\d+)$/.exec(tok);\n  if (m) KERN.set(m[1] + m[2], ((m[3] ? 1 : -1) * Number(m[4])) / 1000);\n}\nconst TRACK = -0.022;\nconst WORD_SPACE = 0.05;\nconst CAP = 0.7;\nconst X_HEIGHT = 0.47;\n\nconst PAN_END = 100;\nconst PULL_LEN = 34;\n\nconst PAN = Easing.bezier(0.38, 0.08, 0.78, 1);\nconst PULL = Easing.bezier(0.55, 0, 0.12, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\n// Letter fill: gradients.sh \"rise\" (sunrise from the baseline). Light keeps\n// the palette's deep end so the type holds contrast on the off-white stage.\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F3F2EF\",\n    muted: \"#8B8A90\",\n    fill: [\"#FFF1E2\", \"#FFD2AE\", \"#FF8A3D\", \"#C4401F\"],\n    grain: 0.07,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    muted: \"#6E6C67\",\n    fill: [\"#2A0D0A\", \"#6E1E12\", \"#A3301A\", \"#E0662A\"],\n    grain: 0.045,\n  },\n} as const;\n\n/** The real remocn \"R\" mark (viewBox 124.06 × 134.26). */\nconst REMOCN_R_PATH =\n  \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\n\n/** Full logo as on remocn.dev: R mark (0.76em, on the baseline) + \"emocn\" in Manrope 600. */\nfunction RemocnLogo({ fontSize, color }: { fontSize: number; color: string }) {\n  return (\n    <div\n      style={{\n        display: \"flex\",\n        alignItems: \"baseline\",\n        color,\n        fontFamily: brand,\n        fontWeight: 600,\n        fontSize,\n        letterSpacing: \"-0.025em\",\n        lineHeight: 1,\n      }}\n    >\n      <svg\n        viewBox=\"0 0 124.06 134.26\"\n        style={{ height: \"0.76em\", width: \"auto\" }}\n        aria-hidden\n      >\n        <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n      </svg>\n      <span style={{ marginLeft: \"0.04em\" }}>emocn</span>\n    </div>\n  );\n}\n\nfunction advance(ch: string) {\n  const code = ch.charCodeAt(0);\n  return (code >= 32 && code < 127 ? ADV[code - 32] : 640) / 1000;\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={41}\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\nexport function MacroPan({\n  title = \"Built to move.\",\n  label = \"remocn\",\n  index = \"01\",\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: MacroPanProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = H / 720;\n  const c = THEMES[theme];\n\n  const layout = useMemo(() => {\n    const chars = Array.from(title.trim());\n    const lefts: number[] = [];\n    let x = 0;\n    chars.forEach((ch, i) => {\n      if (i > 0) x += KERN.get(chars[i - 1] + ch) ?? 0;\n      lefts.push(x);\n      // Serif display wants a slightly wider word space than the font's.\n      const space = ch === \" \" ? WORD_SPACE : 0;\n      x += advance(ch) + space + (i < chars.length - 1 ? TRACK : 0);\n    });\n    return { chars, lefts, total: x };\n  }, [title]);\n\n  const F = Math.min((W * 0.86) / layout.total, (H * 0.36) / CAP);\n  const lineX = (W - layout.total * F) / 2;\n  const baseline = H / 2 + (CAP * F) / 2;\n  const xh = X_HEIGHT * F;\n\n  // Focus path in poster coordinates: across the last letters, ending on the mark.\n  const lastIdx = layout.chars.length - 1;\n  const startIdx = Math.max(0, lastIdx - 4);\n  const endsOnMark = /[.!?]/.test(layout.chars[lastIdx] ?? \"\");\n  const fx0 = lineX + (layout.lefts[startIdx] + 0.08) * F;\n  const fy0 = baseline - xh * 0.62;\n  const fx1 =\n    lineX +\n    (layout.lefts[lastIdx] + advance(layout.chars[lastIdx] ?? \"\") * 0.5) * F;\n  const fy1 = baseline - (endsOnMark ? 0.08 * F : xh * 0.5);\n\n  const s0 = (H * 1.55) / xh;\n  const pan = interpolate(t, [0, PAN_END], [0, 1], { ...CLAMP, easing: PAN });\n  const sPan = s0 * (1 - 0.12 * pan);\n  const sEnd = s0 * 0.88;\n  const pull = interpolate(t, [PAN_END, PAN_END + PULL_LEN], [0, 1], {\n    ...CLAMP,\n    easing: PULL,\n  });\n  const push = interpolate(\n    t,\n    [PAN_END + PULL_LEN, PAN_END + PULL_LEN + 50],\n    [0, 1],\n    { ...CLAMP, easing: Easing.bezier(0.33, 0, 0.67, 1) },\n  );\n\n  let transform: string;\n  if (pull <= 0) {\n    const fx = fx0 + (fx1 - fx0) * pan;\n    const fy = fy0 + (fy1 - fy0) * pan;\n    transform = `translate(${W / 2} ${H / 2}) scale(${sPan}) translate(${-fx} ${-fy})`;\n  } else {\n    const s = Math.exp(Math.log(sEnd) * (1 - pull)) * (1 + push * 0.012);\n    const px = (W / 2 - fx1 * sEnd) / (1 - sEnd);\n    const py = (H / 2 - fy1 * sEnd) / (1 - sEnd);\n    transform = `translate(${px} ${py}) scale(${s}) translate(${-px} ${-py})`;\n  }\n\n  const labelIn = interpolate(t, [4, 22], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const fontSize = 15 * u;\n  const margin = 40 * u;\n  const uid = `mp${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  // Sunrise fill: runs from the top of the x-height down past the baseline and\n  // leans a few degrees as the shot plays.\n  const lean = (6 - t * 0.04) * F * 0.01;\n\n  return (\n    <AbsoluteFill style={{ background: c.bg, overflow: \"hidden\" }}>\n      <svg\n        width={W}\n        height={H}\n        viewBox={`0 0 ${W} ${H}`}\n        style={{ position: \"absolute\", inset: 0 }}\n        aria-hidden\n      >\n        <defs>\n          <linearGradient\n            id={uid}\n            gradientUnits=\"userSpaceOnUse\"\n            x1={lineX + lean}\n            y1={baseline - CAP * F * 1.05}\n            x2={lineX - lean}\n            y2={baseline + 0.06 * F}\n          >\n            {c.fill.map((col, j) => (\n              <stop key={col} offset={[0, 0.3, 0.68, 1][j]} stopColor={col} />\n            ))}\n          </linearGradient>\n        </defs>\n        <g transform={transform}>\n          {layout.chars.map((ch, i) =>\n            ch === \" \" ? null : (\n              <text\n                key={i}\n                x={lineX + layout.lefts[i] * F}\n                y={baseline}\n                fontFamily={display}\n                fontWeight={400}\n                fontSize={F}\n                fill={\n                  /[.!?]/.test(ch) && i === lastIdx ? accent : `url(#${uid})`\n                }\n                style={{ fontKerning: \"none\" }}\n              >\n                {ch}\n              </text>\n            ),\n          )}\n        </g>\n      </svg>\n\n      <div\n        style={{\n          position: \"absolute\",\n          left: margin - 12 * u,\n          bottom: margin - 7 * u,\n          display: \"flex\",\n          alignItems: \"center\",\n          gap: 10 * u,\n          fontFamily: brand,\n          fontWeight: 500,\n          fontSize,\n          lineHeight: 1,\n          letterSpacing: \"-0.005em\",\n          fontVariantNumeric: \"tabular-nums\",\n          // A stage-coloured pill keeps the label legible over the letterforms.\n          padding: `${7 * u}px ${12 * u}px`,\n          borderRadius: 999,\n          background: c.bg,\n          color: c.muted,\n          opacity: labelIn,\n          transform: `translateY(${(1 - labelIn) * 8 * u}px)`,\n        }}\n      >\n        <span style={{ color: c.fg }}>{index}</span>\n        <span>/</span>\n        {label.trim().toLowerCase() === \"remocn\" ? (\n          <RemocnLogo fontSize={fontSize * 1.05} color={c.muted} />\n        ) : (\n          <span>{label}</span>\n        )}\n      </div>\n\n      <Grain opacity={c.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/macro-pan.tsx"
    }
  ],
  "type": "registry:component"
}
