{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "hairline-open",
  "title": "Hairline Open",
  "description": "A hairline of light opens like a slit onto the next serif statement.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/hairline-open/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/InstrumentSerif\";\nimport type React from \"react\";\nimport { useId } from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst { fontFamily: serif } = loadSerif(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nloadSerif(\"italic\", { weights: [\"400\"], subsets: [\"latin\"] });\n\nexport interface HairlineOpenProps {\n  from?: React.ReactNode;\n  to?: React.ReactNode;\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  speed?: number;\n}\n\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst DRAW_AT = 8;\nconst DRAW_END = 26;\nconst OPEN_AT = 36;\nconst OPEN_END = 62;\n\nconst DRAW = Easing.bezier(0.7, 0, 0.2, 1);\nconst SHEAR = Easing.bezier(0.22, 1, 0.36, 1);\nconst OPEN = Easing.bezier(0.7, 0, 0.3, 1);\nconst SETTLE = Easing.bezier(0.22, 1, 0.36, 1);\n\nconst STAGES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    fg: \"#F3F2EF\",\n    light: \"rgba(255,255,255,0.055)\",\n    edge: \"rgba(143,180,255,0.55)\",\n    filament: (accent: string) =>\n      `linear-gradient(90deg, transparent 0%, ${accent} 35%, #8fb4ff 88%, #f4f7ff 100%)`,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    fg: \"#121214\",\n    light: \"rgba(255,255,255,0.9)\",\n    edge: \"rgba(143,180,255,0.7)\",\n    filament: (accent: string) =>\n      `linear-gradient(90deg, transparent 0%, ${accent} 35%, #1a1660 100%)`,\n  },\n};\n\n// Instrument Serif 400 advances (1/1000 em, ASCII 32–126), roman and italic, from HarfBuzz.\nconst SERIF_ADV = [\n  170, 237, 371, 635, 417, 590, 579, 233, 340, 340, 444, 531, 217, 430, 213,\n  258, 460, 249, 404, 371, 393, 382, 404, 364, 433, 402, 213, 217, 531, 531,\n  531, 317, 660, 457, 478, 480, 530, 453, 408, 521, 546, 249, 249, 496, 413,\n  665, 540, 540, 466, 540, 513, 407, 461, 536, 457, 651, 546, 477, 427, 325,\n  258, 325, 433, 376, 354, 399, 443, 339, 457, 355, 288, 402, 470, 223, 215,\n  451, 220, 704, 470, 408, 444, 442, 318, 308, 259, 454, 393, 597, 385, 401,\n  353, 318, 252, 318, 531,\n];\nconst SERIF_IT_ADV = [\n  170, 275, 374, 629, 424, 591, 525, 235, 346, 346, 449, 531, 219, 426, 219,\n  258, 461, 248, 404, 373, 394, 387, 411, 365, 437, 414, 299, 301, 531, 531,\n  531, 358, 665, 457, 479, 475, 536, 454, 411, 514, 545, 250, 251, 499, 414,\n  665, 542, 540, 469, 541, 525, 424, 461, 537, 458, 653, 545, 478, 427, 326,\n  256, 326, 431, 372, 355, 474, 431, 351, 474, 348, 273, 401, 476, 288, 266,\n  447, 240, 745, 521, 414, 450, 425, 368, 302, 272, 508, 412, 609, 450, 418,\n  385, 320, 252, 320, 531,\n];\nconst TRACK = -0.008;\n\nfunction widthEm(text: string, italic: boolean) {\n  const table = italic ? SERIF_IT_ADV : SERIF_ADV;\n  let w = 0;\n  for (const ch of text) {\n    const c = ch.charCodeAt(0);\n    w += (c >= 32 && c < 127 ? table[c - 32] : 420) / 1000 + TRACK;\n  }\n  return Math.max(w, 0.5);\n}\n\n// \"beam\" palette from gradients.sh (#f4f7ff, #8fb4ff, accent, #1a1660) laid out as a horizontal\n// band of light centred on the hairline, so the slit reads as light pouring out. Drifts gently.\nfunction beamGround(accent: string, k: number) {\n  const x = 44 + 12 * k;\n  const mix = (p: number) => `color-mix(in oklab, ${accent} ${p}%, #1a1660)`;\n  const o = 2 * k;\n  return [\n    `radial-gradient(70% 30% at ${x}% 50%, rgba(143,180,255,0.24) 0%, rgba(143,180,255,0) 100%)`,\n    `linear-gradient(180deg, #02030a 0%, #070726 ${10 - o}%, #1a1660 ${22 - o}%, ${mix(45)} ${33 - o}%, ${mix(80)} ${42 - o / 2}%, ${accent} 50%, ${mix(80)} ${58 + o / 2}%, ${mix(45)} ${67 + o}%, #1a1660 ${78 + o}%, #070726 ${90 + o}%, #02030a 100%)`,\n  ].join(\", \");\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n  const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  return (\n    <svg\n      width=\"100%\"\n      height=\"100%\"\n      style={{ position: \"absolute\", inset: 0, opacity, pointerEvents: \"none\" }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={5}\n          stitchTiles=\"stitch\"\n        />\n        <feColorMatrix values=\"0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.9 0\" />\n      </filter>\n      <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n    </svg>\n  );\n}\n\nfunction Title({\n  content,\n  color,\n  max,\n  italic = false,\n}: {\n  content: React.ReactNode;\n  color: string;\n  max: number;\n  italic?: boolean;\n}) {\n  const { width: W, height: H } = useVideoConfig();\n  const u = H / 720;\n  if (typeof content !== \"string\")\n    return <AbsoluteFill>{content}</AbsoluteFill>;\n  const size = Math.min(max * u, (0.8 * W) / widthEm(content, italic));\n  return (\n    <AbsoluteFill\n      style={{\n        alignItems: \"center\",\n        justifyContent: \"center\",\n      }}\n    >\n      <div\n        style={{\n          fontFamily: serif,\n          fontStyle: italic ? \"italic\" : \"normal\",\n          fontWeight: 400,\n          fontSize: size,\n          letterSpacing: `${TRACK}em`,\n          lineHeight: 1,\n          whiteSpace: \"nowrap\",\n          color,\n          paddingBottom: 0.04 * size,\n          paddingRight: italic ? 0.04 * size : 0,\n        }}\n      >\n        {content}\n      </div>\n    </AbsoluteFill>\n  );\n}\n\nexport function HairlineOpen({\n  from = \"Write the story\",\n  to = \"Ship the film\",\n  accent = \"#3B5BFD\",\n  theme = \"dark\",\n  speed = 1,\n}: HairlineOpenProps) {\n  const t = useCurrentFrame() * speed;\n  const { width: W, height: H } = useVideoConfig();\n  const u = H / 720;\n  const stage = STAGES[theme];\n  const line = Math.max(1.5, 2.5 * u);\n\n  const draw = DRAW(interpolate(t, [DRAW_AT, DRAW_END], [0, 1], CLAMP));\n  const head = draw * W;\n  const shear =\n    6 * u * SHEAR(interpolate(t, [DRAW_END - 4, OPEN_AT + 2], [0, 1], CLAMP));\n  const open = OPEN(interpolate(t, [OPEN_AT, OPEN_END], [0, 1], CLAMP));\n  const gap = open * H * 1.24;\n  const slide = 0.06 * W * open;\n  const settle = SETTLE(\n    interpolate(t, [OPEN_AT, OPEN_END + 16], [0, 1], CLAMP),\n  );\n  const bScale = 1.07 - 0.07 * settle;\n  const panelsGone = gap / 2 >= H / 2 + 40 * u;\n  const lineOn = draw > 0 && gap < line;\n\n  const half = (top: boolean) => {\n    const dir = top ? -1 : 1;\n    const shift = top ? -(shear + slide) : shear + slide;\n    const pad = 0.1 * W;\n    return (\n      <AbsoluteFill\n        style={{\n          transform: `translate(${shift}px, ${(dir * gap) / 2}px)`,\n          filter:\n            open > 0\n              ? `drop-shadow(0 ${dir * 10 * u}px ${24 * u}px rgba(0,0,0,${0.28 * Math.min(1, open * 4)}))`\n              : undefined,\n        }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            left: -pad,\n            width: W + 2 * pad,\n            top: top ? 0 : H / 2,\n            height: H / 2,\n            overflow: \"hidden\",\n            background: stage.bg,\n          }}\n        >\n          <div\n            style={{\n              position: \"absolute\",\n              left: pad,\n              top: top ? 0 : -H / 2,\n              width: W,\n              height: H,\n            }}\n          >\n            <AbsoluteFill\n              style={{\n                background: `radial-gradient(ellipse 80% 90% at 24% 0%, ${stage.light}, transparent 70%)`,\n              }}\n            />\n            <Title content={from} color={stage.fg} max={176} />\n          </div>\n          <div\n            style={{\n              position: \"absolute\",\n              left: 0,\n              right: 0,\n              height: Math.max(1, u),\n              [top ? \"bottom\" : \"top\"]: 0,\n              background: stage.edge,\n              opacity: Math.min(1, open * 6),\n            }}\n          />\n        </div>\n      </AbsoluteFill>\n    );\n  };\n\n  return (\n    <AbsoluteFill style={{ background: \"#02030a\", overflow: \"hidden\" }}>\n      <AbsoluteFill\n        style={{\n          background: beamGround(\n            accent,\n            interpolate(t, [OPEN_AT, OPEN_END + 40], [0, 1], CLAMP),\n          ),\n        }}\n      />\n      <AbsoluteFill\n        style={{\n          transform: `scale(${bScale})`,\n          opacity: interpolate(gap, [0.05 * H, 0.32 * H], [0, 1], CLAMP),\n        }}\n      >\n        <Title content={to} color=\"#F7F7F5\" max={196} italic />\n      </AbsoluteFill>\n      {panelsGone ? null : (\n        <>\n          {half(true)}\n          {half(false)}\n        </>\n      )}\n      {lineOn ? (\n        <div\n          style={{\n            position: \"absolute\",\n            left: 0,\n            top: H / 2 - line / 2,\n            width: head,\n            height: line,\n            background: stage.filament(accent),\n          }}\n        />\n      ) : null}\n      <Grain opacity={theme === \"light\" ? 0.04 : 0.055} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/hairline-open.tsx"
    }
  ],
  "type": "registry:component"
}
