{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "glass-lens",
  "title": "Glass Lens",
  "description": "A glass lens drop magnifies a headline word, glides to a clip and flattens into a CTA pill.",
  "dependencies": ["remotion", "@remotion/google-fonts"],
  "files": [
    {
      "path": "registry/remocn/glass-lens/index.tsx",
      "content": "\"use client\";\n\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport { loadFont as loadSerif } from \"@remotion/google-fonts/Newsreader\";\nimport type React from \"react\";\nimport { useEffect, useId, useMemo, useState } from \"react\";\nimport {\n  AbsoluteFill,\n  continueRender,\n  delayRender,\n  Easing,\n  Img,\n  interpolate,\n  spring,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\n\nconst manrope = loadManrope(\"normal\", {\n  weights: [\"500\", \"600\"],\n  subsets: [\"latin\"],\n});\nconst serifUpright = loadSerif(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nconst serifItalic = loadSerif(\"italic\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nconst sans = manrope.fontFamily;\nconst serif = serifUpright.fontFamily;\n\n/**\n * Beat sheet (30fps, speed 1):\n * 0–34     the headline rises; a glass drop slides in and settles on the\n *          focus word, magnifying it. 34–62 hold on the word.\n * 62–124   the drop glides to the highlighted clip in the product pane.\n * 124–180  it travels down to the CTA slot, flattens into a pill and fills\n *          with the accent; the label and arrow land. 180–210 hold.\n * The pane's preview carries the gradients.sh \"silk\" sheen, so the glass has\n * colour to bend as it passes; the refraction is a single clean pass (no\n * RGB split) that pulls the rim inward, never the line next to it.\n */\n\nconst REMOCN_R_PATH =\n  \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\n\n/** Full logo as on remocn.dev: R mark + \"emocn\" in Manrope 600. */\nfunction RemocnLogo({ fontSize, color }: { fontSize: number; color: string }) {\n  return (\n    <div\n      style={{\n        display: \"flex\",\n        alignItems: \"baseline\",\n        color,\n        fontFamily: sans,\n        fontWeight: 600,\n        fontSize,\n        letterSpacing: \"-0.025em\",\n        lineHeight: 1,\n      }}\n    >\n      <svg\n        viewBox=\"0 0 124.06 134.26\"\n        style={{ height: \"0.76em\", width: \"auto\" }}\n        aria-hidden\n      >\n        <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n      </svg>\n      <span style={{ marginLeft: \"0.04em\" }}>emocn</span>\n    </div>\n  );\n}\n\nexport interface GlassLensProps {\n  /** Headline lines, set big on the left. */\n  lines?: string[];\n  /** Set the last headline line in italic. */\n  italicLast?: boolean;\n  /** Which word the lens stops on first: line index and word index. */\n  focus?: { line: number; word: number };\n  /** Label inside the pill the lens becomes. */\n  cta?: string;\n  /** Replaces the remocn logo above the headline. */\n  logo?: React.ReactNode;\n  /** Screenshot for the product pane. */\n  src?: string;\n  /** Custom content for the product pane (wins over `src`). */\n  children?: React.ReactNode;\n  accent?: string;\n  /** Playback multiplier. */\n  speed?: number;\n  theme?: \"dark\" | \"light\";\n}\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst THEMES = {\n  dark: {\n    bg: \"#0A0A0B\",\n    stage: \"rgba(255,255,255,0.06)\",\n    fg: \"#F3F2EF\",\n    muted: \"#8B8A90\",\n    pane: \"#131315\",\n    paneEdge: \"rgba(255,255,255,0.09)\",\n    block: \"rgba(255,255,255,0.06)\",\n    blockHi: \"rgba(255,255,255,0.11)\",\n    hair: \"rgba(255,255,255,0.07)\",\n    paneShadow: \"0 30px 80px -20px rgba(0,0,0,0.9)\",\n    glassTint: \"rgba(255,255,255,0.03)\",\n    rimHi: 0.85,\n    rimLo: 0.22,\n    lensShadow: \"rgba(0,0,0,0.7)\",\n    edgeLine: \"rgba(255,255,255,0.05)\",\n    innerShade: \"rgba(0,0,0,0.3)\",\n    grain: 0.06,\n  },\n  light: {\n    bg: \"#F5F4F0\",\n    stage: \"rgba(255,255,255,0.85)\",\n    fg: \"#121214\",\n    muted: \"#6E6C67\",\n    pane: \"#FFFFFF\",\n    paneEdge: \"rgba(18,18,20,0.08)\",\n    block: \"rgba(18,18,20,0.05)\",\n    blockHi: \"rgba(18,18,20,0.09)\",\n    hair: \"rgba(18,18,20,0.07)\",\n    paneShadow: \"0 30px 70px -24px rgba(60,52,40,0.28)\",\n    glassTint: \"rgba(255,255,255,0.07)\",\n    rimHi: 1,\n    rimLo: 0.45,\n    lensShadow: \"rgba(60,52,40,0.22)\",\n    edgeLine: \"rgba(18,18,20,0.07)\",\n    innerShade: \"rgba(60,52,40,0.12)\",\n    grain: 0.045,\n  },\n} as const;\n\ntype Palette = (typeof THEMES)[keyof typeof THEMES];\n\n/** gradients.sh \"silk\" (bg #030308; #3b3fd8, #f3d6c0, #8a7bff). */\nfunction silk(t: number) {\n  const a = 172 + Math.sin(t / 50) * 3;\n  const x = 45 + Math.sin(t / 61) * 4;\n  return [\n    `linear-gradient(${a}deg, transparent 22%, rgba(243,214,192,0.62) 34%, rgba(59,63,216,0.72) 46%, transparent 82%)`,\n    `radial-gradient(70% 45% at ${x}% 42%, rgba(138,123,255,0.4), transparent 70%)`,\n    \"#030308\",\n  ].join(\", \");\n}\n\nconst HEAD_TRACK = -0.022;\nconst CTA_TRACK = -0.015;\n\ninterface Face {\n  family: string;\n  italic?: boolean;\n  weight: number;\n  track: number;\n}\n\nlet measureCtx: CanvasRenderingContext2D | null = null;\n/** Advance width in em with the loaded face (a rough estimate before that). */\nfunction measureEm(text: string, f: Face) {\n  if (!measureCtx && typeof document !== \"undefined\") {\n    measureCtx = document.createElement(\"canvas\").getContext(\"2d\");\n  }\n  const tracking = f.track * [...text].length;\n  if (!measureCtx) return text.length * 0.48 + tracking;\n  measureCtx.font = `${f.italic ? \"italic \" : \"\"}${f.weight} 100px \"${f.family}\"`;\n  return measureCtx.measureText(text).width / 100 + tracking;\n}\n\n/** Holds the frame until the faces are in, so layout is measured once, right. */\nfunction useFontsReady() {\n  const [handle] = useState(() => delayRender(\"glass-lens: fonts\"));\n  const [ready, setReady] = useState(false);\n  useEffect(() => {\n    Promise.all([\n      manrope.waitUntilDone(),\n      serifUpright.waitUntilDone(),\n      serifItalic.waitUntilDone(),\n    ]).then(() => setReady(true));\n  }, []);\n  useEffect(() => {\n    if (ready) continueRender(handle);\n  }, [ready, handle]);\n  return ready;\n}\n\nfunction Grain({ opacity }: { opacity: number }) {\n  const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  return (\n    <svg\n      width=\"100%\"\n      height=\"100%\"\n      style={{ position: \"absolute\", inset: 0, opacity }}\n      aria-hidden\n    >\n      <filter id={id}>\n        <feTurbulence\n          type=\"fractalNoise\"\n          baseFrequency=\"0.9\"\n          numOctaves={2}\n          seed={7}\n          stitchTiles=\"stitch\"\n        />\n        <feColorMatrix values=\"0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0.9 0\" />\n      </filter>\n      <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n    </svg>\n  );\n}\n\ninterface Layout {\n  u: number;\n  left: number;\n  top: number;\n  size: number;\n  lineH: number;\n  pane: { x: number; y: number; w: number; h: number };\n  clip: { x: number; y: number };\n  ctaY: number;\n}\n\nfunction useLayout(lineEms: number[]): Layout {\n  const { width, height } = useVideoConfig();\n  const u = height / 720;\n  const left = width * 0.075;\n  const longest = Math.max(...lineEms);\n  const size = Math.min(108 * u, (width * 0.43) / Math.max(longest, 1));\n  const lineH = size * 1.02;\n  const top = height * 0.5 - (lineEms.length * lineH) / 2 - 30 * u;\n  const pane = {\n    x: width * 0.535,\n    y: height * 0.17,\n    w: width * 0.4,\n    h: height * 0.66,\n  };\n  // the accent clip in the placeholder timeline: the second lens stop\n  const clip = {\n    x: pane.x + pane.w * 0.47,\n    y: pane.y + pane.h * 0.775,\n  };\n  return {\n    u,\n    left,\n    top,\n    size,\n    lineH,\n    pane,\n    clip,\n    ctaY: top + lineEms.length * lineH + 60 * u,\n  };\n}\n\n/** The abstracted product: a pane of hairlines, a preview and a timeline. */\nfunction Placeholder({\n  w,\n  h,\n  u,\n  p,\n  accent,\n  t,\n}: {\n  w: number;\n  h: number;\n  u: number;\n  p: Palette;\n  accent: string;\n  t: number;\n}) {\n  const pad = w * 0.05;\n  const bar = (x: number, y: number, bw: number, bh: number, c: string) => (\n    <div\n      style={{\n        position: \"absolute\",\n        left: x,\n        top: y,\n        width: bw,\n        height: bh,\n        borderRadius: bh / 2,\n        background: c,\n      }}\n    />\n  );\n  const clips = [\n    [0.05, 0.26, 0],\n    [0.33, 0.28, 1],\n    [0.63, 0.32, 0],\n    [0.05, 0.4, 0],\n    [0.47, 0.22, 0],\n    [0.71, 0.24, 0],\n  ];\n  const head = (w - pad * 2) * interpolate(t, [20, 190], [0.38, 0.62], CLAMP);\n  return (\n    <>\n      {bar(pad, h * 0.045, w * 0.16, 9 * u, p.blockHi)}\n      {bar(w - pad - w * 0.1, h * 0.045, w * 0.1, 9 * u, p.block)}\n      <div\n        style={{\n          position: \"absolute\",\n          left: 0,\n          right: 0,\n          top: h * 0.11,\n          height: 1,\n          background: p.hair,\n        }}\n      />\n      {/* the preview: the film being cut, lit by the silk sheen */}\n      <div\n        style={{\n          position: \"absolute\",\n          left: pad,\n          top: h * 0.155,\n          width: w - pad * 2,\n          height: h * 0.47,\n          borderRadius: 10 * u,\n          background: silk(t),\n          overflow: \"hidden\",\n        }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            left: \"8%\",\n            bottom: \"16%\",\n            fontFamily: serif,\n            fontStyle: \"italic\",\n            fontWeight: 400,\n            fontSize: 34 * u,\n            letterSpacing: \"-0.02em\",\n            lineHeight: 1,\n            color: \"#FFF8F2\",\n          }}\n        >\n          Launch day.\n        </div>\n        <div\n          style={{\n            position: \"absolute\",\n            left: \"8%\",\n            right: \"8%\",\n            bottom: \"8%\",\n            height: 3 * u,\n            borderRadius: 2 * u,\n            background: \"rgba(255,255,255,0.18)\",\n          }}\n        >\n          <div\n            style={{\n              width: `${interpolate(t, [0, 210], [22, 61], CLAMP)}%`,\n              height: \"100%\",\n              borderRadius: 2 * u,\n              background: \"rgba(255,248,242,0.85)\",\n            }}\n          />\n        </div>\n      </div>\n      {[0, 1].map((row) =>\n        clips\n          .filter((_, i) => Math.floor(i / 3) === row)\n          .map(([x, cw, hi], i) => (\n            <div\n              key={`${row}-${x}`}\n              style={{\n                position: \"absolute\",\n                left: pad + (w - pad * 2) * x,\n                top: h * (0.73 + row * 0.1),\n                width: (w - pad * 2) * cw - 4 * u,\n                height: h * 0.075,\n                borderRadius: 6 * u,\n                background: hi ? accent : p.block,\n                boxShadow: hi ? \"none\" : `inset 0 0 0 1px ${p.hair}`,\n                display: \"flex\",\n                alignItems: \"center\",\n                paddingLeft: 8 * u,\n                fontFamily: sans,\n                fontSize: 10.5 * u,\n                fontWeight: 500,\n                color: hi ? \"#FFFFFF\" : p.muted,\n                fontVariantNumeric: \"tabular-nums\",\n                whiteSpace: \"nowrap\",\n                overflow: \"hidden\",\n              }}\n            >\n              {hi ? \"Scene 03 · 4.2s\" : i === 0 && row === 0 ? \"Intro\" : \"\"}\n            </div>\n          )),\n      )}\n      <div\n        style={{\n          position: \"absolute\",\n          left: pad + head,\n          top: h * 0.69,\n          width: Math.max(1, 1.5 * u),\n          height: h * 0.25,\n          background: p.fg,\n          opacity: 0.55,\n        }}\n      />\n    </>\n  );\n}\n\n/** Everything under the glass. Rendered once flat and once magnified. */\nfunction Scene({\n  t,\n  lines,\n  italicLast,\n  logo,\n  src,\n  children,\n  accent,\n  p,\n  L,\n}: {\n  t: number;\n  lines: string[];\n  italicLast: boolean;\n  logo?: React.ReactNode;\n  src?: string;\n  children?: React.ReactNode;\n  accent: string;\n  p: Palette;\n  L: Layout;\n}) {\n  const { width, height } = useVideoConfig();\n  const { u } = L;\n  const rise = (d: number) =>\n    interpolate(t, [d - 8, d + 20], [0, 1], { ...CLAMP, easing: EASE_OUT });\n  const paneIn = rise(4);\n  return (\n    <div\n      style={{\n        position: \"absolute\",\n        left: 0,\n        top: 0,\n        width,\n        height,\n        background: p.bg,\n        overflow: \"hidden\",\n      }}\n    >\n      <div\n        style={{\n          position: \"absolute\",\n          inset: 0,\n          background: `radial-gradient(ellipse 60% 70% at 38% 30%, ${p.stage}, transparent 75%)`,\n        }}\n      />\n      <div\n        style={{\n          position: \"absolute\",\n          left: L.left,\n          top: L.top - 64 * u,\n          opacity: rise(0),\n        }}\n      >\n        {logo ?? <RemocnLogo fontSize={26 * u} color={p.fg} />}\n      </div>\n      {lines.map((line, i) => {\n        const italic = italicLast && i === lines.length - 1 && lines.length > 1;\n        return (\n          <div\n            key={line}\n            style={{\n              position: \"absolute\",\n              left: L.left,\n              top: L.top + i * L.lineH,\n              height: L.lineH,\n              display: \"flex\",\n              alignItems: \"center\",\n              fontFamily: serif,\n              fontStyle: italic ? \"italic\" : \"normal\",\n              fontWeight: 400,\n              fontSize: L.size,\n              letterSpacing: `${HEAD_TRACK}em`,\n              lineHeight: 1,\n              color: p.fg,\n              whiteSpace: \"pre\",\n              opacity: rise(i * 3),\n              transform: `translateY(${(1 - rise(i * 3)) * 24 * u}px)`,\n            }}\n          >\n            {line}\n          </div>\n        );\n      })}\n      <div\n        style={{\n          position: \"absolute\",\n          left: L.pane.x,\n          top: L.pane.y,\n          width: L.pane.w,\n          height: L.pane.h,\n          borderRadius: 16 * u,\n          background: p.pane,\n          boxShadow: `inset 0 0 0 1px ${p.paneEdge}, ${p.paneShadow}`,\n          overflow: \"hidden\",\n          opacity: paneIn,\n          transform: `translateX(${(1 - paneIn) * 40 * u}px)`,\n        }}\n      >\n        {children ??\n          (src ? (\n            <Img\n              src={src}\n              style={{ width: \"100%\", height: \"100%\", objectFit: \"cover\" }}\n            />\n          ) : (\n            <Placeholder\n              w={L.pane.w}\n              h={L.pane.h}\n              u={u}\n              p={p}\n              accent={accent}\n              t={t}\n            />\n          ))}\n      </div>\n    </div>\n  );\n}\n\n/**\n * Displacement map for a convex drop: R/G ramps run from the rim toward the\n * centre (inverted), so the rim samples inward and the lens never pulls in\n * the content around it. Neutral grey (no shift) across the flat middle.\n */\nfunction lensMap(w: number, h: number, edge: number) {\n  const r = h / 2;\n  const iw = Math.max(1, w - edge * 2);\n  const ih = Math.max(1, h - edge * 2);\n  const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${w}' height='${h}'><defs><linearGradient id='x'><stop offset='0' stop-color='#f00'/><stop offset='1' stop-color='#000'/></linearGradient><linearGradient id='y' x2='0' y2='1'><stop offset='0' stop-color='#0f0'/><stop offset='1' stop-color='#000'/></linearGradient><filter id='b' x='-50%' y='-50%' width='200%' height='200%'><feGaussianBlur stdDeviation='${edge * 0.3}'/></filter></defs><rect width='${w}' height='${h}' fill='rgb(128,128,0)'/><rect width='${w}' height='${h}' rx='${r}' fill='url(#x)'/><rect width='${w}' height='${h}' rx='${r}' fill='url(#y)' style='mix-blend-mode:screen'/><rect x='${edge}' y='${edge}' width='${iw}' height='${ih}' rx='${Math.max(0, r - edge)}' fill='rgb(128,128,0)' filter='url(#b)'/></svg>`;\n  return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;\n}\n\n/** White where the glass is flat: the interior passes through untouched. */\nfunction coreMask(w: number, h: number, edge: number) {\n  const inset = edge * 1.6;\n  const iw = Math.max(1, w - inset * 2);\n  const ih = Math.max(1, h - inset * 2);\n  const r = Math.max(0, h / 2 - inset);\n  const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${w}' height='${h}'><defs><filter id='b' x='-50%' y='-50%' width='200%' height='200%'><feGaussianBlur stdDeviation='${edge * 0.14}'/></filter></defs><rect x='${inset}' y='${inset}' width='${iw}' height='${ih}' rx='${r}' fill='#fff' filter='url(#b)'/></svg>`;\n  return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;\n}\n\nexport function GlassLens({\n  lines = [\"Every frame,\", \"composed.\"],\n  italicLast = true,\n  focus = { line: 0, word: 1 },\n  cta = \"Start with remocn\",\n  logo,\n  src,\n  children,\n  accent = \"#3B5BFD\",\n  speed = 1,\n  theme = \"dark\",\n}: GlassLensProps) {\n  const frame = useCurrentFrame() * speed;\n  const { fps, width } = useVideoConfig();\n  const p = THEMES[theme];\n  const fid = `lens${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  const ready = useFontsReady();\n\n  const faceFor = (i: number): Face => ({\n    family: serif,\n    italic: italicLast && i === lines.length - 1 && lines.length > 1,\n    weight: 400,\n    track: HEAD_TRACK,\n  });\n  // biome-ignore lint/correctness/useExhaustiveDependencies: re-measure once the faces load\n  const m = useMemo(() => {\n    const lineEms = lines.map((l, i) => measureEm(l, faceFor(i)));\n    const fl = lines[focus.line] ?? lines[0];\n    const face = faceFor(lines[focus.line] ? focus.line : 0);\n    const words = fl.split(\" \");\n    const before = words.slice(0, focus.word).join(\" \");\n    const wordEm = measureEm(words[focus.word] ?? words[0], face);\n    const beforeEm = before ? measureEm(`${before} `, face) : 0;\n    const ctaEm = measureEm(cta, {\n      family: sans,\n      weight: 500,\n      track: CTA_TRACK,\n    });\n    return { lineEms, wordEm, beforeEm, ctaEm };\n  }, [ready, lines, focus.line, focus.word, cta, italicLast]);\n  const L = useLayout(m.lineEms);\n  const { u } = L;\n\n  // lens stops: off the headline, the focus word, the accent clip, the CTA\n  const fx = L.left + m.beforeEm * L.size + (m.wordEm * L.size) / 2;\n  const fy = L.top + (focus.line + 0.5) * L.lineH;\n\n  const ctaSize = 21 * u;\n  const ctaH = 64 * u;\n  const ctaW = m.ctaEm * ctaSize + 28 * u + 64 * u;\n  const stops = [\n    { t: 0, x: L.left - 60 * u, y: fy + 40 * u, arc: 0 },\n    { t: 34, x: fx, y: fy, arc: -30 },\n    { t: 62, x: fx, y: fy, arc: 0 },\n    { t: 98, x: L.clip.x, y: L.clip.y, arc: 70 },\n    { t: 124, x: L.clip.x, y: L.clip.y, arc: 0 },\n    { t: 158, x: L.left + ctaW / 2, y: L.ctaY, arc: 50 },\n  ];\n  const posAt = (tt: number) => {\n    for (let i = 0; i < stops.length - 1; i++) {\n      const a = stops[i];\n      const b = stops[i + 1];\n      if (tt <= b.t) {\n        const k = EASE_IO(interpolate(tt, [a.t, b.t], [0, 1], CLAMP) as number);\n        const dx = b.x - a.x;\n        const dy = b.y - a.y;\n        const len = Math.hypot(dx, dy) || 1;\n        const bend = Math.sin(Math.PI * k) * b.arc * u;\n        return {\n          x: a.x + dx * k + (-dy / len) * bend,\n          y: a.y + dy * k + (dx / len) * bend,\n        };\n      }\n    }\n    const last = stops[stops.length - 1];\n    return { x: last.x, y: last.y };\n  };\n  const pos = posAt(frame);\n  const prev = posAt(frame - 1.5);\n  const vx = (pos.x - prev.x) / 1.5 / u;\n  const vy = (pos.y - prev.y) / 1.5 / u;\n  const spd = Math.hypot(vx, vy);\n  const still = interpolate(spd, [0, 9], [1, 0], CLAMP);\n\n  // liquid morph into the CTA pill: the drop flattens first and bulges\n  // sideways (volume kept), then the width settles onto the label\n  const mH = spring({\n    frame: frame - 142,\n    fps,\n    config: { damping: 12, stiffness: 110, mass: 0.9 },\n  });\n  const mW = spring({\n    frame: frame - 148,\n    fps,\n    config: { damping: 13, stiffness: 100, mass: 1 },\n  });\n  const bulge = 1 + 0.2 * Math.max(0, mH - mW);\n  // wide enough that the magnified focus word sits inside the flat middle\n  const baseW = Math.max(350 * u, m.wordEm * L.size * 1.18 + 90 * u);\n  const baseH = 150 * u;\n  const sx = 1 + interpolate(Math.abs(vx), [0, 30], [0, 0.2], CLAMP);\n  const sy = 1 + interpolate(Math.abs(vy), [0, 30], [0, 0.2], CLAMP);\n  const lw = (baseW + (ctaW - baseW) * mW) * bulge * sx * (2 - sy);\n  const lh = (baseH + (ctaH - baseH) * mH) * sy * (2 - sx) ** 0.6;\n  // once it lands, the pill grows from its left edge like a real button\n  const anchor = Math.min(1, mH);\n  const cx = pos.x + (L.left + lw / 2 - pos.x) * anchor;\n  const lx = cx - lw / 2;\n  const ly = pos.y - lh / 2;\n  const radius = lh / 2;\n  const morph = Math.min(1, mH);\n\n  const enter = interpolate(frame, [-6, 14], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const mag = 1 + (0.08 + 0.1 * still) * (1 - morph);\n  const disp = (22 + 8 * still) * u * (1 - 0.55 * morph);\n  const edge = Math.min(lw, lh) * 0.24;\n  const M = Math.ceil(disp + 8 * u);\n  const map = lensMap(Math.round(lw), Math.round(lh), edge);\n  const core = coreMask(Math.round(lw), Math.round(lh), edge);\n\n  const tint = interpolate(frame, [147, 160], [0, 0.92], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const label = interpolate(frame, [157, 173], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  const arrow = interpolate(frame, [163, 180], [0, 1], {\n    ...CLAMP,\n    easing: EASE_OUT,\n  });\n  // the key light sits up-left; the rim highlight drifts as the lens travels\n  const rimX = 22 + (pos.x / width) * 16;\n\n  const sceneProps = {\n    t: frame,\n    lines,\n    italicLast,\n    logo,\n    src,\n    children,\n    accent,\n    p,\n    L,\n  };\n\n  return (\n    <AbsoluteFill style={{ background: p.bg, overflow: \"hidden\" }}>\n      <Scene {...sceneProps} />\n\n      <svg width={0} height={0} style={{ position: \"absolute\" }} aria-hidden>\n        <defs>\n          <filter\n            id={fid}\n            x={0}\n            y={0}\n            width={lw + M * 2}\n            height={lh + M * 2}\n            filterUnits=\"userSpaceOnUse\"\n            primitiveUnits=\"userSpaceOnUse\"\n            colorInterpolationFilters=\"sRGB\"\n          >\n            <feImage\n              href={map}\n              x={M}\n              y={M}\n              width={lw}\n              height={lh}\n              preserveAspectRatio=\"none\"\n              result=\"map\"\n            />\n            <feDisplacementMap\n              in=\"SourceGraphic\"\n              in2=\"map\"\n              scale={disp}\n              xChannelSelector=\"R\"\n              yChannelSelector=\"G\"\n              result=\"bent\"\n            />\n            {/* displacement samples nearest-pixel: soften the bent rim, and\n                keep the flat middle as the crisp (magnified) source */}\n            <feGaussianBlur in=\"bent\" stdDeviation={0.6 * u} result=\"soft\" />\n            <feImage\n              href={core}\n              x={M}\n              y={M}\n              width={lw}\n              height={lh}\n              preserveAspectRatio=\"none\"\n              result=\"core\"\n            />\n            <feComposite\n              in=\"SourceGraphic\"\n              in2=\"core\"\n              operator=\"in\"\n              result=\"sharp\"\n            />\n            <feComposite in=\"soft\" in2=\"core\" operator=\"out\" result=\"rim\" />\n            <feComposite\n              in=\"sharp\"\n              in2=\"rim\"\n              operator=\"arithmetic\"\n              k2={1}\n              k3={1}\n            />\n          </filter>\n        </defs>\n      </svg>\n\n      {/* soft cast shadow under the glass */}\n      <div\n        style={{\n          position: \"absolute\",\n          left: lx,\n          top: ly,\n          width: lw,\n          height: lh,\n          borderRadius: radius,\n          boxShadow: `0 0 0 1px ${p.edgeLine}, 0 ${22 * u}px ${44 * u}px -${10 * u}px ${p.lensShadow}, 0 ${4 * u}px ${10 * u}px -${2 * u}px ${p.lensShadow}`,\n          opacity: enter,\n        }}\n      />\n\n      <div\n        style={{\n          position: \"absolute\",\n          left: lx,\n          top: ly,\n          width: lw,\n          height: lh,\n          borderRadius: radius,\n          overflow: \"hidden\",\n          opacity: enter,\n          isolation: \"isolate\",\n        }}\n      >\n        <div\n          style={{\n            position: \"absolute\",\n            left: -M,\n            top: -M,\n            width: lw + M * 2,\n            height: lh + M * 2,\n            filter: `url(#${fid})`,\n          }}\n        >\n          <div\n            style={{\n              position: \"absolute\",\n              left: M - lx,\n              top: M - ly,\n              width,\n              height: \"100%\",\n              transform: `scale(${mag})`,\n              transformOrigin: `${cx}px ${pos.y}px`,\n            }}\n          >\n            <Scene {...sceneProps} />\n          </div>\n        </div>\n\n        {/* body: tint, accent fill for the CTA, inner shade and sheen */}\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            background: p.glassTint,\n          }}\n        />\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            background: accent,\n            opacity: tint,\n          }}\n        />\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            borderRadius: radius,\n            boxShadow: `inset 0 ${-8 * u}px ${18 * u}px -${6 * u}px ${p.innerShade}, inset 0 0 ${10 * u}px ${p.innerShade}`,\n          }}\n        />\n        <div\n          style={{\n            position: \"absolute\",\n            left: radius * 0.35,\n            right: radius * 0.35,\n            top: 2 * u,\n            height: lh * 0.42,\n            borderRadius: `${radius}px ${radius}px ${radius * 0.6}px ${radius * 0.6}px`,\n            background: `linear-gradient(180deg, rgba(255,255,255,${0.12 * p.rimHi}), rgba(255,255,255,0.03) 55%, rgba(255,255,255,0) 100%)`,\n          }}\n        />\n        {/* specular rim */}\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            borderRadius: radius,\n            padding: 1.5 * u,\n            background: `radial-gradient(ellipse 45% 60% at ${rimX}% 0%, rgba(255,255,255,${p.rimHi}), transparent 100%), radial-gradient(ellipse 40% 55% at ${100 - rimX}% 100%, rgba(255,255,255,${p.rimLo}), transparent 100%), rgba(255,255,255,${p.rimLo * 0.25})`,\n            WebkitMask:\n              \"linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)\",\n            WebkitMaskComposite: \"xor\",\n            maskComposite: \"exclude\",\n          }}\n        />\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            borderRadius: radius,\n            boxShadow: `inset 0 0 0 1px rgba(255,255,255,${p.rimLo * 0.5})`,\n          }}\n        />\n\n        {/* CTA label */}\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            display: \"flex\",\n            alignItems: \"center\",\n            justifyContent: \"center\",\n            gap: 10 * u,\n            fontFamily: sans,\n            fontWeight: 500,\n            fontSize: ctaSize,\n            letterSpacing: `${CTA_TRACK}em`,\n            color: \"#FFFFFF\",\n            whiteSpace: \"nowrap\",\n            opacity: label,\n            transform: `translateY(${(1 - label) * 8 * u}px)`,\n          }}\n        >\n          {cta}\n          <svg\n            width={18 * u}\n            height={18 * u}\n            viewBox=\"0 0 18 18\"\n            style={{\n              opacity: arrow,\n              transform: `translateX(${(arrow - 1) * 8 * u}px)`,\n            }}\n            aria-hidden\n          >\n            <path\n              d=\"M3 9h11M10 4.5 14.5 9 10 13.5\"\n              stroke=\"#FFFFFF\"\n              strokeWidth={1.7}\n              fill=\"none\"\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n            />\n          </svg>\n        </div>\n      </div>\n\n      <Grain opacity={p.grain} />\n    </AbsoluteFill>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/remocn/glass-lens.tsx"
    }
  ],
  "type": "registry:component"
}
