{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "escalate-cards",
  "title": "Escalate Cards",
  "description": "Cards flash one word each, accelerating until the last word fills the frame over a date.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/escalate-cards/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/Oswald\";\nimport type React from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily } = loadFont(\"normal\", {\n  weights: [\"300\", \"400\", \"500\"],\n  subsets: [\"latin\"],\n});\n\nexport interface EscalateCardsProps {\n  /** One word per card, smallest first. The last one fills the frame and holds. */\n  words?: string[];\n  /** Small line that cuts in under the last card. Pass \"\" to hide. */\n  date?: string;\n  /** Length of the first card in frames. Every next card is shorter. */\n  firstBeat?: number;\n  /** Each card lasts this share of the one before: below 1 the cuts accelerate. */\n  accel?: number;\n  accent?: string;\n  /** Playback multiplier. */\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\n// Beat sheet (30fps, speed 1, defaults):\n//  0–26    \"ONE\", small and light (300), alone in the middle of the frame\n//  26–42   hard cut: \"CODEBASE\", bigger and a step heavier (400)\n//  42–51   hard cut: \"EVERY\", bigger again; the cuts keep accelerating\n//  51      hard cut to the gradient ground: \"LAUNCH\" edge to edge, its\n//          outer letters cropped by the frame\n//  65      the date cuts in under it; slow push, poster hold to 130\nconst DATE_DELAY = 14;\n/** Frames the default demo needs: the cards plus a long poster hold. */\nexport const ESCALATE_CARDS_DURATION = 130;\n\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\nconst SETTLE = Easing.bezier(0.22, 1, 0.36, 1);\n\nconst THEMES = {\n  /** Dark: the climax cuts to the mesh ground, white type on top. */\n  dark: { bg: \"#0A0A0B\", fg: \"#F5F4F0\", pale: 55, clip: false },\n  /** Light: the stage stays off-white and the mesh fills the letters. */\n  light: { bg: \"#F5F4F0\", fg: \"#0A0A0B\", pale: 18, clip: true },\n} as const;\n\n/** Oswald 500 advance widths (per mille) for ASCII 32–126 (harfbuzz). */\nconst ADV = [\n  243, 233, 315, 511, 488, 950, 587, 149, 319, 295, 411, 433, 213, 314, 217,\n  396, 534, 382, 497, 496, 504, 493, 521, 413, 510, 521, 239, 251, 386, 429,\n  386, 483, 928, 522, 557, 540, 557, 428, 413, 559, 586, 275, 326, 532, 421,\n  683, 545, 563, 527, 564, 561, 494, 430, 566, 516, 712, 499, 487, 425, 336,\n  396, 317, 460, 356, 293, 435, 477, 440, 473, 446, 304, 472, 478, 248, 250,\n  471, 252, 718, 474, 455, 476, 474, 353, 400, 330, 473, 404, 593, 416, 421,\n  370, 338, 251, 351, 465,\n];\n/** Oswald 500 capital pairs that move the most (per mille, tightening). */\nconst KERN = new Map(\n  [\n    \"AT43 AV36 AW23 AY42 BT21 BV24 BX20 BY17 FA35 FJ26 KC21 KG21 KO21 KQ17\",\n    \"LT73 LU14 LV71 LW47 LY86 PA47 PJ26 PZ16 RY19 TA43 TJ26 VA36 WA23 YA42\",\n  ]\n    .join(\" \")\n    .split(\" \")\n    .map((p) => [p.slice(0, 2), -Number(p.slice(2)) / 1000] as const),\n);\nconst CAP = 0.81;\n/** Cap centre inside a line-height: 1 box, in em (ascent 1.193, descent 0.289). */\nconst CAP_MID = 0.547;\n\n/**\n * gradients.sh \"mesh\" palette (bg #0a0d24, [#ecdcf2, #8796ee, #2e45b7,\n * #0e1645]): the climax ground, with the accent in the middle. Blobs\n * drift a few percent over the hold.\n */\nfunction meshGround(drift: number, accent: string, pale: number) {\n  // The palest blob is mixed down so white type over it stays legible.\n  const blobs: Array<[string, number, number]> = [\n    [`color-mix(in oklab, #ecdcf2 ${pale}%, transparent)`, 14, 16],\n    [\"#8796ee\", 86, 24],\n    [\"#2e45b7\", 70, 88],\n    [\"#0e1645\", 22, 82],\n    [accent, 50, 54],\n  ];\n  return [\n    ...blobs.map(\n      ([color, x, y], i) =>\n        `radial-gradient(85% 95% at ${x + drift * (i % 2 ? -4 : 4)}% ${y + drift * (i % 3 ? 3 : -3)}%, ${color} 0%, transparent 68%)`,\n    ),\n    // A solid layer, not a bare colour, so the stack is also a valid background-image.\n    \"linear-gradient(#0a0d24, #0a0d24)\",\n  ].join(\", \");\n}\n\n/**\n * Width in em at 500, tracking between letters. Lighter cuts are narrower,\n * so this is a safe upper bound for them too.\n */\nfunction textWidth(text: string, track: number) {\n  const chars = Array.from(text);\n  let w = 0;\n  chars.forEach((ch, i) => {\n    const code = ch.charCodeAt(0);\n    w += (code >= 32 && code < 127 ? ADV[code - 32] : 680) / 1000;\n    if (i > 0) w += KERN.get(chars[i - 1] + ch) ?? 0;\n  });\n  return w + track * Math.max(0, chars.length - 1);\n}\n\n/**\n * One centred line in a line-height: 1 box; `y` is the cap centre. The left\n * padding cancels the letter-spacing that trails the last glyph.\n */\nfunction Line({\n  y,\n  size,\n  tracking,\n  weight,\n  color,\n  scale,\n  fill,\n  children,\n}: {\n  y: number;\n  size: number;\n  tracking: number;\n  weight: number;\n  color: string;\n  scale: number;\n  /** A frame-sized background painted through the glyphs. */\n  fill?: { image: string; W: number; H: number };\n  children: string;\n}) {\n  const top = y - size * CAP_MID;\n  const paint: React.CSSProperties = fill\n    ? {\n        color: \"transparent\",\n        backgroundImage: fill.image,\n        // The box is twice the frame wide; pin the ground to the frame.\n        backgroundSize: `${fill.W}px ${fill.H}px`,\n        backgroundPosition: `${fill.W / 2}px ${-top}px`,\n        backgroundRepeat: \"no-repeat\",\n        WebkitBackgroundClip: \"text\",\n        backgroundClip: \"text\",\n      }\n    : { color };\n  return (\n    <div\n      style={{\n        position: \"absolute\",\n        left: \"-50%\",\n        right: \"-50%\",\n        top,\n        height: size,\n        textAlign: \"center\",\n        whiteSpace: \"nowrap\",\n        fontFamily,\n        fontWeight: weight,\n        fontSize: size,\n        lineHeight: 1,\n        letterSpacing: `${tracking}em`,\n        paddingLeft: `${tracking}em`,\n        ...paint,\n        fontVariantNumeric: \"tabular-nums\",\n        transform: scale === 1 ? undefined : `scale(${scale})`,\n        transformOrigin: `50% ${CAP_MID * 100}%`,\n      }}\n    >\n      {children}\n    </div>\n  );\n}\n\nexport function EscalateCards({\n  words = [\"ONE\", \"CODEBASE\", \"EVERY\", \"LAUNCH\"],\n  date = \"OCTOBER 30\",\n  firstBeat = 26,\n  accel = 0.6,\n  accent = \"#3B5BFD\",\n  speed = 1,\n  theme = \"dark\",\n}: EscalateCardsProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const c = THEMES[theme];\n  const n = Math.max(1, words.length);\n  const last = n - 1;\n\n  // The climax: the last word set edge to edge, a hair wider than the frame.\n  const lastTrack = -0.02;\n  const lastSize = Math.min(\n    (W * 1.06) / textWidth(words[last] ?? \"\", lastTrack),\n    (H * 0.62) / CAP,\n  );\n\n  // The cards before it grow geometrically from small to half of the climax,\n  // so the last cut is still the biggest jump. Weight climbs 300 → 500.\n  const firstSize = H * 0.07;\n  const peak = lastSize * 0.5;\n  const cards = words.map((text, i) => {\n    const k = last <= 1 ? 1 : i / (last - 1);\n    const climax = i === last;\n    const track = climax ? lastTrack : 0.06 - 0.07 * k;\n    const target = climax ? lastSize : firstSize * (peak / firstSize) ** k;\n    const size = climax\n      ? target\n      : Math.min(target, (W * 0.84) / textWidth(text, track));\n    const weight = climax ? 500 : Math.round(3 + 2 * k) * 100;\n    const length = climax\n      ? Number.POSITIVE_INFINITY\n      : Math.max(4, Math.round(firstBeat * accel ** i));\n    return { text, size, track, weight, length, climax };\n  });\n\n  let start = 0;\n  let active = last;\n  let local = 0;\n  for (let i = 0; i < cards.length; i++) {\n    if (t < start + cards[i].length) {\n      active = i;\n      local = t - start;\n      break;\n    }\n    start += cards[i].length;\n  }\n  const card = cards[active];\n  const settle = card.climax\n    ? interpolate(local, [0, 80], [0, 1], { ...CLAMP, easing: SETTLE })\n    : 0;\n  const mesh = card.climax ? meshGround(settle, accent, c.pale) : \"\";\n  const ground = card.climax && !c.clip ? mesh : c.bg;\n  const ink = card.climax && !c.clip ? \"#FFFFFF\" : c.fg;\n\n  // A hair of drift keeps each card alive without softening the cut; the\n  // climax gets a slow settling push instead.\n  const scale = card.climax\n    ? 1 + 0.045 * settle\n    : 1 + 0.025 * Math.min(1, local / card.length);\n  const showDate = card.climax && date !== \"\" && local >= DATE_DELAY;\n  const titleY = card.climax && date !== \"\" ? H * 0.45 : H * 0.5;\n  const dateSize = H * 0.032;\n\n  return (\n    <AbsoluteFill style={{ background: ground, overflow: \"hidden\" }}>\n      <Line\n        y={titleY}\n        size={card.size}\n        tracking={card.track}\n        weight={card.weight}\n        color={ink}\n        scale={scale}\n        fill={card.climax && c.clip ? { image: mesh, W, H } : undefined}\n      >\n        {card.text}\n      </Line>\n      {showDate ? (\n        <Line\n          y={titleY + (lastSize * CAP * scale) / 2 + H * 0.1}\n          size={dateSize}\n          tracking={0.36}\n          weight={400}\n          color={ink}\n          scale={1}\n        >\n          {date}\n        </Line>\n      ) : null}\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/escalate-cards.tsx"
    }
  ],
  "type": "registry:component"
}
