{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"pov-setup","type":"registry:component","title":"POV Setup","description":"A 'POV:' setup line slides in word by word, then a serif italic punchline lands.","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/pov-setup.tsx","type":"registry:component","target":"components/kuchi/pov-setup.tsx","content":"/*! Portions Copyright (c) 2026 Remocn. MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\n\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport { loadFont } from \"@remotion/google-fonts/Sora\";\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: sora } = 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 PovSetupProps {\n  /** The format label. */\n  label?: string;\n  /** The setup line; words slide in one by one. */\n  setup?: string;\n  /** Lead-in of the punchline, set in the serif italic. */\n  lead?: string;\n  /** The key word of the punchline. */\n  punch?: 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 label, setup and punch word. Load it yourself; Sora by default. */\n  fontFamily?: string;\n  /** Frames between setup words. */\n  stagger?: number;\n  /** Frame the punchline lands. */\n  punchAt?: number;\n  /** Size of the copy, 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  pov: 0,\n  shrink: 6,\n  setup: 10,\n  wordGap: 3,\n  wordLen: 12,\n  punch: 54,\n  lift: 54,\n  rise: 56,\n} as const;\n\nconst ENTER = Easing.bezier(0.32, 0.72, 0, 1);\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 CHIP = { mass: 0.5, damping: 12, stiffness: 200 };\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    stage: \"#0A0807\",\n    ink: \"#F4F1EC\",\n    preset: \"hearth\" as GshPresetId,\n    params: undefined as Partial<GradientParams> | undefined,\n    veilFrom: 0.9,\n    veilTo: 0.18,\n  },\n  light: {\n    stage: \"#F2EEE8\",\n    ink: \"#17120E\",\n    preset: \"paper-crease\" as GshPresetId,\n    params: {\n      colors: [\"#FF8A3A\", \"#FFC79A\", \"#F6E2CF\", \"#5A2410\"],\n      background: \"#F2EEE8\",\n    } as Partial<GradientParams>,\n    veilFrom: 0.78,\n    veilTo: 0.12,\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 > 8) return { x: 0, y: 0 };\n  const k = (1 - d / 8) ** 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 PovSetup({\n  label = \"POV:\",\n  setup = \"you shipped the launch video before standup\",\n  lead = \"and it\",\n  punch = \"slaps.\",\n  ink,\n  background,\n  fontFamily = sora,\n  stagger = BEATS.wordGap,\n  punchAt = BEATS.punch,\n  scale = 1,\n  delay = 0,\n  theme = \"dark\",\n  ground,\n  groundParams,\n  speed = 1,\n}: PovSetupProps) {\n  const t = Math.max(0, useCurrentFrame() - delay) * speed;\n  const { width: W, height: H, fps } = useVideoConfig();\n  const c = THEMES[theme];\n  const fg = ink ?? c.ink;\n  const stage =\n    background === undefined\n      ? c.stage\n      : background === \"transparent\"\n        ? \"transparent\"\n        : background;\n  const shift = punchAt - BEATS.punch;\n  const beats = {\n    ...BEATS,\n    wordGap: stagger,\n    punch: BEATS.punch + shift,\n    lift: BEATS.lift + shift,\n    rise: BEATS.rise + shift,\n  };\n  const tall = H > W;\n  const base = tall ? W * 0.75 : H;\n  const u = Math.min(W / 1280, H / 720);\n\n  const words = setup.split(/\\s+/).filter(Boolean);\n\n  const pov = spring({ frame: t - beats.pov, fps, config: CHIP });\n  const shrink = spring({ frame: t - beats.shrink, fps, config: HEAVY });\n  const lift = spring({ frame: t - beats.lift, fps, config: HEAVY });\n  const p = spring({ frame: t - beats.punch, fps, config: CARD });\n  const punchOn = t >= beats.punch;\n\n  const bump = Math.max(\n    0.5 * kick(t - beats.pov - 4),\n    1.2 * kick(t - beats.punch - 4),\n  );\n  const hit = shake(t - beats.punch - 4, 8 * u, 2.3);\n  const creep = interpolate(t, [beats.setup, beats.punch + 70], [1, 1.035], {\n    ...CLAMP,\n    easing: CAMERA,\n  });\n  const camScale = creep * (1 + 0.03 * bump);\n\n  const povScale = 1.4 - 0.4 * pov;\n  const povBlur = Math.max(0, 1 - pov) * 10;\n  const punchScale = 1.5 - 0.5 * p;\n  const punchBlur = Math.max(0, 1 - p) * 14;\n  const punchTilt = -4 * (1 - p);\n  const stepBack = LIGHT(ramp(t, beats.punch, 12));\n  const setupOpacity = 1 - 0.55 * stepBack;\n\n  const rise = LIGHT(ramp(t, beats.rise, 30));\n  const veil = c.veilFrom + (c.veilTo - c.veilFrom) * rise;\n  const groundShift = (1 - rise) * 0.14 * H;\n\n  const labelFs = 0.075 * base;\n  const setupFs = (tall ? 0.105 : 0.1) * base;\n  const punchFs = 0.3 * base;\n  const left = (tall ? 0.08 : 0.085) * W;\n  const setupWidth = W - 2 * left;\n\n  const POV_BIG = 3.2;\n  const labelGap = 0.035 * base;\n  const punchGap = 0.045 * base;\n  const setupLines = Math.max(\n    1,\n    Math.ceil((setup.length * 0.54 * setupFs) / setupWidth),\n  );\n  const punchLines = tall ? 2 : 1;\n  const labelH = labelFs + labelGap;\n  const setupH = setupLines * setupFs * 1.12;\n  const punchH = punchLines * punchFs * 1.02 + punchGap;\n  const top0 = (H - labelFs * POV_BIG) / 2;\n  const top1 = (H - labelH - setupH) / 2;\n  const top2 = (H - labelH - setupH - punchH) / 2;\n  const blockTop = top0 + (top1 - top0) * shrink + (top2 - top1) * lift;\n  const labelScale = POV_BIG - (POV_BIG - 1) * shrink;\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.08)`,\n            }}\n          >\n            <GshGround\n              preset={ground ?? c.preset}\n              params={groundParams ?? c.params}\n              timeOffset={4}\n              timeScale={0.45}\n            />\n          </AbsoluteFill>\n          <AbsoluteFill\n            style={{\n              background: `linear-gradient(180deg, ${c.stage} 0%, ${c.stage} 38%, transparent 100%)`,\n              opacity: veil,\n            }}\n          />\n          <AbsoluteFill style={{ background: c.stage, opacity: veil * 0.55 }} />\n        </>\n      ) : null}\n\n      <ScaleLayer scale={scale}>\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            transform: `translate(${hit.x}px, ${hit.y}px) scale(${camScale})`,\n            transformOrigin: \"30% 50%\",\n          }}\n        >\n          <div\n            style={{\n              position: \"absolute\",\n              left,\n              right: left,\n              top: blockTop,\n              display: \"flex\",\n              flexDirection: \"column\",\n              alignItems: \"flex-start\",\n            }}\n          >\n            <div\n              style={{\n                fontFamily,\n                fontWeight: 400,\n                fontSize: labelFs,\n                lineHeight: 1,\n                letterSpacing: \"-0.01em\",\n                color: fg,\n                transform: `scale(${povScale * labelScale})`,\n                transformOrigin: \"0% 0%\",\n                height: labelFs,\n                filter: povBlur > 0.2 ? `blur(${povBlur * u}px)` : undefined,\n                opacity: ramp(t, beats.pov - 1, 2),\n                marginBottom: labelGap,\n              }}\n            >\n              {label}\n            </div>\n\n            <div\n              style={{\n                fontFamily,\n                fontWeight: 300,\n                fontSize: setupFs,\n                lineHeight: 1.12,\n                letterSpacing: \"-0.035em\",\n                color: fg,\n                maxWidth: setupWidth,\n                opacity: setupOpacity,\n              }}\n            >\n              {words.map((w, i) => {\n                const at = beats.setup + i * beats.wordGap;\n                const k = ENTER(ramp(t, at, beats.wordLen));\n                return (\n                  <span\n                    key={i}\n                    style={{\n                      display: \"inline-block\",\n                      overflow: \"hidden\",\n                      verticalAlign: \"top\",\n                      paddingBottom: \"0.14em\",\n                      marginBottom: \"-0.14em\",\n                      marginRight: i < words.length - 1 ? \"0.24em\" : 0,\n                    }}\n                  >\n                    <span\n                      style={{\n                        display: \"inline-block\",\n                        transform: `translateY(${(1 - k) * 105}%)`,\n                        opacity: ramp(t, at, 4),\n                      }}\n                    >\n                      {w}\n                    </span>\n                  </span>\n                );\n              })}\n            </div>\n\n            <div\n              style={{\n                height: punchLines * punchFs * 1.02,\n                marginTop: punchGap,\n                display: \"flex\",\n                alignItems: \"flex-end\",\n              }}\n            >\n              {punchOn ? (\n                <div\n                  style={{\n                    display: \"flex\",\n                    flexDirection: tall ? \"column\" : \"row\",\n                    alignItems: tall ? \"flex-start\" : \"baseline\",\n                    whiteSpace: \"nowrap\",\n                    transform: `rotate(${punchTilt}deg) scale(${punchScale})`,\n                    transformOrigin: \"0% 70%\",\n                    filter:\n                      punchBlur > 0.2 ? `blur(${punchBlur * u}px)` : undefined,\n                    opacity: ramp(t, beats.punch, 2),\n                    color: fg,\n                  }}\n                >\n                  <span\n                    style={{\n                      fontFamily: serifItalic,\n                      fontStyle: \"italic\",\n                      fontWeight: 400,\n                      fontSize: punchFs * 1.04,\n                      lineHeight: 1,\n                      letterSpacing: \"-0.03em\",\n                      marginRight: \"0.14em\",\n                    }}\n                  >\n                    {lead}\n                  </span>\n                  <span\n                    style={{\n                      fontFamily,\n                      fontWeight: 400,\n                      fontSize: punchFs,\n                      lineHeight: 1,\n                      letterSpacing: \"-0.06em\",\n                      paddingRight: \"0.04em\",\n                    }}\n                  >\n                    {punch}\n                  </span>\n                </div>\n              ) : null}\n            </div>\n          </div>\n        </div>\n      </ScaleLayer>\n    </AbsoluteFill>\n  );\n}\n"}]}