agentcut 0.2.26 → 0.2.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +177 -177
  2. package/dist/studio/agents/claude.js +3 -2
  3. package/dist/studio/agents/claude.js.map +1 -1
  4. package/dist/studio/chat.js +1 -1
  5. package/dist/studio/chat.js.map +1 -1
  6. package/dist/studio/cli.js +24 -24
  7. package/dist/studio/download.d.ts +24 -0
  8. package/dist/studio/download.js +234 -0
  9. package/dist/studio/download.js.map +1 -0
  10. package/dist/studio/host.js +8 -0
  11. package/dist/studio/host.js.map +1 -1
  12. package/dist/studio/housekeeping.d.ts +2 -2
  13. package/dist/studio/housekeeping.js +18 -17
  14. package/dist/studio/housekeeping.js.map +1 -1
  15. package/dist/studio/release-cursor.js +21 -21
  16. package/dist/studio/release-video.js +10 -10
  17. package/dist/studio/tools.js +7 -0
  18. package/dist/studio/tools.js.map +1 -1
  19. package/package.json +56 -56
  20. package/template/AGENTS.md +14 -14
  21. package/template/components/README.md +70 -70
  22. package/template/components/before-after/BeforeAfter.tsx +89 -89
  23. package/template/components/catalog.ts +107 -107
  24. package/template/components/cinematic/Device3D.tsx +324 -324
  25. package/template/components/cinematic/devices3d/display-model.ts +184 -184
  26. package/template/components/cinematic/devices3d/iphone-model.ts +643 -643
  27. package/template/components/cinematic/devices3d/macbook-model.ts +608 -608
  28. package/template/components/cinematic/devices3d/models.ts +657 -657
  29. package/template/components/cinematic/devices3d/runtime.ts +267 -267
  30. package/template/components/cinematic/math.ts +100 -100
  31. package/template/components/color/grade-effect.ts +650 -650
  32. package/template/components/color/grade.ts +512 -512
  33. package/template/components/color/looks.ts +154 -154
  34. package/template/components/countdown/Countdown.tsx +166 -166
  35. package/template/components/dot-trace-title/DotTraceTitle.tsx +181 -181
  36. package/template/components/dot-trace-title/meta.json +51 -51
  37. package/template/components/generate/GenerateReveal.tsx +381 -381
  38. package/template/components/hook-card/HookCard.tsx +554 -554
  39. package/template/components/index.ts +199 -199
  40. package/template/components/lib.ts +191 -191
  41. package/template/components/line-diagram/LineDiagram.tsx +205 -205
  42. package/template/components/line-diagram/meta.json +215 -215
  43. package/template/components/list-card/ListCard.tsx +104 -104
  44. package/template/components/live-clip.ts +75 -75
  45. package/template/components/looks.tsx +1447 -1447
  46. package/template/components/loops/LoopCanvas.tsx +132 -132
  47. package/template/components/loops/engine.ts +184 -184
  48. package/template/components/loops/library.ts +667 -667
  49. package/template/components/loops/library2.ts +777 -777
  50. package/template/components/motion-loop/MotionLoop.tsx +37 -37
  51. package/template/components/motion-loop/meta.json +311 -311
  52. package/template/components/props.ts +73 -73
  53. package/template/components/quote-card/QuoteCard.tsx +71 -71
  54. package/template/components/style-layer.tsx +233 -233
  55. package/template/components/styles.ts +113 -113
  56. package/template/components/types.ts +66 -66
  57. package/template/components/word-pop/WordPop.tsx +59 -59
  58. package/template/components/word-stack/WordStack.tsx +122 -122
  59. package/template/presets/charcoal-sketch/PROMPT.md +48 -48
  60. package/template/presets/charcoal-sketch/scripts/duck_music.py +34 -34
  61. package/template/presets/punk-cut-paper/scenes/Motif.tsx +376 -376
  62. package/template/presets/punk-cut-paper/scenes/Photo.tsx +73 -73
  63. package/template/presets/punk-cut-paper/scenes/Ransom.tsx +119 -119
  64. package/template/runtime/composition.tsx +1189 -1189
  65. package/template/runtime/helpers.tsx +230 -230
  66. package/template/runtime/index.tsx +22 -22
  67. package/template/runtime/types.ts +315 -315
  68. package/template/skill/SKILL.md +186 -187
  69. package/template/skill/references/broll.md +44 -44
  70. package/template/skill/references/browser-export.md +61 -61
  71. package/template/skill/references/cinematic.md +206 -206
  72. package/template/skill/references/color.md +79 -79
  73. package/template/skill/references/craft.md +97 -97
  74. package/template/skill/references/editing-styles.md +57 -57
  75. package/template/skill/references/feature-launch.md +34 -34
  76. package/template/skill/references/footage.md +72 -72
  77. package/template/skill/references/format.md +142 -142
  78. package/template/skill/references/how-to.md +146 -146
  79. package/template/skill/references/launch-direction.md +89 -89
  80. package/template/skill/references/loops.md +151 -151
  81. package/template/skill/references/mcp-external.md +19 -19
  82. package/template/skill/references/performance.md +93 -93
  83. package/template/skill/references/person-cutout.md +19 -19
  84. package/template/skill/references/presets.md +60 -60
  85. package/template/skill/references/product-launch.md +134 -134
  86. package/template/skill/references/release-capture.md +53 -53
  87. package/template/skill/references/sound.md +167 -166
  88. package/template/skill/references/style-spy.md +160 -160
  89. package/template/skill/references/website-howto.md +45 -45
  90. package/template/starter/.studio/chat.json +1 -1
  91. package/template/starter/layers.json +46 -46
  92. package/template/starter/notes.md +4 -4
  93. package/template/starter/project.json +13 -13
  94. package/template/starter/scenes/Title.tsx +38 -38
@@ -1,1447 +1,1447 @@
1
- // Looks: the graphic language a style draws with (cards, chips, stickers, backdrops, entrances).
2
- // The talking-head components (hook-card, word-pop, sticker-badge, list-card, quote-card,
3
- // before-after), the styled captions and the style overlay are built from these pieces, so one
4
- // `look` restyles all of them. Same rules as the components: react, remotion and ./lib only;
5
- // everything is driven by the frame.
6
- import { useId, type CSSProperties, type ReactNode } from "react";
7
- import { AbsoluteFill, interpolate, spring } from "remotion";
8
- import { FONTS, alpha, clamp01, easeOutExpo, exitOut, glowStyle, mix, onColor, ramp, splitHighlights } from "./lib";
9
-
10
- /**
11
- * ink: neo-brutal · paper: cut-paper craft · notebook: grid paper and pen · crt: terminal ·
12
- * neon: cyberpunk · line: black and white line art, bold centered captions · vhs: 90s tape and TV ·
13
- * clean: soft cards.
14
- */
15
- export type Look = "ink" | "paper" | "notebook" | "crt" | "neon" | "line" | "vhs" | "clean";
16
-
17
- export const LOOKS: Look[] = ["ink", "paper", "notebook", "crt", "neon", "line", "vhs", "clean"];
18
-
19
- /** Colors and fonts every look piece reads. Build it once per component with `lookKit`. */
20
- export interface LookKit {
21
- look: Look;
22
- u: number;
23
- accent: string;
24
- onAccent: string;
25
- /** Card fill and the text on it (also the text on the backdrop). */
26
- panel: string;
27
- panelText: string;
28
- /** Borders, hard shadows, pen strokes, ink. */
29
- line: string;
30
- /** Full-frame fill under the texture. */
31
- backdrop: string;
32
- /** Text straight over footage. */
33
- text: string;
34
- /** Headline / small text. */
35
- head: string;
36
- body: string;
37
- }
38
-
39
- export interface LookProps {
40
- look: string;
41
- accent: string;
42
- panel: string;
43
- panelText: string;
44
- line: string;
45
- backdrop: string;
46
- /** Text straight over footage. */
47
- onVideo: string;
48
- font: string;
49
- }
50
-
51
- const BODY_FONT: Record<Look, string> = {
52
- ink: FONTS.grotesk,
53
- paper: FONTS.mono,
54
- notebook: FONTS.caveat,
55
- crt: FONTS.pixel,
56
- neon: FONTS.mono,
57
- line: FONTS.sans,
58
- vhs: FONTS.pixel,
59
- clean: FONTS.sans,
60
- };
61
-
62
- const isHex = (color: string) => /^#?[0-9a-f]{6}$/i.test(color.trim());
63
- /** alpha() for colors that may not be hex (rgba panels): falls back to a neutral. */
64
- const tint = (color: string, a: number, fallback = "#000000") => alpha(isHex(color) ? color : fallback, a);
65
-
66
- export function lookKit(props: LookProps, u: number): LookKit {
67
- const look = (LOOKS as string[]).includes(props.look) ? (props.look as Look) : "ink";
68
- return {
69
- look,
70
- u,
71
- accent: props.accent,
72
- onAccent: onColor(props.accent),
73
- panel: props.panel,
74
- panelText: props.panelText,
75
- line: props.line,
76
- backdrop: props.backdrop,
77
- text: props.onVideo,
78
- head: FONTS[props.font] ?? FONTS.archivo,
79
- body: BODY_FONT[look],
80
- };
81
- }
82
-
83
- /** Headline weight per look (Archivo Black, Anton, VT323 have one weight). */
84
- export function headWeight(kit: LookKit) {
85
- return kit.look === "line" ? 900 : kit.look === "notebook" ? 700 : kit.look === "clean" || kit.look === "neon" ? 800 : 400;
86
- }
87
-
88
- const labelCase = (kit: LookKit): CSSProperties["textTransform"] =>
89
- kit.look === "notebook" || kit.look === "crt" ? "none" : "uppercase";
90
-
91
- /** VHS color bleed: red and cyan ghosts either side of the text. */
92
- export function chroma(u: number, amount = 1) {
93
- return `${-3 * u * amount}px 0 rgba(255,40,60,0.75), ${3 * u * amount}px 0 rgba(40,220,255,0.7)`;
94
- }
95
-
96
- /** Deterministic 0…1 noise. */
97
- export function hash(a: number, b = 0) {
98
- const n = Math.sin(a * 127.1 + b * 311.7) * 43758.5453;
99
- return n - Math.floor(n);
100
- }
101
-
102
- /** Stop-motion: the frame held for two (paper animates "on twos"). */
103
- const onTwos = (frame: number) => frame - (frame % 2);
104
-
105
- // ---------------------------------------------------------------------------
106
- // Motion
107
-
108
- /** Each look's entrance (opacity + transform), `delay` frames in. `seed` varies the paper jitter. */
109
- export function enter(kit: LookKit, frame: number, fps: number, delay = 0, tilt = 0, seed = 1) {
110
- const f = frame - delay;
111
- switch (kit.look) {
112
- case "ink": {
113
- // A slap: overshooting scale and a twist that settles on the tilt.
114
- const s = spring({ frame: f, fps, config: { damping: 11, stiffness: 230, mass: 0.7 } });
115
- return {
116
- opacity: clamp01(s * 4),
117
- transform: `scale(${mix(0.55, 1, s)}) rotate(${mix(tilt - 9, tilt, s)}deg)`,
118
- };
119
- }
120
- case "paper": {
121
- // Slapped down from above, then the hand-animated wobble of stop-motion.
122
- if (f < 0) return { opacity: 0, transform: "scale(1.8)" };
123
- const s = interpolate(f, [0, 3, 5], [1.8, 0.94, 1], { extrapolateRight: "clamp" });
124
- const h = onTwos(frame);
125
- const settled = f >= 6;
126
- const jx = settled ? (hash(seed, h) - 0.5) * 3 * kit.u : 0;
127
- const jy = settled ? (hash(seed + 7, h) - 0.5) * 3 * kit.u : 0;
128
- const jr = settled ? (hash(seed + 13, h) - 0.5) * 1.2 : 0;
129
- return { opacity: 1, transform: `translate(${jx}px, ${jy}px) rotate(${tilt + jr}deg) scale(${s})` };
130
- }
131
- case "notebook": {
132
- const t = ramp(frame, delay, 14);
133
- return {
134
- opacity: t,
135
- transform: `translateY(${mix(22 * kit.u, 0, t)}px) rotate(${mix(tilt - 3, tilt, t)}deg)`,
136
- };
137
- }
138
- case "neon": {
139
- // Glitches in: a few frames of sideways tearing and flicker, then holds.
140
- if (f < 0) return { opacity: 0, transform: `rotate(${tilt}deg)` };
141
- if (f < 7) {
142
- const k = 1 - f / 7;
143
- const x = (hash(seed + f, 3) - 0.5) * 60 * kit.u * k;
144
- const skew = (hash(seed + f, 5) - 0.5) * 24 * k;
145
- return { opacity: f % 2 === 0 ? 1 : 0.55, transform: `translateX(${x.toFixed(1)}px) skewX(${skew.toFixed(1)}deg) rotate(${tilt}deg)` };
146
- }
147
- return { opacity: 1, transform: `rotate(${tilt}deg)` };
148
- }
149
- case "vhs": {
150
- // Tracking settles: a short roll from above with sideways jitter and flicker.
151
- if (f < 0) return { opacity: 0, transform: `rotate(${tilt}deg)` };
152
- if (f < 8) {
153
- const k = 1 - f / 8;
154
- const x = (hash(seed + f, 7) - 0.5) * 36 * kit.u * k;
155
- return { opacity: f % 3 === 1 ? 0.6 : 1, transform: `translate(${x.toFixed(1)}px, ${(-40 * kit.u * k * k).toFixed(1)}px) rotate(${tilt}deg)` };
156
- }
157
- return { opacity: 1, transform: `rotate(${tilt}deg)` };
158
- }
159
- case "line": {
160
- // A quick pop: overshoot, then settle.
161
- if (f < 0) return { opacity: 0, transform: `scale(0.6) rotate(${tilt}deg)` };
162
- const s = interpolate(f, [0, 3, 6], [0.6, 1.12, 1], { extrapolateRight: "clamp" });
163
- return { opacity: 1, transform: `scale(${s}) rotate(${tilt}deg)` };
164
- }
165
- case "crt": {
166
- // Power-on flicker, no movement.
167
- const opacity = f < 0 ? 0 : f < 2 ? 0.5 : f < 3 ? 0.1 : f < 5 ? 0.85 : 1;
168
- return { opacity, transform: `rotate(${tilt}deg)` };
169
- }
170
- default: {
171
- const t = ramp(frame, delay, 18, easeOutExpo);
172
- return { opacity: t, transform: `translateY(${mix(28 * kit.u, 0, t)}px) rotate(${tilt}deg)` };
173
- }
174
- }
175
- }
176
-
177
- /** Characters of `text` typed so far (crt types, other looks show it all once in). */
178
- export function typed(kit: LookKit, text: string, frame: number, start: number, perFrame = 1.6) {
179
- if (kit.look !== "crt") return text;
180
- return text.slice(0, Math.max(0, Math.floor((frame - start) * perFrame)));
181
- }
182
-
183
- // ---------------------------------------------------------------------------
184
- // Texture
185
-
186
- function useSvgId(prefix: string) {
187
- return `${prefix}${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
188
- }
189
-
190
- const fullSvg: CSSProperties = { position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none" };
191
-
192
- /** Thin horizontal lines, as an SVG pattern (the export draws SVG exactly). */
193
- export function Scanlines({ u, opacity = 0.32 }: { u: number; opacity?: number }) {
194
- const id = useSvgId("scan");
195
- const gap = Math.max(3, 6 * u);
196
- return (
197
- <svg style={fullSvg}>
198
- <defs>
199
- <pattern id={id} width={gap} height={gap} patternUnits="userSpaceOnUse">
200
- <rect width={gap} height={gap / 2} fill={`rgba(0,0,0,${opacity})`} />
201
- </pattern>
202
- </defs>
203
- <rect width="100%" height="100%" fill={`url(#${id})`} />
204
- </svg>
205
- );
206
- }
207
-
208
- /** Paper / film grain (SVG noise). `seed` changes per frame for moving grain. */
209
- export function Grain({ opacity = 0.3, seed = 1, frequency = 0.85, warm = true }: { opacity?: number; seed?: number; frequency?: number; warm?: boolean }) {
210
- const id = useSvgId("grain");
211
- const [r, g, b] = warm ? [0.16, 0.11, 0.05] : [0, 0, 0];
212
- return (
213
- <svg style={fullSvg}>
214
- <filter id={id}>
215
- <feTurbulence type="fractalNoise" baseFrequency={frequency} numOctaves={2} seed={seed} stitchTiles="stitch" />
216
- <feColorMatrix type="matrix" values={`0 0 0 0 ${r} 0 0 0 0 ${g} 0 0 0 0 ${b} 0 0 0 ${opacity * 2.2} -${opacity * 0.5}`} />
217
- </filter>
218
- <rect width="100%" height="100%" filter={`url(#${id})`} />
219
- </svg>
220
- );
221
- }
222
-
223
- /** Corners darkened toward the edges (linear gradients only: the export can't draw sized radials). */
224
- export function Vignette({ color = "#000000", amount = 0.35 }: { color?: string; amount?: number }) {
225
- const c0 = tint(color, amount);
226
- const c1 = tint(color, 0);
227
- return (
228
- <>
229
- <div style={{ position: "absolute", inset: 0, background: `linear-gradient(180deg, ${c0} 0%, ${c1} 24%, ${c1} 76%, ${c0} 100%)` }} />
230
- <div style={{ position: "absolute", inset: 0, background: `linear-gradient(90deg, ${c0} 0%, ${c1} 18%, ${c1} 82%, ${c0} 100%)` }} />
231
- </>
232
- );
233
- }
234
-
235
- /** A torn-edged polygon in a 100×100 box (stretch it with preserveAspectRatio="none"). */
236
- function tornBox(seed: number, depth = 3) {
237
- const pts: string[] = [];
238
- const edge = (x0: number, y0: number, x1: number, y1: number, n: number, side: number) => {
239
- for (let i = 0; i < n; i += 1) {
240
- const t = i / n;
241
- const off = (hash(seed + side * 31, i) - 0.5) * depth;
242
- const x = mix(x0, x1, t) + (y0 === y1 ? 0 : off);
243
- const y = mix(y0, y1, t) + (y0 === y1 ? off : 0);
244
- pts.push(`${x.toFixed(2)},${y.toFixed(2)}`);
245
- }
246
- };
247
- edge(0, 0, 100, 0, 9, 1);
248
- edge(100, 0, 100, 100, 5, 2);
249
- edge(100, 100, 0, 100, 9, 3);
250
- edge(0, 100, 0, 0, 5, 4);
251
- return pts.join(" ");
252
- }
253
-
254
- /** A paper scrap behind its children: torn edges, a drop shadow and grain. */
255
- function Scrap({ bg, seed, children, shadow = 0.4, style }: { bg: string; seed: number; children: ReactNode; shadow?: number; style?: CSSProperties }) {
256
- const points = tornBox(seed, 4);
257
- return (
258
- <span style={{ position: "relative", display: "inline-block", ...style }}>
259
- <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", left: "3%", top: "7%", width: "100%", height: "100%", overflow: "visible" }}>
260
- <polygon points={points} fill={`rgba(20,12,4,${shadow})`} />
261
- </svg>
262
- <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", inset: 0, width: "100%", height: "100%", overflow: "visible" }}>
263
- <polygon points={points} fill={bg} />
264
- </svg>
265
- <span style={{ position: "relative", display: "inline-block" }}>{children}</span>
266
- </span>
267
- );
268
- }
269
-
270
- /** Paper colors a ransom chip can be cut from. */
271
- function paperChips(kit: LookKit) {
272
- return [
273
- { bg: kit.panel, fg: kit.panelText },
274
- { bg: kit.accent, fg: kit.onAccent },
275
- { bg: kit.line, fg: kit.panel },
276
- { bg: "#dcc7a0", fg: "#1a1410" },
277
- { bg: "#ffffff", fg: isHex(kit.accent) ? kit.accent : "#1a1410" },
278
- ];
279
- }
280
-
281
- const RANSOM_FONTS = [FONTS.archivo, FONTS.serif, FONTS.condensed, FONTS.mono, FONTS.fraunces, FONTS.grotesk];
282
-
283
- /** Text cut letter by letter from different papers and typefaces, each letter slapped down in turn. */
284
- export function CutLetters({ kit, text, fontSize, frame, fps, start = 0, stagger = 2, seed = 1 }: { kit: LookKit; text: string; fontSize: number; frame: number; fps: number; start?: number; stagger?: number; seed?: number }) {
285
- const chips = paperChips(kit);
286
- const words = text.toUpperCase().split(/\s+/).filter(Boolean);
287
- // Letters land one after another across the words; a word never breaks across lines.
288
- const offsets = words.map((_, w) => words.slice(0, w).reduce((sum, word) => sum + word.length, 0));
289
- return (
290
- <span style={{ display: "inline-flex", flexWrap: "wrap", alignItems: "center", columnGap: fontSize * 0.3, rowGap: fontSize * 0.1 }}>
291
- {words.map((word, w) => (
292
- <span key={w} style={{ display: "inline-flex", alignItems: "center", whiteSpace: "nowrap" }}>
293
- {Array.from(word).map((ch, c) => {
294
- const index = offsets[w] + c;
295
- const s = seed * 97 + index * 13;
296
- const chip = chips[Math.floor(hash(s, 2) * chips.length)];
297
- const e = enter(kit, frame, fps, start + index * stagger, (hash(s, 3) - 0.5) * 16, s);
298
- return (
299
- <span key={c} style={{ display: "inline-block", margin: `0 ${fontSize * 0.03}px`, opacity: e.opacity, transform: e.transform }}>
300
- <Scrap bg={chip.bg} seed={s}>
301
- <span
302
- style={{
303
- display: "inline-block",
304
- fontFamily: RANSOM_FONTS[Math.floor(hash(s, 1) * RANSOM_FONTS.length)],
305
- fontSize: fontSize * (0.88 + hash(s, 4) * 0.28),
306
- lineHeight: 1.05,
307
- color: chip.fg,
308
- padding: `${fontSize * 0.06}px ${fontSize * 0.14}px ${fontSize * 0.02}px`,
309
- }}
310
- >
311
- {ch}
312
- </span>
313
- </Scrap>
314
- </span>
315
- );
316
- })}
317
- </span>
318
- ))}
319
- </span>
320
- );
321
- }
322
-
323
- /** The full-frame ground of a look: halftone, cut paper, grid paper, CRT glass or a soft gradient. */
324
- export function Backdrop({ kit, width, height, seed = 1 }: { kit: LookKit; width: number; height: number; seed?: number }) {
325
- const id = useSvgId("bd");
326
- const u = kit.u;
327
- const fillStyle: CSSProperties = { position: "absolute", inset: 0, background: kit.backdrop, overflow: "hidden" };
328
- if (kit.look === "ink") {
329
- const step = 26 * u;
330
- return (
331
- <div style={fillStyle}>
332
- <svg style={fullSvg}>
333
- <defs>
334
- <pattern id={`${id}p`} width={step} height={step} patternUnits="userSpaceOnUse">
335
- <circle cx={step / 2} cy={step / 2} r={step * 0.2} fill={tint(kit.line, 0.16)} />
336
- </pattern>
337
- <linearGradient id={`${id}g`} x1="0" y1="0" x2="0" y2="1">
338
- <stop offset="0" stopColor="#fff" stopOpacity="0.15" />
339
- <stop offset="1" stopColor="#fff" stopOpacity="1" />
340
- </linearGradient>
341
- <mask id={`${id}m`}>
342
- <rect width="100%" height="100%" fill={`url(#${id}g)`} />
343
- </mask>
344
- </defs>
345
- <rect width="100%" height="100%" fill={`url(#${id}p)`} mask={`url(#${id}m)`} />
346
- </svg>
347
- </div>
348
- );
349
- }
350
- if (kit.look === "paper") {
351
- // Kraft ground with two torn sheets laid across it.
352
- return (
353
- <div style={fillStyle}>
354
- <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", left: "-12%", top: "8%", width: "80%", height: "46%", transform: "rotate(-7deg)" }}>
355
- <polygon points={tornBox(seed + 3, 3)} fill={kit.accent} />
356
- </svg>
357
- <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", right: "-14%", bottom: "4%", width: "86%", height: "42%", transform: "rotate(5deg)" }}>
358
- <polygon points={tornBox(seed + 9, 3)} fill={kit.panel} />
359
- </svg>
360
- <Grain opacity={0.32} seed={seed} />
361
- </div>
362
- );
363
- }
364
- if (kit.look === "notebook") {
365
- const step = 48 * u;
366
- return (
367
- <div style={fillStyle}>
368
- <svg style={fullSvg}>
369
- <defs>
370
- <pattern id={`${id}p`} width={step} height={step} patternUnits="userSpaceOnUse">
371
- <path d={`M ${step} 0 L 0 0 0 ${step}`} fill="none" stroke="rgba(70,90,130,0.16)" strokeWidth={Math.max(1, 1.5 * u)} />
372
- </pattern>
373
- </defs>
374
- <rect width="100%" height="100%" fill={`url(#${id}p)`} />
375
- </svg>
376
- </div>
377
- );
378
- }
379
- if (kit.look === "neon") {
380
- const horizon = height * 0.58;
381
- const lines: ReactNode[] = [];
382
- for (let i = -12; i <= 12; i += 1) {
383
- lines.push(<line key={`v${i}`} x1={width / 2 + i * width * 0.02} y1={horizon} x2={width / 2 + i * width * 0.22} y2={height} />);
384
- }
385
- for (let i = 1; i <= 9; i += 1) {
386
- const y = horizon + (height - horizon) * Math.pow(i / 9, 2.2);
387
- lines.push(<line key={`h${i}`} x1={0} y1={y} x2={width} y2={y} />);
388
- }
389
- return (
390
- <div style={fillStyle}>
391
- <div style={glowStyle(width * 0.15, height * 0.18, width * 1.2, width * 1.2, kit.accent, 0.3)} />
392
- <div style={glowStyle(width * 0.9, height * 0.75, width * 1.1, width * 1.1, isHex(kit.line) ? kit.line : "#22e8ff", 0.22)} />
393
- <svg style={fullSvg}>
394
- <g stroke={tint(kit.accent, 0.45)} strokeWidth={Math.max(1, 1.6 * u)}>{lines}</g>
395
- <line x1={0} y1={horizon} x2={width} y2={horizon} stroke={isHex(kit.line) ? kit.line : "#22e8ff"} strokeWidth={Math.max(1, 2 * u)} opacity={0.8} />
396
- </svg>
397
- <Scanlines u={u} opacity={0.14} />
398
- </div>
399
- );
400
- }
401
- if (kit.look === "line") {
402
- return <div style={fillStyle} />;
403
- }
404
- if (kit.look === "vhs") {
405
- return (
406
- <div style={{ ...fillStyle, background: `linear-gradient(180deg, ${kit.backdrop} 0%, ${tint(kit.backdrop, 0.85, "#1626c9")} 100%)` }}>
407
- <Grain opacity={0.18} seed={seed} warm={false} frequency={1.1} />
408
- <Scanlines u={u} opacity={0.18} />
409
- <Vignette amount={0.35} />
410
- </div>
411
- );
412
- }
413
- if (kit.look === "crt") {
414
- const step = 60 * u;
415
- return (
416
- <div style={fillStyle}>
417
- <svg style={fullSvg}>
418
- <defs>
419
- <pattern id={`${id}p`} width={step} height={step} patternUnits="userSpaceOnUse">
420
- <path d={`M ${step} 0 L 0 0 0 ${step}`} fill="none" stroke={tint(kit.accent, 0.07)} strokeWidth={Math.max(1, 1.2 * u)} />
421
- </pattern>
422
- </defs>
423
- <rect width="100%" height="100%" fill={`url(#${id}p)`} />
424
- </svg>
425
- <div style={glowStyle(width / 2, height / 2, width * 1.3, height * 1.1, kit.accent, 0.14)} />
426
- <Scanlines u={u} />
427
- <Vignette amount={0.45} />
428
- </div>
429
- );
430
- }
431
- return (
432
- <div style={{ ...fillStyle, background: `linear-gradient(165deg, ${tint(kit.accent, 0.18)} 0%, ${kit.backdrop} 45%, ${kit.backdrop} 100%)` }}>
433
- <div style={glowStyle(width * 0.25, height * 0.15, width * 1.1, width * 1.1, kit.accent, 0.12)} />
434
- </div>
435
- );
436
- }
437
-
438
- // ---------------------------------------------------------------------------
439
- // Cards
440
-
441
- /** A card in the look: ink border + hard shadow, torn paper, taped notebook page, terminal window or a soft card. */
442
- export function Panel({
443
- kit,
444
- children,
445
- style,
446
- title,
447
- seed = 1,
448
- }: {
449
- kit: LookKit;
450
- children: ReactNode;
451
- style?: CSSProperties;
452
- /** crt window title. */
453
- title?: string;
454
- seed?: number;
455
- }) {
456
- const u = kit.u;
457
- const base: CSSProperties = { position: "relative", color: kit.panelText, ...style };
458
- if (kit.look === "ink") {
459
- return (
460
- <div
461
- style={{
462
- ...base,
463
- background: kit.panel,
464
- border: `${Math.max(3, 6 * u)}px solid ${kit.line}`,
465
- borderRadius: 10 * u,
466
- boxShadow: `${14 * u}px ${14 * u}px 0 ${kit.line}`,
467
- }}
468
- >
469
- {children}
470
- </div>
471
- );
472
- }
473
- if (kit.look === "paper") {
474
- const points = tornBox(seed, 2.5);
475
- return (
476
- <div style={base}>
477
- <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", left: 10 * u, top: 16 * u, width: "100%", height: "100%", overflow: "visible" }}>
478
- <polygon points={points} fill="rgba(20,12,4,0.42)" />
479
- </svg>
480
- <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", inset: 0, width: "100%", height: "100%", overflow: "visible" }}>
481
- <polygon points={points} fill={kit.panel} />
482
- </svg>
483
- <div style={{ position: "absolute", inset: 0, overflow: "hidden" }}>
484
- <Grain opacity={0.22} seed={seed + 2} />
485
- </div>
486
- {/* Masking tape across a corner. */}
487
- <div style={{ position: "absolute", left: -24 * u, top: 18 * u, width: 150 * u, height: 40 * u, background: "rgba(232,220,186,0.86)", transform: "rotate(-32deg)" }} />
488
- <div style={{ position: "relative" }}>{children}</div>
489
- </div>
490
- );
491
- }
492
- if (kit.look === "notebook") {
493
- return (
494
- <div
495
- style={{
496
- ...base,
497
- background: kit.panel,
498
- border: `${Math.max(2, 3 * u)}px solid ${kit.line}`,
499
- // Uneven corners read as drawn by hand.
500
- borderRadius: `${10 * u}px ${26 * u}px ${12 * u}px ${20 * u}px / ${20 * u}px ${12 * u}px ${26 * u}px ${10 * u}px`,
501
- boxShadow: `0 ${8 * u}px ${24 * u}px rgba(0,0,0,0.18)`,
502
- }}
503
- >
504
- <div
505
- style={{
506
- position: "absolute",
507
- left: "50%",
508
- top: -22 * u,
509
- width: 170 * u,
510
- height: 44 * u,
511
- marginLeft: -85 * u,
512
- background: "rgba(236,226,196,0.82)",
513
- transform: "rotate(-3deg)",
514
- }}
515
- />
516
- {children}
517
- </div>
518
- );
519
- }
520
- if (kit.look === "neon") {
521
- const cut = 28 * u;
522
- const glowColor = isHex(kit.line) ? kit.line : "#22e8ff";
523
- const shape = `polygon(${cut}px 0, 100% 0, 100% calc(100% - ${cut}px), calc(100% - ${cut}px) 100%, 0 100%, 0 ${cut}px)`;
524
- return (
525
- <div style={{ ...base, filter: `drop-shadow(0 0 ${14 * u}px ${tint(glowColor, 0.55)})` }}>
526
- <div style={{ position: "absolute", inset: 0, background: glowColor, clipPath: shape }} />
527
- <div style={{ position: "absolute", inset: Math.max(2, 3 * u), background: kit.panel, clipPath: shape }} />
528
- <div style={{ position: "absolute", left: cut * 1.4, top: -Math.max(2, 3 * u), width: 90 * u, height: Math.max(4, 7 * u), background: kit.accent }} />
529
- <div style={{ position: "relative" }}>{children}</div>
530
- </div>
531
- );
532
- }
533
- if (kit.look === "line") {
534
- return (
535
- <div style={{ ...base, background: kit.panel, border: `${Math.max(2, 3 * u)}px solid ${kit.line}` }}>
536
- {children}
537
- </div>
538
- );
539
- }
540
- if (kit.look === "vhs") {
541
- return (
542
- <div
543
- style={{
544
- ...base,
545
- background: kit.panel,
546
- border: `${Math.max(2, 3 * u)}px solid ${kit.line}`,
547
- outline: `${Math.max(1, 2 * u)}px solid ${kit.line}`,
548
- outlineOffset: `${6 * u}px`,
549
- }}
550
- >
551
- {children}
552
- <Scanlines u={u} opacity={0.16} />
553
- </div>
554
- );
555
- }
556
- if (kit.look === "crt") {
557
- const bar = 46 * u;
558
- return (
559
- <div
560
- style={{
561
- ...base,
562
- background: kit.panel,
563
- border: `${Math.max(2, 3 * u)}px solid ${kit.line}`,
564
- boxShadow: `0 0 ${30 * u}px ${tint(kit.line, 0.35)}`,
565
- paddingTop: bar,
566
- overflow: "hidden",
567
- }}
568
- >
569
- <div
570
- style={{
571
- position: "absolute",
572
- left: 0,
573
- right: 0,
574
- top: 0,
575
- height: bar,
576
- display: "flex",
577
- alignItems: "center",
578
- gap: 10 * u,
579
- padding: `0 ${18 * u}px`,
580
- borderBottom: `${Math.max(1, 2 * u)}px solid ${tint(kit.line, 0.6)}`,
581
- fontFamily: kit.body,
582
- fontSize: 30 * u,
583
- color: tint(kit.line, 0.85),
584
- }}
585
- >
586
- {[0, 1, 2].map((i) => (
587
- <span key={i} style={{ width: 14 * u, height: 14 * u, background: tint(kit.line, 0.7 - i * 0.2) }} />
588
- ))}
589
- <span style={{ marginLeft: 8 * u }}>{title ?? "~/note.txt"}</span>
590
- </div>
591
- {children}
592
- <Scanlines u={u} opacity={0.22} />
593
- </div>
594
- );
595
- }
596
- return (
597
- <div
598
- style={{
599
- ...base,
600
- background: kit.panel,
601
- borderRadius: 30 * u,
602
- border: `${Math.max(1, 2 * u)}px solid rgba(255,255,255,0.1)`,
603
- boxShadow: `0 ${24 * u}px ${70 * u}px rgba(0,0,0,0.4)`,
604
- }}
605
- >
606
- {children}
607
- </div>
608
- );
609
- }
610
-
611
- // ---------------------------------------------------------------------------
612
- // Words
613
-
614
- /** One highlighted word, drawn the look's way (the *starred* words of a line). */
615
- function Accent({ kit, children, fontSize, onPanel, progress = 1, seed = 1 }: { kit: LookKit; children: ReactNode; fontSize: number; onPanel: boolean; progress?: number; seed?: number }) {
616
- const u = kit.u;
617
- if (kit.look === "ink") {
618
- return (
619
- <span
620
- style={{
621
- display: "inline-block",
622
- background: kit.accent,
623
- color: kit.onAccent,
624
- padding: `0 ${fontSize * 0.14}px`,
625
- border: `${Math.max(2, 3.5 * u)}px solid ${kit.line}`,
626
- borderRadius: 6 * u,
627
- lineHeight: 1.12,
628
- }}
629
- >
630
- {children}
631
- </span>
632
- );
633
- }
634
- if (kit.look === "paper") {
635
- return (
636
- <Scrap bg={kit.accent} seed={seed} shadow={0.35}>
637
- <span style={{ display: "inline-block", color: kit.onAccent, padding: `0 ${fontSize * 0.14}px` }}>{children}</span>
638
- </Scrap>
639
- );
640
- }
641
- if (kit.look === "notebook") {
642
- // A marker swipe that draws across the word.
643
- return (
644
- <span style={{ position: "relative", display: "inline-block" }}>
645
- <span
646
- style={{
647
- position: "absolute",
648
- left: -fontSize * 0.08,
649
- top: "38%",
650
- height: "52%",
651
- width: `calc(${progress * 100}% + ${fontSize * 0.16 * progress}px)`,
652
- background: tint(kit.accent, 0.85, "#ffd60a"),
653
- transform: "rotate(-1.5deg)",
654
- borderRadius: fontSize * 0.1,
655
- }}
656
- />
657
- <span style={{ position: "relative", color: onPanel ? kit.panelText : progress > 0.5 ? kit.onAccent : kit.text }}>{children}</span>
658
- </span>
659
- );
660
- }
661
- if (kit.look === "crt") {
662
- return <span style={{ display: "inline-block", background: kit.accent, color: kit.onAccent, padding: `0 ${fontSize * 0.12}px` }}>{children}</span>;
663
- }
664
- if (kit.look === "line") {
665
- return <span style={{ color: kit.accent }}>{children}</span>;
666
- }
667
- if (kit.look === "vhs") {
668
- return <span style={{ color: kit.accent, textShadow: chroma(u) }}>{children}</span>;
669
- }
670
- if (kit.look === "neon") {
671
- return (
672
- <span
673
- style={{
674
- display: "inline-block",
675
- background: kit.accent,
676
- color: kit.onAccent,
677
- padding: `0 ${fontSize * 0.14}px`,
678
- boxShadow: `${5 * u}px ${4 * u}px 0 ${kit.line}`,
679
- textShadow: "none",
680
- }}
681
- >
682
- {children}
683
- </span>
684
- );
685
- }
686
- return <span style={{ color: kit.accent }}>{children}</span>;
687
- }
688
-
689
- /**
690
- * A line of words with *starred* accents. Words appear one after another from `start`
691
- * (`stagger` frames apart), or at `times` (frames, one per word); otherwise all at once.
692
- */
693
- export function Words({
694
- kit,
695
- line,
696
- fontSize,
697
- frame,
698
- start = 0,
699
- stagger = 0,
700
- times,
701
- onPanel = true,
702
- seed = 1,
703
- style,
704
- }: {
705
- kit: LookKit;
706
- line: string;
707
- fontSize: number;
708
- frame: number;
709
- start?: number;
710
- stagger?: number;
711
- times?: number[];
712
- onPanel?: boolean;
713
- seed?: number;
714
- style?: CSSProperties;
715
- }) {
716
- const words = splitHighlights(line);
717
- const animated = stagger > 0 || Boolean(times);
718
- return (
719
- <span style={{ display: "inline-flex", flexWrap: "wrap", alignItems: "baseline", columnGap: fontSize * 0.26, rowGap: fontSize * 0.08, ...style }}>
720
- {words.map((word, i) => {
721
- const at = times?.[i] ?? start + i * stagger;
722
- // Spoken words (captions) take no space until they're said, so the box grows word by word.
723
- if (times && frame < at) return null;
724
- const t = animated ? ramp(frame, at, 5) : 1;
725
- const pop = animated ? interpolate(frame, [at, at + 3, at + 6], [0.7, 1.08, 1], { extrapolateLeft: "clamp", extrapolateRight: "clamp" }) : 1;
726
- return (
727
- <span key={i} style={{ display: "inline-block", opacity: t, transform: `scale(${pop})` }}>
728
- {word.highlighted ? (
729
- <Accent kit={kit} fontSize={fontSize} onPanel={onPanel} progress={ramp(frame, at + 3, 10)} seed={seed * 31 + i}>
730
- {word.text}
731
- </Accent>
732
- ) : (
733
- word.text
734
- )}
735
- </span>
736
- );
737
- })}
738
- </span>
739
- );
740
- }
741
-
742
- /**
743
- * A caption-like phrase over footage: white box with ink border, ransom-note words on paper,
744
- * handwriting with a marker, terminal text on black, or a dark pill.
745
- */
746
- export function Chip({
747
- kit,
748
- line,
749
- fontSize,
750
- frame,
751
- fps,
752
- start = 0,
753
- stagger = 0,
754
- times,
755
- seed = 1,
756
- onBackdrop = false,
757
- style,
758
- }: {
759
- kit: LookKit;
760
- line: string;
761
- fontSize: number;
762
- frame: number;
763
- fps: number;
764
- start?: number;
765
- stagger?: number;
766
- times?: number[];
767
- seed?: number;
768
- /** Sits on the look's backdrop (a full-frame card) rather than over footage. */
769
- onBackdrop?: boolean;
770
- style?: CSSProperties;
771
- }) {
772
- const u = kit.u;
773
- const words = (onPanel: boolean) => (
774
- <Words kit={kit} line={line} fontSize={fontSize} frame={frame} start={start} stagger={stagger} times={times} onPanel={onPanel} seed={seed} />
775
- );
776
- const text: CSSProperties = { fontSize, lineHeight: 1.15 };
777
- if (kit.look === "ink") {
778
- return (
779
- <span
780
- style={{
781
- ...text,
782
- display: "inline-block",
783
- fontFamily: kit.body,
784
- fontWeight: 700,
785
- textTransform: "uppercase",
786
- background: kit.panel,
787
- color: kit.panelText,
788
- border: `${Math.max(2, 4 * u)}px solid ${kit.line}`,
789
- boxShadow: `${6 * u}px ${6 * u}px 0 ${kit.line}`,
790
- padding: `${fontSize * 0.12}px ${fontSize * 0.3}px`,
791
- ...style,
792
- }}
793
- >
794
- {words(true)}
795
- </span>
796
- );
797
- }
798
- if (kit.look === "paper") {
799
- // Each word on its own scrap, in its own typeface.
800
- const chips = paperChips(kit);
801
- const list = splitHighlights(line);
802
- return (
803
- <span style={{ ...text, display: "inline-flex", flexWrap: "wrap", justifyContent: "center", gap: `${fontSize * 0.16}px ${fontSize * 0.12}px`, ...style }}>
804
- {list.map((word, i) => {
805
- const s = seed * 53 + i * 11;
806
- const chip = word.highlighted ? { bg: kit.accent, fg: kit.onAccent } : chips[Math.floor(hash(s, 2) * 4)];
807
- const at = times?.[i] ?? start + i * stagger;
808
- if (times && frame < at) return null;
809
- const e = enter(kit, frame, fps, at, (hash(s, 3) - 0.5) * 8, s);
810
- return (
811
- <span key={i} style={{ display: "inline-block", opacity: e.opacity, transform: e.transform }}>
812
- <Scrap bg={chip.bg} seed={s}>
813
- <span
814
- style={{
815
- display: "inline-block",
816
- fontFamily: RANSOM_FONTS[Math.floor(hash(s, 1) * RANSOM_FONTS.length)],
817
- fontSize: fontSize * (word.highlighted ? 1.2 : 1),
818
- color: chip.fg,
819
- padding: `${fontSize * 0.06}px ${fontSize * 0.2}px ${fontSize * 0.02}px`,
820
- textTransform: hash(s, 5) > 0.4 ? "uppercase" : "none",
821
- }}
822
- >
823
- {word.text}
824
- </span>
825
- </Scrap>
826
- </span>
827
- );
828
- })}
829
- </span>
830
- );
831
- }
832
- if (kit.look === "notebook") {
833
- return (
834
- <span
835
- style={{
836
- ...text,
837
- display: "inline-block",
838
- fontFamily: kit.head,
839
- fontWeight: 700,
840
- fontSize: fontSize * 1.25,
841
- color: onBackdrop ? kit.panelText : kit.text,
842
- textShadow: onBackdrop ? undefined : `0 ${2 * u}px ${10 * u}px rgba(0,0,0,0.6), 0 0 ${2 * u}px rgba(0,0,0,0.8)`,
843
- ...style,
844
- }}
845
- >
846
- {words(onBackdrop)}
847
- </span>
848
- );
849
- }
850
- if (kit.look === "neon") {
851
- return (
852
- <span
853
- style={{
854
- ...text,
855
- display: "inline-block",
856
- transform: "skewX(-10deg)",
857
- background: "rgba(10,4,24,0.86)",
858
- border: `${Math.max(2, 2.5 * u)}px solid ${kit.line}`,
859
- boxShadow: `0 0 ${16 * u}px ${tint(kit.line, 0.6, "#22e8ff")}, ${6 * u}px ${6 * u}px 0 ${tint(kit.accent, 0.85)}`,
860
- padding: `${fontSize * 0.1}px ${fontSize * 0.34}px`,
861
- ...style,
862
- }}
863
- >
864
- <span style={{ display: "inline-block", transform: "skewX(10deg)", fontFamily: kit.body, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.04em", color: kit.text }}>
865
- {words(true)}
866
- </span>
867
- </span>
868
- );
869
- }
870
- if (kit.look === "line") {
871
- const big = fontSize * 1.55;
872
- const stroke = Math.max(2, big * 0.09);
873
- return (
874
- <span
875
- style={{
876
- display: "inline-block",
877
- fontFamily: FONTS.heavy,
878
- fontWeight: 900,
879
- fontSize: big,
880
- lineHeight: 1.04,
881
- letterSpacing: "-0.01em",
882
- textTransform: "uppercase",
883
- color: onBackdrop ? kit.panelText : kit.text,
884
- WebkitTextStroke: onBackdrop ? undefined : `${stroke}px #000000`,
885
- paintOrder: "stroke fill",
886
- textShadow: onBackdrop ? undefined : `0 ${big * 0.06}px ${big * 0.1}px rgba(0,0,0,0.55)`,
887
- ...style,
888
- }}
889
- >
890
- <Words kit={kit} line={line} fontSize={big} frame={frame} start={start} stagger={stagger} times={times} onPanel={onBackdrop} seed={seed} />
891
- </span>
892
- );
893
- }
894
- if (kit.look === "vhs") {
895
- return (
896
- <span
897
- style={{
898
- ...text,
899
- display: "inline-block",
900
- fontFamily: FONTS.pixel,
901
- fontSize: fontSize * 1.3,
902
- lineHeight: 1.1,
903
- letterSpacing: "0.02em",
904
- textTransform: "uppercase",
905
- background: "#000000",
906
- color: "#ffffff",
907
- padding: `${fontSize * 0.02}px ${fontSize * 0.28}px`,
908
- ...style,
909
- }}
910
- >
911
- {words(true)}
912
- </span>
913
- );
914
- }
915
- if (kit.look === "crt") {
916
- return (
917
- <span
918
- style={{
919
- ...text,
920
- display: "inline-block",
921
- fontFamily: kit.body,
922
- fontSize: fontSize * 1.15,
923
- background: "rgba(0,0,0,0.82)",
924
- color: kit.panelText,
925
- padding: `${fontSize * 0.08}px ${fontSize * 0.3}px`,
926
- ...style,
927
- }}
928
- >
929
- {words(true)}
930
- </span>
931
- );
932
- }
933
- return (
934
- <span
935
- style={{
936
- ...text,
937
- display: "inline-block",
938
- fontFamily: kit.body,
939
- fontWeight: 700,
940
- background: "rgba(10,12,16,0.78)",
941
- color: kit.text,
942
- borderRadius: fontSize,
943
- padding: `${fontSize * 0.18}px ${fontSize * 0.5}px`,
944
- ...style,
945
- }}
946
- >
947
- {words(false)}
948
- </span>
949
- );
950
- }
951
-
952
- /** Big headline lines; each enters in turn. Color: the panel text (it sits on a card or the backdrop). */
953
- export function Headline({
954
- kit,
955
- lines,
956
- fontSize,
957
- frame,
958
- fps,
959
- start = 0,
960
- align = "left",
961
- seed = 1,
962
- }: {
963
- kit: LookKit;
964
- lines: string[];
965
- fontSize: number;
966
- frame: number;
967
- fps: number;
968
- start?: number;
969
- align?: "left" | "center";
970
- seed?: number;
971
- }) {
972
- const items = align === "center" ? "center" : "flex-start";
973
- if (kit.look === "paper") {
974
- // Ransom note: every letter its own cut-out, line after line.
975
- const texts = lines.map((line) => line.replace(/\*/g, ""));
976
- const starts = texts.map((_, i) => start + texts.slice(0, i).reduce((sum, text) => sum + text.replace(/\s/g, "").length * 2 + 4, 0));
977
- return (
978
- <div style={{ display: "flex", flexDirection: "column", alignItems: items, gap: fontSize * 0.08 }}>
979
- {texts.map((text, i) => (
980
- <CutLetters key={i} kit={kit} text={text} fontSize={fontSize * 0.62} frame={frame} fps={fps} start={starts[i]} seed={seed * 7 + i} />
981
- ))}
982
- </div>
983
- );
984
- }
985
- return (
986
- <div
987
- style={{
988
- display: "flex",
989
- flexDirection: "column",
990
- alignItems: items,
991
- textAlign: align,
992
- fontFamily: kit.head,
993
- fontWeight: headWeight(kit),
994
- // Orbitron runs wide: a size down keeps two words on a line.
995
- fontSize: kit.look === "neon" ? fontSize * 0.78 : fontSize,
996
- lineHeight: kit.look === "notebook" ? 1 : 0.98,
997
- letterSpacing: kit.look === "crt" ? "0.02em" : kit.look === "notebook" ? "0" : "-0.02em",
998
- textTransform: kit.look === "crt" || kit.look === "neon" || kit.look === "line" ? "uppercase" : "none",
999
- color: kit.panelText,
1000
- textShadow:
1001
- kit.look === "crt"
1002
- ? `0 0 ${18 * kit.u}px ${tint(kit.accent, 0.55)}`
1003
- : kit.look === "neon"
1004
- ? `${-4 * kit.u}px 0 ${tint(kit.line, 0.9, "#22e8ff")}, ${4 * kit.u}px 0 ${tint(kit.accent, 0.9)}, 0 0 ${24 * kit.u}px ${tint(kit.accent, 0.5)}`
1005
- : kit.look === "vhs"
1006
- ? chroma(kit.u, 1.4)
1007
- : undefined,
1008
- }}
1009
- >
1010
- {lines.map((line, i) => {
1011
- const e = enter(kit, frame, fps, start + i * 5, 0, seed + i);
1012
- // Neon: every couple of seconds a line tears sideways for two frames.
1013
- const tear = kit.look === "neon" && frame % 54 >= 52 - i ? `translateX(${((hash(i, frame) - 0.5) * 30 * kit.u).toFixed(1)}px)` : "";
1014
- return (
1015
- <div key={i} style={{ opacity: e.opacity, transform: `${e.transform} ${tear}`, transformOrigin: align === "center" ? "50% 60%" : "0% 60%" }}>
1016
- <Words
1017
- kit={kit}
1018
- line={kit.look === "crt" ? typed(kit, line, frame, start + i * 10, 1.2) : line}
1019
- fontSize={fontSize}
1020
- frame={frame}
1021
- seed={seed + i}
1022
- style={{ justifyContent: align === "center" ? "center" : "flex-start" }}
1023
- />
1024
- </div>
1025
- );
1026
- })}
1027
- </div>
1028
- );
1029
- }
1030
-
1031
- /** Small kicker / label text. */
1032
- export function Label({ kit, children, fontSize, color, style }: { kit: LookKit; children: ReactNode; fontSize: number; color?: string; style?: CSSProperties }) {
1033
- const big = kit.look === "notebook" || kit.look === "crt";
1034
- return (
1035
- <div
1036
- style={{
1037
- fontFamily: kit.body,
1038
- fontWeight: kit.look === "notebook" ? 600 : 700,
1039
- fontSize: big ? fontSize * 1.35 : fontSize,
1040
- letterSpacing: labelCase(kit) === "uppercase" ? "0.14em" : "0.01em",
1041
- textTransform: labelCase(kit),
1042
- color: color ?? kit.panelText,
1043
- opacity: 0.8,
1044
- ...style,
1045
- }}
1046
- >
1047
- {children}
1048
- </div>
1049
- );
1050
- }
1051
-
1052
- // ---------------------------------------------------------------------------
1053
- // Stickers and tags
1054
-
1055
- /** Points of a starburst polygon centered in a size×size box. */
1056
- function burst(size: number, points = 14, inner = 0.78) {
1057
- const c = size / 2;
1058
- const out: string[] = [];
1059
- for (let i = 0; i < points * 2; i += 1) {
1060
- const r = (i % 2 === 0 ? 1 : inner) * c;
1061
- const a = (Math.PI * i) / points - Math.PI / 2;
1062
- out.push(`${(c + r * Math.cos(a)).toFixed(1)},${(c + r * Math.sin(a)).toFixed(1)}`);
1063
- }
1064
- return out.join(" ");
1065
- }
1066
-
1067
- /** A wobbly hand-drawn loop around a w×h box (slightly overshooting where it closes). */
1068
- function scribble(w: number, h: number) {
1069
- const cx = w / 2;
1070
- const cy = h / 2;
1071
- const pts: string[] = [];
1072
- for (let i = 0; i <= 56; i += 1) {
1073
- const a = (i / 52) * Math.PI * 2 - 2.2;
1074
- const wob = 1 + Math.sin(i * 1.7) * 0.025 + (i > 50 ? 0.06 : 0);
1075
- pts.push(`${(cx + Math.cos(a) * (w / 2 - 6) * wob).toFixed(1)},${(cy + Math.sin(a) * (h / 2 - 6) * wob).toFixed(1)}`);
1076
- }
1077
- return `M ${pts.join(" L ")}`;
1078
- }
1079
-
1080
- /** A badge for a number or one word: starburst, paper rosette, hand-drawn circle, terminal bracket or a disc. */
1081
- export function Sticker({ kit, text, size, frame, fps, start = 0, tilt = 8, seed = 1 }: { kit: LookKit; text: string; size: number; frame: number; fps: number; start?: number; tilt?: number; seed?: number }) {
1082
- const u = kit.u;
1083
- const e = enter(kit, frame, fps, start, kit.look === "crt" ? 0 : tilt, seed);
1084
- const fontSize = size * (text.length <= 2 ? 0.46 : text.length <= 4 ? 0.3 : 0.22);
1085
- const label: CSSProperties = { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", fontSize, lineHeight: 1 };
1086
- if (kit.look === "ink" || kit.look === "paper") {
1087
- const stroke = kit.look === "ink" ? Math.max(3, 6 * u) : 0;
1088
- const pad = stroke + 12 * u;
1089
- return (
1090
- <div style={{ position: "relative", width: size, height: size, opacity: e.opacity, transform: e.transform }}>
1091
- <svg width={size} height={size} viewBox={`${-pad} ${-pad} ${size + pad * 2} ${size + pad * 2}`} style={{ position: "absolute", inset: 0, overflow: "visible" }}>
1092
- <polygon points={burst(size, kit.look === "paper" ? 18 : 14, kit.look === "paper" ? 0.86 : 0.78)} transform={`translate(${10 * u} ${12 * u})`} fill={kit.look === "ink" ? kit.line : "rgba(20,12,4,0.42)"} />
1093
- <polygon points={burst(size, kit.look === "paper" ? 18 : 14, kit.look === "paper" ? 0.86 : 0.78)} fill={kit.accent} stroke={kit.line} strokeWidth={stroke} strokeLinejoin="round" />
1094
- </svg>
1095
- {kit.look === "paper" ? (
1096
- <div style={{ position: "absolute", inset: 0, borderRadius: "50%", overflow: "hidden" }}>
1097
- <Grain opacity={0.25} seed={seed} />
1098
- </div>
1099
- ) : null}
1100
- <div style={{ ...label, fontFamily: kit.head, color: kit.onAccent, WebkitTextStroke: kit.look === "ink" ? `${Math.max(1, 2 * u)}px ${kit.line}` : undefined }}>{text}</div>
1101
- </div>
1102
- );
1103
- }
1104
- if (kit.look === "notebook") {
1105
- const draw = ramp(frame, start + 4, 16);
1106
- const path = scribble(size * 1.25, size);
1107
- return (
1108
- <div style={{ position: "relative", width: size * 1.25, height: size, opacity: e.opacity, transform: e.transform }}>
1109
- <svg width={size * 1.25} height={size} style={{ position: "absolute", inset: 0, overflow: "visible" }}>
1110
- <path d={path} fill="none" stroke={kit.accent} strokeWidth={Math.max(3, 7 * u)} strokeLinecap="round" strokeLinejoin="round" pathLength={1} strokeDasharray={1} strokeDashoffset={1 - draw} />
1111
- </svg>
1112
- <div style={{ ...label, fontFamily: kit.head, fontWeight: 700, color: kit.text, fontSize: fontSize * 1.2, textShadow: "0 2px 10px rgba(0,0,0,0.5)" }}>{text}</div>
1113
- </div>
1114
- );
1115
- }
1116
- if (kit.look === "neon") {
1117
- const pts = Array.from({ length: 6 }, (_, k) => {
1118
- const a = (Math.PI / 3) * k - Math.PI / 2;
1119
- return `${(size / 2 + Math.cos(a) * size * 0.48).toFixed(1)},${(size / 2 + Math.sin(a) * size * 0.48).toFixed(1)}`;
1120
- }).join(" ");
1121
- const glowColor = isHex(kit.line) ? kit.line : "#22e8ff";
1122
- return (
1123
- <div style={{ position: "relative", width: size, height: size, opacity: e.opacity, transform: e.transform, filter: `drop-shadow(0 0 ${12 * u}px ${glowColor})` }}>
1124
- <svg width={size} height={size} style={{ position: "absolute", inset: 0, overflow: "visible" }}>
1125
- <polygon points={pts} fill="rgba(10,4,24,0.85)" stroke={glowColor} strokeWidth={Math.max(2, 4 * u)} />
1126
- <polygon points={pts} fill="none" stroke={kit.accent} strokeWidth={Math.max(1, 2 * u)} transform={`translate(${5 * u} ${4 * u})`} />
1127
- </svg>
1128
- <div style={{ ...label, fontFamily: kit.head, fontWeight: 800, color: "#ffffff", textShadow: `${-3 * u}px 0 ${glowColor}, ${3 * u}px 0 ${kit.accent}` }}>{text}</div>
1129
- </div>
1130
- );
1131
- }
1132
- if (kit.look === "line") {
1133
- const draw = ramp(frame, start, 14);
1134
- const r = size / 2 - 4 * u;
1135
- return (
1136
- <div style={{ position: "relative", width: size, height: size, opacity: e.opacity }}>
1137
- <svg width={size} height={size} style={{ position: "absolute", inset: 0, overflow: "visible" }}>
1138
- <circle cx={size / 2} cy={size / 2} r={r} fill="rgba(0,0,0,0.55)" stroke={kit.line} strokeWidth={Math.max(2, 3 * u)} pathLength={1} strokeDasharray={1} strokeDashoffset={1 - draw} transform={`rotate(-90 ${size / 2} ${size / 2})`} />
1139
- </svg>
1140
- <div style={{ ...label, fontFamily: FONTS.heavy, fontWeight: 900, color: kit.text, transform: e.transform }}>{text}</div>
1141
- </div>
1142
- );
1143
- }
1144
- if (kit.look === "vhs") {
1145
- const segments = 16;
1146
- const fillTo = Math.round(ramp(frame, start + 4, 18) * segments);
1147
- return (
1148
- <div style={{ display: "flex", flexDirection: "column", gap: 10 * u, opacity: e.opacity, transform: e.transform, fontFamily: FONTS.pixel, color: kit.accent, textShadow: chroma(u) }}>
1149
- <span style={{ fontSize: size * 0.42, lineHeight: 0.9 }}>{text}</span>
1150
- <span style={{ display: "flex", gap: 5 * u }}>
1151
- {Array.from({ length: segments }, (_, k) => (
1152
- <span key={k} style={{ width: size * 0.045, height: size * 0.16, background: k < fillTo ? kit.accent : "rgba(255,255,255,0.25)" }} />
1153
- ))}
1154
- </span>
1155
- </div>
1156
- );
1157
- }
1158
- if (kit.look === "crt") {
1159
- const blink = Math.floor((frame - start) / 15) % 2 === 0;
1160
- return (
1161
- <div
1162
- style={{
1163
- display: "inline-flex",
1164
- alignItems: "center",
1165
- gap: 10 * u,
1166
- padding: `${8 * u}px ${20 * u}px`,
1167
- background: "rgba(0,0,0,0.85)",
1168
- border: `${Math.max(2, 3 * u)}px solid ${kit.accent}`,
1169
- boxShadow: `0 0 ${24 * u}px ${tint(kit.accent, 0.45)}`,
1170
- fontFamily: kit.head,
1171
- fontSize: fontSize * 1.1,
1172
- color: kit.accent,
1173
- opacity: e.opacity,
1174
- }}
1175
- >
1176
- <span>{typed(kit, text, frame, start + 4, 0.6)}</span>
1177
- <span style={{ width: fontSize * 0.45, height: fontSize * 0.8, background: kit.accent, opacity: blink ? 1 : 0 }} />
1178
- </div>
1179
- );
1180
- }
1181
- return (
1182
- <div
1183
- style={{
1184
- position: "relative",
1185
- width: size,
1186
- height: size,
1187
- borderRadius: "50%",
1188
- background: kit.accent,
1189
- boxShadow: `0 ${14 * u}px ${40 * u}px ${tint(kit.accent, 0.45)}`,
1190
- opacity: e.opacity,
1191
- transform: e.transform,
1192
- }}
1193
- >
1194
- <div style={{ ...label, fontFamily: kit.head, fontWeight: 800, color: kit.onAccent }}>{text}</div>
1195
- </div>
1196
- );
1197
- }
1198
-
1199
- /** A small tilted label ("Claude Code"): ink tag, masking tape, taped paper scrap, prompt line or pill. */
1200
- export function Tag({ kit, text, fontSize, frame, fps, start = 0, tilt = -7, seed = 1 }: { kit: LookKit; text: string; fontSize: number; frame: number; fps: number; start?: number; tilt?: number; seed?: number }) {
1201
- const u = kit.u;
1202
- const e = enter(kit, frame, fps, start, kit.look === "crt" ? 0 : tilt, seed);
1203
- const common: CSSProperties = { display: "inline-block", opacity: e.opacity, transform: e.transform, fontSize, lineHeight: 1.1, whiteSpace: "nowrap" };
1204
- if (kit.look === "ink") {
1205
- return (
1206
- <span
1207
- style={{
1208
- ...common,
1209
- fontFamily: kit.body,
1210
- fontWeight: 700,
1211
- background: kit.panel,
1212
- color: kit.panelText,
1213
- border: `${Math.max(2, 3.5 * u)}px solid ${kit.line}`,
1214
- boxShadow: `${5 * u}px ${5 * u}px 0 ${kit.line}`,
1215
- padding: `${fontSize * 0.2}px ${fontSize * 0.45}px`,
1216
- }}
1217
- >
1218
- {text}
1219
- </span>
1220
- );
1221
- }
1222
- if (kit.look === "paper") {
1223
- // Written on a strip of masking tape.
1224
- return (
1225
- <span style={common}>
1226
- <Scrap bg="rgba(232,220,186,0.95)" seed={seed} shadow={0.18}>
1227
- <span style={{ display: "inline-block", fontFamily: FONTS.condensed, color: kit.line, padding: `${fontSize * 0.14}px ${fontSize * 0.5}px`, textTransform: "uppercase", letterSpacing: "0.04em" }}>{text}</span>
1228
- </Scrap>
1229
- </span>
1230
- );
1231
- }
1232
- if (kit.look === "notebook") {
1233
- return (
1234
- <span
1235
- style={{
1236
- ...common,
1237
- position: "relative",
1238
- fontFamily: kit.head,
1239
- fontWeight: 700,
1240
- fontSize: fontSize * 1.35,
1241
- background: kit.panel,
1242
- color: kit.panelText,
1243
- padding: `${fontSize * 0.15}px ${fontSize * 0.5}px`,
1244
- boxShadow: `0 ${4 * u}px ${12 * u}px rgba(0,0,0,0.2)`,
1245
- }}
1246
- >
1247
- <span style={{ position: "absolute", left: "50%", top: -fontSize * 0.45, width: fontSize * 2.4, height: fontSize * 0.7, marginLeft: -fontSize * 1.2, background: "rgba(236,226,196,0.85)", transform: "rotate(4deg)" }} />
1248
- {text}
1249
- </span>
1250
- );
1251
- }
1252
- if (kit.look === "neon") {
1253
- return (
1254
- <span
1255
- style={{
1256
- ...common,
1257
- fontFamily: kit.body,
1258
- fontWeight: 700,
1259
- textTransform: "uppercase",
1260
- letterSpacing: "0.08em",
1261
- background: "rgba(10,4,24,0.85)",
1262
- color: kit.line,
1263
- borderLeft: `${Math.max(3, 6 * u)}px solid ${kit.accent}`,
1264
- padding: `${fontSize * 0.2}px ${fontSize * 0.5}px`,
1265
- boxShadow: `0 0 ${12 * u}px ${tint(kit.line, 0.45, "#22e8ff")}`,
1266
- }}
1267
- >
1268
- {"// "}
1269
- {text}
1270
- </span>
1271
- );
1272
- }
1273
- if (kit.look === "line") {
1274
- return (
1275
- <span
1276
- style={{
1277
- ...common,
1278
- fontFamily: kit.body,
1279
- fontWeight: 700,
1280
- textTransform: "uppercase",
1281
- letterSpacing: "0.16em",
1282
- background: "#000000",
1283
- color: kit.text,
1284
- border: `${Math.max(1, 2 * u)}px solid ${kit.line}`,
1285
- padding: `${fontSize * 0.25}px ${fontSize * 0.6}px`,
1286
- }}
1287
- >
1288
- {text}
1289
- </span>
1290
- );
1291
- }
1292
- if (kit.look === "vhs") {
1293
- return (
1294
- <span style={{ ...common, fontFamily: FONTS.pixel, fontSize: fontSize * 1.5, color: "#ffffff", textTransform: "uppercase", textShadow: `0 0 ${2 * u}px #000000, ${chroma(u)}` }}>
1295
- {text}
1296
- </span>
1297
- );
1298
- }
1299
- if (kit.look === "crt") {
1300
- return (
1301
- <span style={{ ...common, fontFamily: kit.body, fontSize: fontSize * 1.3, background: "rgba(0,0,0,0.85)", color: kit.accent, padding: `${fontSize * 0.1}px ${fontSize * 0.4}px` }}>
1302
- {"> "}
1303
- {typed(kit, text, frame, start, 1.2)}
1304
- </span>
1305
- );
1306
- }
1307
- return (
1308
- <span
1309
- style={{
1310
- ...common,
1311
- fontFamily: kit.body,
1312
- fontWeight: 700,
1313
- background: "rgba(10,12,16,0.78)",
1314
- color: kit.text,
1315
- border: `${Math.max(1, 2 * u)}px solid ${tint(kit.accent, 0.6, "#ffffff")}`,
1316
- borderRadius: fontSize,
1317
- padding: `${fontSize * 0.25}px ${fontSize * 0.6}px`,
1318
- }}
1319
- >
1320
- {text}
1321
- </span>
1322
- );
1323
- }
1324
-
1325
- // ---------------------------------------------------------------------------
1326
- // Split layout
1327
-
1328
- /** Jagged torn-paper edge along the bottom of a w-wide strip (deterministic). */
1329
- function tornPath(w: number, h: number, depth: number) {
1330
- const pts: string[] = [`0,0`, `${w},0`];
1331
- const steps = Math.max(12, Math.round(w / (depth * 1.4)));
1332
- for (let i = steps; i >= 0; i -= 1) {
1333
- const x = (i / steps) * w;
1334
- pts.push(`${x.toFixed(1)},${(h - depth + hash(i, 4) * depth).toFixed(1)}`);
1335
- }
1336
- return pts.join(" ");
1337
- }
1338
-
1339
- /**
1340
- * The top part of a split frame (the speaker's footage shows below it): the look's backdrop with a
1341
- * bottom edge (hard ink rule, torn paper, glowing line or a soft fade). Children are laid out inside.
1342
- */
1343
- export function SplitTop({ kit, width, height, fraction, children, reveal, seed = 1 }: { kit: LookKit; width: number; height: number; fraction: number; children: ReactNode; reveal: number; seed?: number }) {
1344
- const u = kit.u;
1345
- const h = Math.round(height * fraction);
1346
- const edge = 40 * u;
1347
- const slide = mix(-(h + edge), 0, reveal);
1348
- const torn = kit.look === "notebook" || kit.look === "paper";
1349
- return (
1350
- <div style={{ position: "absolute", left: 0, top: 0, width, height: h + edge, transform: `translateY(${slide}px)` }}>
1351
- <div style={{ position: "absolute", left: 0, top: 0, width, height: h, overflow: "hidden" }}>
1352
- <Backdrop kit={kit} width={width} height={h} seed={seed} />
1353
- </div>
1354
- {torn ? (
1355
- <svg width={width} height={edge} style={{ position: "absolute", left: 0, top: h - 1 }}>
1356
- <polygon points={tornPath(width, edge, edge * 0.55)} transform={`translate(0 ${6 * u})`} fill="rgba(0,0,0,0.25)" />
1357
- <polygon points={tornPath(width, edge, edge * 0.55)} fill={kit.backdrop} />
1358
- </svg>
1359
- ) : kit.look === "ink" ? (
1360
- <div style={{ position: "absolute", left: 0, top: h, width, height: Math.max(4, 8 * u), background: kit.line, boxShadow: `0 ${10 * u}px 0 ${tint(kit.line, 0.35)}` }} />
1361
- ) : kit.look === "crt" ? (
1362
- <div style={{ position: "absolute", left: 0, top: h, width, height: Math.max(2, 3 * u), background: kit.accent, boxShadow: `0 0 ${20 * u}px ${kit.accent}` }} />
1363
- ) : (
1364
- <div style={{ position: "absolute", left: 0, top: h, width, height: edge * 2, background: `linear-gradient(180deg, ${kit.backdrop} 0%, ${tint(kit.backdrop, 0)} 100%)` }} />
1365
- )}
1366
- <div style={{ position: "absolute", left: 0, top: 0, width, height: h, display: "flex", flexDirection: "column", justifyContent: "center" }}>{children}</div>
1367
- </div>
1368
- );
1369
- }
1370
-
1371
- // ---------------------------------------------------------------------------
1372
- // Card layouts (list-card, quote-card, before-after)
1373
-
1374
- /** Shared frame for the card components: full frame on the look's backdrop, or a card over footage. */
1375
- export function CardStage({
1376
- kit,
1377
- width,
1378
- height,
1379
- layout,
1380
- frame,
1381
- fps,
1382
- durationInFrames,
1383
- footer,
1384
- footerStart,
1385
- title,
1386
- children,
1387
- }: {
1388
- kit: LookKit;
1389
- width: number;
1390
- height: number;
1391
- layout: string;
1392
- frame: number;
1393
- fps: number;
1394
- durationInFrames: number;
1395
- footer: string;
1396
- footerStart: number;
1397
- title: string;
1398
- children: ReactNode;
1399
- }) {
1400
- const vertical = height > width;
1401
- const out = exitOut(frame, durationInFrames, 10);
1402
- const e = enter(kit, frame, fps, 0, kit.look === "ink" || kit.look === "paper" ? -1.5 : 0, 3);
1403
- const cardWidth = width * (vertical ? 0.86 : 0.5);
1404
- const footerSize = Math.min(width, height) * 0.045;
1405
- return (
1406
- <AbsoluteFill style={{ opacity: out }}>
1407
- {layout === "full" ? <Backdrop kit={kit} width={width} height={height} seed={4} /> : null}
1408
- <AbsoluteFill style={{ alignItems: "center", justifyContent: "center", gap: footerSize * 1.6 }}>
1409
- <div style={{ width: cardWidth, opacity: e.opacity, transform: e.transform }}>
1410
- <Panel kit={kit} title={title} seed={6}>
1411
- {children}
1412
- </Panel>
1413
- </div>
1414
- {footer ? (
1415
- <div style={{ maxWidth: width * 0.9 }}>
1416
- <Chip kit={kit} line={footer} fontSize={footerSize} frame={frame} fps={fps} start={footerStart} stagger={3} seed={9} onBackdrop={layout === "full"} />
1417
- </div>
1418
- ) : null}
1419
- </AbsoluteFill>
1420
- </AbsoluteFill>
1421
- );
1422
- }
1423
-
1424
- /** A card title: ransom letters on paper, typed on a terminal, the headline font elsewhere. */
1425
- export function CardTitle({ kit, text, fontSize, frame, fps, start }: { kit: LookKit; text: string; fontSize: number; frame: number; fps: number; start: number }) {
1426
- // Cut letters are wide (a scrap each): smaller so a two-word title stays on a line or two.
1427
- if (kit.look === "paper") return <CutLetters kit={kit} text={text} fontSize={fontSize * 0.7} frame={frame} fps={fps} start={start} seed={11} />;
1428
- const e = enter(kit, frame, fps, start);
1429
- return (
1430
- <div
1431
- style={{
1432
- opacity: e.opacity,
1433
- transform: e.transform,
1434
- transformOrigin: "0% 60%",
1435
- fontFamily: kit.head,
1436
- fontWeight: headWeight(kit),
1437
- fontSize,
1438
- lineHeight: 1,
1439
- letterSpacing: kit.look === "crt" || kit.look === "notebook" ? 0 : "-0.02em",
1440
- textTransform: kit.look === "crt" ? "uppercase" : "none",
1441
- color: kit.panelText,
1442
- }}
1443
- >
1444
- <Words kit={kit} line={typed(kit, text, frame, start, 1.2)} fontSize={fontSize} frame={frame} />
1445
- </div>
1446
- );
1447
- }
1
+ // Looks: the graphic language a style draws with (cards, chips, stickers, backdrops, entrances).
2
+ // The talking-head components (hook-card, word-pop, sticker-badge, list-card, quote-card,
3
+ // before-after), the styled captions and the style overlay are built from these pieces, so one
4
+ // `look` restyles all of them. Same rules as the components: react, remotion and ./lib only;
5
+ // everything is driven by the frame.
6
+ import { useId, type CSSProperties, type ReactNode } from "react";
7
+ import { AbsoluteFill, interpolate, spring } from "remotion";
8
+ import { FONTS, alpha, clamp01, easeOutExpo, exitOut, glowStyle, mix, onColor, ramp, splitHighlights } from "./lib";
9
+
10
+ /**
11
+ * ink: neo-brutal · paper: cut-paper craft · notebook: grid paper and pen · crt: terminal ·
12
+ * neon: cyberpunk · line: black and white line art, bold centered captions · vhs: 90s tape and TV ·
13
+ * clean: soft cards.
14
+ */
15
+ export type Look = "ink" | "paper" | "notebook" | "crt" | "neon" | "line" | "vhs" | "clean";
16
+
17
+ export const LOOKS: Look[] = ["ink", "paper", "notebook", "crt", "neon", "line", "vhs", "clean"];
18
+
19
+ /** Colors and fonts every look piece reads. Build it once per component with `lookKit`. */
20
+ export interface LookKit {
21
+ look: Look;
22
+ u: number;
23
+ accent: string;
24
+ onAccent: string;
25
+ /** Card fill and the text on it (also the text on the backdrop). */
26
+ panel: string;
27
+ panelText: string;
28
+ /** Borders, hard shadows, pen strokes, ink. */
29
+ line: string;
30
+ /** Full-frame fill under the texture. */
31
+ backdrop: string;
32
+ /** Text straight over footage. */
33
+ text: string;
34
+ /** Headline / small text. */
35
+ head: string;
36
+ body: string;
37
+ }
38
+
39
+ export interface LookProps {
40
+ look: string;
41
+ accent: string;
42
+ panel: string;
43
+ panelText: string;
44
+ line: string;
45
+ backdrop: string;
46
+ /** Text straight over footage. */
47
+ onVideo: string;
48
+ font: string;
49
+ }
50
+
51
+ const BODY_FONT: Record<Look, string> = {
52
+ ink: FONTS.grotesk,
53
+ paper: FONTS.mono,
54
+ notebook: FONTS.caveat,
55
+ crt: FONTS.pixel,
56
+ neon: FONTS.mono,
57
+ line: FONTS.sans,
58
+ vhs: FONTS.pixel,
59
+ clean: FONTS.sans,
60
+ };
61
+
62
+ const isHex = (color: string) => /^#?[0-9a-f]{6}$/i.test(color.trim());
63
+ /** alpha() for colors that may not be hex (rgba panels): falls back to a neutral. */
64
+ const tint = (color: string, a: number, fallback = "#000000") => alpha(isHex(color) ? color : fallback, a);
65
+
66
+ export function lookKit(props: LookProps, u: number): LookKit {
67
+ const look = (LOOKS as string[]).includes(props.look) ? (props.look as Look) : "ink";
68
+ return {
69
+ look,
70
+ u,
71
+ accent: props.accent,
72
+ onAccent: onColor(props.accent),
73
+ panel: props.panel,
74
+ panelText: props.panelText,
75
+ line: props.line,
76
+ backdrop: props.backdrop,
77
+ text: props.onVideo,
78
+ head: FONTS[props.font] ?? FONTS.archivo,
79
+ body: BODY_FONT[look],
80
+ };
81
+ }
82
+
83
+ /** Headline weight per look (Archivo Black, Anton, VT323 have one weight). */
84
+ export function headWeight(kit: LookKit) {
85
+ return kit.look === "line" ? 900 : kit.look === "notebook" ? 700 : kit.look === "clean" || kit.look === "neon" ? 800 : 400;
86
+ }
87
+
88
+ const labelCase = (kit: LookKit): CSSProperties["textTransform"] =>
89
+ kit.look === "notebook" || kit.look === "crt" ? "none" : "uppercase";
90
+
91
+ /** VHS color bleed: red and cyan ghosts either side of the text. */
92
+ export function chroma(u: number, amount = 1) {
93
+ return `${-3 * u * amount}px 0 rgba(255,40,60,0.75), ${3 * u * amount}px 0 rgba(40,220,255,0.7)`;
94
+ }
95
+
96
+ /** Deterministic 0…1 noise. */
97
+ export function hash(a: number, b = 0) {
98
+ const n = Math.sin(a * 127.1 + b * 311.7) * 43758.5453;
99
+ return n - Math.floor(n);
100
+ }
101
+
102
+ /** Stop-motion: the frame held for two (paper animates "on twos"). */
103
+ const onTwos = (frame: number) => frame - (frame % 2);
104
+
105
+ // ---------------------------------------------------------------------------
106
+ // Motion
107
+
108
+ /** Each look's entrance (opacity + transform), `delay` frames in. `seed` varies the paper jitter. */
109
+ export function enter(kit: LookKit, frame: number, fps: number, delay = 0, tilt = 0, seed = 1) {
110
+ const f = frame - delay;
111
+ switch (kit.look) {
112
+ case "ink": {
113
+ // A slap: overshooting scale and a twist that settles on the tilt.
114
+ const s = spring({ frame: f, fps, config: { damping: 11, stiffness: 230, mass: 0.7 } });
115
+ return {
116
+ opacity: clamp01(s * 4),
117
+ transform: `scale(${mix(0.55, 1, s)}) rotate(${mix(tilt - 9, tilt, s)}deg)`,
118
+ };
119
+ }
120
+ case "paper": {
121
+ // Slapped down from above, then the hand-animated wobble of stop-motion.
122
+ if (f < 0) return { opacity: 0, transform: "scale(1.8)" };
123
+ const s = interpolate(f, [0, 3, 5], [1.8, 0.94, 1], { extrapolateRight: "clamp" });
124
+ const h = onTwos(frame);
125
+ const settled = f >= 6;
126
+ const jx = settled ? (hash(seed, h) - 0.5) * 3 * kit.u : 0;
127
+ const jy = settled ? (hash(seed + 7, h) - 0.5) * 3 * kit.u : 0;
128
+ const jr = settled ? (hash(seed + 13, h) - 0.5) * 1.2 : 0;
129
+ return { opacity: 1, transform: `translate(${jx}px, ${jy}px) rotate(${tilt + jr}deg) scale(${s})` };
130
+ }
131
+ case "notebook": {
132
+ const t = ramp(frame, delay, 14);
133
+ return {
134
+ opacity: t,
135
+ transform: `translateY(${mix(22 * kit.u, 0, t)}px) rotate(${mix(tilt - 3, tilt, t)}deg)`,
136
+ };
137
+ }
138
+ case "neon": {
139
+ // Glitches in: a few frames of sideways tearing and flicker, then holds.
140
+ if (f < 0) return { opacity: 0, transform: `rotate(${tilt}deg)` };
141
+ if (f < 7) {
142
+ const k = 1 - f / 7;
143
+ const x = (hash(seed + f, 3) - 0.5) * 60 * kit.u * k;
144
+ const skew = (hash(seed + f, 5) - 0.5) * 24 * k;
145
+ return { opacity: f % 2 === 0 ? 1 : 0.55, transform: `translateX(${x.toFixed(1)}px) skewX(${skew.toFixed(1)}deg) rotate(${tilt}deg)` };
146
+ }
147
+ return { opacity: 1, transform: `rotate(${tilt}deg)` };
148
+ }
149
+ case "vhs": {
150
+ // Tracking settles: a short roll from above with sideways jitter and flicker.
151
+ if (f < 0) return { opacity: 0, transform: `rotate(${tilt}deg)` };
152
+ if (f < 8) {
153
+ const k = 1 - f / 8;
154
+ const x = (hash(seed + f, 7) - 0.5) * 36 * kit.u * k;
155
+ return { opacity: f % 3 === 1 ? 0.6 : 1, transform: `translate(${x.toFixed(1)}px, ${(-40 * kit.u * k * k).toFixed(1)}px) rotate(${tilt}deg)` };
156
+ }
157
+ return { opacity: 1, transform: `rotate(${tilt}deg)` };
158
+ }
159
+ case "line": {
160
+ // A quick pop: overshoot, then settle.
161
+ if (f < 0) return { opacity: 0, transform: `scale(0.6) rotate(${tilt}deg)` };
162
+ const s = interpolate(f, [0, 3, 6], [0.6, 1.12, 1], { extrapolateRight: "clamp" });
163
+ return { opacity: 1, transform: `scale(${s}) rotate(${tilt}deg)` };
164
+ }
165
+ case "crt": {
166
+ // Power-on flicker, no movement.
167
+ const opacity = f < 0 ? 0 : f < 2 ? 0.5 : f < 3 ? 0.1 : f < 5 ? 0.85 : 1;
168
+ return { opacity, transform: `rotate(${tilt}deg)` };
169
+ }
170
+ default: {
171
+ const t = ramp(frame, delay, 18, easeOutExpo);
172
+ return { opacity: t, transform: `translateY(${mix(28 * kit.u, 0, t)}px) rotate(${tilt}deg)` };
173
+ }
174
+ }
175
+ }
176
+
177
+ /** Characters of `text` typed so far (crt types, other looks show it all once in). */
178
+ export function typed(kit: LookKit, text: string, frame: number, start: number, perFrame = 1.6) {
179
+ if (kit.look !== "crt") return text;
180
+ return text.slice(0, Math.max(0, Math.floor((frame - start) * perFrame)));
181
+ }
182
+
183
+ // ---------------------------------------------------------------------------
184
+ // Texture
185
+
186
+ function useSvgId(prefix: string) {
187
+ return `${prefix}${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
188
+ }
189
+
190
+ const fullSvg: CSSProperties = { position: "absolute", inset: 0, width: "100%", height: "100%", pointerEvents: "none" };
191
+
192
+ /** Thin horizontal lines, as an SVG pattern (the export draws SVG exactly). */
193
+ export function Scanlines({ u, opacity = 0.32 }: { u: number; opacity?: number }) {
194
+ const id = useSvgId("scan");
195
+ const gap = Math.max(3, 6 * u);
196
+ return (
197
+ <svg style={fullSvg}>
198
+ <defs>
199
+ <pattern id={id} width={gap} height={gap} patternUnits="userSpaceOnUse">
200
+ <rect width={gap} height={gap / 2} fill={`rgba(0,0,0,${opacity})`} />
201
+ </pattern>
202
+ </defs>
203
+ <rect width="100%" height="100%" fill={`url(#${id})`} />
204
+ </svg>
205
+ );
206
+ }
207
+
208
+ /** Paper / film grain (SVG noise). `seed` changes per frame for moving grain. */
209
+ export function Grain({ opacity = 0.3, seed = 1, frequency = 0.85, warm = true }: { opacity?: number; seed?: number; frequency?: number; warm?: boolean }) {
210
+ const id = useSvgId("grain");
211
+ const [r, g, b] = warm ? [0.16, 0.11, 0.05] : [0, 0, 0];
212
+ return (
213
+ <svg style={fullSvg}>
214
+ <filter id={id}>
215
+ <feTurbulence type="fractalNoise" baseFrequency={frequency} numOctaves={2} seed={seed} stitchTiles="stitch" />
216
+ <feColorMatrix type="matrix" values={`0 0 0 0 ${r} 0 0 0 0 ${g} 0 0 0 0 ${b} 0 0 0 ${opacity * 2.2} -${opacity * 0.5}`} />
217
+ </filter>
218
+ <rect width="100%" height="100%" filter={`url(#${id})`} />
219
+ </svg>
220
+ );
221
+ }
222
+
223
+ /** Corners darkened toward the edges (linear gradients only: the export can't draw sized radials). */
224
+ export function Vignette({ color = "#000000", amount = 0.35 }: { color?: string; amount?: number }) {
225
+ const c0 = tint(color, amount);
226
+ const c1 = tint(color, 0);
227
+ return (
228
+ <>
229
+ <div style={{ position: "absolute", inset: 0, background: `linear-gradient(180deg, ${c0} 0%, ${c1} 24%, ${c1} 76%, ${c0} 100%)` }} />
230
+ <div style={{ position: "absolute", inset: 0, background: `linear-gradient(90deg, ${c0} 0%, ${c1} 18%, ${c1} 82%, ${c0} 100%)` }} />
231
+ </>
232
+ );
233
+ }
234
+
235
+ /** A torn-edged polygon in a 100×100 box (stretch it with preserveAspectRatio="none"). */
236
+ function tornBox(seed: number, depth = 3) {
237
+ const pts: string[] = [];
238
+ const edge = (x0: number, y0: number, x1: number, y1: number, n: number, side: number) => {
239
+ for (let i = 0; i < n; i += 1) {
240
+ const t = i / n;
241
+ const off = (hash(seed + side * 31, i) - 0.5) * depth;
242
+ const x = mix(x0, x1, t) + (y0 === y1 ? 0 : off);
243
+ const y = mix(y0, y1, t) + (y0 === y1 ? off : 0);
244
+ pts.push(`${x.toFixed(2)},${y.toFixed(2)}`);
245
+ }
246
+ };
247
+ edge(0, 0, 100, 0, 9, 1);
248
+ edge(100, 0, 100, 100, 5, 2);
249
+ edge(100, 100, 0, 100, 9, 3);
250
+ edge(0, 100, 0, 0, 5, 4);
251
+ return pts.join(" ");
252
+ }
253
+
254
+ /** A paper scrap behind its children: torn edges, a drop shadow and grain. */
255
+ function Scrap({ bg, seed, children, shadow = 0.4, style }: { bg: string; seed: number; children: ReactNode; shadow?: number; style?: CSSProperties }) {
256
+ const points = tornBox(seed, 4);
257
+ return (
258
+ <span style={{ position: "relative", display: "inline-block", ...style }}>
259
+ <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", left: "3%", top: "7%", width: "100%", height: "100%", overflow: "visible" }}>
260
+ <polygon points={points} fill={`rgba(20,12,4,${shadow})`} />
261
+ </svg>
262
+ <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", inset: 0, width: "100%", height: "100%", overflow: "visible" }}>
263
+ <polygon points={points} fill={bg} />
264
+ </svg>
265
+ <span style={{ position: "relative", display: "inline-block" }}>{children}</span>
266
+ </span>
267
+ );
268
+ }
269
+
270
+ /** Paper colors a ransom chip can be cut from. */
271
+ function paperChips(kit: LookKit) {
272
+ return [
273
+ { bg: kit.panel, fg: kit.panelText },
274
+ { bg: kit.accent, fg: kit.onAccent },
275
+ { bg: kit.line, fg: kit.panel },
276
+ { bg: "#dcc7a0", fg: "#1a1410" },
277
+ { bg: "#ffffff", fg: isHex(kit.accent) ? kit.accent : "#1a1410" },
278
+ ];
279
+ }
280
+
281
+ const RANSOM_FONTS = [FONTS.archivo, FONTS.serif, FONTS.condensed, FONTS.mono, FONTS.fraunces, FONTS.grotesk];
282
+
283
+ /** Text cut letter by letter from different papers and typefaces, each letter slapped down in turn. */
284
+ export function CutLetters({ kit, text, fontSize, frame, fps, start = 0, stagger = 2, seed = 1 }: { kit: LookKit; text: string; fontSize: number; frame: number; fps: number; start?: number; stagger?: number; seed?: number }) {
285
+ const chips = paperChips(kit);
286
+ const words = text.toUpperCase().split(/\s+/).filter(Boolean);
287
+ // Letters land one after another across the words; a word never breaks across lines.
288
+ const offsets = words.map((_, w) => words.slice(0, w).reduce((sum, word) => sum + word.length, 0));
289
+ return (
290
+ <span style={{ display: "inline-flex", flexWrap: "wrap", alignItems: "center", columnGap: fontSize * 0.3, rowGap: fontSize * 0.1 }}>
291
+ {words.map((word, w) => (
292
+ <span key={w} style={{ display: "inline-flex", alignItems: "center", whiteSpace: "nowrap" }}>
293
+ {Array.from(word).map((ch, c) => {
294
+ const index = offsets[w] + c;
295
+ const s = seed * 97 + index * 13;
296
+ const chip = chips[Math.floor(hash(s, 2) * chips.length)];
297
+ const e = enter(kit, frame, fps, start + index * stagger, (hash(s, 3) - 0.5) * 16, s);
298
+ return (
299
+ <span key={c} style={{ display: "inline-block", margin: `0 ${fontSize * 0.03}px`, opacity: e.opacity, transform: e.transform }}>
300
+ <Scrap bg={chip.bg} seed={s}>
301
+ <span
302
+ style={{
303
+ display: "inline-block",
304
+ fontFamily: RANSOM_FONTS[Math.floor(hash(s, 1) * RANSOM_FONTS.length)],
305
+ fontSize: fontSize * (0.88 + hash(s, 4) * 0.28),
306
+ lineHeight: 1.05,
307
+ color: chip.fg,
308
+ padding: `${fontSize * 0.06}px ${fontSize * 0.14}px ${fontSize * 0.02}px`,
309
+ }}
310
+ >
311
+ {ch}
312
+ </span>
313
+ </Scrap>
314
+ </span>
315
+ );
316
+ })}
317
+ </span>
318
+ ))}
319
+ </span>
320
+ );
321
+ }
322
+
323
+ /** The full-frame ground of a look: halftone, cut paper, grid paper, CRT glass or a soft gradient. */
324
+ export function Backdrop({ kit, width, height, seed = 1 }: { kit: LookKit; width: number; height: number; seed?: number }) {
325
+ const id = useSvgId("bd");
326
+ const u = kit.u;
327
+ const fillStyle: CSSProperties = { position: "absolute", inset: 0, background: kit.backdrop, overflow: "hidden" };
328
+ if (kit.look === "ink") {
329
+ const step = 26 * u;
330
+ return (
331
+ <div style={fillStyle}>
332
+ <svg style={fullSvg}>
333
+ <defs>
334
+ <pattern id={`${id}p`} width={step} height={step} patternUnits="userSpaceOnUse">
335
+ <circle cx={step / 2} cy={step / 2} r={step * 0.2} fill={tint(kit.line, 0.16)} />
336
+ </pattern>
337
+ <linearGradient id={`${id}g`} x1="0" y1="0" x2="0" y2="1">
338
+ <stop offset="0" stopColor="#fff" stopOpacity="0.15" />
339
+ <stop offset="1" stopColor="#fff" stopOpacity="1" />
340
+ </linearGradient>
341
+ <mask id={`${id}m`}>
342
+ <rect width="100%" height="100%" fill={`url(#${id}g)`} />
343
+ </mask>
344
+ </defs>
345
+ <rect width="100%" height="100%" fill={`url(#${id}p)`} mask={`url(#${id}m)`} />
346
+ </svg>
347
+ </div>
348
+ );
349
+ }
350
+ if (kit.look === "paper") {
351
+ // Kraft ground with two torn sheets laid across it.
352
+ return (
353
+ <div style={fillStyle}>
354
+ <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", left: "-12%", top: "8%", width: "80%", height: "46%", transform: "rotate(-7deg)" }}>
355
+ <polygon points={tornBox(seed + 3, 3)} fill={kit.accent} />
356
+ </svg>
357
+ <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", right: "-14%", bottom: "4%", width: "86%", height: "42%", transform: "rotate(5deg)" }}>
358
+ <polygon points={tornBox(seed + 9, 3)} fill={kit.panel} />
359
+ </svg>
360
+ <Grain opacity={0.32} seed={seed} />
361
+ </div>
362
+ );
363
+ }
364
+ if (kit.look === "notebook") {
365
+ const step = 48 * u;
366
+ return (
367
+ <div style={fillStyle}>
368
+ <svg style={fullSvg}>
369
+ <defs>
370
+ <pattern id={`${id}p`} width={step} height={step} patternUnits="userSpaceOnUse">
371
+ <path d={`M ${step} 0 L 0 0 0 ${step}`} fill="none" stroke="rgba(70,90,130,0.16)" strokeWidth={Math.max(1, 1.5 * u)} />
372
+ </pattern>
373
+ </defs>
374
+ <rect width="100%" height="100%" fill={`url(#${id}p)`} />
375
+ </svg>
376
+ </div>
377
+ );
378
+ }
379
+ if (kit.look === "neon") {
380
+ const horizon = height * 0.58;
381
+ const lines: ReactNode[] = [];
382
+ for (let i = -12; i <= 12; i += 1) {
383
+ lines.push(<line key={`v${i}`} x1={width / 2 + i * width * 0.02} y1={horizon} x2={width / 2 + i * width * 0.22} y2={height} />);
384
+ }
385
+ for (let i = 1; i <= 9; i += 1) {
386
+ const y = horizon + (height - horizon) * Math.pow(i / 9, 2.2);
387
+ lines.push(<line key={`h${i}`} x1={0} y1={y} x2={width} y2={y} />);
388
+ }
389
+ return (
390
+ <div style={fillStyle}>
391
+ <div style={glowStyle(width * 0.15, height * 0.18, width * 1.2, width * 1.2, kit.accent, 0.3)} />
392
+ <div style={glowStyle(width * 0.9, height * 0.75, width * 1.1, width * 1.1, isHex(kit.line) ? kit.line : "#22e8ff", 0.22)} />
393
+ <svg style={fullSvg}>
394
+ <g stroke={tint(kit.accent, 0.45)} strokeWidth={Math.max(1, 1.6 * u)}>{lines}</g>
395
+ <line x1={0} y1={horizon} x2={width} y2={horizon} stroke={isHex(kit.line) ? kit.line : "#22e8ff"} strokeWidth={Math.max(1, 2 * u)} opacity={0.8} />
396
+ </svg>
397
+ <Scanlines u={u} opacity={0.14} />
398
+ </div>
399
+ );
400
+ }
401
+ if (kit.look === "line") {
402
+ return <div style={fillStyle} />;
403
+ }
404
+ if (kit.look === "vhs") {
405
+ return (
406
+ <div style={{ ...fillStyle, background: `linear-gradient(180deg, ${kit.backdrop} 0%, ${tint(kit.backdrop, 0.85, "#1626c9")} 100%)` }}>
407
+ <Grain opacity={0.18} seed={seed} warm={false} frequency={1.1} />
408
+ <Scanlines u={u} opacity={0.18} />
409
+ <Vignette amount={0.35} />
410
+ </div>
411
+ );
412
+ }
413
+ if (kit.look === "crt") {
414
+ const step = 60 * u;
415
+ return (
416
+ <div style={fillStyle}>
417
+ <svg style={fullSvg}>
418
+ <defs>
419
+ <pattern id={`${id}p`} width={step} height={step} patternUnits="userSpaceOnUse">
420
+ <path d={`M ${step} 0 L 0 0 0 ${step}`} fill="none" stroke={tint(kit.accent, 0.07)} strokeWidth={Math.max(1, 1.2 * u)} />
421
+ </pattern>
422
+ </defs>
423
+ <rect width="100%" height="100%" fill={`url(#${id}p)`} />
424
+ </svg>
425
+ <div style={glowStyle(width / 2, height / 2, width * 1.3, height * 1.1, kit.accent, 0.14)} />
426
+ <Scanlines u={u} />
427
+ <Vignette amount={0.45} />
428
+ </div>
429
+ );
430
+ }
431
+ return (
432
+ <div style={{ ...fillStyle, background: `linear-gradient(165deg, ${tint(kit.accent, 0.18)} 0%, ${kit.backdrop} 45%, ${kit.backdrop} 100%)` }}>
433
+ <div style={glowStyle(width * 0.25, height * 0.15, width * 1.1, width * 1.1, kit.accent, 0.12)} />
434
+ </div>
435
+ );
436
+ }
437
+
438
+ // ---------------------------------------------------------------------------
439
+ // Cards
440
+
441
+ /** A card in the look: ink border + hard shadow, torn paper, taped notebook page, terminal window or a soft card. */
442
+ export function Panel({
443
+ kit,
444
+ children,
445
+ style,
446
+ title,
447
+ seed = 1,
448
+ }: {
449
+ kit: LookKit;
450
+ children: ReactNode;
451
+ style?: CSSProperties;
452
+ /** crt window title. */
453
+ title?: string;
454
+ seed?: number;
455
+ }) {
456
+ const u = kit.u;
457
+ const base: CSSProperties = { position: "relative", color: kit.panelText, ...style };
458
+ if (kit.look === "ink") {
459
+ return (
460
+ <div
461
+ style={{
462
+ ...base,
463
+ background: kit.panel,
464
+ border: `${Math.max(3, 6 * u)}px solid ${kit.line}`,
465
+ borderRadius: 10 * u,
466
+ boxShadow: `${14 * u}px ${14 * u}px 0 ${kit.line}`,
467
+ }}
468
+ >
469
+ {children}
470
+ </div>
471
+ );
472
+ }
473
+ if (kit.look === "paper") {
474
+ const points = tornBox(seed, 2.5);
475
+ return (
476
+ <div style={base}>
477
+ <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", left: 10 * u, top: 16 * u, width: "100%", height: "100%", overflow: "visible" }}>
478
+ <polygon points={points} fill="rgba(20,12,4,0.42)" />
479
+ </svg>
480
+ <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ position: "absolute", inset: 0, width: "100%", height: "100%", overflow: "visible" }}>
481
+ <polygon points={points} fill={kit.panel} />
482
+ </svg>
483
+ <div style={{ position: "absolute", inset: 0, overflow: "hidden" }}>
484
+ <Grain opacity={0.22} seed={seed + 2} />
485
+ </div>
486
+ {/* Masking tape across a corner. */}
487
+ <div style={{ position: "absolute", left: -24 * u, top: 18 * u, width: 150 * u, height: 40 * u, background: "rgba(232,220,186,0.86)", transform: "rotate(-32deg)" }} />
488
+ <div style={{ position: "relative" }}>{children}</div>
489
+ </div>
490
+ );
491
+ }
492
+ if (kit.look === "notebook") {
493
+ return (
494
+ <div
495
+ style={{
496
+ ...base,
497
+ background: kit.panel,
498
+ border: `${Math.max(2, 3 * u)}px solid ${kit.line}`,
499
+ // Uneven corners read as drawn by hand.
500
+ borderRadius: `${10 * u}px ${26 * u}px ${12 * u}px ${20 * u}px / ${20 * u}px ${12 * u}px ${26 * u}px ${10 * u}px`,
501
+ boxShadow: `0 ${8 * u}px ${24 * u}px rgba(0,0,0,0.18)`,
502
+ }}
503
+ >
504
+ <div
505
+ style={{
506
+ position: "absolute",
507
+ left: "50%",
508
+ top: -22 * u,
509
+ width: 170 * u,
510
+ height: 44 * u,
511
+ marginLeft: -85 * u,
512
+ background: "rgba(236,226,196,0.82)",
513
+ transform: "rotate(-3deg)",
514
+ }}
515
+ />
516
+ {children}
517
+ </div>
518
+ );
519
+ }
520
+ if (kit.look === "neon") {
521
+ const cut = 28 * u;
522
+ const glowColor = isHex(kit.line) ? kit.line : "#22e8ff";
523
+ const shape = `polygon(${cut}px 0, 100% 0, 100% calc(100% - ${cut}px), calc(100% - ${cut}px) 100%, 0 100%, 0 ${cut}px)`;
524
+ return (
525
+ <div style={{ ...base, filter: `drop-shadow(0 0 ${14 * u}px ${tint(glowColor, 0.55)})` }}>
526
+ <div style={{ position: "absolute", inset: 0, background: glowColor, clipPath: shape }} />
527
+ <div style={{ position: "absolute", inset: Math.max(2, 3 * u), background: kit.panel, clipPath: shape }} />
528
+ <div style={{ position: "absolute", left: cut * 1.4, top: -Math.max(2, 3 * u), width: 90 * u, height: Math.max(4, 7 * u), background: kit.accent }} />
529
+ <div style={{ position: "relative" }}>{children}</div>
530
+ </div>
531
+ );
532
+ }
533
+ if (kit.look === "line") {
534
+ return (
535
+ <div style={{ ...base, background: kit.panel, border: `${Math.max(2, 3 * u)}px solid ${kit.line}` }}>
536
+ {children}
537
+ </div>
538
+ );
539
+ }
540
+ if (kit.look === "vhs") {
541
+ return (
542
+ <div
543
+ style={{
544
+ ...base,
545
+ background: kit.panel,
546
+ border: `${Math.max(2, 3 * u)}px solid ${kit.line}`,
547
+ outline: `${Math.max(1, 2 * u)}px solid ${kit.line}`,
548
+ outlineOffset: `${6 * u}px`,
549
+ }}
550
+ >
551
+ {children}
552
+ <Scanlines u={u} opacity={0.16} />
553
+ </div>
554
+ );
555
+ }
556
+ if (kit.look === "crt") {
557
+ const bar = 46 * u;
558
+ return (
559
+ <div
560
+ style={{
561
+ ...base,
562
+ background: kit.panel,
563
+ border: `${Math.max(2, 3 * u)}px solid ${kit.line}`,
564
+ boxShadow: `0 0 ${30 * u}px ${tint(kit.line, 0.35)}`,
565
+ paddingTop: bar,
566
+ overflow: "hidden",
567
+ }}
568
+ >
569
+ <div
570
+ style={{
571
+ position: "absolute",
572
+ left: 0,
573
+ right: 0,
574
+ top: 0,
575
+ height: bar,
576
+ display: "flex",
577
+ alignItems: "center",
578
+ gap: 10 * u,
579
+ padding: `0 ${18 * u}px`,
580
+ borderBottom: `${Math.max(1, 2 * u)}px solid ${tint(kit.line, 0.6)}`,
581
+ fontFamily: kit.body,
582
+ fontSize: 30 * u,
583
+ color: tint(kit.line, 0.85),
584
+ }}
585
+ >
586
+ {[0, 1, 2].map((i) => (
587
+ <span key={i} style={{ width: 14 * u, height: 14 * u, background: tint(kit.line, 0.7 - i * 0.2) }} />
588
+ ))}
589
+ <span style={{ marginLeft: 8 * u }}>{title ?? "~/note.txt"}</span>
590
+ </div>
591
+ {children}
592
+ <Scanlines u={u} opacity={0.22} />
593
+ </div>
594
+ );
595
+ }
596
+ return (
597
+ <div
598
+ style={{
599
+ ...base,
600
+ background: kit.panel,
601
+ borderRadius: 30 * u,
602
+ border: `${Math.max(1, 2 * u)}px solid rgba(255,255,255,0.1)`,
603
+ boxShadow: `0 ${24 * u}px ${70 * u}px rgba(0,0,0,0.4)`,
604
+ }}
605
+ >
606
+ {children}
607
+ </div>
608
+ );
609
+ }
610
+
611
+ // ---------------------------------------------------------------------------
612
+ // Words
613
+
614
+ /** One highlighted word, drawn the look's way (the *starred* words of a line). */
615
+ function Accent({ kit, children, fontSize, onPanel, progress = 1, seed = 1 }: { kit: LookKit; children: ReactNode; fontSize: number; onPanel: boolean; progress?: number; seed?: number }) {
616
+ const u = kit.u;
617
+ if (kit.look === "ink") {
618
+ return (
619
+ <span
620
+ style={{
621
+ display: "inline-block",
622
+ background: kit.accent,
623
+ color: kit.onAccent,
624
+ padding: `0 ${fontSize * 0.14}px`,
625
+ border: `${Math.max(2, 3.5 * u)}px solid ${kit.line}`,
626
+ borderRadius: 6 * u,
627
+ lineHeight: 1.12,
628
+ }}
629
+ >
630
+ {children}
631
+ </span>
632
+ );
633
+ }
634
+ if (kit.look === "paper") {
635
+ return (
636
+ <Scrap bg={kit.accent} seed={seed} shadow={0.35}>
637
+ <span style={{ display: "inline-block", color: kit.onAccent, padding: `0 ${fontSize * 0.14}px` }}>{children}</span>
638
+ </Scrap>
639
+ );
640
+ }
641
+ if (kit.look === "notebook") {
642
+ // A marker swipe that draws across the word.
643
+ return (
644
+ <span style={{ position: "relative", display: "inline-block" }}>
645
+ <span
646
+ style={{
647
+ position: "absolute",
648
+ left: -fontSize * 0.08,
649
+ top: "38%",
650
+ height: "52%",
651
+ width: `calc(${progress * 100}% + ${fontSize * 0.16 * progress}px)`,
652
+ background: tint(kit.accent, 0.85, "#ffd60a"),
653
+ transform: "rotate(-1.5deg)",
654
+ borderRadius: fontSize * 0.1,
655
+ }}
656
+ />
657
+ <span style={{ position: "relative", color: onPanel ? kit.panelText : progress > 0.5 ? kit.onAccent : kit.text }}>{children}</span>
658
+ </span>
659
+ );
660
+ }
661
+ if (kit.look === "crt") {
662
+ return <span style={{ display: "inline-block", background: kit.accent, color: kit.onAccent, padding: `0 ${fontSize * 0.12}px` }}>{children}</span>;
663
+ }
664
+ if (kit.look === "line") {
665
+ return <span style={{ color: kit.accent }}>{children}</span>;
666
+ }
667
+ if (kit.look === "vhs") {
668
+ return <span style={{ color: kit.accent, textShadow: chroma(u) }}>{children}</span>;
669
+ }
670
+ if (kit.look === "neon") {
671
+ return (
672
+ <span
673
+ style={{
674
+ display: "inline-block",
675
+ background: kit.accent,
676
+ color: kit.onAccent,
677
+ padding: `0 ${fontSize * 0.14}px`,
678
+ boxShadow: `${5 * u}px ${4 * u}px 0 ${kit.line}`,
679
+ textShadow: "none",
680
+ }}
681
+ >
682
+ {children}
683
+ </span>
684
+ );
685
+ }
686
+ return <span style={{ color: kit.accent }}>{children}</span>;
687
+ }
688
+
689
+ /**
690
+ * A line of words with *starred* accents. Words appear one after another from `start`
691
+ * (`stagger` frames apart), or at `times` (frames, one per word); otherwise all at once.
692
+ */
693
+ export function Words({
694
+ kit,
695
+ line,
696
+ fontSize,
697
+ frame,
698
+ start = 0,
699
+ stagger = 0,
700
+ times,
701
+ onPanel = true,
702
+ seed = 1,
703
+ style,
704
+ }: {
705
+ kit: LookKit;
706
+ line: string;
707
+ fontSize: number;
708
+ frame: number;
709
+ start?: number;
710
+ stagger?: number;
711
+ times?: number[];
712
+ onPanel?: boolean;
713
+ seed?: number;
714
+ style?: CSSProperties;
715
+ }) {
716
+ const words = splitHighlights(line);
717
+ const animated = stagger > 0 || Boolean(times);
718
+ return (
719
+ <span style={{ display: "inline-flex", flexWrap: "wrap", alignItems: "baseline", columnGap: fontSize * 0.26, rowGap: fontSize * 0.08, ...style }}>
720
+ {words.map((word, i) => {
721
+ const at = times?.[i] ?? start + i * stagger;
722
+ // Spoken words (captions) take no space until they're said, so the box grows word by word.
723
+ if (times && frame < at) return null;
724
+ const t = animated ? ramp(frame, at, 5) : 1;
725
+ const pop = animated ? interpolate(frame, [at, at + 3, at + 6], [0.7, 1.08, 1], { extrapolateLeft: "clamp", extrapolateRight: "clamp" }) : 1;
726
+ return (
727
+ <span key={i} style={{ display: "inline-block", opacity: t, transform: `scale(${pop})` }}>
728
+ {word.highlighted ? (
729
+ <Accent kit={kit} fontSize={fontSize} onPanel={onPanel} progress={ramp(frame, at + 3, 10)} seed={seed * 31 + i}>
730
+ {word.text}
731
+ </Accent>
732
+ ) : (
733
+ word.text
734
+ )}
735
+ </span>
736
+ );
737
+ })}
738
+ </span>
739
+ );
740
+ }
741
+
742
+ /**
743
+ * A caption-like phrase over footage: white box with ink border, ransom-note words on paper,
744
+ * handwriting with a marker, terminal text on black, or a dark pill.
745
+ */
746
+ export function Chip({
747
+ kit,
748
+ line,
749
+ fontSize,
750
+ frame,
751
+ fps,
752
+ start = 0,
753
+ stagger = 0,
754
+ times,
755
+ seed = 1,
756
+ onBackdrop = false,
757
+ style,
758
+ }: {
759
+ kit: LookKit;
760
+ line: string;
761
+ fontSize: number;
762
+ frame: number;
763
+ fps: number;
764
+ start?: number;
765
+ stagger?: number;
766
+ times?: number[];
767
+ seed?: number;
768
+ /** Sits on the look's backdrop (a full-frame card) rather than over footage. */
769
+ onBackdrop?: boolean;
770
+ style?: CSSProperties;
771
+ }) {
772
+ const u = kit.u;
773
+ const words = (onPanel: boolean) => (
774
+ <Words kit={kit} line={line} fontSize={fontSize} frame={frame} start={start} stagger={stagger} times={times} onPanel={onPanel} seed={seed} />
775
+ );
776
+ const text: CSSProperties = { fontSize, lineHeight: 1.15 };
777
+ if (kit.look === "ink") {
778
+ return (
779
+ <span
780
+ style={{
781
+ ...text,
782
+ display: "inline-block",
783
+ fontFamily: kit.body,
784
+ fontWeight: 700,
785
+ textTransform: "uppercase",
786
+ background: kit.panel,
787
+ color: kit.panelText,
788
+ border: `${Math.max(2, 4 * u)}px solid ${kit.line}`,
789
+ boxShadow: `${6 * u}px ${6 * u}px 0 ${kit.line}`,
790
+ padding: `${fontSize * 0.12}px ${fontSize * 0.3}px`,
791
+ ...style,
792
+ }}
793
+ >
794
+ {words(true)}
795
+ </span>
796
+ );
797
+ }
798
+ if (kit.look === "paper") {
799
+ // Each word on its own scrap, in its own typeface.
800
+ const chips = paperChips(kit);
801
+ const list = splitHighlights(line);
802
+ return (
803
+ <span style={{ ...text, display: "inline-flex", flexWrap: "wrap", justifyContent: "center", gap: `${fontSize * 0.16}px ${fontSize * 0.12}px`, ...style }}>
804
+ {list.map((word, i) => {
805
+ const s = seed * 53 + i * 11;
806
+ const chip = word.highlighted ? { bg: kit.accent, fg: kit.onAccent } : chips[Math.floor(hash(s, 2) * 4)];
807
+ const at = times?.[i] ?? start + i * stagger;
808
+ if (times && frame < at) return null;
809
+ const e = enter(kit, frame, fps, at, (hash(s, 3) - 0.5) * 8, s);
810
+ return (
811
+ <span key={i} style={{ display: "inline-block", opacity: e.opacity, transform: e.transform }}>
812
+ <Scrap bg={chip.bg} seed={s}>
813
+ <span
814
+ style={{
815
+ display: "inline-block",
816
+ fontFamily: RANSOM_FONTS[Math.floor(hash(s, 1) * RANSOM_FONTS.length)],
817
+ fontSize: fontSize * (word.highlighted ? 1.2 : 1),
818
+ color: chip.fg,
819
+ padding: `${fontSize * 0.06}px ${fontSize * 0.2}px ${fontSize * 0.02}px`,
820
+ textTransform: hash(s, 5) > 0.4 ? "uppercase" : "none",
821
+ }}
822
+ >
823
+ {word.text}
824
+ </span>
825
+ </Scrap>
826
+ </span>
827
+ );
828
+ })}
829
+ </span>
830
+ );
831
+ }
832
+ if (kit.look === "notebook") {
833
+ return (
834
+ <span
835
+ style={{
836
+ ...text,
837
+ display: "inline-block",
838
+ fontFamily: kit.head,
839
+ fontWeight: 700,
840
+ fontSize: fontSize * 1.25,
841
+ color: onBackdrop ? kit.panelText : kit.text,
842
+ textShadow: onBackdrop ? undefined : `0 ${2 * u}px ${10 * u}px rgba(0,0,0,0.6), 0 0 ${2 * u}px rgba(0,0,0,0.8)`,
843
+ ...style,
844
+ }}
845
+ >
846
+ {words(onBackdrop)}
847
+ </span>
848
+ );
849
+ }
850
+ if (kit.look === "neon") {
851
+ return (
852
+ <span
853
+ style={{
854
+ ...text,
855
+ display: "inline-block",
856
+ transform: "skewX(-10deg)",
857
+ background: "rgba(10,4,24,0.86)",
858
+ border: `${Math.max(2, 2.5 * u)}px solid ${kit.line}`,
859
+ boxShadow: `0 0 ${16 * u}px ${tint(kit.line, 0.6, "#22e8ff")}, ${6 * u}px ${6 * u}px 0 ${tint(kit.accent, 0.85)}`,
860
+ padding: `${fontSize * 0.1}px ${fontSize * 0.34}px`,
861
+ ...style,
862
+ }}
863
+ >
864
+ <span style={{ display: "inline-block", transform: "skewX(10deg)", fontFamily: kit.body, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.04em", color: kit.text }}>
865
+ {words(true)}
866
+ </span>
867
+ </span>
868
+ );
869
+ }
870
+ if (kit.look === "line") {
871
+ const big = fontSize * 1.55;
872
+ const stroke = Math.max(2, big * 0.09);
873
+ return (
874
+ <span
875
+ style={{
876
+ display: "inline-block",
877
+ fontFamily: FONTS.heavy,
878
+ fontWeight: 900,
879
+ fontSize: big,
880
+ lineHeight: 1.04,
881
+ letterSpacing: "-0.01em",
882
+ textTransform: "uppercase",
883
+ color: onBackdrop ? kit.panelText : kit.text,
884
+ WebkitTextStroke: onBackdrop ? undefined : `${stroke}px #000000`,
885
+ paintOrder: "stroke fill",
886
+ textShadow: onBackdrop ? undefined : `0 ${big * 0.06}px ${big * 0.1}px rgba(0,0,0,0.55)`,
887
+ ...style,
888
+ }}
889
+ >
890
+ <Words kit={kit} line={line} fontSize={big} frame={frame} start={start} stagger={stagger} times={times} onPanel={onBackdrop} seed={seed} />
891
+ </span>
892
+ );
893
+ }
894
+ if (kit.look === "vhs") {
895
+ return (
896
+ <span
897
+ style={{
898
+ ...text,
899
+ display: "inline-block",
900
+ fontFamily: FONTS.pixel,
901
+ fontSize: fontSize * 1.3,
902
+ lineHeight: 1.1,
903
+ letterSpacing: "0.02em",
904
+ textTransform: "uppercase",
905
+ background: "#000000",
906
+ color: "#ffffff",
907
+ padding: `${fontSize * 0.02}px ${fontSize * 0.28}px`,
908
+ ...style,
909
+ }}
910
+ >
911
+ {words(true)}
912
+ </span>
913
+ );
914
+ }
915
+ if (kit.look === "crt") {
916
+ return (
917
+ <span
918
+ style={{
919
+ ...text,
920
+ display: "inline-block",
921
+ fontFamily: kit.body,
922
+ fontSize: fontSize * 1.15,
923
+ background: "rgba(0,0,0,0.82)",
924
+ color: kit.panelText,
925
+ padding: `${fontSize * 0.08}px ${fontSize * 0.3}px`,
926
+ ...style,
927
+ }}
928
+ >
929
+ {words(true)}
930
+ </span>
931
+ );
932
+ }
933
+ return (
934
+ <span
935
+ style={{
936
+ ...text,
937
+ display: "inline-block",
938
+ fontFamily: kit.body,
939
+ fontWeight: 700,
940
+ background: "rgba(10,12,16,0.78)",
941
+ color: kit.text,
942
+ borderRadius: fontSize,
943
+ padding: `${fontSize * 0.18}px ${fontSize * 0.5}px`,
944
+ ...style,
945
+ }}
946
+ >
947
+ {words(false)}
948
+ </span>
949
+ );
950
+ }
951
+
952
+ /** Big headline lines; each enters in turn. Color: the panel text (it sits on a card or the backdrop). */
953
+ export function Headline({
954
+ kit,
955
+ lines,
956
+ fontSize,
957
+ frame,
958
+ fps,
959
+ start = 0,
960
+ align = "left",
961
+ seed = 1,
962
+ }: {
963
+ kit: LookKit;
964
+ lines: string[];
965
+ fontSize: number;
966
+ frame: number;
967
+ fps: number;
968
+ start?: number;
969
+ align?: "left" | "center";
970
+ seed?: number;
971
+ }) {
972
+ const items = align === "center" ? "center" : "flex-start";
973
+ if (kit.look === "paper") {
974
+ // Ransom note: every letter its own cut-out, line after line.
975
+ const texts = lines.map((line) => line.replace(/\*/g, ""));
976
+ const starts = texts.map((_, i) => start + texts.slice(0, i).reduce((sum, text) => sum + text.replace(/\s/g, "").length * 2 + 4, 0));
977
+ return (
978
+ <div style={{ display: "flex", flexDirection: "column", alignItems: items, gap: fontSize * 0.08 }}>
979
+ {texts.map((text, i) => (
980
+ <CutLetters key={i} kit={kit} text={text} fontSize={fontSize * 0.62} frame={frame} fps={fps} start={starts[i]} seed={seed * 7 + i} />
981
+ ))}
982
+ </div>
983
+ );
984
+ }
985
+ return (
986
+ <div
987
+ style={{
988
+ display: "flex",
989
+ flexDirection: "column",
990
+ alignItems: items,
991
+ textAlign: align,
992
+ fontFamily: kit.head,
993
+ fontWeight: headWeight(kit),
994
+ // Orbitron runs wide: a size down keeps two words on a line.
995
+ fontSize: kit.look === "neon" ? fontSize * 0.78 : fontSize,
996
+ lineHeight: kit.look === "notebook" ? 1 : 0.98,
997
+ letterSpacing: kit.look === "crt" ? "0.02em" : kit.look === "notebook" ? "0" : "-0.02em",
998
+ textTransform: kit.look === "crt" || kit.look === "neon" || kit.look === "line" ? "uppercase" : "none",
999
+ color: kit.panelText,
1000
+ textShadow:
1001
+ kit.look === "crt"
1002
+ ? `0 0 ${18 * kit.u}px ${tint(kit.accent, 0.55)}`
1003
+ : kit.look === "neon"
1004
+ ? `${-4 * kit.u}px 0 ${tint(kit.line, 0.9, "#22e8ff")}, ${4 * kit.u}px 0 ${tint(kit.accent, 0.9)}, 0 0 ${24 * kit.u}px ${tint(kit.accent, 0.5)}`
1005
+ : kit.look === "vhs"
1006
+ ? chroma(kit.u, 1.4)
1007
+ : undefined,
1008
+ }}
1009
+ >
1010
+ {lines.map((line, i) => {
1011
+ const e = enter(kit, frame, fps, start + i * 5, 0, seed + i);
1012
+ // Neon: every couple of seconds a line tears sideways for two frames.
1013
+ const tear = kit.look === "neon" && frame % 54 >= 52 - i ? `translateX(${((hash(i, frame) - 0.5) * 30 * kit.u).toFixed(1)}px)` : "";
1014
+ return (
1015
+ <div key={i} style={{ opacity: e.opacity, transform: `${e.transform} ${tear}`, transformOrigin: align === "center" ? "50% 60%" : "0% 60%" }}>
1016
+ <Words
1017
+ kit={kit}
1018
+ line={kit.look === "crt" ? typed(kit, line, frame, start + i * 10, 1.2) : line}
1019
+ fontSize={fontSize}
1020
+ frame={frame}
1021
+ seed={seed + i}
1022
+ style={{ justifyContent: align === "center" ? "center" : "flex-start" }}
1023
+ />
1024
+ </div>
1025
+ );
1026
+ })}
1027
+ </div>
1028
+ );
1029
+ }
1030
+
1031
+ /** Small kicker / label text. */
1032
+ export function Label({ kit, children, fontSize, color, style }: { kit: LookKit; children: ReactNode; fontSize: number; color?: string; style?: CSSProperties }) {
1033
+ const big = kit.look === "notebook" || kit.look === "crt";
1034
+ return (
1035
+ <div
1036
+ style={{
1037
+ fontFamily: kit.body,
1038
+ fontWeight: kit.look === "notebook" ? 600 : 700,
1039
+ fontSize: big ? fontSize * 1.35 : fontSize,
1040
+ letterSpacing: labelCase(kit) === "uppercase" ? "0.14em" : "0.01em",
1041
+ textTransform: labelCase(kit),
1042
+ color: color ?? kit.panelText,
1043
+ opacity: 0.8,
1044
+ ...style,
1045
+ }}
1046
+ >
1047
+ {children}
1048
+ </div>
1049
+ );
1050
+ }
1051
+
1052
+ // ---------------------------------------------------------------------------
1053
+ // Stickers and tags
1054
+
1055
+ /** Points of a starburst polygon centered in a size×size box. */
1056
+ function burst(size: number, points = 14, inner = 0.78) {
1057
+ const c = size / 2;
1058
+ const out: string[] = [];
1059
+ for (let i = 0; i < points * 2; i += 1) {
1060
+ const r = (i % 2 === 0 ? 1 : inner) * c;
1061
+ const a = (Math.PI * i) / points - Math.PI / 2;
1062
+ out.push(`${(c + r * Math.cos(a)).toFixed(1)},${(c + r * Math.sin(a)).toFixed(1)}`);
1063
+ }
1064
+ return out.join(" ");
1065
+ }
1066
+
1067
+ /** A wobbly hand-drawn loop around a w×h box (slightly overshooting where it closes). */
1068
+ function scribble(w: number, h: number) {
1069
+ const cx = w / 2;
1070
+ const cy = h / 2;
1071
+ const pts: string[] = [];
1072
+ for (let i = 0; i <= 56; i += 1) {
1073
+ const a = (i / 52) * Math.PI * 2 - 2.2;
1074
+ const wob = 1 + Math.sin(i * 1.7) * 0.025 + (i > 50 ? 0.06 : 0);
1075
+ pts.push(`${(cx + Math.cos(a) * (w / 2 - 6) * wob).toFixed(1)},${(cy + Math.sin(a) * (h / 2 - 6) * wob).toFixed(1)}`);
1076
+ }
1077
+ return `M ${pts.join(" L ")}`;
1078
+ }
1079
+
1080
+ /** A badge for a number or one word: starburst, paper rosette, hand-drawn circle, terminal bracket or a disc. */
1081
+ export function Sticker({ kit, text, size, frame, fps, start = 0, tilt = 8, seed = 1 }: { kit: LookKit; text: string; size: number; frame: number; fps: number; start?: number; tilt?: number; seed?: number }) {
1082
+ const u = kit.u;
1083
+ const e = enter(kit, frame, fps, start, kit.look === "crt" ? 0 : tilt, seed);
1084
+ const fontSize = size * (text.length <= 2 ? 0.46 : text.length <= 4 ? 0.3 : 0.22);
1085
+ const label: CSSProperties = { position: "absolute", inset: 0, display: "flex", alignItems: "center", justifyContent: "center", fontSize, lineHeight: 1 };
1086
+ if (kit.look === "ink" || kit.look === "paper") {
1087
+ const stroke = kit.look === "ink" ? Math.max(3, 6 * u) : 0;
1088
+ const pad = stroke + 12 * u;
1089
+ return (
1090
+ <div style={{ position: "relative", width: size, height: size, opacity: e.opacity, transform: e.transform }}>
1091
+ <svg width={size} height={size} viewBox={`${-pad} ${-pad} ${size + pad * 2} ${size + pad * 2}`} style={{ position: "absolute", inset: 0, overflow: "visible" }}>
1092
+ <polygon points={burst(size, kit.look === "paper" ? 18 : 14, kit.look === "paper" ? 0.86 : 0.78)} transform={`translate(${10 * u} ${12 * u})`} fill={kit.look === "ink" ? kit.line : "rgba(20,12,4,0.42)"} />
1093
+ <polygon points={burst(size, kit.look === "paper" ? 18 : 14, kit.look === "paper" ? 0.86 : 0.78)} fill={kit.accent} stroke={kit.line} strokeWidth={stroke} strokeLinejoin="round" />
1094
+ </svg>
1095
+ {kit.look === "paper" ? (
1096
+ <div style={{ position: "absolute", inset: 0, borderRadius: "50%", overflow: "hidden" }}>
1097
+ <Grain opacity={0.25} seed={seed} />
1098
+ </div>
1099
+ ) : null}
1100
+ <div style={{ ...label, fontFamily: kit.head, color: kit.onAccent, WebkitTextStroke: kit.look === "ink" ? `${Math.max(1, 2 * u)}px ${kit.line}` : undefined }}>{text}</div>
1101
+ </div>
1102
+ );
1103
+ }
1104
+ if (kit.look === "notebook") {
1105
+ const draw = ramp(frame, start + 4, 16);
1106
+ const path = scribble(size * 1.25, size);
1107
+ return (
1108
+ <div style={{ position: "relative", width: size * 1.25, height: size, opacity: e.opacity, transform: e.transform }}>
1109
+ <svg width={size * 1.25} height={size} style={{ position: "absolute", inset: 0, overflow: "visible" }}>
1110
+ <path d={path} fill="none" stroke={kit.accent} strokeWidth={Math.max(3, 7 * u)} strokeLinecap="round" strokeLinejoin="round" pathLength={1} strokeDasharray={1} strokeDashoffset={1 - draw} />
1111
+ </svg>
1112
+ <div style={{ ...label, fontFamily: kit.head, fontWeight: 700, color: kit.text, fontSize: fontSize * 1.2, textShadow: "0 2px 10px rgba(0,0,0,0.5)" }}>{text}</div>
1113
+ </div>
1114
+ );
1115
+ }
1116
+ if (kit.look === "neon") {
1117
+ const pts = Array.from({ length: 6 }, (_, k) => {
1118
+ const a = (Math.PI / 3) * k - Math.PI / 2;
1119
+ return `${(size / 2 + Math.cos(a) * size * 0.48).toFixed(1)},${(size / 2 + Math.sin(a) * size * 0.48).toFixed(1)}`;
1120
+ }).join(" ");
1121
+ const glowColor = isHex(kit.line) ? kit.line : "#22e8ff";
1122
+ return (
1123
+ <div style={{ position: "relative", width: size, height: size, opacity: e.opacity, transform: e.transform, filter: `drop-shadow(0 0 ${12 * u}px ${glowColor})` }}>
1124
+ <svg width={size} height={size} style={{ position: "absolute", inset: 0, overflow: "visible" }}>
1125
+ <polygon points={pts} fill="rgba(10,4,24,0.85)" stroke={glowColor} strokeWidth={Math.max(2, 4 * u)} />
1126
+ <polygon points={pts} fill="none" stroke={kit.accent} strokeWidth={Math.max(1, 2 * u)} transform={`translate(${5 * u} ${4 * u})`} />
1127
+ </svg>
1128
+ <div style={{ ...label, fontFamily: kit.head, fontWeight: 800, color: "#ffffff", textShadow: `${-3 * u}px 0 ${glowColor}, ${3 * u}px 0 ${kit.accent}` }}>{text}</div>
1129
+ </div>
1130
+ );
1131
+ }
1132
+ if (kit.look === "line") {
1133
+ const draw = ramp(frame, start, 14);
1134
+ const r = size / 2 - 4 * u;
1135
+ return (
1136
+ <div style={{ position: "relative", width: size, height: size, opacity: e.opacity }}>
1137
+ <svg width={size} height={size} style={{ position: "absolute", inset: 0, overflow: "visible" }}>
1138
+ <circle cx={size / 2} cy={size / 2} r={r} fill="rgba(0,0,0,0.55)" stroke={kit.line} strokeWidth={Math.max(2, 3 * u)} pathLength={1} strokeDasharray={1} strokeDashoffset={1 - draw} transform={`rotate(-90 ${size / 2} ${size / 2})`} />
1139
+ </svg>
1140
+ <div style={{ ...label, fontFamily: FONTS.heavy, fontWeight: 900, color: kit.text, transform: e.transform }}>{text}</div>
1141
+ </div>
1142
+ );
1143
+ }
1144
+ if (kit.look === "vhs") {
1145
+ const segments = 16;
1146
+ const fillTo = Math.round(ramp(frame, start + 4, 18) * segments);
1147
+ return (
1148
+ <div style={{ display: "flex", flexDirection: "column", gap: 10 * u, opacity: e.opacity, transform: e.transform, fontFamily: FONTS.pixel, color: kit.accent, textShadow: chroma(u) }}>
1149
+ <span style={{ fontSize: size * 0.42, lineHeight: 0.9 }}>{text}</span>
1150
+ <span style={{ display: "flex", gap: 5 * u }}>
1151
+ {Array.from({ length: segments }, (_, k) => (
1152
+ <span key={k} style={{ width: size * 0.045, height: size * 0.16, background: k < fillTo ? kit.accent : "rgba(255,255,255,0.25)" }} />
1153
+ ))}
1154
+ </span>
1155
+ </div>
1156
+ );
1157
+ }
1158
+ if (kit.look === "crt") {
1159
+ const blink = Math.floor((frame - start) / 15) % 2 === 0;
1160
+ return (
1161
+ <div
1162
+ style={{
1163
+ display: "inline-flex",
1164
+ alignItems: "center",
1165
+ gap: 10 * u,
1166
+ padding: `${8 * u}px ${20 * u}px`,
1167
+ background: "rgba(0,0,0,0.85)",
1168
+ border: `${Math.max(2, 3 * u)}px solid ${kit.accent}`,
1169
+ boxShadow: `0 0 ${24 * u}px ${tint(kit.accent, 0.45)}`,
1170
+ fontFamily: kit.head,
1171
+ fontSize: fontSize * 1.1,
1172
+ color: kit.accent,
1173
+ opacity: e.opacity,
1174
+ }}
1175
+ >
1176
+ <span>{typed(kit, text, frame, start + 4, 0.6)}</span>
1177
+ <span style={{ width: fontSize * 0.45, height: fontSize * 0.8, background: kit.accent, opacity: blink ? 1 : 0 }} />
1178
+ </div>
1179
+ );
1180
+ }
1181
+ return (
1182
+ <div
1183
+ style={{
1184
+ position: "relative",
1185
+ width: size,
1186
+ height: size,
1187
+ borderRadius: "50%",
1188
+ background: kit.accent,
1189
+ boxShadow: `0 ${14 * u}px ${40 * u}px ${tint(kit.accent, 0.45)}`,
1190
+ opacity: e.opacity,
1191
+ transform: e.transform,
1192
+ }}
1193
+ >
1194
+ <div style={{ ...label, fontFamily: kit.head, fontWeight: 800, color: kit.onAccent }}>{text}</div>
1195
+ </div>
1196
+ );
1197
+ }
1198
+
1199
+ /** A small tilted label ("Claude Code"): ink tag, masking tape, taped paper scrap, prompt line or pill. */
1200
+ export function Tag({ kit, text, fontSize, frame, fps, start = 0, tilt = -7, seed = 1 }: { kit: LookKit; text: string; fontSize: number; frame: number; fps: number; start?: number; tilt?: number; seed?: number }) {
1201
+ const u = kit.u;
1202
+ const e = enter(kit, frame, fps, start, kit.look === "crt" ? 0 : tilt, seed);
1203
+ const common: CSSProperties = { display: "inline-block", opacity: e.opacity, transform: e.transform, fontSize, lineHeight: 1.1, whiteSpace: "nowrap" };
1204
+ if (kit.look === "ink") {
1205
+ return (
1206
+ <span
1207
+ style={{
1208
+ ...common,
1209
+ fontFamily: kit.body,
1210
+ fontWeight: 700,
1211
+ background: kit.panel,
1212
+ color: kit.panelText,
1213
+ border: `${Math.max(2, 3.5 * u)}px solid ${kit.line}`,
1214
+ boxShadow: `${5 * u}px ${5 * u}px 0 ${kit.line}`,
1215
+ padding: `${fontSize * 0.2}px ${fontSize * 0.45}px`,
1216
+ }}
1217
+ >
1218
+ {text}
1219
+ </span>
1220
+ );
1221
+ }
1222
+ if (kit.look === "paper") {
1223
+ // Written on a strip of masking tape.
1224
+ return (
1225
+ <span style={common}>
1226
+ <Scrap bg="rgba(232,220,186,0.95)" seed={seed} shadow={0.18}>
1227
+ <span style={{ display: "inline-block", fontFamily: FONTS.condensed, color: kit.line, padding: `${fontSize * 0.14}px ${fontSize * 0.5}px`, textTransform: "uppercase", letterSpacing: "0.04em" }}>{text}</span>
1228
+ </Scrap>
1229
+ </span>
1230
+ );
1231
+ }
1232
+ if (kit.look === "notebook") {
1233
+ return (
1234
+ <span
1235
+ style={{
1236
+ ...common,
1237
+ position: "relative",
1238
+ fontFamily: kit.head,
1239
+ fontWeight: 700,
1240
+ fontSize: fontSize * 1.35,
1241
+ background: kit.panel,
1242
+ color: kit.panelText,
1243
+ padding: `${fontSize * 0.15}px ${fontSize * 0.5}px`,
1244
+ boxShadow: `0 ${4 * u}px ${12 * u}px rgba(0,0,0,0.2)`,
1245
+ }}
1246
+ >
1247
+ <span style={{ position: "absolute", left: "50%", top: -fontSize * 0.45, width: fontSize * 2.4, height: fontSize * 0.7, marginLeft: -fontSize * 1.2, background: "rgba(236,226,196,0.85)", transform: "rotate(4deg)" }} />
1248
+ {text}
1249
+ </span>
1250
+ );
1251
+ }
1252
+ if (kit.look === "neon") {
1253
+ return (
1254
+ <span
1255
+ style={{
1256
+ ...common,
1257
+ fontFamily: kit.body,
1258
+ fontWeight: 700,
1259
+ textTransform: "uppercase",
1260
+ letterSpacing: "0.08em",
1261
+ background: "rgba(10,4,24,0.85)",
1262
+ color: kit.line,
1263
+ borderLeft: `${Math.max(3, 6 * u)}px solid ${kit.accent}`,
1264
+ padding: `${fontSize * 0.2}px ${fontSize * 0.5}px`,
1265
+ boxShadow: `0 0 ${12 * u}px ${tint(kit.line, 0.45, "#22e8ff")}`,
1266
+ }}
1267
+ >
1268
+ {"// "}
1269
+ {text}
1270
+ </span>
1271
+ );
1272
+ }
1273
+ if (kit.look === "line") {
1274
+ return (
1275
+ <span
1276
+ style={{
1277
+ ...common,
1278
+ fontFamily: kit.body,
1279
+ fontWeight: 700,
1280
+ textTransform: "uppercase",
1281
+ letterSpacing: "0.16em",
1282
+ background: "#000000",
1283
+ color: kit.text,
1284
+ border: `${Math.max(1, 2 * u)}px solid ${kit.line}`,
1285
+ padding: `${fontSize * 0.25}px ${fontSize * 0.6}px`,
1286
+ }}
1287
+ >
1288
+ {text}
1289
+ </span>
1290
+ );
1291
+ }
1292
+ if (kit.look === "vhs") {
1293
+ return (
1294
+ <span style={{ ...common, fontFamily: FONTS.pixel, fontSize: fontSize * 1.5, color: "#ffffff", textTransform: "uppercase", textShadow: `0 0 ${2 * u}px #000000, ${chroma(u)}` }}>
1295
+ {text}
1296
+ </span>
1297
+ );
1298
+ }
1299
+ if (kit.look === "crt") {
1300
+ return (
1301
+ <span style={{ ...common, fontFamily: kit.body, fontSize: fontSize * 1.3, background: "rgba(0,0,0,0.85)", color: kit.accent, padding: `${fontSize * 0.1}px ${fontSize * 0.4}px` }}>
1302
+ {"> "}
1303
+ {typed(kit, text, frame, start, 1.2)}
1304
+ </span>
1305
+ );
1306
+ }
1307
+ return (
1308
+ <span
1309
+ style={{
1310
+ ...common,
1311
+ fontFamily: kit.body,
1312
+ fontWeight: 700,
1313
+ background: "rgba(10,12,16,0.78)",
1314
+ color: kit.text,
1315
+ border: `${Math.max(1, 2 * u)}px solid ${tint(kit.accent, 0.6, "#ffffff")}`,
1316
+ borderRadius: fontSize,
1317
+ padding: `${fontSize * 0.25}px ${fontSize * 0.6}px`,
1318
+ }}
1319
+ >
1320
+ {text}
1321
+ </span>
1322
+ );
1323
+ }
1324
+
1325
+ // ---------------------------------------------------------------------------
1326
+ // Split layout
1327
+
1328
+ /** Jagged torn-paper edge along the bottom of a w-wide strip (deterministic). */
1329
+ function tornPath(w: number, h: number, depth: number) {
1330
+ const pts: string[] = [`0,0`, `${w},0`];
1331
+ const steps = Math.max(12, Math.round(w / (depth * 1.4)));
1332
+ for (let i = steps; i >= 0; i -= 1) {
1333
+ const x = (i / steps) * w;
1334
+ pts.push(`${x.toFixed(1)},${(h - depth + hash(i, 4) * depth).toFixed(1)}`);
1335
+ }
1336
+ return pts.join(" ");
1337
+ }
1338
+
1339
+ /**
1340
+ * The top part of a split frame (the speaker's footage shows below it): the look's backdrop with a
1341
+ * bottom edge (hard ink rule, torn paper, glowing line or a soft fade). Children are laid out inside.
1342
+ */
1343
+ export function SplitTop({ kit, width, height, fraction, children, reveal, seed = 1 }: { kit: LookKit; width: number; height: number; fraction: number; children: ReactNode; reveal: number; seed?: number }) {
1344
+ const u = kit.u;
1345
+ const h = Math.round(height * fraction);
1346
+ const edge = 40 * u;
1347
+ const slide = mix(-(h + edge), 0, reveal);
1348
+ const torn = kit.look === "notebook" || kit.look === "paper";
1349
+ return (
1350
+ <div style={{ position: "absolute", left: 0, top: 0, width, height: h + edge, transform: `translateY(${slide}px)` }}>
1351
+ <div style={{ position: "absolute", left: 0, top: 0, width, height: h, overflow: "hidden" }}>
1352
+ <Backdrop kit={kit} width={width} height={h} seed={seed} />
1353
+ </div>
1354
+ {torn ? (
1355
+ <svg width={width} height={edge} style={{ position: "absolute", left: 0, top: h - 1 }}>
1356
+ <polygon points={tornPath(width, edge, edge * 0.55)} transform={`translate(0 ${6 * u})`} fill="rgba(0,0,0,0.25)" />
1357
+ <polygon points={tornPath(width, edge, edge * 0.55)} fill={kit.backdrop} />
1358
+ </svg>
1359
+ ) : kit.look === "ink" ? (
1360
+ <div style={{ position: "absolute", left: 0, top: h, width, height: Math.max(4, 8 * u), background: kit.line, boxShadow: `0 ${10 * u}px 0 ${tint(kit.line, 0.35)}` }} />
1361
+ ) : kit.look === "crt" ? (
1362
+ <div style={{ position: "absolute", left: 0, top: h, width, height: Math.max(2, 3 * u), background: kit.accent, boxShadow: `0 0 ${20 * u}px ${kit.accent}` }} />
1363
+ ) : (
1364
+ <div style={{ position: "absolute", left: 0, top: h, width, height: edge * 2, background: `linear-gradient(180deg, ${kit.backdrop} 0%, ${tint(kit.backdrop, 0)} 100%)` }} />
1365
+ )}
1366
+ <div style={{ position: "absolute", left: 0, top: 0, width, height: h, display: "flex", flexDirection: "column", justifyContent: "center" }}>{children}</div>
1367
+ </div>
1368
+ );
1369
+ }
1370
+
1371
+ // ---------------------------------------------------------------------------
1372
+ // Card layouts (list-card, quote-card, before-after)
1373
+
1374
+ /** Shared frame for the card components: full frame on the look's backdrop, or a card over footage. */
1375
+ export function CardStage({
1376
+ kit,
1377
+ width,
1378
+ height,
1379
+ layout,
1380
+ frame,
1381
+ fps,
1382
+ durationInFrames,
1383
+ footer,
1384
+ footerStart,
1385
+ title,
1386
+ children,
1387
+ }: {
1388
+ kit: LookKit;
1389
+ width: number;
1390
+ height: number;
1391
+ layout: string;
1392
+ frame: number;
1393
+ fps: number;
1394
+ durationInFrames: number;
1395
+ footer: string;
1396
+ footerStart: number;
1397
+ title: string;
1398
+ children: ReactNode;
1399
+ }) {
1400
+ const vertical = height > width;
1401
+ const out = exitOut(frame, durationInFrames, 10);
1402
+ const e = enter(kit, frame, fps, 0, kit.look === "ink" || kit.look === "paper" ? -1.5 : 0, 3);
1403
+ const cardWidth = width * (vertical ? 0.86 : 0.5);
1404
+ const footerSize = Math.min(width, height) * 0.045;
1405
+ return (
1406
+ <AbsoluteFill style={{ opacity: out }}>
1407
+ {layout === "full" ? <Backdrop kit={kit} width={width} height={height} seed={4} /> : null}
1408
+ <AbsoluteFill style={{ alignItems: "center", justifyContent: "center", gap: footerSize * 1.6 }}>
1409
+ <div style={{ width: cardWidth, opacity: e.opacity, transform: e.transform }}>
1410
+ <Panel kit={kit} title={title} seed={6}>
1411
+ {children}
1412
+ </Panel>
1413
+ </div>
1414
+ {footer ? (
1415
+ <div style={{ maxWidth: width * 0.9 }}>
1416
+ <Chip kit={kit} line={footer} fontSize={footerSize} frame={frame} fps={fps} start={footerStart} stagger={3} seed={9} onBackdrop={layout === "full"} />
1417
+ </div>
1418
+ ) : null}
1419
+ </AbsoluteFill>
1420
+ </AbsoluteFill>
1421
+ );
1422
+ }
1423
+
1424
+ /** A card title: ransom letters on paper, typed on a terminal, the headline font elsewhere. */
1425
+ export function CardTitle({ kit, text, fontSize, frame, fps, start }: { kit: LookKit; text: string; fontSize: number; frame: number; fps: number; start: number }) {
1426
+ // Cut letters are wide (a scrap each): smaller so a two-word title stays on a line or two.
1427
+ if (kit.look === "paper") return <CutLetters kit={kit} text={text} fontSize={fontSize * 0.7} frame={frame} fps={fps} start={start} seed={11} />;
1428
+ const e = enter(kit, frame, fps, start);
1429
+ return (
1430
+ <div
1431
+ style={{
1432
+ opacity: e.opacity,
1433
+ transform: e.transform,
1434
+ transformOrigin: "0% 60%",
1435
+ fontFamily: kit.head,
1436
+ fontWeight: headWeight(kit),
1437
+ fontSize,
1438
+ lineHeight: 1,
1439
+ letterSpacing: kit.look === "crt" || kit.look === "notebook" ? 0 : "-0.02em",
1440
+ textTransform: kit.look === "crt" ? "uppercase" : "none",
1441
+ color: kit.panelText,
1442
+ }}
1443
+ >
1444
+ <Words kit={kit} line={typed(kit, text, frame, start, 1.2)} fontSize={fontSize} frame={frame} />
1445
+ </div>
1446
+ );
1447
+ }