{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"hook-punch","type":"registry:component","title":"Hook Punch","description":"A two-beat hook stops the scroll, then a gradient payoff lands: 'This video took 1 day.'.","dependencies":["remotion","@remotion/google-fonts"],"docs":"Needs a Remotion project. If a frame renders black, the component is drawing on a transparent layer: put a background behind it, e.g. <AbsoluteFill style={{ background: \"#faf9f6\" }}><Component /></AbsoluteFill>.","registryDependencies":["https://kuchi.kalarislabs.com/r/gradient-ground.json"],"files":[{"path":"components/kuchi/hook-punch.tsx","type":"registry:component","target":"components/kuchi/hook-punch.tsx","content":"/*! Portions Copyright (c) 2026 Remocn. MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/BricolageGrotesque\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport type React from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  spring,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/kuchi/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/kuchi/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/kuchi/gsh/presets\";\n\nconst { fontFamily: grotesk } = loadFont(\"normal\", {\n  weights: [\"300\", \"400\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: serifItalic } = loadSerif(\"italic\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\n\nexport interface HookPunchProps {\n  /** First beat, set in the grotesk. */\n  stop?: string;\n  /** Second word of the first beat, set in the serif italic. */\n  scroll?: string;\n  /** Lead-in of the second beat. */\n  lead?: string;\n  /** The payoff, slammed huge. */\n  payoff?: string;\n  /** Kept for the shared draft API; the colour comes from the ground. */\n  accent?: string;\n  /** Text color; overrides the theme ink. */\n  ink?: string;\n  /** Solid fill in place of the gradient ground; \"transparent\" drops it. */\n  background?: string;\n  /** Typeface for the grotesk words. Load it yourself; Bricolage Grotesque by default. */\n  fontFamily?: string;\n  /** Frames the first beat holds before the whip to the payoff. */\n  hold?: number;\n  /** Size of the words, around the frame's center. */\n  scale?: number;\n  /** Frames to hold the first frame before anything moves. */\n  delay?: number;\n  theme?: \"dark\" | \"light\";\n  /** gradients.sh preset id for the ground. */\n  ground?: GshPresetId;\n  /** Overrides for the ground shader. */\n  groundParams?: Partial<GradientParams>;\n  speed?: number;\n}\n\nconst BEATS = {\n  stop: 0,\n  scroll: 6,\n  whip: 30,\n  whipLen: 8,\n  lead: 33,\n  pay: 42,\n  rise: 43,\n} as const;\n\nconst EXIT = Easing.bezier(0.55, 0, 1, 0.45);\nconst LIGHT = Easing.bezier(0.22, 1, 0.36, 1);\nconst CAMERA = Easing.bezier(0.87, 0, 0.13, 1);\nconst HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    stage: \"#03040A\",\n    ink: \"#F2F3F8\",\n    preset: \"cobalt-rise\" as GshPresetId,\n    params: undefined as Partial<GradientParams> | undefined,\n    veilFrom: 0.86,\n    veilTo: 0.34,\n  },\n  light: {\n    stage: \"#EEF0F6\",\n    ink: \"#0E1230\",\n    preset: \"paper-crease\" as GshPresetId,\n    params: undefined as Partial<GradientParams> | undefined,\n    veilFrom: 0.8,\n    veilTo: 0.22,\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 kick(d: number) {\n  if (d < 0) return 0;\n  if (d < 2) return d / 2;\n  const k = Math.max(0, 1 - (d - 2) / 8);\n  return k * k;\n}\n\nfunction shake(d: number, amp: number, seed: number) {\n  if (d < 0 || d > 7) return { x: 0, y: 0 };\n  const k = (1 - d / 7) ** 2;\n  return {\n    x: amp * k * Math.sin(d * 2.7 + seed),\n    y: amp * 0.7 * k * Math.cos(d * 3.3 + seed * 1.7),\n  };\n}\n\n/** The foreground at `scale`, around the frame's center; nothing extra at 1. */\nfunction ScaleLayer({\n  scale,\n  children,\n}: {\n  scale: number;\n  children: React.ReactNode;\n}) {\n  if (scale === 1) return children;\n  return (\n    <AbsoluteFill style={{ transform: `scale(${scale})` }}>\n      {children}\n    </AbsoluteFill>\n  );\n}\n\nexport function HookPunch({\n  stop = \"Stop\",\n  scroll = \"scrolling.\",\n  lead = \"This video took\",\n  payoff = \"1 day.\",\n  ink,\n  background,\n  fontFamily = grotesk,\n  hold = BEATS.whip,\n  scale = 1,\n  delay = 0,\n  theme = \"dark\",\n  ground,\n  groundParams,\n  speed = 1,\n}: HookPunchProps) {\n  const t = Math.max(0, useCurrentFrame() - delay) * speed;\n  const { width: W, height: H, fps } = useVideoConfig();\n  const c = THEMES[theme];\n  const stage =\n    background === undefined\n      ? c.stage\n      : background === \"transparent\"\n        ? \"transparent\"\n        : background;\n  const shift = hold - BEATS.whip;\n  const beats = {\n    ...BEATS,\n    whip: BEATS.whip + shift,\n    lead: BEATS.lead + shift,\n    pay: BEATS.pay + shift,\n    rise: BEATS.rise + shift,\n  };\n  const tall = H > W;\n  const base = tall ? W * 0.56 : H;\n  const u = Math.min(W / 1280, H / 720);\n\n  const slam = (at: number, from: number) => {\n    const p = spring({ frame: t - at, fps, config: CARD });\n    return {\n      scale: from + (1 - from) * p,\n      blur: Math.max(0, 1 - p) ** 2 * 18,\n      opacity: ramp(t, at - 1, 2),\n    };\n  };\n\n  const bump = Math.max(\n    kick(t - beats.stop - 4),\n    kick(t - beats.scroll - 4),\n    1.3 * kick(t - beats.pay - 4),\n  );\n  const s1 = shake(t - beats.stop - 4, 6 * u, 0.4);\n  const s2 = shake(t - beats.scroll - 4, 5 * u, 2.1);\n  const s3 = shake(t - beats.pay - 4, 8 * u, 4.2);\n  const camScale = 1 + 0.03 * bump;\n\n  const pStop = slam(beats.stop, 1.5);\n  const pScroll = slam(beats.scroll, 1.5);\n  const shove = 1 - spring({ frame: t - beats.scroll, fps, config: HEAVY });\n  const creep1 = interpolate(t, [beats.scroll + 6, beats.whip], [1, 1.04], {\n    ...CLAMP,\n    easing: CAMERA,\n  });\n  const whip = EXIT(ramp(t, beats.whip, beats.whipLen));\n  const line1Scale = creep1 * (1 + 1.6 * whip);\n  const line1Blur = 22 * whip;\n  const line1Opacity = 1 - ramp(t, beats.whip + 3, beats.whipLen - 3);\n\n  const lead2 = spring({ frame: t - beats.lead, fps, config: HEAVY });\n  const leadScale = 0.6 + 0.4 * lead2;\n  const leadBlur = Math.max(0, 1 - lead2) * 16;\n  const leadOpacity = ramp(t, beats.lead, 3);\n  const pPay = slam(beats.pay, 1.6);\n  const creep2 = interpolate(t, [beats.pay + 6, beats.pay + 62], [1, 1.035], {\n    ...CLAMP,\n    easing: CAMERA,\n  });\n\n  const rise = LIGHT(ramp(t, beats.rise, 26));\n  const veil = c.veilFrom + (c.veilTo - c.veilFrom) * rise;\n  const groundShift = (0.06 + (1 - rise) * 0.14) * H;\n\n  const bigFs = 0.43 * base;\n  const leadFs = 0.11 * base;\n  const payFs = 0.56 * base;\n\n  const word = (\n    text: string,\n    family: string,\n    fs: number,\n    p: { scale: number; blur: number; opacity: number },\n    extra: React.CSSProperties = {},\n  ) => (\n    <div\n      style={{\n        fontFamily: family,\n        fontSize: fs,\n        lineHeight: 0.86,\n        whiteSpace: \"nowrap\",\n        transform: `scale(${p.scale})`,\n        filter: p.blur > 0.2 ? `blur(${p.blur * u}px)` : undefined,\n        opacity: p.opacity,\n        ...extra,\n      }}\n    >\n      {text}\n    </div>\n  );\n\n  return (\n    <AbsoluteFill style={{ background: stage, overflow: \"hidden\" }}>\n      {background === undefined ? (\n        <>\n          <AbsoluteFill\n            style={{\n              top: -0.3 * H,\n              height: 1.55 * H,\n              transform: `translateY(${groundShift - 0.25 * H}px) scale(1.06)`,\n            }}\n          >\n            <GshGround\n              preset={ground ?? c.preset}\n              params={groundParams ?? c.params}\n              timeOffset={3}\n              timeScale={0.5}\n            />\n          </AbsoluteFill>\n          <AbsoluteFill style={{ background: c.stage, opacity: veil }} />\n        </>\n      ) : null}\n\n      <ScaleLayer scale={scale}>\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            transform: `translate(${s1.x + s2.x + s3.x}px, ${s1.y + s2.y + s3.y}px) scale(${camScale})`,\n            transformOrigin: \"50% 50%\",\n            color: ink ?? c.ink,\n          }}\n        >\n          {t < beats.whip + beats.whipLen ? (\n            <div\n              style={{\n                position: \"absolute\",\n                inset: 0,\n                display: \"flex\",\n                flexDirection: \"column\",\n                alignItems: \"center\",\n                justifyContent: \"center\",\n                gap: 0.01 * base,\n                transform: `scale(${line1Scale})`,\n                filter:\n                  line1Blur > 0.2 ? `blur(${line1Blur * u}px)` : undefined,\n                opacity: line1Opacity,\n              }}\n            >\n              <div\n                style={{\n                  transform: `translateY(${shove * 0.5 * (bigFs * 1.06 * 0.86 + 0.01 * base)}px)`,\n                }}\n              >\n                {word(stop, fontFamily, bigFs, pStop, {\n                  fontWeight: 400,\n                  letterSpacing: \"-0.05em\",\n                  paddingRight: 0.02 * W,\n                })}\n              </div>\n              {word(scroll, serifItalic, bigFs * 1.06, pScroll, {\n                fontStyle: \"italic\",\n                fontWeight: 400,\n                letterSpacing: \"-0.03em\",\n                paddingLeft: (tall ? 0.03 : 0.06) * W,\n              })}\n            </div>\n          ) : null}\n\n          {t >= beats.lead ? (\n            <div\n              style={{\n                position: \"absolute\",\n                inset: 0,\n                display: \"flex\",\n                flexDirection: \"column\",\n                alignItems: \"center\",\n                justifyContent: \"center\",\n                transform: `scale(${creep2})`,\n              }}\n            >\n              <div\n                style={{\n                  fontFamily,\n                  fontWeight: 300,\n                  fontSize: leadFs,\n                  lineHeight: 1,\n                  letterSpacing: \"-0.03em\",\n                  whiteSpace: \"nowrap\",\n                  transform: `scale(${leadScale})`,\n                  filter:\n                    leadBlur > 0.2 ? `blur(${leadBlur * u}px)` : undefined,\n                  opacity: leadOpacity,\n                  marginBottom: 0.02 * base,\n                }}\n              >\n                {lead}\n              </div>\n              <div style={{ height: payFs * 0.92 }}>\n                {t >= beats.pay - 1\n                  ? word(payoff, fontFamily, payFs, pPay, {\n                      fontWeight: 400,\n                      lineHeight: 1,\n                      letterSpacing: \"-0.055em\",\n                      paddingRight: 0.03 * payFs,\n                    })\n                  : null}\n              </div>\n            </div>\n          ) : null}\n        </div>\n      </ScaleLayer>\n    </AbsoluteFill>\n  );\n}\n"}]}