{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"t-minus","type":"registry:component","title":"T Minus","description":"A mission clock ticks T-minus with rolling characters, then slams 'LIFTOFF' over a sunrise glow.","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>.","files":[{"path":"components/kuchi/t-minus.tsx","type":"registry:component","target":"components/kuchi/t-minus.tsx","content":"/*! Portions Copyright (c) 2026 Remocn. MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\n\nimport { loadFont } from \"@remotion/google-fonts/IBMPlexMono\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: mono } = loadFont(\"normal\", {\n  weights: [\"400\", \"500\"],\n  subsets: [\"latin\"],\n});\n\nexport interface TMinusProps {\n  /** Seconds on the clock when it starts. */\n  from?: number;\n  /** Frames per counted second (the countdown is compressed). */\n  beat?: number;\n  /** The word that slams in at T–0. Set in caps. */\n  title?: string;\n  /** Small line under the title. Pass \"\" to hide it. */\n  subtitle?: string;\n  /** Telemetry, top left. */\n  stage?: string;\n  /** Telemetry, top right, next to the live pip. */\n  status?: string;\n  /** Live pip and the small accent marks. */\n  accent?: string;\n  /** Text color of the count, title and readouts; overrides the theme. */\n  ink?: string;\n  background?: string;\n  /** Typeface for the count, title and subtitle. Load it yourself; IBM Plex Mono by default. The telemetry stays mono. */\n  fontFamily?: string;\n  /** Strength of the ignition bloom; 0 hides it. */\n  bloom?: number;\n  /** White hit at T–0. */\n  flash?: boolean;\n  /** Size of the count, title and telemetry, around the frame's center. */\n  scale?: number;\n  /** Frames to hold the first frame before anything moves. */\n  delay?: number;\n  grain?: boolean;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\n// Beat sheet (30fps, speed 1, from 10, beat 8):\n//   0–14   \"T–10\" is already up; the edge telemetry boots with a flicker\n//  14–86   one hard cut per counted second, each with a small scale snap; the\n//          small clock above rolls its last digit; from T–3 the bottom of the\n//          frame starts to warm\n//   86     T–0: the bloom fires from the bottom (\"halo\" palette), a white hit\n//   89     LIFTOFF slams in where the number was; the clock flips to\n//          T+00:00:01 and keeps counting up in real seconds\n//  100–    poster: clock, LIFTOFF, subtitle, the bloom breathing at the bottom\nconst FIRST = 14;\nconst SLAM = Easing.bezier(0.22, 1, 0.36, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\n// gradients.sh \"halo\": bg #030306, #fff4ec #ffb36b #e2457a #3d4dff.\nconst HALO = [\"#FFF4EC\", \"#FFB36B\", \"#E2457A\", \"#3D4DFF\"] as const;\n\nconst THEMES = {\n  dark: {\n    stage: \"#050508\",\n    ink: \"#F4F2EE\",\n    dim: \"#76757D\",\n    faint: \"#3A3A42\",\n    title: \"#FFF7F0\",\n    bloomOp: 1,\n    hit: `radial-gradient(130% 110% at 50% 100%, ${HALO[0]} 0%, ${HALO[1]} 30%, ${HALO[2]} 62%, ${HALO[3]} 100%)`,\n    grain: 0.07,\n  },\n  light: {\n    stage: \"#F5F4F0\",\n    ink: \"#121214\",\n    dim: \"#86857F\",\n    faint: \"#C9C7C0\",\n    title: \"#121214\",\n    bloomOp: 0.8,\n    hit: `radial-gradient(130% 110% at 50% 100%, #FFFFFF 0%, ${HALO[0]} 35%, ${HALO[1]} 70%, ${HALO[2]} 100%)`,\n    grain: 0.05,\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\n/** A short hit: up in 1 frame, eases back over `len`. */\nfunction kick(d: number, len: number) {\n  if (d < 0 || d > len + 1) return 0;\n  if (d < 1) return d;\n  const k = 1 - (d - 1) / len;\n  return k * k;\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 pad(n: number) {\n  return String(n).padStart(2, \"0\");\n}\n\n/** \"T–00:00:10\" / \"T+00:00:01\". */\nfunction clockText(sign: \"–\" | \"+\", s: number) {\n  const h = Math.floor(s / 3600);\n  const m = Math.floor((s % 3600) / 60);\n  return `T${sign}${pad(h)}:${pad(m)}:${pad(s % 60)}`;\n}\n\n/** Boot flicker: on, off, on, dim, on — then steady. */\nfunction boot(t: number, at: number) {\n  const d = Math.floor(t - at);\n  if (d < 0) return 0;\n  return [1, 0, 1, 0.35, 1][d] ?? 1;\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n  const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  return (\n    <svg\n      width=\"100%\"\n      height=\"100%\"\n      style={{ position: \"absolute\", inset: 0, opacity }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={7}\n          stitchTiles=\"stitch\"\n        />\n        <feColorMatrix values=\"0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.9 0\" />\n      </filter>\n      <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n    </svg>\n  );\n}\n\n/** One character that rolls up when it changes. Every glyph sits in the same clipped box. */\nfunction RollChar({\n  prev,\n  next,\n  p,\n}: {\n  prev: string;\n  next: string;\n  p: number;\n}) {\n  const rolling = prev !== next && p < 1;\n  return (\n    <span\n      style={{\n        display: \"inline-block\",\n        position: \"relative\",\n        height: \"1.2em\",\n        lineHeight: \"1.2em\",\n        overflow: \"hidden\",\n        verticalAlign: \"top\",\n      }}\n    >\n      <span\n        style={{\n          display: \"block\",\n          transform: rolling ? `translateY(${(1 - p) * 100}%)` : undefined,\n        }}\n      >\n        {next}\n      </span>\n      {rolling ? (\n        <span\n          style={{\n            position: \"absolute\",\n            left: 0,\n            top: 0,\n            transform: `translateY(${-p * 100}%)`,\n          }}\n        >\n          {prev}\n        </span>\n      ) : null}\n    </span>\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 TMinus({\n  from = 10,\n  beat = 8,\n  title = \"Liftoff\",\n  subtitle = \"acme 2.0 is live\",\n  stage = \"Stage 1\",\n  status = \"Go\",\n  accent = \"#3B5BFD\",\n  ink,\n  background,\n  fontFamily = mono,\n  bloom: bloomK = 1,\n  flash = true,\n  scale = 1,\n  delay = 0,\n  grain = true,\n  theme = \"dark\",\n  speed = 1,\n}: TMinusProps) {\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 u = Math.min(W / 1280, H / 720);\n\n  const start = Math.max(1, Math.floor(from));\n  const zeroAt = FIRST + (start - 1) * beat;\n  const liftAt = zeroAt + 3;\n\n  // Countdown value and the frame the current value appeared.\n  const ticks =\n    t < FIRST ? 0 : Math.min(start, 1 + Math.floor((t - FIRST) / beat));\n  const n = start - ticks;\n  const tickAt = ticks === 0 ? 0 : FIRST + (ticks - 1) * beat;\n  const lifted = t >= liftAt;\n\n  // Small clock: counts down with the big one, then up in real seconds.\n  const upS = lifted ? 1 + Math.floor((t - liftAt) / fps) : 0;\n  const upAt = lifted ? liftAt + (upS - 1) * fps : tickAt;\n  const clock = lifted ? clockText(\"+\", upS) : clockText(\"–\", n);\n  const prevClock = lifted\n    ? upS === 1\n      ? clockText(\"–\", 0)\n      : clockText(\"+\", upS - 1)\n    : ticks === 0\n      ? clock\n      : clockText(\"–\", n + 1);\n  const rollP = SLAM(ramp(t, upAt - 1.5, lifted && upS === 1 ? 7 : 4));\n\n  // ── Motion ────────────────────────────────────────────────────────────────\n  const snap = ticks === 0 ? 0 : kick(t - tickAt, 5);\n  const numScale =\n    (1 + 0.045 * snap) * (n === 0 ? 1 + 0.03 * kick(t - zeroAt, 3) : 1);\n  const intro = SLAM(ramp(t, -4, 10));\n\n  const warm = Easing.bezier(\n    0.65,\n    0,\n    0.35,\n    1,\n  )(ramp(t, FIRST + (start - 3) * beat, 3 * beat));\n  const fire = SLAM(ramp(t, zeroAt, 16));\n  const hit = kick(t - zeroAt - 1, 7);\n  const breathe = lifted ? Math.sin((t - liftAt) / 14) * 0.5 + 0.5 : 0;\n\n  const titleIn = SLAM(ramp(t, liftAt, 8));\n  const titleHit = kick(t - (liftAt + 4), 8);\n  const subIn = SLAM(ramp(t, liftAt + 9, 10));\n\n  // ── Layout ────────────────────────────────────────────────────────────────\n  const numFs = 330 * u;\n  const numCY = H / 2 + 22 * u;\n  const titleFs = 210 * u;\n  const titleCY = H / 2 - 4 * u;\n  const clockFs = 34 * u;\n  const clockY = lifted\n    ? interpolate(\n        titleIn,\n        [0, 1],\n        [numCY - numFs * 0.5 - 70 * u, titleCY - titleFs * 0.5 - 62 * u],\n      )\n    : numCY - numFs * 0.5 - 70 * u;\n  const margin = 56 * u;\n\n  // Telemetry values flicker in their last digit.\n  const flick = (k: number, every: number) =>\n    hash(Math.floor(t / every) * 13 + k);\n  const lox = (99.6 + flick(1, 3) * 0.3).toFixed(1);\n  const rp1 = (99.8 + flick(2, 4) * 0.2).toFixed(1);\n  const press = (3.4 + flick(3, 3) * 0.05).toFixed(2);\n  const sinceLift = Math.max(0, t - liftAt) / fps;\n  const kmh = Math.round(sinceLift * sinceLift * 38);\n  const alt = (sinceLift * sinceLift * 0.012).toFixed(2);\n\n  const label: React.CSSProperties = {\n    fontFamily: mono,\n    fontWeight: 400,\n    fontSize: 15 * u,\n    letterSpacing: \"0.14em\",\n    textTransform: \"uppercase\",\n    color: c.dim,\n    lineHeight: 1.6,\n    whiteSpace: \"nowrap\",\n    fontVariantNumeric: \"tabular-nums\",\n  };\n  const value: React.CSSProperties = {\n    color: fg,\n    fontWeight: 500,\n  };\n\n  const bloom = (size: number) =>\n    [\n      `radial-gradient(${size * 0.9}% ${size * 0.62}% at 50% 112%, ${HALO[0]} 0%, ${HALO[1]} 20%, color-mix(in oklab, ${HALO[2]} 85%, transparent) 42%, color-mix(in oklab, ${HALO[3]} 55%, transparent) 66%, transparent 86%)`,\n    ].join(\", \");\n  const bloomSize = interpolate(fire, [0, 1], [26, 100]) + breathe * 4;\n  const bloomOp =\n    bloomK *\n    c.bloomOp *\n    (lifted || t >= zeroAt\n      ? interpolate(fire, [0, 0.4, 1], [0.6, 1, 0.92])\n      : 0);\n\n  const blink = Math.floor(t / 12) % 2 === 0 ? 1 : 0.3;\n\n  return (\n    <AbsoluteFill\n      style={{ background: background ?? c.stage, overflow: \"hidden\" }}\n    >\n      {/* Pre-ignition warmth. */}\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          background: `radial-gradient(60% 34% at 50% 108%, color-mix(in oklab, ${HALO[1]} 70%, transparent) 0%, color-mix(in oklab, ${HALO[2]} 35%, transparent) 45%, transparent 75%)`,\n          opacity: warm * (1 - fire) * (theme === \"dark\" ? 1 : 0.7),\n        }}\n      />\n      {/* The bloom. */}\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          background: bloom(bloomSize),\n          opacity: bloomOp,\n        }}\n      />\n      {grain ? <Grain opacity={c.grain} /> : null}\n\n      <ScaleLayer scale={scale}>\n        {/* Corner telemetry. */}\n        <div\n          style={{\n            ...label,\n            position: \"absolute\",\n            left: margin,\n            top: margin - 8 * u,\n            opacity: boot(t, 2),\n          }}\n        >\n          <div>{stage}</div>\n          <div>\n            Vehicle <span style={value}>{lifted ? \"Ascent\" : \"Pad 39\"}</span>\n          </div>\n        </div>\n        <div\n          style={{\n            ...label,\n            position: \"absolute\",\n            right: margin,\n            top: margin - 8 * u,\n            textAlign: \"right\",\n            opacity: boot(t, 4),\n          }}\n        >\n          <div\n            style={{\n              display: \"flex\",\n              alignItems: \"center\",\n              justifyContent: \"flex-end\",\n              gap: 10 * u,\n            }}\n          >\n            <div\n              style={{\n                width: 8 * u,\n                height: 8 * u,\n                background: accent,\n                opacity: lifted ? 1 : blink,\n              }}\n            />\n            Status <span style={value}>{status}</span>\n          </div>\n          <div>\n            Range <span style={value}>{lifted ? \"Clear\" : \"Green\"}</span>\n          </div>\n        </div>\n        <div\n          style={{\n            ...label,\n            position: \"absolute\",\n            left: margin,\n            bottom: margin - 8 * u,\n            opacity: boot(t, 6),\n          }}\n        >\n          {lifted ? (\n            <>\n              <div>\n                Speed <span style={value}>{kmh}</span> km/h\n              </div>\n              <div>\n                Alt <span style={value}>{alt}</span> km\n              </div>\n            </>\n          ) : (\n            <>\n              <div>\n                LOX <span style={value}>{lox}</span>%\n              </div>\n              <div>\n                RP-1 <span style={value}>{rp1}</span>%\n              </div>\n            </>\n          )}\n        </div>\n        <div\n          style={{\n            ...label,\n            position: \"absolute\",\n            right: margin,\n            bottom: margin - 8 * u,\n            textAlign: \"right\",\n            opacity: boot(t, 8),\n          }}\n        >\n          <div>\n            Tank press <span style={value}>{press}</span> bar\n          </div>\n          <div>\n            Engines <span style={value}>{t >= zeroAt ? \"9 / 9\" : \"Chill\"}</span>\n          </div>\n        </div>\n\n        {/* Small clock. */}\n        <div\n          style={{\n            position: \"absolute\",\n            left: 0,\n            right: 0,\n            top: clockY,\n            display: \"flex\",\n            justifyContent: \"center\",\n            fontFamily: mono,\n            fontWeight: 400,\n            fontSize: clockFs,\n            lineHeight: 1.1,\n            letterSpacing: \"0.06em\",\n            color: lifted ? fg : c.dim,\n            fontVariantNumeric: \"tabular-nums\",\n            opacity: intro,\n          }}\n        >\n          {clock.split(\"\").map((ch, i) => (\n            <RollChar key={i} prev={prevClock[i] ?? ch} next={ch} p={rollP} />\n          ))}\n        </div>\n\n        {/* The big number, hard cut per second. */}\n        {!lifted ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: 0,\n              right: 0,\n              top: numCY - numFs / 2,\n              height: numFs,\n              display: \"flex\",\n              justifyContent: \"center\",\n              alignItems: \"center\",\n              fontFamily,\n              fontWeight: 500,\n              fontSize: numFs,\n              lineHeight: 1,\n              letterSpacing: \"-0.05em\",\n              fontVariantNumeric: \"tabular-nums\",\n              whiteSpace: \"nowrap\",\n              transform: `translateY(${(1 - intro) * 40 * u}px) scale(${numScale})`,\n              opacity: intro,\n            }}\n          >\n            <span style={{ color: c.faint }}>T–</span>\n            <span style={{ color: fg }}>{n}</span>\n          </div>\n        ) : null}\n\n        {/* LIFTOFF. */}\n        <div\n          style={{\n            position: \"absolute\",\n            left: 0,\n            right: 0,\n            top: titleCY - titleFs / 2,\n            height: titleFs,\n            display: \"flex\",\n            justifyContent: \"center\",\n            alignItems: \"center\",\n            fontFamily,\n            fontWeight: 500,\n            fontSize: titleFs,\n            lineHeight: 1,\n            letterSpacing: \"-0.04em\",\n            textTransform: \"uppercase\",\n            whiteSpace: \"nowrap\",\n            color: ink ?? c.title,\n            opacity: lifted ? ramp(titleIn, 0, 0.2) : 0,\n            transform: `scale(${(1.24 - 0.24 * titleIn) * (1 + 0.02 * titleHit)})`,\n          }}\n        >\n          {title}\n        </div>\n        {subtitle ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: 0,\n              right: 0,\n              top: titleCY + titleFs * 0.5 + 18 * u,\n              display: \"flex\",\n              justifyContent: \"center\",\n              fontFamily,\n              fontWeight: 400,\n              fontSize: 30 * u,\n              letterSpacing: \"0.02em\",\n              color: fg,\n              whiteSpace: \"nowrap\",\n              opacity: subIn,\n              transform: `translateY(${(1 - subIn) * 24 * u}px)`,\n            }}\n          >\n            {subtitle}\n          </div>\n        ) : null}\n      </ScaleLayer>\n\n      {/* Ignition hit. */}\n      {flash && hit > 0 ? (\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            background: c.hit,\n            opacity: hit,\n          }}\n        />\n      ) : null}\n    </AbsoluteFill>\n  );\n}\n"}]}