{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "crash-zoom",
  "title": "Crash Zoom",
  "description": "A calm serif tease crash-zooms into a huge gradient '1 DAY.' with speed lines.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "registryDependencies": ["@remocn/gsh"],
  "files": [
    {
      "path": "registry/remocn/crash-zoom/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { loadFont } from \"@remotion/google-fonts/SchibstedGrotesk\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  spring,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/remocn/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/remocn/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/remocn/gsh/presets\";\n\nconst { fontFamily: grotesk } = loadFont(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: serifItalic } = loadSerif(\"italic\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\n\nexport interface CrashZoomProps {\n  /** The calm tease, set in the serif italic. A trailing \"…\" types in dot by dot. */\n  tease?: string;\n  /** The reveal, slammed huge in solid ink. */\n  reveal?: string;\n  /** Line under the reveal. Empty string hides it. */\n  tagline?: string;\n  /** Kept for the shared draft API; the payoff colour comes from the ground. */\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n  /** gradients.sh preset for the ground. Defaults to \"ember\" (dark) or a warm paper mist (light). */\n  ground?: GshPresetId;\n  groundParams?: Partial<GradientParams>;\n}\n\nconst BEAT = {\n  teaseIn: 0,\n  dots: 9,\n  dotGap: 6,\n  crash: 36,\n  crashLen: 6,\n  impact: 42,\n  tag: 54,\n} as const;\n\nconst ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst SOFT = Easing.bezier(0.22, 1, 0.36, 1);\nconst EXIT = Easing.bezier(0.55, 0, 1, 0.45);\nconst CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst LIGHT_GROUND: Partial<GradientParams> = {\n  kind: \"radial-glow\",\n  colors: [\"#fff3e4\", \"#ffb27a\", \"#f2643a\", \"#e889b5\"],\n  background: \"#f5f4f0\",\n  speed: 0.97,\n  loopSeconds: 10,\n  warp: 0.6,\n  blur: 0.7,\n  grain: 0.12,\n  seed: 14,\n};\n\nconst THEMES = {\n  dark: {\n    stage: \"#0A0A0B\",\n    ink: \"#F3F2EF\",\n    lines: \"#F3F2EF\",\n    veil: \"10,10,11\",\n    veilRest: 0.18,\n  },\n  light: {\n    stage: \"#F5F4F0\",\n    ink: \"#121214\",\n    lines: \"#121214\",\n    veil: \"245,244,240\",\n    veilRest: 0.1,\n  },\n} as const;\n\nfunction ramp(t: number, from: number, len: number) {\n  return interpolate(t, [from, from + len], [0, 1], CLAMP);\n}\n\nfunction hash(n: number) {\n  const s = Math.sin(n * 127.1 + 311.7) * 43758.5453;\n  return s - Math.floor(s);\n}\n\nfunction shake(d: number, amp: number, len: number, seed: number) {\n  if (d < 0 || d > len) return { x: 0, y: 0, r: 0 };\n  const k = (1 - d / len) ** 2;\n  return {\n    x: amp * k * Math.sin(d * 2.9 + seed),\n    y: amp * 0.75 * k * Math.cos(d * 3.7 + seed * 1.3),\n    r: 0.5 * k * Math.sin(d * 2.3 + seed * 0.7),\n  };\n}\n\nconst LINE_COUNT = 72;\n\nexport function CrashZoom({\n  tease = \"Wait for it…\",\n  reveal = \"1 DAY.\",\n  tagline = \"to make this video.\",\n  theme = \"dark\",\n  speed = 1,\n  ground,\n  groundParams,\n}: CrashZoomProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H, fps } = useVideoConfig();\n  const c = THEMES[theme];\n  const u = Math.min(W / 1280, H / 720);\n  const inverted = t >= BEAT.impact && t < BEAT.impact + 1;\n\n  const hasDots = tease.endsWith(\"…\");\n  const teaseBody = hasDots ? tease.slice(0, -1) : tease;\n  const teaseIn = ENTER(ramp(t, BEAT.teaseIn, 12));\n  const dots = hasDots\n    ? Math.min(3, Math.max(0, Math.floor((t - BEAT.dots) / BEAT.dotGap) + 1))\n    : 0;\n  const push = interpolate(t, [0, BEAT.crash], [1, 1.28], {\n    ...CLAMP,\n    easing: EXIT,\n  });\n  const crash = ramp(t, BEAT.crash, BEAT.crashLen);\n  const teaseScale = push * (1 + 7 * crash ** 2.2);\n  const teaseBlur = crash > 0 ? 2 + 10 * crash : 0;\n  const teaseOpacity = teaseIn * (1 - ramp(t, BEAT.crash + 3, 3));\n\n  const slam = spring({\n    frame: t - BEAT.impact - 1,\n    fps,\n    config: CARD,\n  });\n  const revealScale = inverted ? 1.14 : 1.14 - 0.14 * slam;\n  const revealBlur = inverted ? 0 : 10 * Math.max(0, 1 - slam * 1.4);\n\n  const rumble = ramp(t, BEAT.crash, BEAT.crashLen);\n  const rx = t < BEAT.impact ? 5 * u * rumble * Math.sin(t * 2.1) : 0;\n  const ry = t < BEAT.impact ? 4 * u * rumble * Math.cos(t * 2.7) : 0;\n  const hit = shake(t - BEAT.impact, 14 * u, 12, 1.7);\n\n  const linesIn = ramp(t, BEAT.crash + 1, BEAT.crashLen - 1) ** 1.4;\n  const linesBack = SOFT(ramp(t, BEAT.impact + 1, 20));\n  const reach = t < BEAT.impact ? 1.9 - 0.9 * linesIn : 1 + 0.18 * linesBack;\n  const linesAlpha =\n    t < BEAT.impact ? 0.55 * linesIn : 0.55 - (0.55 - 0.1) * linesBack;\n  const cx = W / 2;\n  const cy = H / 2;\n  const far = Math.hypot(W, H) * 0.75;\n  const lines: string[] = [];\n  for (let i = 0; i < LINE_COUNT; i++) {\n    const a =\n      (i / LINE_COUNT) * Math.PI * 2 +\n      (hash(i) - 0.5) * ((Math.PI * 2) / LINE_COUNT) * 0.9;\n    const near = 1 + 0.35 * hash(i + 91);\n    const rxIn = 0.44 * W * near * reach;\n    const ryIn = 0.36 * H * near * reach;\n    const half = (1.5 + 6 * hash(i + 37)) * u;\n    const ca = Math.cos(a);\n    const sa = Math.sin(a);\n    const ox = cx + far * ca;\n    const oy = cy + far * sa;\n    const tipX = cx + rxIn * ca;\n    const tipY = cy + ryIn * sa;\n    lines.push(\n      `M${(ox - sa * half).toFixed(1)} ${(oy + ca * half).toFixed(1)}L${(ox + sa * half).toFixed(1)} ${(oy - ca * half).toFixed(1)}L${tipX.toFixed(1)} ${tipY.toFixed(1)}Z`,\n    );\n  }\n\n  const bloom = ENTER(ramp(t, BEAT.impact, 18));\n  const veil = t < BEAT.impact ? 0.9 : 0.9 - (0.9 - c.veilRest) * bloom;\n  const groundScale = 1.12 - 0.12 * bloom + 0.03 * ramp(t, BEAT.impact, 80);\n\n  const revealFs = Math.min(0.5 * H, (0.84 * W) / (0.43 * reveal.length));\n  const teaseFs = Math.min(0.1 * H, 0.085 * W);\n  const tagFs = Math.min(0.075 * H, 0.062 * W);\n  const tagIn = ENTER(ramp(t, BEAT.tag, 12));\n\n  const teaseText = (scale: number, opacity: number, key: string) => (\n    <div\n      key={key}\n      style={{\n        position: \"absolute\",\n        inset: 0,\n        display: \"flex\",\n        alignItems: \"center\",\n        justifyContent: \"center\",\n        transform: `translateY(${(1 - teaseIn) * 0.04 * H}px) scale(${scale})`,\n        filter:\n          teaseBlur > 0.2\n            ? `blur(${(teaseBlur * u) / scale}px)`\n            : `blur(${(1 - teaseIn) * 6 * u}px)`,\n        opacity,\n      }}\n    >\n      <div\n        style={{\n          fontFamily: serifItalic,\n          fontStyle: \"italic\",\n          fontWeight: 400,\n          fontSize: teaseFs,\n          lineHeight: 1,\n          letterSpacing: \"-0.01em\",\n          color: c.ink,\n          whiteSpace: \"nowrap\",\n        }}\n      >\n        {teaseBody}\n        {hasDots ? (\n          <span\n            style={{\n              display: \"inline-block\",\n              clipPath: `inset(-20% ${100 - (dots / 3) * 100}% -20% 0)`,\n            }}\n          >\n            …\n          </span>\n        ) : null}\n      </div>\n    </div>\n  );\n\n  return (\n    <AbsoluteFill\n      style={{\n        background: inverted ? c.ink : c.stage,\n        overflow: \"hidden\",\n      }}\n    >\n      {!inverted ? (\n        <>\n          <AbsoluteFill style={{ transform: `scale(${groundScale})` }}>\n            <GshGround\n              preset={ground ?? (theme === \"dark\" ? \"ember\" : undefined)}\n              params={\n                groundParams ?? (theme === \"light\" ? LIGHT_GROUND : undefined)\n              }\n              timeOffset={2.4}\n              timeScale={0.5}\n            />\n          </AbsoluteFill>\n          <AbsoluteFill style={{ background: `rgba(${c.veil},${veil})` }} />\n        </>\n      ) : null}\n\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          transform: `translate(${rx + hit.x}px, ${ry + hit.y}px) rotate(${hit.r}deg)`,\n          transformOrigin: \"50% 50%\",\n        }}\n      >\n        {linesAlpha > 0.01 ? (\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            <path\n              d={lines.join(\"\")}\n              fill={inverted ? c.stage : c.lines}\n              opacity={inverted ? 0.8 : linesAlpha}\n            />\n          </svg>\n        ) : null}\n\n        {t < BEAT.impact ? (\n          <>\n            {crash > 0.02\n              ? [5, 4, 3, 2, 1].map((k) =>\n                  teaseText(\n                    teaseScale * (1 + 0.07 * k * crash),\n                    (teaseOpacity * 0.5) / (1 + 0.6 * k),\n                    `ghost-${k}`,\n                  ),\n                )\n              : null}\n            {teaseText(teaseScale, teaseOpacity, \"tease\")}\n          </>\n        ) : (\n          <div\n            style={{\n              position: \"absolute\",\n              inset: 0,\n              display: \"flex\",\n              flexDirection: \"column\",\n              alignItems: \"center\",\n              justifyContent: \"center\",\n            }}\n          >\n            <div\n              style={{\n                fontFamily: grotesk,\n                fontWeight: 400,\n                fontSize: revealFs,\n                lineHeight: 0.9,\n                letterSpacing: \"-0.05em\",\n                whiteSpace: \"nowrap\",\n                color: inverted ? c.stage : c.ink,\n                transform: `scale(${revealScale})`,\n                filter:\n                  revealBlur > 0.2 ? `blur(${revealBlur * u}px)` : undefined,\n              }}\n            >\n              {reveal}\n            </div>\n            {tagline ? (\n              <div\n                style={{\n                  marginTop: 0.035 * H,\n                  fontFamily: serifItalic,\n                  fontStyle: \"italic\",\n                  fontWeight: 400,\n                  fontSize: tagFs,\n                  lineHeight: 1,\n                  color: c.ink,\n                  whiteSpace: \"nowrap\",\n                  opacity: inverted ? 0 : tagIn,\n                  transform: `translateY(${(1 - tagIn) * 0.03 * H}px)`,\n                  filter: `blur(${(1 - tagIn) * 6 * u}px)`,\n                }}\n              >\n                {tagline}\n              </div>\n            ) : null}\n          </div>\n        )}\n      </div>\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/crash-zoom.tsx"
    }
  ],
  "type": "registry:component"
}
