{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"achievement-pop","type":"registry:component","title":"Achievement Pop","description":"Stacked achievement toasts unlock one by one, the last a rare gradient-filled card.","dependencies":["remotion","@remotion/google-fonts"],"docs":"Needs a Remotion project. If a frame renders black, the component is drawing on a transparent layer: put a background behind it, e.g. <AbsoluteFill style={{ background: \"#faf9f6\" }}><Component /></AbsoluteFill>.","registryDependencies":["https://kuchi.kalarislabs.com/r/gradient-ground.json"],"files":[{"path":"components/kuchi/achievement-pop.tsx","type":"registry:component","target":"components/kuchi/achievement-pop.tsx","content":"/*! Portions Copyright (c) 2026 Remocn. MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\n\nimport { loadFont as loadGeist } from \"@remotion/google-fonts/Geist\";\nimport { loadFont as loadMono } from \"@remotion/google-fonts/GeistMono\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport type React from \"react\";\nimport {\n  AbsoluteFill,\n  Easing,\n  interpolate,\n  spring,\n  useCurrentFrame,\n  useVideoConfig,\n} from \"remotion\";\nimport type { GradientParams } from \"@/lib/kuchi/gsh/gradient-engine\";\nimport { GshGround } from \"@/lib/kuchi/gsh/gsh-ground\";\nimport type { GshPresetId } from \"@/lib/kuchi/gsh/presets\";\n\nconst { fontFamily: geist } = loadGeist(\"normal\", {\n  weights: [\"300\", \"400\"],\n  subsets: [\"latin\"],\n});\nconst { fontFamily: mono } = loadMono(\"normal\", {\n  weights: [\"400\"],\n  subsets: [\"latin\"],\n});\nconst manrope = loadManrope(\"normal\", {\n  weights: [\"600\"],\n  subsets: [\"latin\"],\n});\n\n\nfunction KuchiLogo({ fontSize, color }: { fontSize: number; color: string }) {\n  return (\n    <div\n      style={{\n        display: \"flex\",\n        alignItems: \"baseline\",\n        color,\n        fontFamily: manrope.fontFamily,\n        fontWeight: 600,\n        fontSize,\n        letterSpacing: \"-0.025em\",\n        lineHeight: 1,\n      }}\n    >\n      <span>Acme</span>\n    </div>\n  );\n}\n\nexport type AchievementIcon = \"trophy\" | \"bolt\" | \"star\";\n\nexport interface Achievement {\n  label: string;\n  title: string;\n  points: number;\n  icon?: AchievementIcon;\n}\n\nexport interface AchievementPopProps {\n  achievements?: Achievement[];\n  accent?: string;\n  theme?: \"dark\" | \"light\";\n  ground?: GshPresetId;\n  groundParams?: Partial<GradientParams>;\n  /** Small caps label above the running total (portrait only). */\n  totalLabel?: string;\n  /** Unit after each points value and the total. */\n  unit?: string;\n  /** Replaces the acme mark under the stack. */\n  logo?: React.ReactNode;\n  /** Text color of the titles and total; overrides the theme ink. */\n  ink?: string;\n  /** Solid fill in place of the gradient ground; \"transparent\" drops it. */\n  background?: string;\n  /** Typeface for the titles and numbers. Load it yourself; Geist by default. */\n  fontFamily?: string;\n  /** Size of the stack, around the frame's center. */\n  scale?: number;\n  /** Frames to hold the first frame before anything moves. */\n  delay?: number;\n  speed?: number;\n}\n\nconst BEATS = {\n  starts: [4, 34, 58],\n  open: 6,\n  shiftLead: 6,\n  poster: 30,\n  logo: 10,\n} as const;\n\nconst ENTER = Easing.bezier(0.32, 0.72, 0, 1);\nconst CLAMP = {\n  extrapolateLeft: \"clamp\",\n  extrapolateRight: \"clamp\",\n} as const;\n\nconst CHIP = { mass: 0.5, damping: 12, stiffness: 200 };\nconst CARD = { mass: 0.8, damping: 18, stiffness: 160 };\nconst HEAVY = { mass: 1, damping: 26, stiffness: 120 };\nconst MORPH = { damping: 200 };\n\nconst KILN = [\"#5C0A02\", \"#E2340C\", \"#FF9A3A\", \"#FFE9C7\"] as const;\nconst RARE_FILL = `linear-gradient(104deg, #2A0903 0%, ${KILN[0]} 30%, #A8260A 68%, ${KILN[1]} 100%)`;\n\nconst DARK_GROUND: Partial<GradientParams> = {\n  colors: [\"#2A0601\", \"#7A1404\", \"#E2340C\", \"#FF9A3A\"],\n};\n\nconst LIGHT_GROUND: Partial<GradientParams> = {\n  kind: \"mist\",\n  colors: [\"#F08A4B\", \"#F7C39A\", \"#F3E3D3\", \"#7A2E12\"],\n  background: \"#F2EEE8\",\n  speed: 0.8,\n  loopSeconds: 14,\n  scale: 0.8,\n  warp: 0.4,\n  blur: 0.65,\n  grain: 0.3,\n  seed: 4,\n};\n\nconst THEMES = {\n  dark: {\n    base: \"#060201\",\n    scrim:\n      \"radial-gradient(64% 58% at 50% 44%, rgba(6,3,2,0.7) 0%, rgba(6,3,2,0) 100%)\",\n    pill: \"#141112\",\n    depth:\n      \"inset 0 1px 0 rgba(255,255,255,0.07), 0 0 0 1px rgba(255,255,255,0.08), 0 18px 40px -14px rgba(0,0,0,0.7)\",\n    badge: \"#1D191A\",\n    ring: \"rgba(255,255,255,0.12)\",\n    ink: \"#F4F1EC\",\n    dim: \"#9A928C\",\n    rule: \"rgba(255,255,255,0.1)\",\n    flash: KILN[3],\n    logo: \"#1A0803\",\n  },\n  light: {\n    base: \"#F2EEE8\",\n    scrim:\n      \"radial-gradient(64% 58% at 50% 44%, rgba(246,243,238,0.7) 0%, rgba(246,243,238,0.2) 100%)\",\n    pill: \"#FFFFFF\",\n    depth:\n      \"0 0 0 1px rgba(40,24,12,0.06), 0 1px 3px rgba(40,24,12,0.06), 0 16px 32px -14px rgba(90,40,10,0.22)\",\n    badge: \"#F6F3EE\",\n    ring: \"rgba(40,24,12,0.1)\",\n    ink: \"#17120F\",\n    dim: \"#857B73\",\n    rule: \"rgba(40,24,12,0.1)\",\n    flash: KILN[1],\n    logo: \"#17120F\",\n  },\n} as const;\n\n/** The foreground at `scale`, around the frame's center; nothing extra at 1. */\nfunction ScaleLayer({\n  scale,\n  children,\n}: {\n  scale: number;\n  children: React.ReactNode;\n}) {\n  if (scale === 1) return children;\n  return (\n    <AbsoluteFill style={{ transform: `scale(${scale})` }}>\n      {children}\n    </AbsoluteFill>\n  );\n}\n\nfunction Icon({\n  name,\n  size,\n  color,\n}: {\n  name: AchievementIcon;\n  size: number;\n  color: string;\n}) {\n  const common = {\n    fill: \"none\",\n    stroke: color,\n    strokeWidth: 1.5,\n    strokeLinecap: \"round\" as const,\n    strokeLinejoin: \"round\" as const,\n  };\n  return (\n    <svg viewBox=\"0 0 24 24\" width={size} height={size} aria-hidden>\n      {name === \"trophy\" ? (\n        <g {...common}>\n          <path d=\"M7.5 4h9v4.5a4.5 4.5 0 0 1-9 0V4Z\" />\n          <path d=\"M7.5 6H5.2a2 2 0 0 0 0 4h2.6M16.5 6h2.3a2 2 0 0 1 0 4h-2.6\" />\n          <path d=\"M12 13v4M9 20h6M10 17h4\" />\n        </g>\n      ) : name === \"bolt\" ? (\n        <path {...common} d=\"M13.5 3 6 13.4h5.4L10.5 21 18 10.6h-5.4L13.5 3Z\" />\n      ) : (\n        <path\n          {...common}\n          d=\"M12 3.6l2.6 5.3 5.8.8-4.2 4.1 1 5.8L12 16.9l-5.2 2.7 1-5.8-4.2-4.1 5.8-.8L12 3.6Z\"\n        />\n      )}\n    </svg>\n  );\n}\n\nexport function AchievementPop({\n  achievements = [\n    {\n      label: \"Unlocked · 64% of makers\",\n      title: \"Shipped in one day\",\n      points: 100,\n      icon: \"trophy\",\n    },\n    {\n      label: \"Unlocked · 23% of makers\",\n      title: \"Zero keyframes by hand\",\n      points: 50,\n      icon: \"bolt\",\n    },\n    {\n      label: \"Rare · 1.8% of makers\",\n      title: \"Launch video shipped\",\n      points: 250,\n      icon: \"star\",\n    },\n  ],\n  theme = \"dark\",\n  ground,\n  groundParams,\n  totalLabel = \"Launch week\",\n  unit = \"XP\",\n  logo,\n  ink: inkProp,\n  background,\n  fontFamily = geist,\n  scale = 1,\n  delay = 0,\n  speed = 1,\n}: AchievementPopProps) {\n  const t = Math.max(0, useCurrentFrame() - delay) * speed;\n  const { width: W, height: H, fps } = useVideoConfig();\n  const tall = H > W;\n  const dark = theme === \"dark\";\n  const c = THEMES[theme];\n  const fg = inkProp ?? c.ink;\n  const u = tall ? (W * 0.88) / 820 : Math.min(W / 1280, H / 720);\n  const resolvedGround: GshPresetId | undefined =\n    ground ?? (groundParams ? undefined : dark ? \"kiln\" : undefined);\n  const resolvedParams = groundParams ?? (dark ? DARK_GROUND : LIGHT_GROUND);\n\n  const list = achievements.slice(0, BEATS.starts.length);\n  const n = list.length;\n  const starts = BEATS.starts.slice(0, n);\n  const lastStart = starts[n - 1] ?? BEATS.starts[0];\n\n  const ph = 116 * u;\n  const D = ph;\n  const pw = 820 * u;\n  const gap = ph + 20 * u;\n  const cy = tall ? 0.4 * H : 0.46 * H;\n\n  const sp = (from: number, config: Partial<typeof CARD>, dur?: number) =>\n    spring({\n      frame: t - from,\n      fps,\n      config,\n      durationInFrames: dur,\n    });\n\n  const kf =\n    1 + starts.slice(1).reduce((a, s) => a + sp(s - BEATS.shiftLead, CARD), 0);\n  const posterAt = lastStart + BEATS.poster;\n  const poster = sp(posterAt, HEAVY);\n  const stackK = interpolate(kf, [1, 2, 3], [1.26, 1.1, 1], CLAMP);\n  const groupK = stackK * interpolate(poster, [0, 1], [1, tall ? 1.04 : 1.12]);\n  const logoP = interpolate(\n    t,\n    [posterAt + BEATS.logo, posterAt + BEATS.logo + 14],\n    [0, 1],\n    { ...CLAMP, easing: ENTER },\n  );\n\n  const total = list.reduce(\n    (a, item, i) =>\n      a +\n      item.points *\n        interpolate(t, [starts[i] + 10, starts[i] + 22], [0, 1], {\n          ...CLAMP,\n          easing: ENTER,\n        }),\n    0,\n  );\n  const totalIn = interpolate(t, [starts[0] + 8, starts[0] + 22], [0, 1], {\n    ...CLAMP,\n    easing: ENTER,\n  });\n\n  return (\n    <AbsoluteFill\n      style={{\n        background:\n          background === undefined\n            ? c.base\n            : background === \"transparent\"\n              ? undefined\n              : background,\n        overflow: \"hidden\",\n      }}\n    >\n      {background === undefined ? (\n        <>\n          <GshGround\n            preset={resolvedGround}\n            params={resolvedParams}\n            timeOffset={dark ? 5 : 3}\n            timeScale={0.45}\n          />\n          <AbsoluteFill style={{ background: c.scrim }} />\n        </>\n      ) : null}\n\n      <ScaleLayer scale={scale}>\n        <div\n          style={{\n            position: \"absolute\",\n            inset: 0,\n            transform: `scale(${groupK})`,\n            transformOrigin: `50% ${(cy / H) * 100}%`,\n          }}\n        >\n          {list.map((a, i) => {\n            const s = starts[i];\n            if (t < s) return null;\n            const rare = i === n - 1 && n > 1;\n            const y = cy + (i - (kf - 1) / 2) * gap;\n            const pop = sp(s, CHIP);\n            const badgeK = 0.5 + 0.5 * pop;\n            const open = sp(s + BEATS.open, MORPH, 16);\n            const pillW = D + (pw - D) * open;\n            const left = W / 2 - pillW / 2;\n            const textP = interpolate(\n              t,\n              [s + BEATS.open + 4, s + BEATS.open + 16],\n              [0, 1],\n              { ...CLAMP, easing: ENTER },\n            );\n            const ptsP = interpolate(\n              t,\n              [s + BEATS.open + 8, s + BEATS.open + 20],\n              [0, 1],\n              { ...CLAMP, easing: ENTER },\n            );\n            const flashP = interpolate(t, [s + 2, s + 16], [0, 1], {\n              ...CLAMP,\n              easing: ENTER,\n            });\n            const sheen = interpolate(\n              t,\n              [s + BEATS.open + 14, s + BEATS.open + 32],\n              [0, 1],\n              { ...CLAMP, easing: Easing.bezier(0.65, 0, 0.35, 1) },\n            );\n            const ink = rare ? \"#FFF4E8\" : fg;\n            const dim = rare ? \"rgba(255,233,199,0.72)\" : c.dim;\n            const bx = left + D / 2;\n            const R = D / 2;\n            const appear = interpolate(t, [s, s + 3], [0, 1], CLAMP);\n            return (\n              <div key={`${a.title}-${s}`}>\n                <div\n                  style={{\n                    position: \"absolute\",\n                    left,\n                    top: y - ph / 2,\n                    width: pillW,\n                    height: ph,\n                    borderRadius: ph / 2,\n                    overflow: \"hidden\",\n                    background: rare ? RARE_FILL : c.pill,\n                    boxShadow: rare\n                      ? `inset 0 1px 0 rgba(255,233,199,0.28), 0 0 0 1px rgba(255,154,58,0.28), 0 22px 48px -14px rgba(120,24,4,${dark ? 0.8 : 0.45})`\n                      : c.depth,\n                    opacity: appear,\n                  }}\n                >\n                  {rare && sheen > 0 && sheen < 1 ? (\n                    <div\n                      style={{\n                        position: \"absolute\",\n                        top: 0,\n                        bottom: 0,\n                        width: 160 * u,\n                        left: interpolate(\n                          sheen,\n                          [0, 1],\n                          [-200 * u, pw + 40 * u],\n                        ),\n                        background:\n                          \"linear-gradient(100deg, transparent 0%, rgba(255,233,199,0.32) 50%, transparent 100%)\",\n                        transform: \"skewX(-20deg)\",\n                      }}\n                    />\n                  ) : null}\n                  <div\n                    style={{\n                      position: \"absolute\",\n                      left: D + 22 * u,\n                      top: 0,\n                      bottom: 0,\n                      display: \"flex\",\n                      flexDirection: \"column\",\n                      justifyContent: \"center\",\n                      gap: 10 * u,\n                      opacity: textP,\n                      transform: `translateX(${(1 - textP) * -24 * u}px)`,\n                      whiteSpace: \"nowrap\",\n                    }}\n                  >\n                    <div\n                      style={{\n                        fontFamily: mono,\n                        fontWeight: 400,\n                        fontSize: 17 * u,\n                        lineHeight: 1,\n                        letterSpacing: \"0.04em\",\n                        textTransform: \"uppercase\",\n                        color: dim,\n                      }}\n                    >\n                      {a.label}\n                    </div>\n                    <div\n                      style={{\n                        fontFamily,\n                        fontWeight: 400,\n                        fontSize: 40 * u,\n                        lineHeight: 1,\n                        letterSpacing: \"-0.03em\",\n                        color: ink,\n                      }}\n                    >\n                      {a.title}\n                    </div>\n                  </div>\n                  <div\n                    style={{\n                      position: \"absolute\",\n                      left: pw - 220 * u,\n                      width: 180 * u,\n                      top: 0,\n                      bottom: 0,\n                      display: \"flex\",\n                      alignItems: \"center\",\n                      justifyContent: \"flex-end\",\n                      gap: 8 * u,\n                      opacity: ptsP,\n                      transform: `translateX(${(1 - ptsP) * -16 * u}px)`,\n                      whiteSpace: \"nowrap\",\n                    }}\n                  >\n                    <span\n                      style={{\n                        fontFamily,\n                        fontWeight: 300,\n                        fontSize: 40 * u,\n                        lineHeight: 1,\n                        letterSpacing: \"-0.03em\",\n                        fontVariantNumeric: \"tabular-nums\",\n                        color: ink,\n                      }}\n                    >\n                      +{a.points}\n                    </span>\n                    <span\n                      style={{\n                        fontFamily: mono,\n                        fontWeight: 400,\n                        fontSize: 17 * u,\n                        letterSpacing: \"0.04em\",\n                        color: dim,\n                        transform: `translateY(${4 * u}px)`,\n                      }}\n                    >\n                      {unit}\n                    </span>\n                  </div>\n                </div>\n\n                {flashP > 0 && flashP < 1 ? (\n                  <svg\n                    width={W}\n                    height={H}\n                    style={{\n                      position: \"absolute\",\n                      inset: 0,\n                      overflow: \"visible\",\n                    }}\n                    aria-hidden\n                  >\n                    <circle\n                      cx={bx}\n                      cy={y}\n                      r={R * interpolate(flashP, [0, 1], [0.9, 1.7])}\n                      fill=\"none\"\n                      stroke={rare ? KILN[2] : c.flash}\n                      strokeWidth={interpolate(flashP, [0, 1], [5, 0.5]) * u}\n                      opacity={(1 - flashP) * 0.9}\n                    />\n                  </svg>\n                ) : null}\n\n                <div\n                  style={{\n                    position: \"absolute\",\n                    left: bx - R,\n                    top: y - R,\n                    width: D,\n                    height: D,\n                    transform: `scale(${badgeK})`,\n                    opacity: appear,\n                  }}\n                >\n                  <div\n                    style={{\n                      position: \"absolute\",\n                      inset: 10 * u,\n                      borderRadius: \"50%\",\n                      background: rare ? \"rgba(255,233,199,0.12)\" : c.badge,\n                      boxShadow: rare\n                        ? \"inset 0 0 0 1px rgba(255,233,199,0.45)\"\n                        : `inset 0 0 0 1px ${c.ring}`,\n                      display: \"flex\",\n                      alignItems: \"center\",\n                      justifyContent: \"center\",\n                    }}\n                  >\n                    <Icon name={a.icon ?? \"trophy\"} size={40 * u} color={ink} />\n                  </div>\n                </div>\n              </div>\n            );\n          })}\n        </div>\n\n        {tall ? (\n          <div\n            style={{\n              position: \"absolute\",\n              left: 0,\n              right: 0,\n              top: 0.66 * H,\n              display: \"flex\",\n              flexDirection: \"column\",\n              alignItems: \"center\",\n              gap: 18 * u,\n              opacity: totalIn,\n              transform: `translateY(${(1 - totalIn) * 24 * u}px)`,\n            }}\n          >\n            <div\n              style={{\n                fontFamily: mono,\n                fontWeight: 400,\n                fontSize: 20 * u,\n                letterSpacing: \"0.06em\",\n                textTransform: \"uppercase\",\n                color: c.dim,\n              }}\n            >\n              {totalLabel}\n            </div>\n            <div\n              style={{\n                fontFamily,\n                fontWeight: 300,\n                fontSize: 170 * u,\n                lineHeight: 1,\n                letterSpacing: \"-0.05em\",\n                fontVariantNumeric: \"tabular-nums\",\n                color: fg,\n              }}\n            >\n              {Math.round(total)}\n              <span\n                style={{ fontSize: 56 * u, letterSpacing: \"0\", color: c.dim }}\n              >\n                {\" \"}\n                {unit}\n              </span>\n            </div>\n          </div>\n        ) : null}\n\n        <div\n          style={{\n            position: \"absolute\",\n            left: 0,\n            width: W,\n            top: tall ? 0.88 * H : 0.885 * H,\n            display: \"flex\",\n            justifyContent: \"center\",\n            opacity: logoP,\n            transform: `translateY(${(1 - logoP) * 14 * u}px)`,\n          }}\n        >\n          {logo ?? <KuchiLogo fontSize={30 * u} color={c.logo} />}\n        </div>\n      </ScaleLayer>\n    </AbsoluteFill>\n  );\n}\n"}]}