{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"roster-grant","type":"registry:component","title":"Roster Grant","description":"Access granted animation: a cursor clicks a CTA and team avatars switch on. Three rows of roster cards stream past a call to action, a pointer walks in and clicks it, and the monograms start turning to the accent one every seven frames — top row, middle, bottom, top, bottom, middle, so it reads as a system granting rather than a list iterating.","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>. Pass mode=\"dark\" for dark frames.","registryDependencies":["https://kuchi.kalarislabs.com/r/kuchi-ui.json"],"files":[{"path":"components/kuchi/roster-grant.tsx","type":"registry:component","target":"components/kuchi/roster-grant.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport { loadFont as loadSans } from \"@remotion/google-fonts/Inter\";\r\nimport { type CSSProperties, forwardRef, type ReactNode, useMemo } from \"react\";\r\nimport {\r\n  AbsoluteFill,\r\n  getRemotionEnvironment,\r\n  interpolate,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\nimport {\r\n  Item,\r\n  mixOklch,\r\n  parseColor,\r\n  resolveFont,\r\n  type KuchiTheme,\r\n  useKuchiTheme,\r\n  withAlpha,\r\n} from \"@/lib/kuchi-ui\";\r\n\r\n/**\r\n * Three rows of roster cards drifting past a pill, a pointer that clicks it,\r\n * and then the roster lighting up one card at a time.\r\n *\r\n * It is the \"and everyone gets it\" shot: the outer rows stream in opposite\r\n * directions, the middle row parts around a single call to action, a pointer\r\n * walks in and presses it, the pill flips to the accent, and a beat later the\r\n * monograms start turning over — not left to right but sprinkled, one every\r\n * seven frames, so it reads as a system granting rather than a list iterating.\r\n *\r\n * Beat by beat, measured off the reference at 30fps:\r\n *\r\n * | beat | seconds | what moves |\r\n * | --- | --- | --- |\r\n * | settle | 0 – 3.0 | camera 1.184 → 1, the middle row closing on the pill |\r\n * | approach | 0 – 1.32 | pointer (123, 90) → (104, −3) |\r\n * | press | 1.62 – 2.33 | pill 1 → 0.931 → 1 |\r\n * | flip | 1.69 | pill goes accent, on one frame |\r\n * | leave | 2.05 – 3.1 | pointer out to (178, 79) |\r\n * | grant | 2.333 + n/30 × 7 | one monogram per step |\r\n * | push | 3.0 – 4.0 | the whole scene pans left, accelerating |\r\n *\r\n * The camera and the middle row settle on the **same shape** — a plain\r\n * `exp(-t / τ)`, no knots — and on nearly the same clock: τ = 0.75 for the\r\n * pull-back, 0.80 and 0.91 for the gap the middle row leaves either side of the\r\n * pill. Near enough that the two read as one settle; far enough that forcing\r\n * them onto one number leaves a card 5px wide through the first half second.\r\n *\r\n * The outer rows do **not** run off that clock, and that is the whole texture\r\n * of the shot. Row 1 covers 372px in four seconds and row 3 covers 355, but row\r\n * 3 spends a quarter of its travel in the first 0.3s and row 1 does not — so\r\n * the two are never symmetric about the pill and the frame never reads as a\r\n * pattern. Fitting both to a shared exponential was tried; it came out 10px\r\n * wrong through the middle of the shot, which is a third of a card gap, and the\r\n * rows visibly locked into step. They are measured knots because they are not a\r\n * formula.\r\n */\r\n\r\nconst { fontFamily: SANS } = loadSans(\"normal\", {\r\n  weights: [\"400\", \"500\"],\r\n  subsets: [\"latin\"],\r\n});\r\n\r\n/* ─────────────────────────────────────────────────────────────────────────\r\n   Geometry, in the reference's own 712×398 pixels\r\n   ───────────────────────────────────────────────────────────────────────── */\r\n\r\nexport const REF_W = 712;\r\nexport const REF_H = 398;\r\n\r\n/**\r\n * What the pull-back scales about, and what every content coordinate below is\r\n * measured from.\r\n *\r\n * Horizontally it is where the pill's centre sits for the first fifty frames of\r\n * the reference without moving a pixel — 356, the middle of the frame. It is\r\n * the camera's fixed point by measurement, not by assumption.\r\n */\r\nexport const ORIGIN = { x: 356, y: 200 };\r\n\r\n/** Row centre to row centre, at scale 1. */\r\nexport const ROW_PITCH = 109.5;\r\n\r\n/**\r\n * A card, at scale 1.\r\n *\r\n * Fixed width, left-aligned content — worth stating because the reference only\r\n * makes it obvious once: its longest name ends 134px short of the card's right\r\n * edge. Content-sized chips would have made the rows ragged and the pitch\r\n * unmeasurable, and the pitch is what the whole marquee is fitted to.\r\n */\r\nexport const CARD = { w: 286, h: 76, radius: 8, gap: 26 };\r\nexport const CARD_PITCH = CARD.w + CARD.gap;\r\n\r\n/** Inside a card. */\r\nexport const AVATAR = { size: 48, padX: 17.5, initials: 24 };\r\nexport const TEXT_X = AVATAR.padX + AVATAR.size + 12;\r\n/** Line boxes at `lineHeight: 1`, offset from the card's top edge. */\r\nexport const NAME = { size: 20, top: 16.7, weight: 500 };\r\nexport const ROLE = { size: 13, top: 43.3, weight: 400 };\r\n\r\n/** The pill. Content-sized: the padding is measured, the width follows the label. */\r\nexport const PILL = {\r\n  h: 43,\r\n  radius: 8,\r\n  padX: 43,\r\n  label: 20,\r\n  /** The reference sets \"Give access\" with a double word space. */\r\n  wordSpacing: 5,\r\n  iconGap: 22,\r\n  iconW: 24,\r\n  iconH: 20,\r\n};\r\n\r\n/**\r\n * The pointer — lucide's `MousePointer2`, and where its tip sits in that icon's\r\n * own 24×24 box.\r\n *\r\n * 22, not the reference's 14: the reference draws a plain disc, and an arrow of\r\n * the same *height* reads smaller because most of its box is empty. 22 puts the\r\n * arrow's ink at about the disc's weight.\r\n */\r\nexport const CURSOR = { size: 22, tip: { x: 4.04, y: 4.69 } };\r\n\r\n/* ─────────────────────────────────────────────────────────────────────────\r\n   Curves — every number below was read off the reference's own frames\r\n   ───────────────────────────────────────────────────────────────────────── */\r\n\r\n/** The camera's clock. The middle row settles on the same shape a shade slower. */\r\nexport const TAU = 0.753;\r\nexport const ZOOM = 0.184;\r\n\r\nexport function ease(t: number): number {\r\n  return Math.exp(-Math.max(0, t) / TAU);\r\n}\r\n\r\n/**\r\n * The camera, as a multiple of the settled scale.\r\n *\r\n * 1.184 at the first frame down to 1 — fitted, not knotted, because a pure\r\n * exponential lands inside a pixel at every one of the eleven frames it was\r\n * checked against. It never actually arrives, which is the point: this shot is\r\n * still shedding scale at frame 90, and a shot that truly settles reads as a\r\n * freeze-frame with a marquee glued on.\r\n */\r\nexport function cameraScale(t: number): number {\r\n  return 1 + ZOOM * ease(t);\r\n}\r\n\r\nfunction knots(\r\n  ts: readonly number[],\r\n  vs: readonly number[],\r\n  t: number,\r\n): number {\r\n  return interpolate(t, ts as number[], vs as number[], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n  });\r\n}\r\n\r\n/**\r\n * The top row, streaming left, in content px — its **own** drift, with the\r\n * camera and the exit pan both taken out.\r\n *\r\n * Tracked by aligning each frame against the next *in content space*, undoing\r\n * the camera first, so what is left is the row's motion and nothing else. A\r\n * plain screen-space correlation cannot tell a row sliding left from a camera\r\n * pulling back, and cheerfully reports a decelerating drift for a scene that\r\n * has none.\r\n *\r\n * Then the pan is subtracted, and that subtraction is the check on the whole\r\n * decomposition: the raw track runs to −372 and never flattens, but −372 minus\r\n * the pan lands on −258.8 at 3.73 and stays there to the last frame. The rows\r\n * stop; the camera does not. Left in as measured, the pan gets counted twice\r\n * and the top row is 34px past the reference by the final second.\r\n */\r\nexport const ROW1_T = [\r\n  0, 0.322, 0.564, 0.964, 1.455, 1.964, 3.172, 3.497, 3.73, 4.005,\r\n];\r\nexport const ROW1_V = [\r\n  0, -69.7, -104.5, -144.2, -178.2, -204.5, -242.8, -248.9, -254.8, -258.8,\r\n];\r\n\r\n/** The bottom row, streaming right — front-loaded where the top row is not. */\r\nexport const ROW3_T = [\r\n  0, 0.164, 0.247, 0.322, 0.564, 0.805, 1.047, 1.405, 1.855, 2.447, 3.047,\r\n  3.364, 4.005,\r\n];\r\nexport const ROW3_V = [\r\n  0, 58.2, 93.6, 119.7, 175.8, 216.2, 247.4, 282.6, 314.5, 342.2, 357.9, 363,\r\n  365,\r\n];\r\n\r\n/** Where a row sits, in content px. The middle row does not drift at all. */\r\nexport function rowDrift(row: 0 | 1 | 2, t: number): number {\r\n  if (row === 0) return knots(ROW1_T, ROW1_V, t);\r\n  if (row === 2) return knots(ROW3_T, ROW3_V, t);\r\n  return 0;\r\n}\r\n\r\n/**\r\n * Where each outer row's slot 0 starts, so the first frame frames like the\r\n * reference's.\r\n *\r\n * Free parameters — the content is ours, so which card sits where is a choice —\r\n * but not arbitrary ones: these put every monogram within 10px of the\r\n * reference's for all 121 frames, which is what lets the two clips be diffed\r\n * on top of each other rather than only compared beat for beat.\r\n */\r\nexport const ROW_PHASE = [-118, 0, -142.3];\r\n\r\n/**\r\n * The push out of the shot, in content px.\r\n *\r\n * Zero for three seconds and then everything — rows, pill, pointer — leaves\r\n * together, which is what makes it read as a camera and not as more marquee.\r\n * Measured on the pill's own centre, the one thing in frame with no drift of\r\n * its own to subtract first.\r\n */\r\nexport const PAN_T = [\r\n  0, 2.95, 3.014, 3.247, 3.447, 3.564, 3.73, 3.814, 3.93, 3.972, 4.005,\r\n];\r\nexport const PAN_V = [\r\n  0, 0, -1, -6.5, -16.5, -25.5, -43.4, -55.9, -82.4, -95.4, -113.4,\r\n];\r\n\r\nexport function pan(t: number): number {\r\n  return knots(PAN_T, PAN_V, t);\r\n}\r\n\r\n/**\r\n * How much room the middle row leaves either side of the pill, in content px,\r\n * as `[floor, amplitude, time constant]`.\r\n *\r\n * Its two flanking cards close in — 91 → 51 on the left, 123 → 65 on the right\r\n * — on the same shape as the camera and, near enough, the same clock: 0.80s and\r\n * 0.91s against the camera's 0.75s. Near enough to read as one settle, far\r\n * enough that sharing the camera's number literally puts the right-hand card 5px\r\n * wide through the first half second.\r\n *\r\n * They are asymmetric and stay asymmetric, which is why this is two rows and not\r\n * one gap: forcing them equal put the right-hand card 14px wrong for a whole\r\n * second, and a card 14px out of place beside a pill that never moves is the one\r\n * misalignment the eye finds.\r\n *\r\n * This is also the reading that killed \"the middle row is a marquee too\". Over\r\n * four seconds its left card travels *right* by 40px while its right card\r\n * travels left by 58, and no single translation does that.\r\n */\r\nexport const CLEARANCE = {\r\n  left: [51, 57.3, 0.805],\r\n  right: [65, 79.7, 0.91],\r\n} as const;\r\n\r\nexport function clearance(side: \"left\" | \"right\", t: number): number {\r\n  const [floor, amp, tau] = CLEARANCE[side];\r\n  return floor + amp * Math.exp(-Math.max(0, t) / tau);\r\n}\r\n\r\n/**\r\n * The pill's own scale under the press.\r\n *\r\n * Down in 0.18s, back in 0.53s — three times as long coming up as going down,\r\n * which is the whole reason a click feels like a click. Symmetric, it feels\r\n * like a bounce.\r\n */\r\nexport const PRESS_T = [\r\n  1.622, 1.689, 1.764, 1.805, 1.897, 1.964, 2.047, 2.122, 2.205, 2.255, 2.33,\r\n];\r\nexport const PRESS_V = [\r\n  1, 0.969, 0.946, 0.931, 0.949, 0.958, 0.968, 0.977, 0.986, 0.995, 1,\r\n];\r\n\r\nexport function pressScale(t: number): number {\r\n  return knots(PRESS_T, PRESS_V, t);\r\n}\r\n\r\n/** When the pill turns over. Instant in the reference — no crossfade to find. */\r\nexport const FLIP_AT = 1.689;\r\n\r\n/**\r\n * The pointer, in content px from `ORIGIN`.\r\n *\r\n * It arrives in two moves, not one: a fast approach that eases out to a hover\r\n * about 30px below the pill around t = 0.9, then a second, *accelerating* drop\r\n * onto the target. That second move peaks at 112px/s — quicker than anything in\r\n * the first — and it is what makes the click read as a decision rather than as\r\n * an arrival.\r\n */\r\nexport const CURSOR_T = [\r\n  0, 0.164, 0.247, 0.322, 0.414, 0.489, 0.564, 0.722, 0.889, 0.93, 1.047, 1.164,\r\n  1.289, 1.405, 2.03, 2.089, 2.172, 2.255, 2.33, 2.414, 2.505, 2.605, 2.73,\r\n  2.897, 3.089, 3.289, 3.497, 3.689, 4.005,\r\n];\r\nexport const CURSOR_X = [\r\n  123, 117.8, 110.6, 106, 103.8, 102.3, 101.7, 101.3, 101.6, 101.6, 101.8,\r\n  102.5, 103.6, 103.7, 104.9, 107, 112.1, 121.1, 133, 143, 150.2, 158, 163.6,\r\n  168.8, 173, 175.4, 177.9, 178.4, 178.2,\r\n];\r\nexport const CURSOR_Y = [\r\n  89.5, 85.4, 76.1, 65.6, 56.6, 49.1, 43.2, 35.4, 30.2, 28.2, 22.2, 13.8, -0.2,\r\n  -2.6, -2.6, 0.5, 5.8, 16.4, 29.6, 40.4, 48.3, 56.8, 62.7, 65.6, 72.9, 75.8,\r\n  77.6, 78.5, 78.7,\r\n];\r\n\r\n/**\r\n * How far inside the pill's trailing edge the pointer comes to rest, in\r\n * reference px.\r\n *\r\n * Measured: it stops 104px right of centre on a pill 122px wide either side —\r\n * 18px in from the edge, past the icon rather than on it. Kept as an *inset*\r\n * rather than as an absolute x, because the pill is content-sized and a short\r\n * label would otherwise leave the pointer clicking thin air beside it.\r\n */\r\nexport const LAND_INSET = 18;\r\n/** The pill the track was measured against, half-width in content px. */\r\nexport const REF_PILL_HALF = 122;\r\n\r\n/**\r\n * The pointer's place at `t`, in content px from `ORIGIN`.\r\n *\r\n * The measured track is the track everywhere except over the pill: there x is\r\n * pulled in to the pill's own trailing edge, and the pull fades in across the\r\n * pill's height so no frame ever jumps. Scaling the *whole* track by the pill's\r\n * width instead moved the pointer's entry and exit too — 13px at the first\r\n * frame, on a path that has nothing to do with how wide the button is.\r\n */\r\nexport function cursorAt(\r\n  t: number,\r\n  pillHalf: number,\r\n): { x: number; y: number } {\r\n  const x = knots(CURSOR_T, CURSOR_X, t);\r\n  const y = knots(CURSOR_T, CURSOR_Y, t);\r\n  const over = Math.min(1, Math.max(0, (PILL.h * 1.5 - Math.abs(y)) / PILL.h));\r\n  const pull = Math.max(0, x - (pillHalf - LAND_INSET));\r\n  return { x: x - pull * over, y };\r\n}\r\n\r\n/**\r\n * When the first monogram turns over, and how often after that.\r\n *\r\n * Seven frames, not the 7.25 the five measured onsets average to. Four of those\r\n * five land on a 7-frame grid off 2.333 to the frame; averaging instead put\r\n * three of them a frame late to buy back one that is two frames early, and a\r\n * cascade that is consistently a frame behind is worse than one that is right\r\n * four times out of five.\r\n */\r\nexport const GRANT_AT = 70 / 30;\r\nexport const GRANT_STEP = 7 / 30;\r\n\r\nexport function granted(order: number, t: number): boolean {\r\n  // A frame's worth of slack, because `70 / 30 + 2 * (7 / 30)` is 2.8000000000000003\r\n  // and the frame it is supposed to fire on is 2.8. Without it the third turn\r\n  // lands one frame late and nothing in the code says why.\r\n  return t + 1e-6 >= GRANT_AT + GRANT_STEP * order;\r\n}\r\n\r\n/* ─────────────────────────────────────────────────────────────────────────\r\n   Content\r\n   ───────────────────────────────────────────────────────────────────────── */\r\n\r\nexport interface RosterEntry {\r\n  /** Shown large. */\r\n  name: string;\r\n  /** Shown small, under it. */\r\n  role: string;\r\n  /** Two characters at most. Derived from `name` when omitted. */\r\n  initials?: string;\r\n}\r\n\r\n/**\r\n * What kuchi is granting: its own registry.\r\n *\r\n * Four per row, because at this pitch a row shows three cards at once and a\r\n * roster of three tiles visibly across the frame.\r\n */\r\nexport const KUCHI_ROSTER: readonly (readonly RosterEntry[])[] = [\r\n  [\r\n    { name: \"Text Reveal\", role: \"Animation\" },\r\n    { name: \"Prompt Send\", role: \"Composition\" },\r\n    { name: \"Logo Drift\", role: \"Background\" },\r\n    { name: \"Word Flip\", role: \"Animation\" },\r\n  ],\r\n  [\r\n    { name: \"Count Grid\", role: \"Composition\" },\r\n    { name: \"Agent Steps\", role: \"Composition\" },\r\n    { name: \"Type Morph\", role: \"Animation\" },\r\n    { name: \"Text Swell\", role: \"Animation\" },\r\n  ],\r\n  [\r\n    { name: \"Karaoke Captions\", role: \"Composition\" },\r\n    { name: \"Search Typing\", role: \"Composition\" },\r\n    { name: \"Text Highlight\", role: \"Animation\" },\r\n    { name: \"Orbit Gallery\", role: \"Composition\" },\r\n  ],\r\n];\r\n\r\n/**\r\n * Which turn each row takes, over two passes of the three rows.\r\n *\r\n * The reference goes top, middle, bottom, top, **bottom, middle** — the second\r\n * pass swaps the last two, so no row ever grants twice running and the sixth\r\n * monogram does not land where the third did. Six is the whole visible cascade;\r\n * it repeats from there.\r\n */\r\nexport const TURNS = [\r\n  [0, 3],\r\n  [1, 5],\r\n  [2, 4],\r\n] as const;\r\n\r\nexport function turnOf(row: number, step: number): number {\r\n  return 6 * Math.floor(step / 2) + (TURNS[row % 3]?.[step % 2] ?? 0);\r\n}\r\n\r\n/**\r\n * Which roster entry a row starts its cascade on.\r\n *\r\n * Not entry 0. The marquee has moved 200-odd pixels by the time anything is\r\n * granted, so whichever entry sits at slot 0 is wherever the drift table left\r\n * it — keyed on entry 0, the cascade opened on a card whose avatar was 73px off\r\n * the left edge, and the reference's frame-70 grant did not appear until frame\r\n * 78. Seeding on the entry nearest the middle of the frame at `GRANT_AT` puts\r\n * the first monogram where a viewer is already looking, for any phase, any\r\n * drift and any roster length.\r\n *\r\n * Keyed on the roster entry rather than on the marquee slot, so every copy of a\r\n * card on screen turns over on the same frame: a component is installed once,\r\n * not once per place it is drawn.\r\n */\r\nexport function grantSeed(\r\n  row: 0 | 1 | 2,\r\n  len: number,\r\n  pillHalf: number,\r\n): number {\r\n  // The *monogram's* distance from the middle, not the card's: a card can be\r\n  // half on screen with its avatar 65px past the left edge, and a grant nobody\r\n  // can see is a grant that did not happen. Seeding on the card instead put the\r\n  // second turn nine frames behind the reference's.\r\n  const reach = REF_W / 2 / cameraScale(GRANT_AT);\r\n  let left = Number.NEGATIVE_INFINITY;\r\n  let leftSlot: number | null = null;\r\n  let near = Number.POSITIVE_INFINITY;\r\n  let nearSlot = 0;\r\n  for (const { slot, u } of slotsFor(row, GRANT_AT, pillHalf)) {\r\n    const disc = u - CARD.w / 2 + AVATAR.padX + AVATAR.size / 2;\r\n    if (Math.abs(disc) > reach - AVATAR.size / 2) continue;\r\n    if (disc <= 0 && disc > left) {\r\n      left = disc;\r\n      leftSlot = slot;\r\n    }\r\n    if (Math.abs(disc) < near) {\r\n      near = Math.abs(disc);\r\n      nearSlot = slot;\r\n    }\r\n  }\r\n  // The nearest monogram *left* of centre, not simply the nearest — because the\r\n  // next entry in the roster is one slot to the right, and a cascade seeded on\r\n  // the right-hand card sends its own second turn off the right edge. That is\r\n  // what the reference does in all three rows, and the one row where it cannot\r\n  // (the middle: the pill hides the card to its left) is the one row it seeds on\r\n  // the right.\r\n  const best = leftSlot ?? nearSlot;\r\n  return ((best % len) + len) % len;\r\n}\r\n\r\nexport function grantOrderOf(\r\n  row: 0 | 1 | 2,\r\n  entryIndex: number,\r\n  len: number,\r\n  seed: number,\r\n): number {\r\n  return turnOf(row, (((entryIndex - seed) % len) + len) % len);\r\n}\r\n\r\nexport function initialsOf(entry: RosterEntry): string {\r\n  if (entry.initials) return entry.initials;\r\n  return entry.name\r\n    .split(/\\s+/)\r\n    .slice(0, 2)\r\n    .map((w) => w[0] ?? \"\")\r\n    .join(\"\")\r\n    .toUpperCase();\r\n}\r\n\r\n/* ─────────────────────────────────────────────────────────────────────────\r\n   Layout\r\n   ───────────────────────────────────────────────────────────────────────── */\r\n\r\n/**\r\n * Inter's advance widths, in em, for the characters a button label uses.\r\n *\r\n * The pill is drawn `width: max-content`, so the *drawn* pill is always exactly\r\n * its content plus its padding and no label can ever be cramped. This table is\r\n * for everything that has to know how wide that pill will be **before** it is\r\n * drawn — where the middle row's cards sit either side of it, and where the\r\n * pointer lands on it.\r\n *\r\n * It replaced \"0.52em to the character\", which read a 130px label as 216 and\r\n * left the pill 30px wider than its own contents: balanced padding, and 15px\r\n * too much of it on each side. A per-character table is 30 lines of data and it\r\n * gets \"Install all\" to within a pixel; a single average cannot get any label\r\n * right, because the whole point of a label is that you do not know it yet.\r\n */\r\nconst ADVANCE: Record<string, number> = {\r\n  \" \": 0.26,\r\n  \"-\": 0.35,\r\n  \".\": 0.27,\r\n  \",\": 0.27,\r\n  \"'\": 0.19,\r\n  \"!\": 0.29,\r\n  a: 0.541,\r\n  b: 0.578,\r\n  c: 0.512,\r\n  d: 0.578,\r\n  e: 0.541,\r\n  f: 0.34,\r\n  g: 0.578,\r\n  h: 0.552,\r\n  i: 0.24,\r\n  j: 0.24,\r\n  k: 0.512,\r\n  l: 0.24,\r\n  m: 0.827,\r\n  n: 0.552,\r\n  o: 0.571,\r\n  p: 0.578,\r\n  q: 0.578,\r\n  r: 0.351,\r\n  s: 0.501,\r\n  t: 0.35,\r\n  u: 0.552,\r\n  v: 0.499,\r\n  w: 0.753,\r\n  x: 0.501,\r\n  y: 0.499,\r\n  z: 0.474,\r\n  A: 0.665,\r\n  B: 0.654,\r\n  C: 0.677,\r\n  D: 0.7,\r\n  E: 0.6,\r\n  F: 0.578,\r\n  G: 0.72,\r\n  H: 0.71,\r\n  I: 0.273,\r\n  J: 0.531,\r\n  K: 0.644,\r\n  L: 0.57,\r\n  M: 0.872,\r\n  N: 0.73,\r\n  O: 0.747,\r\n  P: 0.635,\r\n  Q: 0.747,\r\n  R: 0.635,\r\n  S: 0.614,\r\n  T: 0.601,\r\n  U: 0.71,\r\n  V: 0.665,\r\n  W: 0.948,\r\n  X: 0.632,\r\n  Y: 0.619,\r\n  Z: 0.601,\r\n};\r\n/** Digits are one width in Inter, and anything unlisted gets a lowercase mean. */\r\nconst ADVANCE_FALLBACK = (ch: string) => (/[0-9]/.test(ch) ? 0.6 : 0.55);\r\n\r\n/** How wide the label's text runs, in reference px. */\r\nexport function labelWidth(label: string): number {\r\n  let em = 0;\r\n  let spaces = 0;\r\n  for (const ch of label) {\r\n    em += ADVANCE[ch] ?? ADVANCE_FALLBACK(ch);\r\n    if (ch === \" \") spaces++;\r\n  }\r\n  return em * PILL.label + spaces * PILL.wordSpacing;\r\n}\r\n\r\n/** The pill's width, in reference px — content plus the measured padding. */\r\nexport function pillWidth(label: string): number {\r\n  return PILL.padX * 2 + labelWidth(label.trim()) + PILL.iconGap + PILL.iconW;\r\n}\r\n\r\n/**\r\n * Where a card sits at rest, in reference px — before the row's own motion.\r\n *\r\n * Rows 0 and 2 are plain marquees on a pitch. Row 1 is two stacks anchored to\r\n * the pill's edges at their *closed* clearance, with the slot behind the pill\r\n * left empty — see `CLEARANCE` for why it cannot be a marquee.\r\n */\r\nexport function slotRest(\r\n  row: 0 | 1 | 2,\r\n  slot: number,\r\n  pillHalf: number,\r\n): number {\r\n  if (row !== 1) return (ROW_PHASE[row] ?? 0) + slot * CARD_PITCH;\r\n  const edge = pillHalf + CARD.w / 2;\r\n  return slot < 0\r\n    ? -(edge + CLEARANCE.left[0]) + (slot + 1) * CARD_PITCH\r\n    : edge + CLEARANCE.right[0] + slot * CARD_PITCH;\r\n}\r\n\r\n/**\r\n * How far a row (or, for the middle row, one of its two stacks) has moved from\r\n * rest at `t` — the one number that is animated, per group, per frame.\r\n */\r\nexport function rowShift(row: 0 | 1 | 2, slot: number, t: number): number {\r\n  if (row !== 1) return rowDrift(row, t);\r\n  const side = slot < 0 ? \"left\" : \"right\";\r\n  const open = clearance(side, t) - CLEARANCE[side][0];\r\n  return side === \"left\" ? -open : open;\r\n}\r\n\r\n/** Where a card actually is at `t`, in reference px. */\r\nexport function slotsFor(\r\n  row: 0 | 1 | 2,\r\n  t: number,\r\n  pillHalf: number,\r\n): { slot: number; u: number }[] {\r\n  return slotRange(row, pillHalf).map((slot) => ({\r\n    slot,\r\n    u: slotRest(row, slot, pillHalf) + rowShift(row, slot, t),\r\n  }));\r\n}\r\n\r\n/**\r\n * Every slot of a row that reaches the frame at **any** point in the clip.\r\n *\r\n * Fixed, so the DOM never changes: a card that is drawn is drawn for all 120\r\n * frames and only its group's `translateX` moves. Mounting and unmounting cards\r\n * as they cross the edge is a layout pass on a frame that also has to composite\r\n * a camera move, and it lands on exactly the frames a marquee is least able to\r\n * hide it — the ones where something is entering.\r\n */\r\nexport function slotRange(row: 0 | 1 | 2, pillHalf: number): number[] {\r\n  let lo = Number.POSITIVE_INFINITY;\r\n  let hi = Number.NEGATIVE_INFINITY;\r\n  // 0.05s is a quarter of the fastest thing in the clip; the union cannot open\r\n  // and close again between two samples.\r\n  for (let t = 0; t <= 4.2; t += 0.05) {\r\n    const reach = REF_W / 2 / cameraScale(t) + CARD.w;\r\n    lo = Math.min(lo, -pan(t) - reach);\r\n    hi = Math.max(hi, -pan(t) + reach);\r\n  }\r\n  // The middle row's stacks are indexed -1, -2, … and 0, 1, … — there is no\r\n  // centre slot to skip, because the pill *is* the gap.\r\n  const out: number[] = [];\r\n  for (let slot = -12; slot <= 12; slot++) {\r\n    let seen = false;\r\n    for (let t = 0; t <= 4.2 && !seen; t += 0.05) {\r\n      const u = slotRest(row, slot, pillHalf) + rowShift(row, slot, t);\r\n      if (u > lo && u < hi) seen = true;\r\n    }\r\n    if (seen) out.push(slot);\r\n  }\r\n  return out;\r\n}\r\n\r\n/* ─────────────────────────────────────────────────────────────────────────\r\n   Component\r\n   ───────────────────────────────────────────────────────────────────────── */\r\n\r\nexport interface RosterGrantProps {\r\n  /** Three rows of cards. Each row repeats across the frame. */\r\n  rows?: readonly (readonly RosterEntry[])[];\r\n  /** The pill's label. */\r\n  label?: string;\r\n  /** Overrides the design system's `primary` for the pill and the monograms. */\r\n  accentColor?: string;\r\n  /** Design-system token overrides. */\r\n  theme?: Partial<KuchiTheme>;\r\n  mode?: \"light\" | \"dark\";\r\n  /**\r\n   * The face this scene paints its words in — a label from `fonts.ts` or a CSS\r\n   * family you have loaded yourself. Overrides `theme.fontFamily`.\r\n   */\r\n  fontFamily?: string;\r\n  /** 1 is the measured speed. */\r\n  speed?: number;\r\n}\r\n\r\nexport function RosterGrant({\r\n  rows = KUCHI_ROSTER,\r\n  label = \"Install all\",\r\n  accentColor,\r\n  theme,\r\n  mode,\r\n  fontFamily,\r\n  speed = 1,\r\n}: RosterGrantProps) {\r\n  const frame = useCurrentFrame();\r\n  const { fps, width, height } = useVideoConfig();\r\n  // `frame * speed`, so 2 is twice as fast — the convention every other timed\r\n  // scene in this registry uses.\r\n  const t = (frame * speed) / fps;\r\n\r\n  const th = useKuchiTheme(theme, mode);\r\n  const accent = accentColor ?? th.primary;\r\n  const face = resolveFont(fontFamily ?? th.fontFamily) ?? SANS;\r\n\r\n  // Reference px → render px. The whole scene is laid out once in the\r\n  // reference's own 712×398 and then scaled here, so nothing below this line\r\n  // depends on the render size.\r\n  const k = Math.min(width / REF_W, height / REF_H);\r\n  const ox = (width - REF_W * k) / 2;\r\n  const oy = (height - REF_H * k) / 2;\r\n\r\n  const half = pillWidth(label) / 2;\r\n  const point = cursorAt(t, half);\r\n\r\n  // A hairline that belongs to the palette: the token walked most of the way\r\n  // back toward the fill it edges, because `border` at full strength is a\r\n  // shadcn *control* border and these are 76px chips, not controls.\r\n  const edge = mixOklch(th.secondary, th.border, 0.55);\r\n\r\n  // `will-change` is right for the Player and wrong for the render. One\r\n  // continuous tab with an 8ms budget wants the camera handed to the\r\n  // compositor; a render is spread across parallel tabs, each of which would\r\n  // inherit a stale raster from whatever scale *it* drew last.\r\n  const live = !getRemotionEnvironment().isRendering\r\n    ? { willChange: \"transform\" as const }\r\n    : null;\r\n\r\n  // Fixed for the whole clip, so this is a `useMemo` and not a per-frame scan.\r\n  const ranges = useMemo(\r\n    () => [slotRange(0, half), slotRange(1, half), slotRange(2, half)],\r\n    [half],\r\n  );\r\n\r\n  const groups: ReactNode[] = [];\r\n  // An entry's index in `rows` read row by row — what Studio calls it by.\r\n  let base = 0;\r\n  for (const row of [0, 1, 2] as const) {\r\n    const roster = rows[row] ?? [];\r\n    const first = base;\r\n    base += roster.length;\r\n    if (roster.length === 0) continue;\r\n    const seed = grantSeed(row, roster.length, half);\r\n    // A row repeats its entries across the frame. Studio outlines the copy\r\n    // nearest the middle of the frame; the others are only pictures of it.\r\n    const nearest = new Map<number, number>();\r\n    const held = new Map<number, number>();\r\n    for (const slot of ranges[row] ?? []) {\r\n      const i = ((slot % roster.length) + roster.length) % roster.length;\r\n      const d = Math.abs(\r\n        slotRest(row, slot, half) + rowShift(row, slot, t) + pan(t),\r\n      );\r\n      if (d < (held.get(i) ?? Number.POSITIVE_INFINITY)) {\r\n        held.set(i, d);\r\n        nearest.set(i, slot);\r\n      }\r\n    }\r\n    const y = ORIGIN.y + (row - 1) * ROW_PITCH - CARD.h / 2;\r\n    // One group per thing that moves: a whole row, or — for the middle row —\r\n    // each side of the pill, which close in at different rates.\r\n    const sides = row === 1 ? ([-1, 1] as const) : ([0] as const);\r\n    for (const side of sides) {\r\n      const slots = (ranges[row] ?? []).filter((n) =>\r\n        row === 1 ? (side < 0 ? n < 0 : n >= 0) : true,\r\n      );\r\n      if (slots.length === 0) continue;\r\n      groups.push(\r\n        <div\r\n          key={`${row}:${side}`}\r\n          style={{\r\n            position: \"absolute\",\r\n            inset: 0,\r\n            transform: `translateX(${rowShift(row, side, t)}px)`,\r\n            ...live,\r\n          }}\r\n        >\r\n          {slots.map((slot) => {\r\n            const i = ((slot % roster.length) + roster.length) % roster.length;\r\n            const entry = roster[i];\r\n            if (!entry) return null;\r\n            return (\r\n              <Item\r\n                key={slot}\r\n                index={first + i}\r\n                primary={nearest.get(i) === slot}\r\n              >\r\n                <Card\r\n                  accent={accent}\r\n                  edge={edge}\r\n                  entry={entry}\r\n                  left={slotRest(row, slot, half) + ORIGIN.x - CARD.w / 2}\r\n                  on={granted(grantOrderOf(row, i, roster.length, seed), t)}\r\n                  th={th}\r\n                  top={y}\r\n                />\r\n              </Item>\r\n            );\r\n          })}\r\n        </div>,\r\n      );\r\n    }\r\n  }\r\n\r\n  return (\r\n    <AbsoluteFill\r\n      style={{\r\n        backgroundColor: th.background,\r\n        fontFamily: face,\r\n        // Hinting re-snaps every stem as the camera scale slides and the\r\n        // letterforms boil. This is the fix, and it is not optional in a scene\r\n        // that never stops scaling.\r\n        textRendering: \"geometricPrecision\",\r\n        overflow: \"hidden\",\r\n      }}\r\n    >\r\n      {/* A transparent page asks for no page, and the backdrop is the page. */}\r\n      {parseColor(th.background).alpha !== 0 && (\r\n        <Backdrop accent={accent} th={th} />\r\n      )}\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          left: ox,\r\n          top: oy,\r\n          width: REF_W,\r\n          height: REF_H,\r\n          transform: `scale(${k})`,\r\n          transformOrigin: \"0 0\",\r\n        }}\r\n      >\r\n        {/* The camera. Everything under it is laid out once, at scale 1, and\r\n            nothing in the scene animates a size or a position — only this\r\n            transform and one `translateX` per row. Transforms do not reflow;\r\n            an animated `fontSize` re-shapes every glyph in the frame on every\r\n            frame, which is the most expensive thing a browser can be asked to\r\n            do per frame and the reason the same scene can measure correct and\r\n            still look like it is sticking. */}\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            inset: 0,\r\n            transform: `translateX(${pan(t) * cameraScale(t)}px) scale(${cameraScale(t)})`,\r\n            transformOrigin: `${ORIGIN.x}px ${ORIGIN.y}px`,\r\n            ...live,\r\n          }}\r\n        >\r\n          {groups}\r\n          <Pill\r\n            accent={accent}\r\n            label={label}\r\n            on={t >= FLIP_AT}\r\n            press={pressScale(t)}\r\n            th={th}\r\n          />\r\n          <Pointer color={th.foreground} rim={th.background} at={point} />\r\n        </div>\r\n      </div>\r\n    </AbsoluteFill>\r\n  );\r\n}\r\n\r\n/* ─────────────────────────────────────────────────────────────────────────\r\n   Pieces — all laid out in reference px, none of them animated\r\n   ───────────────────────────────────────────────────────────────────────── */\r\n\r\n/**\r\n * One roster card. Takes a `ref` and a `style` on top of its own so Remotion\r\n * Studio can outline it and nudge it (see `Item`).\r\n */\r\nconst Card = forwardRef<\r\n  HTMLDivElement,\r\n  {\r\n    accent: string;\r\n    edge: string;\r\n    entry: RosterEntry;\r\n    left: number;\r\n    on: boolean;\r\n    th: KuchiTheme;\r\n    top: number;\r\n    style?: CSSProperties;\r\n  }\r\n>(function Card({ accent, edge, entry, left, on, th, top, style }, ref) {\r\n  return (\r\n    <div\r\n      ref={ref}\r\n      style={{\r\n        ...style,\r\n        position: \"absolute\",\r\n        left,\r\n        top,\r\n        width: CARD.w,\r\n        height: CARD.h,\r\n        borderRadius: CARD.radius,\r\n        background: th.secondary,\r\n        // A hairline and nothing else. A drop shadow under nine light chips on\r\n        // a light page is nine grey smears — and the reference's own card edge\r\n        // is five levels of luma, which is a border, not a shadow.\r\n        boxShadow: `inset 0 0 0 1px ${edge}`,\r\n        overflow: \"hidden\",\r\n      }}\r\n    >\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          left: AVATAR.padX,\r\n          top: (CARD.h - AVATAR.size) / 2,\r\n          width: AVATAR.size,\r\n          height: AVATAR.size,\r\n          borderRadius: \"50%\",\r\n          background: on ? accent : th.card,\r\n          color: on ? th.primaryForeground : th.foreground,\r\n          display: \"flex\",\r\n          alignItems: \"center\",\r\n          justifyContent: \"center\",\r\n          fontSize: AVATAR.initials,\r\n          fontWeight: 500,\r\n          lineHeight: 1,\r\n        }}\r\n      >\r\n        {initialsOf(entry)}\r\n      </div>\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          left: TEXT_X,\r\n          top: NAME.top,\r\n          right: 10,\r\n          fontSize: NAME.size,\r\n          fontWeight: NAME.weight,\r\n          lineHeight: 1,\r\n          color: th.foreground,\r\n          whiteSpace: \"nowrap\",\r\n          overflow: \"hidden\",\r\n          textOverflow: \"ellipsis\",\r\n        }}\r\n      >\r\n        {entry.name}\r\n      </div>\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          left: TEXT_X,\r\n          top: ROLE.top,\r\n          right: 10,\r\n          fontSize: ROLE.size,\r\n          fontWeight: ROLE.weight,\r\n          lineHeight: 1,\r\n          color: th.mutedForeground,\r\n          whiteSpace: \"nowrap\",\r\n          overflow: \"hidden\",\r\n          textOverflow: \"ellipsis\",\r\n        }}\r\n      >\r\n        {entry.role}\r\n      </div>\r\n    </div>\r\n  );\r\n});\r\n\r\nfunction Pill({\r\n  accent,\r\n  label,\r\n  on,\r\n  press,\r\n  th,\r\n}: {\r\n  accent: string;\r\n  label: string;\r\n  on: boolean;\r\n  press: number;\r\n  th: KuchiTheme;\r\n}) {\r\n  const fill = on ? accent : th.foreground;\r\n  return (\r\n    <div\r\n      style={{\r\n        position: \"absolute\",\r\n        left: ORIGIN.x,\r\n        top: ORIGIN.y,\r\n        // `max-content`, so the pill is its own contents plus the measured\r\n        // padding and a long label can never be cramped inside a guessed width.\r\n        width: \"max-content\",\r\n        height: PILL.h,\r\n        padding: `0 ${PILL.padX}px`,\r\n        boxSizing: \"border-box\",\r\n        transform: `translate(-50%, -50%) scale(${press})`,\r\n        borderRadius: PILL.radius,\r\n        background: fill,\r\n        color: on ? th.primaryForeground : th.background,\r\n        display: \"flex\",\r\n        alignItems: \"center\",\r\n        justifyContent: \"center\",\r\n        gap: PILL.iconGap,\r\n        fontSize: PILL.label,\r\n        fontWeight: 500,\r\n        wordSpacing: PILL.wordSpacing,\r\n        lineHeight: 1,\r\n        whiteSpace: \"nowrap\",\r\n        // A 1px lighter rim along the top, which is what the reference has and\r\n        // what stops a saturated pill reading as a sticker, plus a glow in the\r\n        // pill's *own* colour — so it can never be the grey smear a neutral\r\n        // drop shadow would be on this page.\r\n        boxShadow: [\r\n          `inset 0 1px 0 ${withAlpha(\"#ffffff\", 0.22)}`,\r\n          `0 10px 26px -6px ${withAlpha(fill, 0.34)}`,\r\n        ].join(\", \"),\r\n      }}\r\n    >\r\n      <span>{label}</span>\r\n      <svg\r\n        width={PILL.iconW}\r\n        height={PILL.iconH}\r\n        viewBox=\"0 0 24 20\"\r\n        fill=\"none\"\r\n        stroke=\"currentColor\"\r\n        strokeWidth={1.8}\r\n        strokeLinecap=\"round\"\r\n        strokeLinejoin=\"round\"\r\n        aria-hidden\r\n      >\r\n        <title>Install</title>\r\n        <path d=\"M12 1.5v10.5\" />\r\n        <path d=\"M7.5 7.5 12 12l4.5-4.5\" />\r\n        <path d=\"M3.5 14.5v3a1.5 1.5 0 0 0 1.5 1.5h14a1.5 1.5 0 0 0 1.5-1.5v-3\" />\r\n      </svg>\r\n    </div>\r\n  );\r\n}\r\n\r\n/**\r\n * The pointer — lucide's `MousePointer2`, filled, with a rim in the page colour\r\n * so it reads over a card, over the pill and over the backdrop alike.\r\n *\r\n * Positioned by its **tip**, not its centre: the reference's pointer is a plain\r\n * disc and the tracked point is that disc's middle, but an arrow's hotspot is\r\n * the point it is drawn from. Anchoring the box instead puts the click a third\r\n * of the glyph away from where the reference clicked.\r\n */\r\nfunction Pointer({\r\n  at,\r\n  color,\r\n  rim,\r\n}: {\r\n  at: { x: number; y: number };\r\n  color: string;\r\n  rim: string;\r\n}) {\r\n  return (\r\n    <svg\r\n      width={CURSOR.size}\r\n      height={CURSOR.size}\r\n      viewBox=\"0 0 24 24\"\r\n      style={{\r\n        position: \"absolute\",\r\n        left: 0,\r\n        top: 0,\r\n        transform: `translate(${ORIGIN.x + at.x - CURSOR.tip.x * (CURSOR.size / 24)}px, ${ORIGIN.y + at.y - CURSOR.tip.y * (CURSOR.size / 24)}px)`,\r\n        overflow: \"visible\",\r\n      }}\r\n      aria-hidden\r\n    >\r\n      <title>Pointer</title>\r\n      <path\r\n        d=\"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z\"\r\n        fill={color}\r\n        stroke={rim}\r\n        strokeWidth={1.6}\r\n        strokeLinejoin=\"round\"\r\n      />\r\n    </svg>\r\n  );\r\n}\r\n\r\n/**\r\n * The page under it all.\r\n *\r\n * The reference's backdrop is a mesh: white through the middle of the top edge,\r\n * a wash of its brand indigo climbing out of the bottom-right, and a lighter\r\n * core right behind the pill. Its *shape* is worth keeping and its paint is\r\n * not — so the wash here is the accent, at the alphas measured off the\r\n * reference, and it follows a user's theme instead of a stranger's brand.\r\n */\r\nfunction Backdrop({ accent, th }: { accent: string; th: KuchiTheme }) {\r\n  return (\r\n    <AbsoluteFill\r\n      style={{\r\n        background: [\r\n          `radial-gradient(58% 44% at 50% 46%, ${withAlpha(th.card, 0.9)} 0%, ${withAlpha(th.card, 0)} 100%)`,\r\n          `radial-gradient(78% 62% at 64% 116%, ${withAlpha(accent, 0.42)} 0%, ${withAlpha(accent, 0)} 100%)`,\r\n          `radial-gradient(52% 46% at -4% -8%, ${withAlpha(accent, 0.16)} 0%, ${withAlpha(accent, 0)} 100%)`,\r\n          th.background,\r\n        ].join(\", \"),\r\n      }}\r\n    />\r\n  );\r\n}\r\n\r\nexport default RosterGrant;\r\n"}]}