{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cta-collapse-mark",
  "title": "CTA Collapse Mark",
  "description": "Call-to-action content collapses into the Remocn wordmark over a glowing planet horizon.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "registryDependencies": ["@remocn/gsh"],
  "files": [
    {
      "path": "registry/remocn/cta-collapse-mark/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n  AbsoluteFill,\n  continueRender,\n  delayRender,\n  Easing,\n  interpolate,\n  interpolateColors,\n  random,\n  spring,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/remocn/gsh/gradient-engine\";\nimport { GshGround, gshParams } from \"@/lib/remocn/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/remocn/gsh/presets\";\n\nconst manrope = loadManrope(\"normal\", {\n  weights: [\"300\", \"400\", \"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;\nconst COLS = 12;\nconst BIG = 1.7;\nconst ROWS = 13;\n\nconst ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst LIGHT = Easing.bezier(0.22, 1, 0.36, 1);\nconst MOVE = Easing.bezier(0.65, 0, 0.35, 1);\nconst EXIT = Easing.bezier(0.55, 0, 1, 0.45);\nconst SWAY = Easing.bezier(0.45, 0, 0.55, 1);\nconst HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst LETTER = { mass: 0.6, damping: 14, stiffness: 180 };\n\nconst B = {\n  cta: 0,\n  wordStep: 2,\n  url: 12,\n  shed: 36,\n  shedSpread: 12,\n  drift: 7,\n  travel: 18,\n  merge: 74,\n  snap: 78,\n  word: 84,\n  letterStep: 4,\n  end: 138,\n};\n\nexport const CTA_COLLAPSE_MARK_DURATION = B.end;\n\nconst MEASURE_PX = 100;\n\nconst ramp = (f: number, start: number, dur: number, easing = ENTER) =>\n  interpolate(f, [start, start + dur], [0, 1], {\n    extrapolateLeft: \"clamp\",\n    extrapolateRight: \"clamp\",\n    easing,\n  });\n\nconst mix = (a: number, b: number, t: number) => a + (b - a) * t;\n\ninterface Face {\n  width: (s: string) => number;\n  asc: number;\n  desc: number;\n}\n\ninterface Metrics {\n  cta: Face;\n  logo: Face;\n}\n\nfunction face(\n  ctx: CanvasRenderingContext2D | null,\n  weight: number,\n  fallback: number,\n): Face {\n  const font = `${weight} ${MEASURE_PX}px \"${manrope.fontFamily}\"`;\n  const cache: Record<string, number> = {};\n  let asc = 1.02;\n  let desc = 0.28;\n  if (ctx) {\n    ctx.font = font;\n    const mm = ctx.measureText(\"Hg\");\n    if (mm.fontBoundingBoxAscent) asc = mm.fontBoundingBoxAscent / MEASURE_PX;\n    if (mm.fontBoundingBoxDescent)\n      desc = mm.fontBoundingBoxDescent / MEASURE_PX;\n  }\n  return {\n    width: (s: string) => {\n      if (cache[s] === undefined) {\n        if (!ctx) return s.length * fallback;\n        ctx.font = font;\n        cache[s] = ctx.measureText(s).width / MEASURE_PX;\n      }\n      return cache[s];\n    },\n    asc,\n    desc,\n  };\n}\n\nfunction buildMetrics(_version: number): Metrics {\n  const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n  return { cta: face(ctx, 400, 0.55), logo: face(ctx, 600, 0.6) };\n}\n\nfunction useMetrics() {\n  const [version, setVersion] = useState(0);\n  const [handle] = useState(() => delayRender(\"cta-collapse-mark: measuring\"));\n  const released = useRef(false);\n  useEffect(() => {\n    let live = true;\n    const bump = () => {\n      if (live) setVersion((v) => v + 1);\n    };\n    document.fonts.addEventListener(\"loadingdone\", bump);\n    Promise.all([\n      manrope.waitUntilDone(),\n      document.fonts.load(`400 ${MEASURE_PX}px \"${manrope.fontFamily}\"`),\n      document.fonts.load(`600 ${MEASURE_PX}px \"${manrope.fontFamily}\"`),\n    ])\n      .catch(() => undefined)\n      .then(() => {\n        bump();\n        if (!released.current) {\n          released.current = true;\n          continueRender(handle);\n        }\n      });\n    return () => {\n      live = false;\n      document.fonts.removeEventListener(\"loadingdone\", bump);\n    };\n  }, [handle]);\n  return useMemo(() => buildMetrics(version), [version]);\n}\n\nfunction computeCells(): { c: number; r: number }[] {\n  const ctx = document.createElement(\"canvas\").getContext(\"2d\");\n  const out: { c: number; r: number }[] = [];\n  if (!ctx) return out;\n  const path = new Path2D(REMOCN_R_PATH);\n  const cw = R_W / COLS;\n  const ch = R_H / ROWS;\n  for (let r = 0; r < ROWS; r++) {\n    for (let c = 0; c < COLS; c++) {\n      let hits = 0;\n      for (let sy = 0; sy < 3; sy++) {\n        for (let sx = 0; sx < 3; sx++) {\n          const x = (c + (sx + 0.5) / 3) * cw;\n          const y = (r + (sy + 0.5) / 3) * ch;\n          if (ctx.isPointInPath(path, x, y)) hits++;\n        }\n      }\n      if (hits >= 4) out.push({ c, r });\n    }\n  }\n  return out;\n}\n\nfunction splitLines(words: string[], w: (s: string) => number, two: boolean) {\n  if (!two || words.length < 2) return [words.join(\" \")];\n  let best = 1;\n  let bestW = Number.POSITIVE_INFINITY;\n  for (let i = 1; i < words.length; i++) {\n    const a = w(words.slice(0, i).join(\" \"));\n    const b = w(words.slice(i).join(\" \"));\n    const mx = Math.max(a, b);\n    if (mx < bestW) {\n      bestW = mx;\n      best = i;\n    }\n  }\n  return [words.slice(0, best).join(\" \"), words.slice(best).join(\" \")];\n}\n\ntype Glyph = {\n  ch: string;\n  x: number;\n  base: number;\n  adv: number;\n  size: number;\n  word: number;\n  url: boolean;\n};\n\nexport interface CtaCollapseMarkProps {\n  theme?: \"dark\" | \"light\";\n  accent?: string;\n  cta?: string;\n  url?: string;\n  ground?: GshPresetId;\n  groundParams?: Partial<GradientParams>;\n}\n\nexport function CtaCollapseMark({\n  theme = \"dark\",\n  accent = \"#3B5BFD\",\n  cta = \"Ship your first launch film\",\n  url = \"remocn.dev\",\n  ground,\n  groundParams,\n}: CtaCollapseMarkProps) {\n  const frame = useCurrentFrame();\n  const { width, height, fps } = useVideoConfig();\n  const m = useMetrics();\n  const cells = useMemo(() => computeCells(), []);\n  const dark = theme === \"dark\";\n  const portrait = height > width * 1.2;\n  const stageW = portrait ? 1080 : 1280;\n  const stageH = portrait ? 1920 : 720;\n  const sc = width / stageW;\n\n  const ink = dark ? \"#f2f3f8\" : \"#14161c\";\n  const markColor = dark\n    ? interpolateColors(0.16, [0, 1], [accent, \"#ffffff\"])\n    : accent;\n  const urlColor = dark\n    ? interpolateColors(0.4, [0, 1], [accent, \"#ffffff\"])\n    : accent;\n\n  const cx = stageW / 2;\n  const cy = portrait ? stageH * 0.48 : stageH * 0.5;\n  const F = portrait ? 108 : 72;\n  const U = F * (portrait ? 0.42 : 0.46);\n  const lineGap = F * 1.12;\n\n  const words = cta.split(\" \");\n  const lines = splitLines(words, (s) => m.cta.width(s) * F, portrait);\n  const ctaBlockH = (lines.length - 1) * lineGap + F * 0.72 + U * 1.9;\n  const firstBase = cy - ctaBlockH / 2 + F * 0.72;\n  const glyphs: Glyph[] = [];\n  let wordIdx = 0;\n  lines.forEach((line, li) => {\n    const lw = m.cta.width(line) * F;\n    const x0 = cx - lw / 2;\n    const base = firstBase + li * lineGap;\n    const chars = Array.from(line);\n    chars.forEach((ch, i) => {\n      if (ch === \" \") {\n        wordIdx++;\n        return;\n      }\n      const px = m.cta.width(chars.slice(0, i).join(\"\")) * F;\n      const adv = m.cta.width(ch) * F;\n      glyphs.push({\n        ch,\n        x: x0 + px,\n        base,\n        adv,\n        size: F,\n        word: wordIdx,\n        url: false,\n      });\n    });\n    wordIdx++;\n  });\n  const urlBase = firstBase + (lines.length - 1) * lineGap + U * 1.9;\n  const urlW = m.cta.width(url) * U;\n  Array.from(url).forEach((ch, i, arr) => {\n    glyphs.push({\n      ch,\n      x: cx - urlW / 2 + m.cta.width(arr.slice(0, i).join(\"\")) * U,\n      base: urlBase,\n      adv: m.cta.width(ch) * U,\n      size: U,\n      word: wordIdx,\n      url: true,\n    });\n  });\n\n  const maxDist = Math.max(\n    1,\n    ...glyphs.map((g) => Math.abs(g.x + g.adv / 2 - cx)),\n  );\n  const shedAt = (g: Glyph) =>\n    B.shed +\n    Math.round(\n      (1 - Math.abs(g.x + g.adv / 2 - cx) / maxDist) * B.shedSpread +\n        (g.url ? 2 : 0),\n    );\n\n  const L = portrait ? 196 : 176;\n  const Rh = L * 0.76;\n  const Rw = (Rh * R_W) / R_H;\n  const baseY = cy + Rh / 2;\n  const word = \"emocn\";\n  const wChars = Array.from(word);\n  const wPrefix = wChars.map(\n    (_, i) => m.logo.width(wChars.slice(0, i).join(\"\")) * L,\n  );\n  const wordW = m.logo.width(word) * L;\n  const settle = spring({\n    frame: frame - B.word - 6,\n    fps,\n    config: HEAVY,\n    durationInFrames: 30,\n  });\n  const extra = L * 0.16 * (1 - settle);\n  const reveal = spring({\n    frame: frame - B.word,\n    fps,\n    config: HEAVY,\n    durationInFrames: 26,\n  });\n  const rs = mix(BIG, 1, reveal);\n  const RwS = Rw * rs;\n  const RhS = Rh * rs;\n  const rTop = cy - RhS / 2;\n  const tail = L * 0.04 + wordW - L * 0.025 * 4 + extra * 4;\n  const lockW = RwS + reveal * tail;\n  const lockL = cx - lockW / 2;\n  const letterX = (i: number) =>\n    lockL + RwS + L * 0.04 + wPrefix[i] - L * 0.025 * i + extra * i;\n\n  const cellW = RwS / COLS;\n  const cellH = RhS / ROWS;\n  const sq = Math.min(cellW, cellH);\n  const sortedCells = cells\n    .map((c, i) => ({ ...c, k: i, j: random(`ccm-cell-${i}`) }))\n    .sort((a, b) => a.c + a.j * 0.6 - (b.c + b.j * 0.6));\n  const srcGlyphs = glyphs\n    .map((g, i) => ({ g, i }))\n    .sort((a, b) => a.g.x - b.g.x);\n  const N = sortedCells.length;\n  const G = srcGlyphs.length;\n\n  const merge = ramp(frame, B.merge, 4, MOVE);\n  const snap = ramp(frame, B.snap, 5, LIGHT);\n  const punch = interpolate(\n    frame,\n    [B.snap, B.snap + 2, B.snap + 9],\n    [1, 1.05, 1],\n    { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\", easing: SWAY },\n  );\n  const push = 1 + 0.03 * ramp(frame, 0, B.end, SWAY);\n\n  const ctaFace = manrope.fontFamily;\n  const baseOff = (size: number) =>\n    (size - (m.cta.asc + m.cta.desc) * size) / 2 + m.cta.asc * size;\n  const logoOff = (L - (m.logo.asc + m.logo.desc) * L) / 2 + m.logo.asc * L;\n\n  const resolvedGround: GshPresetId | undefined =\n    ground ?? (dark ? \"earthshine\" : undefined);\n  const resolvedParams: Partial<GradientParams> | undefined =\n    groundParams ??\n    (!dark && !ground\n      ? {\n          kind: \"mist\",\n          colors: [\"#ffffff\", \"#c9d2ff\", \"#8a9cff\", \"#ece8e0\"],\n          background: \"#f2f1ed\",\n          speed: 0.7,\n          loopSeconds: 18,\n          scale: 0.9,\n          warp: 0.35,\n          blur: 0.8,\n          grain: 0.06,\n          seed: 5,\n        }\n      : undefined);\n\n  return (\n    <AbsoluteFill style={{ fontFamily: ctaFace, overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          background: gshParams(resolvedGround, resolvedParams).background,\n        }}\n      >\n        <AbsoluteFill\n          style={{\n            transform:\n              dark && !ground && !groundParams\n                ? `translateY(${portrait ? 16 : 22}%)`\n                : undefined,\n          }}\n        >\n          <GshGround\n            preset={resolvedGround}\n            params={resolvedParams}\n            timeOffset={5}\n            timeScale={0.4}\n          />\n        </AbsoluteFill>\n      </AbsoluteFill>\n      <div\n        style={{\n          position: \"absolute\",\n          left: 0,\n          top: 0,\n          width: stageW,\n          height: stageH,\n          transform: `scale(${sc})`,\n          transformOrigin: \"0 0\",\n          overflow: \"hidden\",\n        }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            transform: `scale(${push * punch})`,\n            transformOrigin: `${cx}px ${cy}px`,\n          }}\n        >\n          {glyphs.map((g, i) => {\n            const enterAt = g.url ? B.url : B.cta + g.word * B.wordStep;\n            const inK = ramp(frame, enterAt, 12, LIGHT);\n            const s0 = shedAt(g);\n            const out = ramp(frame, s0, 10, EXIT);\n            if (out >= 1) return null;\n            const jx = (random(`ccm-gx-${i}`) - 0.5) * g.size * 0.12;\n            const jy = -random(`ccm-gy-${i}`) * g.size * 0.1;\n            return (\n              <span\n                key={`g${i.toString()}`}\n                style={{\n                  position: \"absolute\",\n                  left: g.x,\n                  top: g.base - baseOff(g.size),\n                  fontSize: g.size,\n                  lineHeight: `${g.size}px`,\n                  fontWeight: g.url ? 400 : 300,\n                  letterSpacing: 0,\n                  whiteSpace: \"pre\",\n                  color: g.url ? urlColor : ink,\n                  opacity: inK * (1 - out),\n                  filter:\n                    inK < 0.99 || out > 0.01\n                      ? `blur(${(1 - inK) * 8 + out * 9}px)`\n                      : undefined,\n                  transform: `translate(${jx * out}px, ${(1 - inK) * g.size * 0.32 + jy * out}px) scale(${1 - 0.12 * out})`,\n                }}\n              >\n                {g.ch}\n              </span>\n            );\n          })}\n\n          {sortedCells.map((cell, k) => {\n            const src = srcGlyphs[Math.min(G - 1, Math.floor((k * G) / N))];\n            if (!src) return null;\n            const g = src.g;\n            const s0 = shedAt(g) + (k % 3);\n            if (frame < s0) return null;\n            const r1 = random(`ccm-a-${k}`);\n            const r2 = random(`ccm-b-${k}`);\n            const r3 = random(`ccm-c-${k}`);\n            const ox = g.x + r1 * g.adv;\n            const oy = g.base - r2 * g.size * 0.62;\n            const dx = (r3 - 0.5) * g.size * 0.7;\n            const dy = -(0.2 + r2 * 0.5) * g.size * 0.5;\n            const dr = ramp(frame, s0, B.drift, ENTER);\n            const startT = s0 + 5;\n            const tr = ramp(frame, startT, B.travel + Math.round(r1 * 4), MOVE);\n            const tx = lockL + (cell.c + 0.5) * cellW;\n            const ty = rTop + (cell.r + 0.5) * cellH;\n            const sx = ox + dx * dr;\n            const sy = oy + dy * dr;\n            const arc = Math.sin(Math.PI * tr) * (r3 - 0.5) * g.size * 1.2;\n            const x = mix(sx, tx, tr) + arc * 0.4;\n            const y = mix(sy, ty, tr) - Math.abs(arc) * 0.3;\n            const size = mix(sq * 0.5, sq * mix(0.84, 1.04, merge), tr);\n            const color = interpolateColors(\n              tr,\n              [0, 0.6, 1],\n              [g.url ? urlColor : ink, markColor, markColor],\n            );\n            const vis = ramp(frame, s0, 3, LIGHT) * (1 - snap);\n            const speed = tr > 0.05 && tr < 0.95 ? 1 : 0;\n            return (\n              <div\n                key={`f${cell.k.toString()}`}\n                style={{\n                  position: \"absolute\",\n                  left: x - size / 2,\n                  top: y - size / 2,\n                  width: size,\n                  height: size,\n                  borderRadius: size * 0.12,\n                  background: color,\n                  opacity: vis,\n                  filter: speed ? \"blur(0.6px)\" : undefined,\n                }}\n              />\n            );\n          })}\n\n          <svg\n            viewBox={`0 0 ${R_W} ${R_H}`}\n            width={RwS}\n            height={RhS}\n            style={{\n              position: \"absolute\",\n              left: lockL,\n              top: rTop,\n              opacity: snap,\n            }}\n            aria-hidden\n          >\n            <path fill={markColor} d={REMOCN_R_PATH} />\n          </svg>\n\n          {wChars.map((ch, i) => {\n            const p = spring({\n              frame: frame - B.word - 6 - i * B.letterStep,\n              fps,\n              config: LETTER,\n            });\n            const vis = Math.min(\n              1,\n              ramp(frame, B.word + 6 + i * B.letterStep, 6),\n            );\n            return (\n              <span\n                key={`w${i.toString()}`}\n                style={{\n                  position: \"absolute\",\n                  left: letterX(i),\n                  top: baseY - logoOff,\n                  fontSize: L,\n                  lineHeight: `${L}px`,\n                  fontWeight: 600,\n                  color: ink,\n                  whiteSpace: \"pre\",\n                  opacity: vis,\n                  transform: `translateY(${(1 - p) * L * 0.18}px) scale(${mix(0.82, 1, p)})`,\n                  transformOrigin: \"50% 80%\",\n                  filter: vis < 0.99 ? `blur(${(1 - vis) * 6}px)` : undefined,\n                }}\n              >\n                {ch}\n              </span>\n            );\n          })}\n        </div>\n      </div>\n    </AbsoluteFill>\n  );\n}\n\nexport default CtaCollapseMark;\n",
      "type": "registry:component",
      "target": "components/remocn/cta-collapse-mark.tsx"
    }
  ],
  "type": "registry:component"
}
