{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"moodboard-reveal","type":"registry:component","title":"Moodboard Reveal","description":"Photo gallery reveal: a moodboard fly-through that lands on a hero image. A kinetic headline with a swapping inline image, then a scattered gallery of photos flies in, the camera pushes through it as the background lifts from near-black to off-white, and it lands on a single hero image.","dependencies":["remotion"],"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/kuchi-ui.json"],"files":[{"path":"components/kuchi/moodboard-reveal.tsx","type":"registry:component","target":"components/kuchi/moodboard-reveal.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport type { CSSProperties } from \"react\";\r\nimport { forwardRef } from \"react\";\r\nimport {\r\n  Easing,\r\n  getRemotionEnvironment,\r\n  Img,\r\n  interpolate,\r\n  interpolateColors,\r\n  staticFile,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\nimport {\r\n  Item,\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 * A \"moodboard reveal\": a kinetic headline with a swapping inline image, then a\r\n * scattered gallery of image cards flies in, the camera pushes through it while\r\n * the background lifts from near-black to off-white, and it lands on a single\r\n * hero image. A camera-drives-through montage (see MOTION.md), replicated from a\r\n * reference reel and populated with the showcase assets.\r\n */\r\n\r\nexport interface MoodboardRevealProps {\r\n  /** Text before the inline image. */\r\n  leadIn?: string;\r\n  /** The emphasised (bold) word right after the inline image. */\r\n  emphasis?: string;\r\n  /** Text after the emphasised word. */\r\n  tailIn?: string;\r\n  /** Image URLs for the gallery + the intro swap. First-served covers the slots. */\r\n  images?: string[];\r\n  /** The image the montage lands on. Defaults to `images[3]`. */\r\n  heroImage?: string;\r\n  /** Near-black start background. Defaults to the dark theme's `background`. */\r\n  darkColor?: string;\r\n  /** Off-white end background. Defaults to the light theme's `background`. */\r\n  lightColor?: string;\r\n  /**\r\n   * Design-system token overrides. Applied to both ends of the crossfade —\r\n   * this scene spans light and dark, so it takes no `mode`.\r\n   */\r\n  theme?: Partial<KuchiTheme>;\r\n  /**\r\n   * The face this scene paints its words in — a label from `fonts.ts`\r\n   * (\"Inter\", \"Space Grotesk\", \"Instrument Serif\") or a CSS family you have\r\n   * loaded yourself. Unset, the scene keeps the face it was designed around.\r\n   *\r\n   * Overrides `theme.fontFamily`, which is how a brand kit re-skins a whole\r\n   * timeline from one value.\r\n   */\r\n  fontFamily?: string;\r\n  speed?: number;\r\n  className?: string;\r\n}\r\n\r\nconst FONT_FAMILY =\r\n  'Inter, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif';\r\n\r\n/** Sample images. Absolute, because a root-relative default becomes\r\n *  `staticFile()` in a render and 404s in the project this file was just\r\n *  copied into. Pass your own — root-relative or remote, both resolve. */\r\nconst DEFAULT_IMAGES = [\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-11.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-08.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-08.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-07.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-07.svg\",\r\n  \"https://kuchi-media.kalarislabs.com/components/art/art-02.svg\",\r\n];\r\n\r\n// ─── Timeline (frames @ 30fps; ~5s to mirror the ~4.7s reference) ──────────────\r\n// The sentence holds long enough that the last intro image lands and rests\r\n// before it fades; the fade overlaps the first gallery positions appearing.\r\nexport const SENTENCE_OUT = 50;\r\nexport const COLLAGE_START = 46;\r\nexport const APPEAR_FRAMES = 12;\r\n/** Each position swaps its image every `FLICKER_HOLD` frames — the shuffle. */\r\nexport const FLICKER_HOLD = 2;\r\n/** The cluster orbits its centre from COLLAGE_START to here, sweeping ORBIT_DEG°. */\r\nexport const ORBIT_END = 88;\r\nexport const ORBIT_DEG = 130;\r\n/** Then every position converges to the centre — the \"merge into one\". */\r\nexport const MERGE_START = 88;\r\n// Fast collapse — the positions snap together, they don't drift in.\r\nexport const MERGE_END = 100;\r\nexport const BG_START = 88;\r\nexport const BG_END = 104;\r\n/**\r\n * Every position collapses to this common width at the centre and un-rotates, so\r\n * the cards stack exactly on top of each other. They never fade — the topmost\r\n * card (the hero) simply covers the rest, so the merge *becomes* the one image.\r\n */\r\nexport const MERGE_W = 300;\r\n\r\n/** Moderate decelerate — not quint/expo-out, which freeze on a frame clock. */\r\nexport const EASE = Easing.bezier(0.2, 0.6, 0.35, 1);\r\nconst CLAMP = { extrapolateLeft: \"clamp\", extrapolateRight: \"clamp\" } as const;\r\n\r\nconst CARD_RATIO = 1.34; // portrait cards (~3:4)\r\n\r\n/**\r\n * Gallery *positions* (offset from centre, width, tilt) — slots, not fixed\r\n * pictures. Each one flickers through the whole image set (see `flickerImage`).\r\n * Laid out as the spread moodboard the montage orbits and then collapses.\r\n */\r\nexport const SLOTS: ReadonlyArray<{\r\n  x: number;\r\n  y: number;\r\n  w: number;\r\n  rot: number;\r\n}> = [\r\n  { x: -401, y: -51, w: 188, rot: -5 },\r\n  { x: -186, y: -191, w: 164, rot: 4 },\r\n  { x: 44, y: -168, w: 214, rot: -2 },\r\n  { x: 283, y: -79, w: 173, rot: 6 },\r\n  { x: 377, y: 151, w: 169, rot: -4 },\r\n  { x: -340, y: 179, w: 183, rot: 5 },\r\n  { x: -101, y: 193, w: 214, rot: -3 },\r\n  { x: 138, y: 193, w: 188, rot: 3 },\r\n];\r\n\r\n/** The cluster's orbit angle (degrees) at `frame`. */\r\nexport function orbitAngle(frame: number): number {\r\n  return interpolate(frame, [COLLAGE_START, ORBIT_END], [0, ORBIT_DEG], {\r\n    ...CLAMP,\r\n    easing: Easing.inOut(Easing.cubic),\r\n  });\r\n}\r\n\r\n/** How far the merge-to-centre has progressed (0 → 1). */\r\nexport function mergeProgress(frame: number): number {\r\n  return interpolate(frame, [MERGE_START, MERGE_END], [0, 1], {\r\n    ...CLAMP,\r\n    easing: EASE,\r\n  });\r\n}\r\n\r\n/**\r\n * Which image a position shows. Positions don't hold one picture — they flicker\r\n * through the whole set every `FLICKER_HOLD` frames, staggered per slot, so it\r\n * reads as all the photos shuffling in place. The image freezes at `MERGE_START`\r\n * so the convergence isn't a strobe.\r\n */\r\nexport function flickerImage(\r\n  frame: number,\r\n  slot: number,\r\n  count: number,\r\n): number {\r\n  const f = Math.min(frame, MERGE_START);\r\n  const step = Math.max(0, Math.floor((f - COLLAGE_START) / FLICKER_HOLD));\r\n  return (step * 3 + slot * 5) % count;\r\n}\r\n\r\nexport interface SlotPose {\r\n  x: number;\r\n  y: number;\r\n  scale: number;\r\n  opacity: number;\r\n}\r\n\r\n/**\r\n * A position's live pose: it fades/scales in, orbits the centre, then converges\r\n * to the centre and to the common `MERGE_W` footprint during the merge. Opacity\r\n * is only the entrance fade — it NEVER fades on merge, so the positions stack on\r\n * top of each other and the topmost one (the hero) covers the rest.\r\n */\r\nexport function slotPose(\r\n  frame: number,\r\n  slot: { x: number; y: number; w: number },\r\n  index: number,\r\n): SlotPose {\r\n  const appear = COLLAGE_START + index * 2;\r\n  const opacity = interpolate(\r\n    frame,\r\n    [appear, appear + APPEAR_FRAMES],\r\n    [0, 1],\r\n    CLAMP,\r\n  );\r\n  const scIn = interpolate(frame, [appear, appear + APPEAR_FRAMES], [0.6, 1], {\r\n    ...CLAMP,\r\n    easing: EASE,\r\n  });\r\n  const a = (orbitAngle(frame) * Math.PI) / 180;\r\n  const ox = slot.x * Math.cos(a) - slot.y * Math.sin(a);\r\n  const oy = slot.x * Math.sin(a) + slot.y * Math.cos(a);\r\n  const m = mergeProgress(frame);\r\n  const target = MERGE_W / slot.w; // every card lands at the same width\r\n  return {\r\n    x: ox * (1 - m),\r\n    y: oy * (1 - m),\r\n    scale: scIn * (1 + (target - 1) * m),\r\n    opacity,\r\n  };\r\n}\r\n\r\n/** Motion blur (px) as the positions converge — peaks mid-merge, zero at ends. */\r\nexport function mergeBlur(frame: number): number {\r\n  return interpolate(\r\n    frame,\r\n    [MERGE_START, (MERGE_START + MERGE_END) / 2, MERGE_END],\r\n    [0, 6, 0],\r\n    CLAMP,\r\n  );\r\n}\r\n\r\n/** 0 = dark background, 1 = light background. */\r\nexport function bgProgress(frame: number): number {\r\n  return interpolate(frame, [BG_START, BG_END], [0, 1], CLAMP);\r\n}\r\n\r\n/** Intro image swap cadence, and the \"drop\" each new image lands with. */\r\nexport const INLINE_START = 8;\r\nexport const INLINE_HOLD = 12;\r\n/** How many images cycle in the intro (kept small so each drop is legible). */\r\nexport const INLINE_COUNT = 3;\r\nexport const DROP_FRAMES = 9;\r\nexport const DROP_SCALE = 1.16;\r\n\r\nexport interface InlineDrop {\r\n  index: number;\r\n  scale: number;\r\n  opacity: number;\r\n}\r\n\r\n/**\r\n * The inline image drops in — the *same* smooth landing the hero uses: each new\r\n * image fades in over a few frames while settling from a slight zoom\r\n * (`DROP_SCALE` → 1), so you actually see it drop into place rather than cut.\r\n * Past images stay stacked underneath so the swap never flashes empty; the\r\n * newest sits on top. `DROP_FRAMES` < `INLINE_HOLD`, so every image — the last\r\n * one included — fully lands before the next arrives.\r\n */\r\nexport function inlineImage(frame: number, count: number): InlineDrop {\r\n  const index = Math.min(\r\n    count - 1,\r\n    Math.max(0, Math.floor((frame - INLINE_START) / INLINE_HOLD)),\r\n  );\r\n  const age = frame - (INLINE_START + index * INLINE_HOLD);\r\n  const scale = interpolate(age, [0, DROP_FRAMES], [DROP_SCALE, 1], {\r\n    ...CLAMP,\r\n    easing: EASE,\r\n  });\r\n  const opacity = interpolate(age, [0, 5], [0, 1], { ...CLAMP, easing: EASE });\r\n  return { index, scale, opacity };\r\n}\r\n\r\n/**\r\n * Forwards its `ref` so Remotion Studio can outline an intro card (see `Item`);\r\n * its `style` already arrives with Studio's merged in.\r\n */\r\nconst Card = forwardRef<\r\n  HTMLImageElement,\r\n  { src: string; style: CSSProperties }\r\n>(function Card({ src, style }, ref) {\r\n  return (\r\n    <Img\r\n      ref={ref}\r\n      src={resolveSrc(src)}\r\n      style={{\r\n        width: \"100%\",\r\n        height: \"100%\",\r\n        maxWidth: \"none\",\r\n        objectFit: \"cover\",\r\n        display: \"block\",\r\n        ...style,\r\n      }}\r\n    />\r\n  );\r\n});\r\n\r\n/** Rewrite root-relative assets through staticFile everywhere but the Player. */\r\nfunction resolveSrc(src: string): string {\r\n  const isLocal = src.startsWith(\"/\") && !src.startsWith(\"//\");\r\n  if (!isLocal || getRemotionEnvironment().isPlayer) return src;\r\n  // A value that already came out of staticFile() carries the static base\r\n  // (`/static-<hash>/…`); running it through again would prefix it twice.\r\n  const base = staticFile(\"_\").slice(0, -2);\r\n  if (base && src.startsWith(`${base}/`)) return src;\r\n  try {\r\n    return staticFile(src.replace(/^\\/+/, \"\"));\r\n  } catch {\r\n    return src;\r\n  }\r\n}\r\n\r\n/** Thin wireframe square/diamond marker that drifts and slowly rotates. */\r\nfunction WireMarker({\r\n  frame,\r\n  cx,\r\n  cy,\r\n  size,\r\n  spin,\r\n  color,\r\n  from,\r\n  to,\r\n}: {\r\n  frame: number;\r\n  cx: number;\r\n  cy: number;\r\n  size: number;\r\n  spin: number;\r\n  color: string;\r\n  from: number;\r\n  to: number;\r\n}) {\r\n  const opacity = interpolate(\r\n    frame,\r\n    [from, from + 8, to - 8, to],\r\n    [0, 1, 1, 0],\r\n    CLAMP,\r\n  );\r\n  if (opacity <= 0) return null;\r\n  const drift = Math.sin((frame - from) / 22) * 8;\r\n  const rot = spin + (frame - from) * 0.6;\r\n  return (\r\n    <div\r\n      style={{\r\n        position: \"absolute\",\r\n        left: cx,\r\n        top: cy + drift,\r\n        width: size,\r\n        height: size,\r\n        border: `1px solid ${color}`,\r\n        transform: `rotate(${rot}deg)`,\r\n        opacity,\r\n      }}\r\n    />\r\n  );\r\n}\r\n\r\nexport function MoodboardReveal({\r\n  leadIn = \"that lets you\",\r\n  emphasis = \"filter\",\r\n  tailIn = \"out AI.\",\r\n  images = DEFAULT_IMAGES,\r\n  heroImage,\r\n  darkColor,\r\n  lightColor,\r\n  theme,\r\n  fontFamily,\r\n  speed = 1,\r\n  className,\r\n}: MoodboardRevealProps) {\r\n  const frame = useCurrentFrame() * speed;\r\n  const { width, height } = useVideoConfig();\r\n  // The scene crossfades a dark page into a light one, so it needs both ends of\r\n  // the system at once rather than one resolved mode. Both still take a user's\r\n  // `theme` override.\r\n  const dark = useKuchiTheme(theme, \"dark\");\r\n  const face = resolveFont(fontFamily ?? dark.fontFamily) ?? FONT_FAMILY;\r\n  const light = useKuchiTheme(theme, \"light\");\r\n  const cx = width / 2;\r\n  const cy = height / 2;\r\n\r\n  const bg = bgProgress(frame);\r\n  const bgColor = interpolateColors(\r\n    bg,\r\n    [0, 1],\r\n    [darkColor ?? dark.background, lightColor ?? light.background],\r\n  );\r\n  // Both pages transparent — the scene as an overlay — asks for no page: no\r\n  // dotted grid, and ink that reads on light footage from the first frame.\r\n  const bare =\r\n    parseColor(darkColor ?? dark.background).alpha === 0 &&\r\n    parseColor(lightColor ?? light.background).alpha === 0;\r\n  // The marker is always the opposite page: light ink on the dark half, dark on\r\n  // the light one.\r\n  const markerColor =\r\n    bg < 0.5 && !bare\r\n      ? withAlpha(light.background, 0.55)\r\n      : withAlpha(dark.background, 0.5);\r\n  const hero = heroImage ?? images[3] ?? images[0];\r\n\r\n  // ── Intro sentence ──────────────────────────────────────────────────────────\r\n  const sentenceOp = interpolate(\r\n    frame,\r\n    [0, 8, SENTENCE_OUT - 6, SENTENCE_OUT],\r\n    [0, 1, 1, 0],\r\n    CLAMP,\r\n  );\r\n  const inline = inlineImage(frame, Math.min(INLINE_COUNT, images.length));\r\n\r\n  // ── Gallery (flicker + orbit + merge) ────────────────────────────────────────\r\n  const mBlur = mergeBlur(frame);\r\n  const merge = mergeProgress(frame);\r\n  const isRendering = getRemotionEnvironment().isRendering;\r\n  // The index into `images` each gallery position shows this frame; -1 when it\r\n  // is hidden, or holds a `heroImage` that isn't one of `images`.\r\n  const slotImage = SLOTS.map((s, i) => {\r\n    if (slotPose(frame, s, i).opacity <= 0) return -1;\r\n    if (i === SLOTS.length - 1 && frame >= MERGE_START)\r\n      return hero ? images.indexOf(hero) : -1;\r\n    return flickerImage(frame, i, images.length);\r\n  });\r\n  // One photo can be on screen twice — an intro card still fading as the\r\n  // gallery opens, two positions on the same picture. Studio outlines the\r\n  // front-most copy (drawn last); the others are only pictures of it.\r\n  const front = new Map<number, string>();\r\n  if (sentenceOp > 0)\r\n    for (let i = 0; i <= inline.index; i++) front.set(i, `in-${i}`);\r\n  slotImage.forEach((k, i) => {\r\n    if (k >= 0) front.set(k, `slot-${i}`);\r\n  });\r\n\r\n  return (\r\n    <div\r\n      className={className}\r\n      style={{\r\n        position: \"absolute\",\r\n        inset: 0,\r\n        overflow: \"hidden\",\r\n        backgroundColor: bgColor,\r\n        fontFamily: face,\r\n        // Any scaled text renders as the outline, not re-hinted per frame.\r\n        textRendering: \"geometricPrecision\",\r\n      }}\r\n    >\r\n      {/* Dotted grid, only on the dark background */}\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          inset: 0,\r\n          opacity: bare ? 0 : 1 - bg,\r\n          backgroundImage: `radial-gradient(circle, ${withAlpha(\r\n            light.background,\r\n            0.07,\r\n          )} 1px, transparent 1.5px)`,\r\n          backgroundSize: \"20px 20px\",\r\n        }}\r\n      />\r\n\r\n      {/* ── Intro sentence: \"<leadIn> [img] <emphasis> <tailIn>\" ── */}\r\n      {sentenceOp > 0 && (\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            inset: 0,\r\n            display: \"flex\",\r\n            alignItems: \"center\",\r\n            justifyContent: \"center\",\r\n            gap: 18,\r\n            opacity: sentenceOp,\r\n            color: bare ? light.foreground : dark.foreground,\r\n            fontSize: 28,\r\n            fontWeight: 400,\r\n            letterSpacing: \"-0.01em\",\r\n          }}\r\n        >\r\n          <span>{leadIn}</span>\r\n          <div\r\n            style={{\r\n              position: \"relative\",\r\n              width: 108,\r\n              height: 108 * CARD_RATIO,\r\n              overflow: \"hidden\",\r\n              flexShrink: 0,\r\n            }}\r\n          >\r\n            {images.slice(0, INLINE_COUNT).map((src, i) => {\r\n              if (i > inline.index) return null; // future image, not yet dropped\r\n              const isActive = i === inline.index;\r\n              return (\r\n                <Item key={src} index={i} primary={front.get(i) === `in-${i}`}>\r\n                  <Card\r\n                    src={src}\r\n                    style={{\r\n                      position: \"absolute\",\r\n                      inset: 0,\r\n                      zIndex: i,\r\n                      opacity: isActive ? inline.opacity : 1,\r\n                      transform: isActive\r\n                        ? `scale(${inline.scale})`\r\n                        : undefined,\r\n                      transformOrigin: \"center center\",\r\n                    }}\r\n                  />\r\n                </Item>\r\n              );\r\n            })}\r\n          </div>\r\n          <span>\r\n            <strong style={{ fontWeight: 700 }}>{emphasis}</strong> {tailIn}\r\n          </span>\r\n        </div>\r\n      )}\r\n\r\n      {/* ── Gallery: positions that flicker, orbit, then merge to centre ── */}\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          inset: 0,\r\n          filter: mBlur > 0.1 ? `blur(${mBlur}px)` : undefined,\r\n          ...(isRendering ? {} : { willChange: \"filter\" as const }),\r\n        }}\r\n      >\r\n        {SLOTS.map((s, i) => {\r\n          const pose = slotPose(frame, s, i);\r\n          if (pose.opacity <= 0) return null;\r\n          // The last-rendered position sits on top of the merged stack, so it is\r\n          // the one that remains — freeze it to the hero as the merge begins.\r\n          const isTop = i === SLOTS.length - 1;\r\n          const src =\r\n            isTop && frame >= MERGE_START\r\n              ? hero\r\n              : images[flickerImage(frame, i, images.length)];\r\n          const h = s.w * CARD_RATIO;\r\n          // Un-rotate as they merge so the stack aligns into one clean image.\r\n          const rot = s.rot * (1 - merge);\r\n          return (\r\n            <Item\r\n              key={`slot-${s.x}-${s.y}`}\r\n              index={slotImage[i] ?? -1}\r\n              primary={front.get(slotImage[i] ?? -1) === `slot-${i}`}\r\n            >\r\n              <div\r\n                style={{\r\n                  position: \"absolute\",\r\n                  left: cx + pose.x - s.w / 2,\r\n                  top: cy + pose.y - h / 2,\r\n                  width: s.w,\r\n                  height: h,\r\n                  opacity: pose.opacity,\r\n                  transform: `rotate(${rot}deg) scale(${pose.scale})`,\r\n                  // Shadow gives depth in the spread, but 8 stacked shadows pile\r\n                  // into a dark halo — so fade it out as they merge to one.\r\n                  boxShadow:\r\n                    merge > 0.98\r\n                      ? \"none\"\r\n                      : `0 18px 40px ${withAlpha(dark.background, 0.28 * (1 - merge))}`,\r\n                }}\r\n              >\r\n                <Card src={src} style={{}} />\r\n              </div>\r\n            </Item>\r\n          );\r\n        })}\r\n      </div>\r\n\r\n      {/* ── Wireframe markers ── */}\r\n      <WireMarker\r\n        frame={frame}\r\n        cx={cx + 150}\r\n        cy={cy - 130}\r\n        size={44}\r\n        spin={0}\r\n        color={markerColor}\r\n        from={4}\r\n        to={SENTENCE_OUT}\r\n      />\r\n      <WireMarker\r\n        frame={frame}\r\n        cx={cx - 240}\r\n        cy={cy + 40}\r\n        size={54}\r\n        spin={45}\r\n        color={markerColor}\r\n        from={MERGE_END - 6}\r\n        to={150}\r\n      />\r\n      <WireMarker\r\n        frame={frame}\r\n        cx={cx + 190}\r\n        cy={cy + 70}\r\n        size={40}\r\n        spin={12}\r\n        color={markerColor}\r\n        from={MERGE_END + 8}\r\n        to={150}\r\n      />\r\n    </div>\r\n  );\r\n}\r\n"}]}