{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bokeh-title",
  "title": "Bokeh Title",
  "description": "A serif headline sharpens out of drifting bokeh lights.",
  "dependencies": ["remotion", "@remotion/google-fonts", "@remotion/paths"],
  "files": [
    {
      "path": "registry/remocn/bokeh-title/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadSans } from \"@remotion/google-fonts/InstrumentSans\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { getLength, getPointAtLength } from \"@remotion/paths\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  interpolateColors,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: sans } = loadSans(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: serif } = loadSerif(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: serifItalic } = loadSerif(\"italic\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", {\n  weights: [\"500\", \"600\"],\n  subsets: [\"latin\"],\n});\n\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\";\nconst R_W = 124.06;\nconst R_H = 134.26;\n\n/** Full logo as on remocn.dev: R mark (0.76em tall, baseline-aligned) + \"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: manrope.fontFamily,\n        fontWeight: 600,\n        fontSize,\n        letterSpacing: \"-0.025em\",\n        lineHeight: 1,\n      }}\n    >\n      <svg\n        viewBox={`0 0 ${R_W} ${R_H}`}\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\n/** The R outline as a polygon, for point-in-mark tests. */\nconst R_POLY: [number, number][] = (() => {\n  const len = getLength(REMOCN_R_PATH);\n  const n = 360;\n  return Array.from({ length: n }, (_, i) => {\n    const pt = getPointAtLength(REMOCN_R_PATH, (i / n) * len);\n    return [pt?.x ?? 0, pt?.y ?? 0] as [number, number];\n  });\n})();\n\nexport interface BokehTitleProps {\n  title?: string;\n  subtitle?: string;\n  /** What the lights resolve into during the rack focus. */\n  pattern?: \"mark\" | \"grid\";\n  /** Aperture shape of the out-of-focus lights. */\n  shape?: \"circle\" | \"hexagon\";\n  accent?: string;\n  /** Playback multiplier. */\n  speed?: number;\n  /** Dark = night lights; light = soft daylight bokeh. */\n  theme?: \"dark\" | \"light\";\n}\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst T_FOCUS_IN = [34, 66] as const;\nconst T_FOCUS_OUT = [90, 120] as const;\nconst T_TITLE = 106;\nconst AMBIENT = 24;\n\n// gradients.sh \"halo\" palette: bg #030306, [#fff4ec, #ffb36b, #e2457a, #3d4dff].\n// It colours the lights: cream and amber out of focus, and a gradient across the R in focus.\nconst HALO = [\"#fff4ec\", \"#ffb36b\", \"#e2457a\", \"#3d4dff\"] as const;\n\nconst PALETTES = {\n  dark: {\n    bg: \"radial-gradient(ellipse 90% 80% at 50% 45%, #0f0c12 0%, #030306 72%)\",\n    fg: \"#F6F1EC\",\n    muted: \"#9A938E\",\n    lights: [\"#fff4ec\", \"#ffe3cc\", \"#ffb36b\", \"#fff4ec\", \"#f2b9c9\"],\n    blend: \"screen\" as const,\n    base: 0.2,\n    titleVeil: \"rgba(3,3,6,0.6)\",\n    grain: 0.06,\n  },\n  light: {\n    bg: \"radial-gradient(ellipse 90% 80% at 50% 40%, #F7F2EC 0%, #EADFD3 100%)\",\n    fg: \"#16131A\",\n    muted: \"#6E6660\",\n    lights: [\"#FFFFFF\", \"#FFF4EC\", \"#FFE0C2\", \"#FFFFFF\", \"#F8D3DE\"],\n    blend: \"normal\" as const,\n    base: 0.42,\n    titleVeil: \"rgba(247,242,236,0.62)\",\n    grain: 0.045,\n  },\n} as const;\n\ntype Palette = (typeof PALETTES)[keyof typeof PALETTES];\n\nfunction hash(n: number) {\n  const x = Math.sin(n * 127.1 + 311.7) * 43758.5453;\n  return x - Math.floor(x);\n}\n\n/** Even-odd point-in-polygon test against the R outline (R units). */\nfunction inMark(x: number, y: number) {\n  let inside = false;\n  for (let i = 0, j = R_POLY.length - 1; i < R_POLY.length; j = i++) {\n    const [xi, yi] = R_POLY[i];\n    const [xj, yj] = R_POLY[j];\n    if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) {\n      inside = !inside;\n    }\n  }\n  return inside;\n}\n\ninterface Target {\n  x: number;\n  y: number;\n  /** Position along the pattern's gradient, 0..1. */\n  g: number;\n}\n\n/**\n * Pattern targets in a normalised space centred on 0, plus the size of one\n * unit (as a share of the frame height) and the in-focus dot diameter in units.\n */\nfunction buildTargets(pattern: \"mark\" | \"grid\") {\n  const out: Target[] = [];\n  if (pattern === \"grid\") {\n    for (let r = 0; r < 6; r++) {\n      for (let c = 0; c < 11; c++) {\n        out.push({ x: (c - 5) * 3.4, y: (r - 2.5) * 3.4, g: c / 10 });\n      }\n    }\n    return { targets: out, unit: 0.46 / 31, dot: 1.05 };\n  }\n  // a hex-packed dot screen clipped by the real R\n  const step = 6.6;\n  const rowH = step * 0.866;\n  let row = 0;\n  for (let y = rowH / 2; y < R_H; y += rowH, row++) {\n    for (let x = (row % 2) * (step / 2) + step / 2; x < R_W; x += step) {\n      if (inMark(x, y)) {\n        out.push({\n          x: x - R_W / 2,\n          y: y - R_H / 2,\n          g: Math.min(1, Math.max(0, (x / R_W) * 0.55 + (y / R_H) * 0.45)),\n        });\n      }\n    }\n  }\n  return { targets: out, unit: 0.5 / R_H, dot: step * 0.74 };\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 }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={23}\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\nconst HEX =\n  \"polygon(25% 6.7%, 75% 6.7%, 100% 50%, 75% 93.3%, 25% 93.3%, 0% 50%)\";\n\n/** One out-of-focus light: a disc with a faintly brighter rim, softened by blur. */\nfunction Light({\n  x,\n  y,\n  size,\n  blur,\n  color,\n  opacity,\n  blend,\n  shape,\n  rim,\n}: {\n  x: number;\n  y: number;\n  size: number;\n  blur: number;\n  color: string;\n  opacity: number;\n  blend: React.CSSProperties[\"mixBlendMode\"];\n  shape: \"circle\" | \"hexagon\";\n  rim: number;\n}) {\n  return (\n    <div\n      style={{\n        position: \"absolute\",\n        left: x - size / 2,\n        top: y - size / 2,\n        width: size,\n        height: size,\n        opacity,\n        mixBlendMode: blend,\n        filter: blur > 0.3 ? `blur(${blur}px)` : undefined,\n      }}\n    >\n      <div\n        style={{\n          width: \"100%\",\n          height: \"100%\",\n          borderRadius: shape === \"circle\" ? \"50%\" : undefined,\n          clipPath: shape === \"hexagon\" ? HEX : undefined,\n          background: `radial-gradient(circle closest-side, ${color} 0%, ${color} 78%, ${color} 100%)`,\n          boxShadow:\n            shape === \"circle\" && rim > 0\n              ? `inset 0 0 0 ${Math.max(1, size * 0.035)}px rgba(255,255,255,${rim})`\n              : undefined,\n        }}\n      />\n    </div>\n  );\n}\n\nexport function BokehTitle({\n  title = \"Launch films, made in code\",\n  subtitle = \"remocn · Spring release\",\n  pattern = \"mark\",\n  shape = \"circle\",\n  accent = \"#3B5BFD\",\n  speed = 1,\n  theme = \"dark\",\n}: BokehTitleProps) {\n  const t = useCurrentFrame() * speed;\n  const { width, height } = useVideoConfig();\n  const u = height / 720;\n  const p: Palette = PALETTES[theme];\n\n  const built = buildTargets(pattern);\n  const targets = built.targets;\n  const unit = height * built.unit;\n  // more lights in the pattern -> each defocused disc a little smaller\n  const crowd = Math.min(1, Math.sqrt(80 / targets.length));\n\n  // focus pull: 0 = lights defocused, 1 = pattern plane sharp\n  const focus =\n    interpolate(t, T_FOCUS_IN, [0, 1], { ...CLAMP, easing: EASE_IO }) -\n    interpolate(t, T_FOCUS_OUT, [0, 1], { ...CLAMP, easing: EASE_IO });\n  // lens breathing: the frame scales a hair with the focus throw\n  const breathe = 1 + focus * 0.025;\n  const drift = interpolate(t, [0, 200], [0, 1], { ...CLAMP, easing: EASE_IO });\n  const open = interpolate(t, [0, 14], [0.55, 1], CLAMP);\n\n  const titleP = interpolate(t, [T_TITLE, T_TITLE + 40], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const subP = interpolate(t, [T_TITLE + 18, T_TITLE + 46], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const behindTitle = 1 - titleP * 0.35;\n  const titleSize = Math.min(104 * u, width * 0.085);\n  // keep a one-line title on one line while tracking wide, so it never reflows\n  const fitsOneLine = title.length * titleSize * 0.36 < width * 0.84;\n  // the last word is set in the italic: the editorial accent of the line\n  const words = title.trim().split(/\\s+/);\n  const lead = words.slice(0, -1).join(\" \");\n  const last = words[words.length - 1] ?? \"\";\n  const [subLead, ...subRest] = subtitle.split(\" · \");\n  const subIsBrand = subLead.trim().toLowerCase() === \"remocn\";\n\n  const lights: React.ReactNode[] = [];\n\n  // pattern lights: they live on the focal plane\n  for (const [i, tg] of targets.entries()) {\n    const d = hash(i * 3 + 1); // 0 near … 1 far\n    const tx = width / 2 + tg.x * unit;\n    const ty = height / 2 + tg.y * unit;\n    const sx = tx + (hash(i * 5 + 2) - 0.5) * width * 0.78;\n    const sy = ty + (hash(i * 7 + 3) - 0.5) * height * 0.8;\n    const par = (0.4 + (1 - d) * 0.6) * u;\n    const dx = (-60 * drift + Math.sin(t / 50 + i) * 6) * par;\n    const dy = (-14 * drift + Math.cos(t / 60 + i * 1.7) * 4) * par;\n    // lights gather first, then sharpen: reads as a focus pull, not a swarm\n    const ease = 1 - (1 - focus) ** 2.4;\n    const sharp = focus ** 1.7;\n    const x = sx + (tx - sx) * ease + dx * (1 - ease);\n    const y = sy + (ty - sy) * ease + dy * (1 - ease);\n    const big = (22 + (1 - d) ** 2 * 96) * u * crowd;\n    const small = unit * built.dot;\n    const size = big + (small - big) * sharp;\n    const blur = (big * 0.075 + 2 * u) * (1 - sharp) ** 1.2;\n    const focusColor = interpolateColors(\n      tg.g,\n      [0, 0.5, 1],\n      [HALO[1], HALO[2], HALO[3]],\n    );\n    const color = interpolateColors(\n      sharp,\n      [0.35, 0.95],\n      [p.lights[Math.floor(hash(i * 11) * p.lights.length)], focusColor],\n    );\n    const op = (p.base + (1 - d) * 0.14) * (1 - sharp) + 0.95 * sharp;\n    lights.push(\n      <Light\n        key={`p${i}`}\n        x={x}\n        y={y}\n        size={size}\n        blur={blur}\n        color={color}\n        opacity={op * open * behindTitle}\n        blend={sharp > 0.5 ? \"normal\" : p.blend}\n        shape={shape}\n        rim={theme === \"dark\" ? 0.12 * (1 - focus) : 0}\n      />,\n    );\n  }\n\n  // ambient lights in front of the focal plane: they bloom wider as focus racks back\n  const ambient: React.ReactNode[] = [];\n  for (let i = 0; i < AMBIENT; i++) {\n    const d = hash(i * 13 + 400);\n    const near = 1 - d;\n    const x0 = hash(i * 17 + 401) * width * 1.1 - width * 0.05;\n    const y0 = hash(i * 19 + 402) * height * 1.1 - height * 0.05;\n    const par = (0.6 + near * 1.4) * u;\n    const x = x0 - 90 * drift * par + Math.sin(t / 70 + i * 2.1) * 5 * par;\n    const y = y0 - 20 * drift * par;\n    const size = (40 + near ** 1.6 * 190) * u * (1 + focus * 0.18);\n    const blur = (size * 0.06 + 3 * u) * (1 + focus * 0.6);\n    const tint = hash(i * 23 + 403) < 0.08;\n    const color = tint\n      ? accent\n      : p.lights[Math.floor(hash(i * 29 + 404) * p.lights.length)];\n    const op =\n      (tint ? 0.12 : (0.07 + near * 0.13) * (theme === \"light\" ? 2.6 : 1)) *\n      (1 - focus * 0.35) *\n      open *\n      behindTitle;\n    ambient.push(\n      <Light\n        key={`a${i}`}\n        x={x}\n        y={y}\n        size={size}\n        blur={blur}\n        color={color}\n        opacity={op}\n        blend={p.blend}\n        shape={shape}\n        rim={theme === \"dark\" ? 0.08 : 0}\n      />,\n    );\n  }\n\n  return (\n    <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          transform: `scale(${breathe})`,\n          transformOrigin: \"50% 50%\",\n        }}\n      >\n        {lights}\n        {ambient}\n      </AbsoluteFill>\n\n      {/* a soft pool of shade behind the type keeps it crisp over the lights */}\n      <AbsoluteFill\n        style={{\n          background: `radial-gradient(ellipse 46% 26% at 50% 50%, ${p.titleVeil}, transparent 80%)`,\n          opacity: titleP,\n        }}\n      />\n\n      <AbsoluteFill\n        style={{\n          alignItems: \"center\",\n          justifyContent: \"center\",\n          flexDirection: \"column\",\n          gap: 22 * u,\n          padding: `0 ${width * 0.1}px`,\n        }}\n      >\n        <div\n          style={{\n            fontFamily: serif,\n            fontWeight: 400,\n            fontSize: titleSize,\n            lineHeight: 1,\n            letterSpacing: `${0.08 - titleP * 0.095}em`,\n            color: p.fg,\n            textAlign: \"center\",\n            textWrap: \"balance\",\n            whiteSpace: fitsOneLine ? \"nowrap\" : \"normal\",\n            maxWidth: fitsOneLine ? undefined : width * 0.84,\n            opacity: titleP,\n            filter:\n              titleP < 0.98 ? `blur(${(1 - titleP) * 10 * u}px)` : undefined,\n            transform: `scale(${1.04 - titleP * 0.04})`,\n          }}\n        >\n          {lead ? `${lead} ` : \"\"}\n          <span style={{ fontFamily: serifItalic, fontStyle: \"italic\" }}>\n            {last}\n          </span>\n        </div>\n        {subtitle ? (\n          <div\n            style={{\n              display: \"flex\",\n              alignItems: \"center\",\n              gap: 14 * u,\n              fontFamily: sans,\n              fontWeight: 400,\n              fontSize: 21 * u,\n              letterSpacing: \"-0.005em\",\n              color: p.muted,\n              opacity: subP,\n              transform: `translateY(${(1 - subP) * 10 * u}px)`,\n            }}\n          >\n            {subIsBrand ? (\n              <>\n                <RemocnLogo fontSize={24 * u} color={p.fg} />\n                {subRest.length ? (\n                  <>\n                    <div\n                      style={{\n                        width: Math.max(1, u),\n                        height: 18 * u,\n                        background: p.muted,\n                        opacity: 0.5,\n                      }}\n                    />\n                    <span>{subRest.join(\" · \")}</span>\n                  </>\n                ) : null}\n              </>\n            ) : (\n              <span>{subtitle}</span>\n            )}\n          </div>\n        ) : null}\n      </AbsoluteFill>\n\n      <AbsoluteFill\n        style={{\n          background:\n            theme === \"dark\"\n              ? \"radial-gradient(ellipse 75% 75% at 50% 50%, transparent 55%, rgba(0,0,0,0.5) 100%)\"\n              : \"radial-gradient(ellipse 80% 80% at 50% 50%, transparent 60%, rgba(120,105,85,0.12) 100%)\",\n        }}\n      />\n      <Grain opacity={p.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/bokeh-title.tsx"
    }
  ],
  "type": "registry:component"
}
