{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"cta-section","type":"registry:block","title":"CTA section","description":"A call to action as a centered closing section, a split beside a setup card that completes itself, or a dismissible banner.","categories":["blocks"],"dependencies":["lucide-react","motion"],"registryDependencies":["https://ui.teamofsilicons.com/r/silicon-motion-tokens.json","https://ui.teamofsilicons.com/r/button.json","https://ui.teamofsilicons.com/r/segmented-control.json"],"files":[{"path":"registry/blocks/cta-section/cta-section.tsx","type":"registry:component","target":"@components/silicon-ui/blocks/cta-section/cta-section.tsx","content":"\"use client\";\n\nimport { forwardRef, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { AnimatePresence, animate, motion, useInView, useMotionValue, useReducedMotion } from \"motion/react\";\nimport { ArrowRight, Check, X } from \"lucide-react\";\nimport { Button } from \"../../button/button\";\nimport SegmentedControl from \"../../segmented-control/segmented-control\";\nimport { motionTokens } from \"../../lib/motion-tokens\";\nimport { ctaCopy, ctaFaces, ctaSetup, type CtaAction } from \"./cta-section-data\";\nimport styles from \"./cta-section.module.css\";\n\nexport type { CtaAction } from \"./cta-section-data\";\nexport type CtaVariant = \"centered\" | \"split\" | \"banner\";\n\nexport interface CtaSectionProps {\n  /** `centered` is a closing section, `split` sits beside a product visual, `banner` is one dismissible line. */\n  variant?: CtaVariant;\n  title?: string;\n  description?: string;\n  primaryAction?: CtaAction;\n  /** Not shown in the banner variant. Pass null to hide it. */\n  secondaryAction?: CtaAction | null;\n  /** Small print under the actions in the centered variant, such as \"No credit card required\". */\n  note?: string;\n  /** Faces beside the note in the centered variant. Pass an empty array to hide them. */\n  faces?: string[];\n  /** Short benefit lines in the split variant. */\n  points?: string[];\n  /** Replaces the split variant's setup card. */\n  visual?: ReactNode;\n  /** Banner only: shows a dismiss button and calls this after it closes. */\n  onDismiss?: () => void;\n  className?: string;\n}\n\ntype Bezier = [number, number, number, number];\nconst enter = [...motionTokens.ease.enter] as Bezier;\nconst standard = [...motionTokens.ease.standard] as Bezier;\n\n/** A link, a callback, or (with neither) a button that confirms in place, so previews always answer a click. */\nfunction Action({ action, variant, size = \"lg\", arrow }: { action: CtaAction; variant: \"primary\" | \"secondary\"; size?: \"sm\" | \"md\" | \"lg\"; arrow?: boolean }) {\n  const [confirmed, setConfirmed] = useState(false);\n  if (action.href) {\n    return <a className={styles.linkAction} data-variant={variant} data-size={size} href={action.href}>\n      {action.label}{arrow && <ArrowRight className={styles.arrow} size={16} strokeWidth={2} aria-hidden=\"true\" />}\n    </a>;\n  }\n  const simulated = !action.onClick;\n  return <Button\n    className={styles.action}\n    variant={variant}\n    size={size}\n    aria-live={simulated ? \"polite\" : undefined}\n    onClick={() => { if (action.onClick) action.onClick(); else setConfirmed(value => !value); }}\n  >\n    {confirmed\n      ? <><Check size={16} strokeWidth={2.25} aria-hidden=\"true\" />{action.confirmedLabel ?? action.label}</>\n      : <>{action.label}{arrow && <ArrowRight className={styles.arrow} size={16} strokeWidth={2} aria-hidden=\"true\" />}</>}\n  </Button>;\n}\n\n/** A setup card that ticks through its steps once it scrolls into view. */\nfunction SetupVisual({ reduced }: { reduced: boolean }) {\n  const ref = useRef<HTMLDivElement>(null);\n  const inView = useInView(ref, { once: true, amount: .5 });\n  const total = ctaSetup.steps.length;\n  const [step, setStep] = useState(0);\n  const shown = reduced ? total : step;\n\n  useEffect(() => {\n    if (!inView || reduced) return;\n    const timers = ctaSetup.steps.map((_, index) => window.setTimeout(() => setStep(index + 1), 520 + index * 620));\n    return () => timers.forEach(window.clearTimeout);\n  }, [inView, reduced]);\n\n  return <div ref={ref} className={styles.setup} aria-hidden=\"true\" data-done={shown === total ? \"\" : undefined}>\n    <div className={styles.setupHead}>\n      <span className={styles.workspaceMark}>{ctaSetup.workspace.charAt(0)}</span>\n      <span className={styles.setupTitle}>{ctaSetup.workspace}</span>\n      <span className={styles.setupStatus}>\n        <span data-shown={shown < total ? \"\" : undefined}>Setting up</span>\n        <span data-shown={shown === total ? \"\" : undefined}>Ready</span>\n      </span>\n    </div>\n    <div className={styles.progress}><span style={{ transform: `scaleX(${shown / total})` }} /></div>\n    <ol className={styles.steps}>\n      {ctaSetup.steps.map((label, index) => {\n        const done = index < shown;\n        return <li key={label} className={styles.step} data-done={done ? \"\" : undefined} data-active={index === shown ? \"\" : undefined}>\n          <span className={styles.stepMark}><Check size={12} strokeWidth={2.75} /></span>\n          <span className={styles.stepLabel}>{label}</span>\n          {index === total - 1 && <span className={styles.stepFaces}>\n            {/* eslint-disable-next-line @next/next/no-img-element */}\n            {ctaSetup.faces.map((src, face) => <img key={src} src={src} alt=\"\" width={22} height={22} style={{ transitionDelay: `${face * 60}ms` }} />)}\n          </span>}\n        </li>;\n      })}\n    </ol>\n  </div>;\n}\n\nfunction Faces({ faces }: { faces: string[] }) {\n  if (!faces.length) return null;\n  return <span className={styles.faces} aria-hidden=\"true\">\n    {/* eslint-disable-next-line @next/next/no-img-element */}\n    {faces.slice(0, 4).map(src => <img key={src} src={src} alt=\"\" width={26} height={26} />)}\n  </span>;\n}\n\n/**\n * A call to action in three shapes: a centered closing section, a split layout beside a setup card that completes\n * itself in view, and a compact banner that closes its gap when dismissed.\n */\nexport const CtaSection = forwardRef<HTMLElement, CtaSectionProps>(function CtaSection({\n  variant = \"centered\",\n  title,\n  description,\n  primaryAction,\n  secondaryAction,\n  note,\n  faces = ctaFaces,\n  points,\n  visual,\n  onDismiss,\n  className,\n}, ref) {\n  const id = useId();\n  const reduced = !!useReducedMotion();\n  const [open, setOpen] = useState(true);\n  const copy = ctaCopy[variant];\n  const heading = title ?? copy.title;\n  const text = description ?? copy.description;\n  const primary = primaryAction ?? copy.primary;\n  const secondary = secondaryAction === null ? null : secondaryAction ?? (\"secondary\" in copy ? copy.secondary : undefined);\n  const classes = [styles.cta, className].filter(Boolean).join(\" \");\n\n  if (variant === \"banner\") {\n    return <section ref={ref} className={classes} data-variant=\"banner\" aria-labelledby={`${id}-title`}>\n      <AnimatePresence initial={false} onExitComplete={onDismiss}>\n        {open && <motion.div\n          key=\"banner\"\n          className={styles.bannerWrap}\n          exit={reduced ? { opacity: 0, transition: { duration: motionTokens.duration.instant } } : { opacity: 0, height: 0, transition: { height: motionTokens.spring.smooth, opacity: { duration: motionTokens.duration.fast, ease: standard } } }}\n        >\n          <div className={styles.bannerPad}><div className={styles.banner}>\n            <p className={styles.bannerText}>\n              <strong id={`${id}-title`}>{heading}</strong>\n              <span>{text}</span>\n            </p>\n            <div className={styles.bannerActions}>\n              <Action action={primary} variant=\"primary\" size=\"sm\" arrow />\n              {onDismiss !== undefined && <button type=\"button\" className={styles.dismiss} aria-label=\"Dismiss\" onClick={() => setOpen(false)}>\n                <X size={16} strokeWidth={1.75} aria-hidden=\"true\" />\n              </button>}\n            </div>\n          </div></div>\n        </motion.div>}\n      </AnimatePresence>\n    </section>;\n  }\n\n  if (variant === \"split\") {\n    const list = points ?? ctaCopy.split.points;\n    return <section ref={ref} className={classes} data-variant=\"split\" aria-labelledby={`${id}-title`}>\n      <div className={styles.split}>\n        <div className={styles.splitCopy}>\n          <h2 id={`${id}-title`} className={styles.title}>{heading}</h2>\n          <p className={styles.description}>{text}</p>\n          {list.length > 0 && <ul className={styles.points}>\n            {list.map(point => <li key={point}><Check size={16} strokeWidth={2} aria-hidden=\"true\" />{point}</li>)}\n          </ul>}\n          <div className={styles.actions}>\n            <Action action={primary} variant=\"primary\" arrow />\n            {secondary && <Action action={secondary} variant=\"secondary\" />}\n          </div>\n        </div>\n        <motion.div\n          className={styles.stage}\n          initial={reduced ? false : { opacity: 0, y: 24 }}\n          whileInView={{ opacity: 1, y: 0 }}\n          viewport={{ once: true, amount: .35 }}\n          transition={{ duration: motionTokens.duration.expressive, ease: enter }}\n        >\n          {visual ?? <SetupVisual reduced={reduced} />}\n        </motion.div>\n      </div>\n    </section>;\n  }\n\n  const small = note ?? ctaCopy.centered.note;\n  return <section ref={ref} className={classes} data-variant=\"centered\" aria-labelledby={`${id}-title`}>\n    <div className={styles.centeredWrap}>\n      <div className={styles.centered}>\n        <h2 id={`${id}-title`} className={styles.title}>{heading}</h2>\n        <p className={styles.description}>{text}</p>\n        <div className={styles.actions}>\n          <Action action={primary} variant=\"primary\" arrow />\n          {secondary && <Action action={secondary} variant=\"secondary\" />}\n        </div>\n        {(small || faces.length > 0) && <p className={styles.note}><Faces faces={faces} />{small}</p>}\n      </div>\n    </div>\n  </section>;\n});\n\nCtaSection.displayName = \"CtaSection\";\n\nconst variantOptions = [{ value: \"centered\", label: \"Centered\" }, { value: \"split\", label: \"Split\" }, { value: \"banner\", label: \"Banner\" }];\n\n/** Springs the frame to its content's height after a discrete change (a new layout, a dismissed banner), so the preview never snaps.\n *  Other resizes, such as the banner's own collapse or a parent reflow, follow at once so nothing lags. */\nfunction useFrameHeight(key: string, reduced: boolean) {\n  const content = useRef<HTMLDivElement>(null);\n  const height = useMotionValue<number | \"auto\">(\"auto\");\n  const lastKey = useRef(key), armedUntil = useRef(0);\n  useLayoutEffect(() => {\n    if (lastKey.current === key) return;\n    lastKey.current = key;\n    armedUntil.current = performance.now() + 700;\n  }, [key]);\n  useEffect(() => {\n    const node = content.current;\n    if (!node || typeof ResizeObserver === \"undefined\") return;\n    let measured = false;\n    const observer = new ResizeObserver(() => {\n      const next = node.offsetHeight;\n      if (!measured || reduced || performance.now() > armedUntil.current) { measured = next > 0; height.jump(next || \"auto\"); return; }\n      animate(height, next, motionTokens.spring.smooth);\n    });\n    observer.observe(node);\n    return () => observer.disconnect();\n  }, [height, reduced]);\n  return { content, height };\n}\n\n/** Preview: all three shapes. Buttons confirm in place; nothing is sent. */\nexport function CtaSectionBlock() {\n  const reduced = !!useReducedMotion();\n  const [variant, setVariant] = useState<CtaVariant>(\"centered\");\n  const [dismissed, setDismissed] = useState(false);\n  const showRestore = variant === \"banner\" && dismissed;\n  const view = showRestore ? \"restore\" : variant;\n  const { content, height } = useFrameHeight(view, reduced);\n  // The first layout appears as is; later layouts fade in while the frame springs to their height.\n  const [changed, setChanged] = useState(false);\n  return <div className={styles.preview}>\n    <SegmentedControl label=\"Call to action layout\" options={variantOptions} value={variant} onValueChange={next => { setChanged(true); setVariant(next as CtaVariant); setDismissed(false); }} />\n    <motion.div className={styles.frame} style={{ height }}>\n      <div ref={content}>\n        <motion.div key={view} initial={reduced || !changed ? false : { opacity: 0 }} animate={{ opacity: 1 }} transition={{ duration: motionTokens.duration.standard, ease: standard }}>\n          {showRestore\n            ? <div className={styles.restore}><Button variant=\"secondary\" size=\"sm\" onClick={() => setDismissed(false)}>Show the banner again</Button></div>\n            : <CtaSection variant={variant} onDismiss={variant === \"banner\" ? () => { setChanged(true); setDismissed(true); } : undefined} />}\n        </motion.div>\n      </div>\n    </motion.div>\n  </div>;\n}\n\nexport default CtaSectionBlock;\n"},{"path":"registry/blocks/cta-section/cta-section-data.ts","type":"registry:component","target":"@components/silicon-ui/blocks/cta-section/cta-section-data.ts","content":"import { avatar, type PersonId } from \"../../lib/media\";\n\nexport interface CtaAction {\n  label: string;\n  /** Renders a link. */\n  href?: string;\n  onClick?: () => void;\n  /** With no href or onClick, the button confirms in place with this label, which suits previews. */\n  confirmedLabel?: string;\n}\n\nexport const ctaCopy = {\n  centered: {\n    title: \"Start building in minutes\",\n    description: \"Set up a workspace, invite your team, and ship the first project this week. Free for 14 days.\",\n    primary: { label: \"Start free trial\", confirmedLabel: \"Trial started\" },\n    secondary: { label: \"Talk to sales\", confirmedLabel: \"We'll email you\" },\n    note: \"No credit card required\",\n  },\n  split: {\n    title: \"Your team, set up before lunch\",\n    description: \"Import your projects, bring everyone in, and keep working the way you already do.\",\n    primary: { label: \"Create a workspace\", confirmedLabel: \"Workspace created\" },\n    secondary: { label: \"Book a demo\", confirmedLabel: \"Demo requested\" },\n    points: [\"Import from any tracker in one step\", \"Single sign-on and audit logs included\", \"Cancel anytime from settings\"],\n  },\n  banner: {\n    title: \"Workflows are here\",\n    description: \"Automate handoffs between teams with no code.\",\n    primary: { label: \"See how it works\", confirmedLabel: \"Opened\" },\n  },\n} satisfies Record<string, { title: string; description: string; primary: CtaAction; secondary?: CtaAction; note?: string; points?: string[] }>;\n\n/** Faces for the social proof line in the centered variant. */\nexport const ctaFaces = ([\"sofia-ramirez\", \"nathan-cole\", \"chloe-nguyen\", \"tyler-hayes\"] as PersonId[]).map(id => avatar(id));\n\n/** Sample content for the split variant's setup card. */\nexport const ctaSetup = {\n  workspace: \"Northwind\",\n  steps: [\"Create workspace\", \"Import 214 issues\", \"Invite 4 teammates\"],\n  faces: ([\"emma-collins\", \"marcus-johnson\", \"jasmine-brooks\", \"daniel-kim\"] as PersonId[]).map(id => avatar(id)),\n};\n"},{"path":"lib/media.ts","type":"registry:lib","target":"@components/silicon-ui/lib/media.ts","content":"/**\n * Shared demo media. Files live in `public/media/`, credits in `public/media/CREDITS.md`.\n * Portraits are 400 px squares; photos are 1600 px on the long side.\n */\n\nexport interface MediaPerson {\n  id: string;\n  name: string;\n  role?: string;\n  src: string;\n}\n\nexport interface MediaPhoto {\n  id: string;\n  alt: string;\n  src: string;\n  width: number;\n  height: number;\n}\n\nexport const people = [\n  { id: \"emma-collins\", name: \"Emma Collins\", role: \"Product designer\", src: \"/media/people/emma-collins.jpg\" },\n  { id: \"marcus-johnson\", name: \"Marcus Johnson\", role: \"Frontend engineer\", src: \"/media/people/marcus-johnson.jpg\" },\n  { id: \"jasmine-brooks\", name: \"Jasmine Brooks\", role: \"Design lead\", src: \"/media/people/jasmine-brooks.jpg\" },\n  { id: \"olivia-bennett\", name: \"Olivia Bennett\", role: \"Platform engineer\", src: \"/media/people/olivia-bennett.jpg\" },\n  { id: \"sofia-ramirez\", name: \"Sofia Ramirez\", role: \"Operations lead\", src: \"/media/people/sofia-ramirez.jpg\" },\n  { id: \"ryan-sullivan\", name: \"Ryan Sullivan\", role: \"Account executive\", src: \"/media/people/ryan-sullivan.jpg\" },\n  { id: \"hannah-walsh\", name: \"Hannah Walsh\", role: \"Customer success\", src: \"/media/people/hannah-walsh.jpg\" },\n  { id: \"chloe-nguyen\", name: \"Chloe Nguyen\", role: \"Data analyst\", src: \"/media/people/chloe-nguyen.jpg\" },\n  { id: \"ava-mitchell\", name: \"Ava Mitchell\", role: \"Marketing manager\", src: \"/media/people/ava-mitchell.jpg\" },\n  { id: \"daniel-kim\", name: \"Daniel Kim\", role: \"Backend engineer\", src: \"/media/people/daniel-kim.jpg\" },\n  { id: \"jordan-reyes\", name: \"Jordan Reyes\", role: \"Support specialist\", src: \"/media/people/jordan-reyes.jpg\" },\n  { id: \"mateo-alvarez\", name: \"Mateo Alvarez\", role: \"Mobile engineer\", src: \"/media/people/mateo-alvarez.jpg\" },\n  { id: \"tyler-hayes\", name: \"Tyler Hayes\", role: \"Sales lead\", src: \"/media/people/tyler-hayes.jpg\" },\n  { id: \"andre-williams\", name: \"Andre Williams\", role: \"Finance partner\", src: \"/media/people/andre-williams.jpg\" },\n  { id: \"nathan-cole\", name: \"Nathan Cole\", role: \"Engineering manager\", src: \"/media/people/nathan-cole.jpg\" },\n  { id: \"diane-foster\", name: \"Diane Foster\", role: \"Chief operating officer\", src: \"/media/people/diane-foster.jpg\" },\n] as const satisfies readonly MediaPerson[];\n\nexport const photos = [\n  { id: \"lounge-chair\", alt: \"A woven oak lounge chair with a sheepskin and linen cushion on a concrete floor\", src: \"/media/photos/lounge-chair.jpg\", width: 1280, height: 1600 },\n  { id: \"table-lamp\", alt: \"A white mushroom table lamp glowing beside books and a small vase\", src: \"/media/photos/table-lamp.jpg\", width: 1600, height: 900 },\n  { id: \"linen-throw\", alt: \"Folded natural linen throws with fringed edges in soft window light\", src: \"/media/photos/linen-throw.jpg\", width: 1067, height: 1600 },\n  { id: \"glass-carafe\", alt: \"A hand pouring water from a ribbed glass carafe into tumblers\", src: \"/media/photos/glass-carafe.jpg\", width: 1280, height: 1600 },\n  { id: \"stoneware-cups\", alt: \"Two speckled stoneware cups with a lid on a pale table\", src: \"/media/photos/stoneware-cups.jpg\", width: 1067, height: 1600 },\n  { id: \"stacked-bowls\", alt: \"Two stacked speckled ceramic bowls against a dark wall\", src: \"/media/photos/stacked-bowls.jpg\", width: 1600, height: 1067 },\n  { id: \"ceramic-lamp\", alt: \"A sculptural ceramic lamp with a linen shade on a walnut sideboard\", src: \"/media/photos/ceramic-lamp.jpg\", width: 1067, height: 1600 },\n  { id: \"living-room\", alt: \"A bright living room with timber beams, arched windows, and cream sofas\", src: \"/media/photos/living-room.jpg\", width: 1200, height: 1600 },\n  { id: \"sunroom\", alt: \"A sunroom with a round dining table, plants, and windows on three sides\", src: \"/media/photos/sunroom.jpg\", width: 1600, height: 1067 },\n  { id: \"home-office\", alt: \"A home office with a wooden desk and deep green walls\", src: \"/media/photos/home-office.jpg\", width: 1600, height: 1200 },\n  { id: \"reading-chair\", alt: \"A grey armchair and ottoman with a knit throw in a dark green room\", src: \"/media/photos/reading-chair.jpg\", width: 1600, height: 900 },\n  { id: \"bedroom\", alt: \"A made bed with striped linen pillows against an oak headboard\", src: \"/media/photos/bedroom.jpg\", width: 1067, height: 1600 },\n  { id: \"restaurant\", alt: \"A warm restaurant dining room with woven pendant lights and a tree\", src: \"/media/photos/restaurant.jpg\", width: 1067, height: 1600 },\n  { id: \"wine-bar\", alt: \"A glass carafe of red wine on a bar table in low evening light\", src: \"/media/photos/wine-bar.jpg\", width: 1600, height: 1067 },\n  { id: \"concert-hall\", alt: \"Curved stainless steel panels of the Walt Disney Concert Hall against a blue sky\", src: \"/media/photos/concert-hall.jpg\", width: 1600, height: 1143 },\n  { id: \"curved-facade\", alt: \"A white tiled building facade with curved balconies\", src: \"/media/photos/curved-facade.jpg\", width: 1600, height: 1067 },\n  { id: \"pool-house\", alt: \"A modern glass house beside a long pool under a clear sky\", src: \"/media/photos/pool-house.jpg\", width: 1600, height: 900 },\n  { id: \"terracotta-waves\", alt: \"Wavy terracotta walls rising toward a blue sky\", src: \"/media/photos/terracotta-waves.jpg\", width: 1067, height: 1600 },\n  { id: \"mountain-ridges\", alt: \"Layered mountain ridges under a warm evening sky\", src: \"/media/photos/mountain-ridges.jpg\", width: 1600, height: 1068 },\n  { id: \"alpine-lake\", alt: \"A calm alpine lake reflecting a rocky peak at golden hour\", src: \"/media/photos/alpine-lake.jpg\", width: 1067, height: 1600 },\n  { id: \"coastline\", alt: \"A long coastline with waves rolling onto a beach below green cliffs\", src: \"/media/photos/coastline.jpg\", width: 1200, height: 1600 },\n  { id: \"sea-at-dusk\", alt: \"A calm sea at dusk with a low island on the horizon\", src: \"/media/photos/sea-at-dusk.jpg\", width: 1067, height: 1600 },\n  { id: \"lisbon-tram\", alt: \"A yellow tram on a street lined with historic buildings in Lisbon\", src: \"/media/photos/lisbon-tram.jpg\", width: 1600, height: 1064 },\n  { id: \"lisbon-bridge\", alt: \"The 25 de Abril Bridge crossing the Tagus in Lisbon\", src: \"/media/photos/lisbon-bridge.jpg\", width: 1600, height: 1166 },\n  { id: \"lisbon-rooftops\", alt: \"Terracotta rooftops of Lisbon running down to the river\", src: \"/media/photos/lisbon-rooftops.jpg\", width: 1280, height: 1600 },\n  { id: \"salmon-dinner\", alt: \"Seared salmon with a bright herb salsa and a glass of red wine\", src: \"/media/photos/salmon-dinner.jpg\", width: 1067, height: 1600 },\n  { id: \"chef-plating\", alt: \"A chef spooning sauce onto a plated dish in a dark kitchen\", src: \"/media/photos/chef-plating.jpg\", width: 1600, height: 1600 },\n] as const satisfies readonly MediaPhoto[];\n\nexport type PersonId = (typeof people)[number][\"id\"];\nexport type PhotoId = (typeof photos)[number][\"id\"];\n\n/** Looks up a person by id. */\nexport function person(id: PersonId): MediaPerson {\n  return people.find(entry => entry.id === id)!;\n}\n\n/** Looks up a photo by id. */\nexport function photo(id: PhotoId): MediaPhoto {\n  return photos.find(entry => entry.id === id)!;\n}\n\n/** Square 400 px avatar path for a person id, for `src` props. */\nexport const avatar = (id: PersonId) => person(id).src;\n\n/** 800 × 1000 portrait crop of the same photo, for image-led layouts. */\nexport const portrait = (id: PersonId) => `/media/people/portrait/${id}.jpg`;\n\n/** The first `count` people, for avatar stacks and lists. */\nexport const peopleSample = (count: number) => people.slice(0, count);\n"},{"path":"registry/blocks/cta-section/cta-section.module.css","type":"registry:component","target":"@components/silicon-ui/blocks/cta-section/cta-section.module.css","content":".cta { container: cta / inline-size; background: var(--background); color: var(--foreground); font-family: var(--font-body); letter-spacing: var(--tracking-body); }\n.cta *, .cta *::before, .cta *::after { box-sizing: border-box; }\n\n.title { margin: 0; font-family: var(--font-display); font-size: clamp(var(--text-2xl), var(--text-base) + 3.4cqi, var(--text-4xl)); font-weight: var(--weight-medium); letter-spacing: var(--tracking-display); line-height: var(--leading-display); text-wrap: balance; }\n.description { margin: 0; color: var(--text-secondary); font-size: var(--text-lg); line-height: var(--leading-body); text-wrap: pretty; }\n.actions { display: flex; flex-wrap: wrap; gap: var(--space-group); }\n\n/* Actions: the arrow leans forward on hover; links match the button shapes. */\n.arrow { transition: transform var(--duration-fast) var(--ease-standard); }\n@media (hover: hover) and (pointer: fine) { .action:hover .arrow, .linkAction:hover .arrow { transform: translateX(3px); } }\n.linkAction { display: inline-flex; height: var(--control-height-lg); align-items: center; justify-content: center; gap: var(--space-related); border: 1px solid transparent; border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: 0 var(--space-comfort); font-size: var(--text-sm); font-weight: var(--weight-medium); text-decoration: none; transition: background-color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), transform var(--duration-instant) var(--ease-standard); }\n.linkAction[data-size=\"sm\"] { height: var(--control-height-sm); padding: 0 var(--space-inset); }\n.linkAction[data-variant=\"primary\"] { background: var(--foreground); color: var(--background); }\n.linkAction[data-variant=\"secondary\"] { border-color: var(--border); background: var(--surface); color: var(--foreground); }\n.linkAction:active { transform: scale(.97); }\n\n/* Centered: a closing section on one quiet surface. */\n.centeredWrap { max-width: 1120px; margin: 0 auto; padding: var(--space-stage) var(--space-block); }\n.centered { display: grid; justify-items: center; gap: var(--space-inset); border: 1px solid var(--border); border-radius: var(--radius-overlay); corner-shape: var(--corner-shape); padding: var(--space-screen) var(--space-block); background: color-mix(in oklab, var(--surface-muted) 45%, var(--surface)); text-align: center; }\n.centered .title { max-width: 18ch; }\n.centered .description { max-width: 34rem; }\n.centered .actions { justify-content: center; margin-top: var(--space-inset); }\n.note { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-group); margin: var(--space-group) 0 0; color: var(--text-muted); font-size: var(--text-sm); }\n.faces { display: flex; padding-left: var(--space-related); }\n.faces img { display: block; width: 26px; height: 26px; margin-left: calc(var(--space-related) * -1); border: 2px solid var(--surface); border-radius: 50%; corner-shape: round; object-fit: cover; }\n\n/* Split: copy beside a setup card that completes itself. */\n.split { display: grid; max-width: 1120px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: var(--space-stage); margin: 0 auto; padding: var(--space-screen) var(--space-block); }\n.splitCopy { display: grid; justify-items: start; gap: var(--space-inset); }\n.splitCopy .actions { margin-top: var(--space-inset); }\n.points { display: grid; gap: var(--space-related); margin: var(--space-related) 0 0; padding: 0; list-style: none; }\n.points li { display: flex; align-items: center; gap: var(--space-group); color: var(--text-secondary); font-size: var(--text-sm); }\n.points svg { flex: none; color: var(--success); }\n.stage { display: grid; min-height: 380px; place-items: center; border: 1px solid var(--border); border-radius: var(--radius-overlay); corner-shape: var(--corner-shape); padding: var(--space-block); background: color-mix(in oklab, var(--surface-muted) 55%, var(--surface)); }\n\n.setup { width: min(100%, 360px); border: 1px solid var(--border); border-radius: var(--radius-container); corner-shape: var(--corner-shape); background: var(--surface-raised); box-shadow: var(--shadow-raised); overflow: hidden; }\n.setupHead { display: flex; align-items: center; gap: var(--space-group); padding: var(--space-inset) var(--space-comfort) var(--space-inset); }\n.workspaceMark { display: grid; width: 28px; height: 28px; flex: none; place-items: center; border-radius: var(--radius-detail); corner-shape: var(--corner-shape); background: var(--foreground); color: var(--background); font-size: var(--text-sm); font-weight: var(--weight-medium); }\n.setupTitle { font-size: var(--text-sm); font-weight: var(--weight-medium); }\n.setupStatus { display: inline-grid; margin-left: auto; color: var(--text-muted); font-size: var(--text-xs); justify-items: end; }\n.setupStatus > span { grid-area: 1 / 1; opacity: 0; transform: translateY(4px); filter: blur(2px); transition: opacity var(--duration-fast) var(--ease-standard), transform var(--duration-standard) var(--ease-enter), filter var(--duration-fast) var(--ease-standard); }\n.setupStatus > span[data-shown] { opacity: 1; transform: none; filter: blur(0); }\n.setup[data-done] .setupStatus > span:last-child { color: var(--success); font-weight: var(--weight-medium); }\n.progress { height: 2px; margin: 0 var(--space-comfort); border-radius: var(--radius-full); corner-shape: round; background: var(--border); overflow: hidden; }\n.progress > span { display: block; height: 100%; background: var(--success); transform-origin: left; transition: transform var(--duration-expressive) var(--ease-in-out); }\n.steps { display: grid; gap: var(--space-hair); margin: 0; padding: var(--space-group) var(--space-related) var(--space-group); list-style: none; }\n.step { display: flex; min-height: 44px; align-items: center; gap: var(--space-group); border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: 0 var(--space-group); color: var(--text-muted); font-size: var(--text-sm); transition: color var(--duration-standard) var(--ease-standard), background-color var(--duration-standard) var(--ease-standard); }\n.step[data-active] { background: var(--surface-muted); color: var(--foreground); }\n.step[data-done] { color: var(--foreground); }\n.stepMark { position: relative; display: grid; width: 20px; height: 20px; flex: none; place-items: center; border: 1.5px dashed var(--border-strong); border-radius: 50%; corner-shape: round; color: transparent; transition: border-color var(--duration-standard) var(--ease-standard), background-color var(--duration-standard) var(--ease-standard), color var(--duration-standard) var(--ease-standard); }\n.stepMark svg { transform: scale(.5); opacity: 0; transition: transform var(--duration-spring) var(--ease-spring), opacity var(--duration-fast) var(--ease-standard); }\n.step[data-active] .stepMark { border-style: solid; border-color: var(--text-muted); }\n.step[data-done] .stepMark { border-style: solid; border-color: var(--success); background: var(--success); color: var(--background); }\n.step[data-done] .stepMark svg { transform: scale(1); opacity: 1; }\n.stepLabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.stepFaces { display: flex; margin-left: auto; padding-left: var(--space-related); }\n.stepFaces img { display: block; width: 22px; height: 22px; margin-left: calc(var(--space-related) * -1); border: 2px solid var(--surface-raised); border-radius: 50%; corner-shape: round; object-fit: cover; opacity: 0; transform: translateX(-6px) scale(.9); transition: opacity var(--duration-standard) var(--ease-standard), transform var(--duration-spring) var(--ease-spring); }\n.step[data-done] .stepFaces img, .step[data-active] .stepFaces img { opacity: 1; transform: none; }\n\n/* Banner: one line that closes its gap when dismissed. */\n.bannerWrap { overflow: hidden; }\n.bannerPad { max-width: calc(1120px + 2 * var(--space-block)); margin: 0 auto; padding: var(--space-section) var(--space-block); }\n.banner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-inset); border: 1px solid var(--border); border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: var(--space-group) var(--space-group) var(--space-group) var(--space-comfort); background: var(--surface); }\n.bannerText { display: flex; min-width: 0; flex-wrap: wrap; align-items: baseline; gap: var(--space-hair) var(--space-related); margin: 0; font-size: var(--text-sm); line-height: var(--leading-body); }\n.bannerText strong { font-weight: var(--weight-medium); }\n.bannerText span { color: var(--text-secondary); }\n.bannerActions { display: flex; flex: none; align-items: center; gap: var(--space-tight); }\n.dismiss { display: grid; width: var(--control-height-sm); height: var(--control-height-sm); place-items: center; border: 0; border-radius: 50%; corner-shape: round; background: none; color: var(--text-muted); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color var(--duration-fast) var(--ease-standard), color var(--duration-fast) var(--ease-standard), transform var(--duration-instant) var(--ease-standard); }\n@media (hover: hover) and (pointer: fine) { .dismiss:hover { background: var(--surface-muted); color: var(--foreground); } }\n.dismiss:active { transform: scale(.94); }\n\n@container cta (max-width: 860px) {\n  .split { grid-template-columns: minmax(0, 1fr); gap: var(--space-page); padding: var(--space-stage) var(--space-block); }\n  .stage { min-height: 320px; }\n}\n@container cta (max-width: 560px) {\n  .centeredWrap { padding: var(--space-page) var(--space-inset); }\n  .centered { padding: var(--space-stage) var(--space-comfort); border-radius: var(--radius-container); corner-shape: var(--corner-shape); }\n  .split { padding: var(--space-page) var(--space-inset); }\n  .stage { padding: var(--space-comfort); border-radius: var(--radius-container); corner-shape: var(--corner-shape); }\n  .description { font-size: var(--text-base); }\n  .actions { width: 100%; flex-direction: column; }\n  .actions > * { width: 100%; }\n  .bannerPad { padding: var(--space-inset); }\n  .banner { align-items: flex-start; flex-direction: column; padding: var(--space-inset); }\n  .bannerActions { width: 100%; justify-content: space-between; }\n}\n\n.preview { display: grid; width: 100%; justify-items: center; gap: var(--space-inset); }\n.frame { width: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-control); corner-shape: var(--corner-shape); background: var(--background); }\n.restore { display: grid; min-height: 104px; place-items: center; padding: var(--space-section); }\n\n@media (prefers-reduced-motion: reduce) {\n  .arrow, .setupStatus > span, .progress > span, .step, .stepMark, .stepMark svg, .stepFaces img { transition: none; }\n}\n"},{"path":"registry/components/segmented-control/segmented-control.tsx","type":"registry:component","target":"@components/silicon-ui/segmented-control/segmented-control.tsx","content":"\"use client\";\n\nimport { useEffect, useId, useLayoutEffect, useRef, type KeyboardEvent, type ReactNode } from \"react\";\nimport { LayoutGroup, motion, useReducedMotion } from \"motion/react\";\nimport { motionTokens } from \"../lib/motion-tokens\";\nimport { FluidHoverHighlight, useFluidHover } from \"../lib/fluid-hover\";\nimport styles from \"./segmented-control.module.css\";\n\nexport interface Segment { value: string; label: string; /** Optional content after the label, such as a badge. */ accessory?: ReactNode; }\nexport interface SegmentedControlProps {\n  options: Segment[];\n  value: string;\n  onValueChange: (value: string) => void;\n  label?: string;\n  /** Called when the pointer or focus reaches an option, before it is chosen. Use it to start loading what that option shows. */\n  onOptionIntent?: (value: string) => void;\n  /** `sm` (default) or `xs`, a compact 24px control for dense UI such as an Edit/Read toggle in a toolbar. */\n  size?: \"sm\" | \"xs\";\n  className?: string;\n}\n\nexport default function SegmentedControl({ options, value, onValueChange, label, onOptionIntent, size = \"sm\", className }: SegmentedControlProps) {\n  const id = useId();\n  const reduced = useReducedMotion();\n  const track = useRef<HTMLDivElement>(null);\n  // Fluid hover: the nearest option is lit and a click in a gap picks it. Focus already moves the selection, so it leaves the fill alone.\n  const hover = useFluidHover(track, { items: \"[data-value]\", axis: \"x\", followFocus: false });\n\n  // When the options are wider than the container, the track scrolls inside itself. Edges fade only on the side with more to see.\n  useLayoutEffect(() => {\n    const node = track.current;\n    if (!node) return;\n    const edges = () => {\n      const rest = node.scrollWidth - node.clientWidth - node.scrollLeft;\n      node.toggleAttribute(\"data-fade-start\", node.scrollLeft > 1);\n      node.toggleAttribute(\"data-fade-end\", rest > 1);\n    };\n    edges();\n    node.addEventListener(\"scroll\", edges, { passive: true });\n    const observer = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(edges);\n    observer?.observe(node);\n    return () => { node.removeEventListener(\"scroll\", edges); observer?.disconnect(); };\n  }, [options.length]);\n\n  // The selected option is always scrolled fully into view, with a little room so it clears the fade.\n  const first = useRef(true);\n  useEffect(() => {\n    const node = track.current;\n    const button = node?.querySelector<HTMLElement>('[aria-pressed=\"true\"]');\n    if (!node || !button || node.scrollWidth <= node.clientWidth) { first.current = false; return; }\n    const room = 20, start = button.offsetLeft - room, end = button.offsetLeft + button.offsetWidth + room - node.clientWidth;\n    const left = node.scrollLeft > start ? start : node.scrollLeft < end ? end : node.scrollLeft;\n    if (left !== node.scrollLeft) node.scrollTo({ left: Math.max(0, left), behavior: first.current || reduced ? \"auto\" : \"smooth\" });\n    first.current = false;\n  }, [value, reduced]);\n\n  // Arrow keys, Home and End move the selection like a tab list; only the selected option is a tab stop.\n  const selectedIndex = Math.max(0, options.findIndex(option => option.value === value));\n  const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n    const last = options.length - 1;\n    const target = event.key === \"ArrowRight\" || event.key === \"ArrowDown\" ? (selectedIndex === last ? 0 : selectedIndex + 1)\n      : event.key === \"ArrowLeft\" || event.key === \"ArrowUp\" ? (selectedIndex === 0 ? last : selectedIndex - 1)\n        : event.key === \"Home\" ? 0 : event.key === \"End\" ? last : -1;\n    if (target < 0 || !options[target]) return;\n    event.preventDefault();\n    onValueChange(options[target].value);\n    track.current?.querySelector<HTMLElement>(`[data-value=\"${CSS.escape(options[target].value)}\"]`)?.focus({ preventScroll: true });\n  };\n\n  return <div className={`${styles.root} ${className ?? \"\"}`} role=\"group\" aria-label={label} data-size={size}>\n    <LayoutGroup id={id}><motion.div ref={track} layoutScroll className={styles.track} {...hover.handlers}>\n      <FluidHoverHighlight hover={hover} className={styles.hover} />\n      {options.map((option, index) => <button key={option.value} id={`${id}-${option.value}`} className={styles.button} type=\"button\" data-value={option.value} aria-pressed={value === option.value} tabIndex={index === selectedIndex ? 0 : -1} onClick={() => onValueChange(option.value)} onKeyDown={onKeyDown} onPointerEnter={onOptionIntent ? () => onOptionIntent(option.value) : undefined} onFocus={onOptionIntent ? () => onOptionIntent(option.value) : undefined}>\n        {value === option.value && <motion.span className={styles.selection} layoutId=\"selection\" layoutDependency={value} transition={reduced ? { duration: 0 } : motionTokens.spring.morph} aria-hidden=\"true\" />}\n        <span className={styles.label}>{option.label}{option.accessory}</span>\n      </button>)}\n    </motion.div></LayoutGroup>\n  </div>;\n}\n"},{"path":"registry/components/segmented-control/segmented-control.module.css","type":"registry:component","target":"@components/silicon-ui/segmented-control/segmented-control.module.css","content":"/* The frame can shrink below its content inside flex and grid parents; the track then scrolls inside it. */\n.root { display: inline-flex; min-width: 0; max-width: 100%; flex-shrink: 1; border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--surface-muted); }\n/* The track owns the stacking context so the gliding highlight passes under every label, not over earlier ones. */\n.track { --fade-start: 0px; --fade-end: 0px; position: relative; isolation: isolate; display: flex; min-width: 0; gap: var(--space-hair); overflow-x: auto; overscroll-behavior-x: contain; padding: var(--space-hair); border-radius: inherit; corner-shape: inherit; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); mask-image: linear-gradient(to right, transparent, #000 var(--fade-start), #000 calc(100% - var(--fade-end)), transparent); }\n.track::-webkit-scrollbar { display: none; }\n.track[data-fade-start] { --fade-start: 20px; }\n.track[data-fade-end] { --fade-end: 20px; }\n/* Items never scale or change weight; only the highlight travels and the label color follows it. */\n.button { position: relative; flex: 0 0 auto; min-height: var(--control-height-sm); border: 0; border-radius: calc(var(--radius-control) - var(--space-hair)); padding: 0 var(--space-group); background: transparent; color: var(--text-muted); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color var(--duration-fast) var(--ease-standard); }\n/* The frame around the options is 2px, as in Tabs: too thin to hold the keyboard ring outside an option, so it is drawn inside. */\n.button:focus-visible { --focus-outline-offset: -3px; }\n@media (hover: hover) and (pointer: fine) { .button:hover { color: var(--foreground); } }\n.button:active, .button[aria-pressed=\"true\"] { color: var(--foreground); }\n/* The hover fill glides under the options and under the selection, so the selected option never changes on hover. */\n.hover { z-index: -1; border-radius: calc(var(--radius-control) - var(--space-hair)); corner-shape: var(--corner-shape); background: color-mix(in oklab, var(--foreground) 5%, transparent); }\n.selection { position: absolute; z-index: -1; inset: 0; border: 1px solid var(--border); border-radius: inherit; corner-shape: inherit; background: var(--surface); box-shadow: var(--shadow-resting); }\n.label { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: var(--space-related); }\n/* Compact: 24px segments at the small type step. */\n.root[data-size=\"xs\"] .button { min-height: var(--control-height-xs); padding: 0 var(--space-related); font-size: var(--text-xs); }\n@media (max-width: 380px) { .button { padding: 0 var(--space-group); } }\n@media (prefers-reduced-motion: reduce) { .button { transition: none; } }\n"},{"path":"registry/components/button/button.tsx","type":"registry:component","target":"@components/silicon-ui/button/button.tsx","content":"\"use client\";\n\nimport { forwardRef, isValidElement, useCallback, useEffect, useLayoutEffect, useRef } from \"react\";\nimport type { ButtonHTMLAttributes, ReactNode, Ref, RefObject } from \"react\";\nimport { AnimatePresence, animate, motion, useIsPresent, useMotionValue, useReducedMotion } from \"motion/react\";\nimport type { TargetAndTransition, Variants } from \"motion/react\";\nimport { motionTokens } from \"../lib/motion-tokens\";\nimport styles from \"./button.module.css\";\n\n/** `soft` is filled and borderless, for controls in a bar (experimental). `link` is text with an underline, for an action\n * among words (a switch under a field); `--button-link-underline` sets the resting underline (transparent: on hover only). */\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"danger\" | \"soft\" | \"link\";\n/** `xs` (24px) is for dense UI such as tree rows and toolbars, usually icon-only with an aria-label. */\nexport type ButtonSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n\nexport interface ButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"onDrag\" | \"onDragEnd\" | \"onDragStart\" | \"onAnimationStart\"> {\n  /** The look: `primary` (default) for the main action, `secondary` bordered, `ghost` quiet, `danger` destructive, `soft` filled for bars, `link` underlined text. */\n  variant?: ButtonVariant;\n  /** Height: `xs` 24px, `sm` 36px, `md` 44px (default), `lg` 50px. */\n  size?: ButtonSize;\n  /** Shows a spinner in place of the label and sets aria-busy, keeping the button's width. */\n  loading?: boolean;\n}\n\n/** Icon buttons press a little deeper, wide buttons a little less, so every size reads as the same push. */\nconst pressVariants: Variants = {\n  pressed: (button: RefObject<HTMLButtonElement | null>) => {\n    const width = button.current?.offsetWidth ?? 0;\n    return { scale: width > 220 ? .985 : width && width <= 48 ? .96 : .97, transition: { duration: motionTokens.duration.instant, ease: [...motionTokens.ease.standard] } };\n  },\n};\n\nconst rest: TargetAndTransition = { opacity: 1, y: 0, scale: 1, filter: \"blur(0px)\" };\n/** Text rises about .3em out of a soft blur; the outgoing label lifts away a little faster. */\nconst textIn: TargetAndTransition = { opacity: 0, y: 4, filter: `blur(${motionTokens.blur.soft}px)` };\nconst textOut: TargetAndTransition = { opacity: 0, y: -3, filter: `blur(${motionTokens.blur.soft}px)`, transition: { duration: motionTokens.duration.fast, ease: [...motionTokens.ease.standard] } };\nconst iconIn: TargetAndTransition = { opacity: 0, scale: .6, filter: `blur(${motionTokens.blur.subtle}px)` };\nconst iconOut: TargetAndTransition = { opacity: 0, scale: .6, filter: `blur(${motionTokens.blur.subtle}px)`, transition: { duration: motionTokens.duration.fast, ease: [...motionTokens.ease.standard] } };\nconst fadeIn: TargetAndTransition = { ...rest, opacity: 0 };\nconst fadeOut: TargetAndTransition = { opacity: 0, transition: { duration: motionTokens.duration.instant } };\n/** Scale rides the spring; opacity and blur tween so blur never overshoots below zero. */\nconst iconEnter = { ...motionTokens.spring.snappy, opacity: { duration: motionTokens.duration.fast, ease: [...motionTokens.ease.enter] }, filter: { duration: motionTokens.duration.fast, ease: [...motionTokens.ease.enter] } } as const;\n\n/** A key for the label content: text plus element names, so a new label or icon crossfades while prop-only updates stay in place. */\nfunction labelKey(node: ReactNode): string {\n  if (node == null || typeof node === \"boolean\") return \"\";\n  if (typeof node === \"string\" || typeof node === \"number\" || typeof node === \"bigint\") return String(node);\n  if (Array.isArray(node)) return node.map(labelKey).join(\"\");\n  if (!isValidElement(node)) return \"\";\n  const type = node.type as string | { displayName?: string; name?: string };\n  return `<${typeof type === \"string\" ? type : type?.displayName ?? type?.name ?? \"\"}>${labelKey((node.props as { children?: ReactNode }).children)}`;\n}\n\n/** Springs the slot to the natural width of the incoming label when it changes, so a new label never snaps the button's size.\n *  The outgoing label is popped out of flow at once, so it never holds the old width. Other resizes (a late web font, a parent reflow) jump straight to the new width, so nothing wobbles on first paint. */\nfunction useMorphWidth(content: RefObject<HTMLElement | null>, key: string, reduced: boolean) {\n  const width = useMotionValue<number | \"auto\">(\"auto\");\n  const lastKey = useRef(key), armedUntil = useRef(0);\n  useLayoutEffect(() => {\n    if (lastKey.current === key) return;\n    lastKey.current = key;\n    armedUntil.current = performance.now() + 700;\n  }, [key]);\n  useEffect(() => {\n    const node = content.current, slot = node?.parentElement;\n    if (!node || !slot || typeof ResizeObserver === \"undefined\") return;\n    let measured = false;\n    const observer = new ResizeObserver(([entry]) => {\n      if (!entry) return;\n      const next = entry.contentRect.width;\n      if (!next || !measured || reduced || performance.now() > armedUntil.current) { measured = next > 0; width.jump(next || \"auto\"); delete slot.dataset.morphing; return; }\n      slot.dataset.morphing = \"\";\n      animate(width, next, { ...motionTokens.spring.morph, onComplete: () => { delete slot.dataset.morphing; } });\n    });\n    observer.observe(node);\n    return () => observer.disconnect();\n  }, [content, reduced, width]);\n  return width;\n}\n\nfunction LabelPhase({ children, icon, reduced, ref }: { children: ReactNode; icon: boolean; reduced: boolean; ref?: Ref<HTMLSpanElement> }) {\n  const present = useIsPresent();\n  return <motion.span ref={ref} className={styles.labelPhase} aria-hidden={present ? undefined : true} initial={reduced ? fadeIn : icon ? iconIn : textIn} animate={rest} exit={reduced ? fadeOut : icon ? iconOut : textOut} transition={reduced ? { duration: motionTokens.duration.instant } : icon ? iconEnter : { duration: motionTokens.duration.standard, ease: [...motionTokens.ease.enter] }}>{children}</motion.span>;\n}\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(\n  { className, variant = \"primary\", size = \"md\", loading = false, disabled, children, onClick, ...props },\n  ref,\n) {\n  const reduceMotion = useReducedMotion() ?? false;\n  const buttonRef = useRef<HTMLButtonElement | null>(null);\n  const contentRef = useRef<HTMLSpanElement>(null);\n  const key = labelKey(children);\n  const width = useMorphWidth(contentRef, key, reduceMotion);\n  const setRefs = useCallback((node: HTMLButtonElement | null) => {\n    buttonRef.current = node;\n    if (typeof ref === \"function\") ref(node); else if (ref) ref.current = node;\n  }, [ref]);\n  // A trigger that anchors a menu, popover, or dialog keeps its rect still while pressed, so the layer never measures a scaled anchor.\n  // Radix triggers (asChild) pass aria-haspopup or data-state through; the stylesheet repeats the guard.\n  const popup = props[\"aria-haspopup\"];\n  const anchorsLayer = (popup !== undefined && popup !== false && popup !== \"false\") || props.role === \"combobox\" || (props as Record<string, unknown>)[\"data-state\"] !== undefined;\n  const inert = disabled || loading || props[\"aria-disabled\"] === true || props[\"aria-disabled\"] === \"true\";\n  const classes = [styles.button, styles[variant], styles[size], className].filter(Boolean).join(\" \");\n  // An icon with no text: square at the compact size.\n  const iconOnly = !/\\S/.test(key.replace(/<[^>]*>/g, \"\"));\n\n  return (\n    <motion.button\n      ref={setRefs}\n      tabIndex={props.tabIndex ?? 0}\n      className={classes}\n      data-variant={variant}\n      data-icon-only={iconOnly || undefined}\n      disabled={disabled}\n      aria-busy={loading || undefined}\n      custom={buttonRef}\n      variants={pressVariants}\n      whileTap={reduceMotion || anchorsLayer || inert ? undefined : \"pressed\"}\n      transition={motionTokens.spring.snappy}\n      {...props}\n      // Loading keeps the button focusable (a disabled button would drop keyboard focus mid-action) and swallows presses instead.\n      aria-disabled={loading || props[\"aria-disabled\"] || undefined}\n      onClick={loading ? event => event.preventDefault() : onClick}\n    >\n      <AnimatePresence initial={false}>\n        {loading ? <motion.span key=\"loader\" className={styles.loader} aria-hidden=\"true\" initial={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: .6 }} animate={{ opacity: 1, scale: 1 }} exit={reduceMotion ? fadeOut : { ...iconOut, scale: .8 }} transition={reduceMotion ? { duration: motionTokens.duration.instant } : iconEnter}><span className={styles.spinner} /></motion.span> : null}\n      </AnimatePresence>\n      <motion.span className={[styles.labelSlot, loading ? styles.loadingLabel : \"\"].filter(Boolean).join(\" \")} style={{ width }}>\n        <span ref={contentRef} className={styles.labelContent}>\n          <AnimatePresence mode=\"popLayout\" initial={false}>\n            <LabelPhase key={key} icon={!/\\S/.test(key.replace(/<[^>]*>/g, \"\"))} reduced={reduceMotion}>{children}</LabelPhase>\n          </AnimatePresence>\n        </span>\n      </motion.span>\n    </motion.button>\n  );\n});\n\nButton.displayName = \"Button\";\n\nexport default Button;\n"},{"path":"registry/components/button/button.module.css","type":"registry:component","target":"@components/silicon-ui/button/button.module.css","content":"/* Press scale is driven by Motion (whileTap) alone, so transform never gets a CSS transition here. */\n.button { position: relative; display: inline-flex; min-height: var(--control-height-md); align-items: center; justify-content: center; gap: var(--space-related); border: 1px solid transparent; border-radius: var(--radius-control); corner-shape: var(--corner-shape); padding: 0 var(--space-inset); font: inherit; font-size: var(--text-sm); font-weight: var(--weight-medium); letter-spacing: var(--tracking-body); line-height: var(--leading-body); white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard), opacity var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard); }\n.button:disabled { cursor: not-allowed; opacity: .52; }\n.button[aria-busy=\"true\"] { cursor: progress; }\n/* Anchors of floating layers never scale: Radix opens on pointerdown and would measure a shrunken trigger. */\n.button:is([aria-haspopup]:not([aria-haspopup=\"false\"]), [data-state], [role=\"combobox\"]) { transform: none !important; }\n/* The slot's width follows the incoming label on a spring. The label stays centered and may overflow evenly while the slot catches up;\n   the outgoing label pops out of flow against the slot itself, so it keeps its place instead of following the new content box. */\n.labelSlot { position: relative; display: inline-flex; min-width: 0; align-items: center; justify-content: center; transition: opacity var(--duration-fast) var(--ease-standard); }\n.labelSlot[data-morphing] { clip-path: inset(-50% calc(var(--space-group) * -1)); }\n.labelContent { display: inline-flex; flex: none; align-items: center; }\n.labelPhase { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-related); white-space: nowrap; }\n.labelPhase svg { flex: none; }\n.primary { color: var(--primary-foreground); background: var(--primary); border-color: var(--primary); }\n.secondary { color: var(--foreground); background: var(--surface); border-color: var(--border); }\n.ghost { color: var(--text-secondary); background: transparent; border-color: transparent; }\n.danger { color: var(--danger); background: var(--surface); border-color: var(--border); }\n/* Filled and borderless, for controls that live in a bar (a search trigger, a toolbar, a switcher). Place it on --background or\n   --surface; on a --surface-muted panel it has no fill to show. */\n.soft { color: var(--foreground); background: var(--surface-muted); border-color: transparent; }\n/* A disabled outlined button keeps its shape and fades only its label, so it still reads as a button that is off, not as plain text. */\n.secondary:disabled, .danger:disabled { opacity: 1; color: var(--text-muted); background: var(--surface-muted); border-color: var(--border); }\n.danger:disabled { color: color-mix(in oklab, var(--danger) 55%, var(--surface-muted)); }\n.ghost:disabled, .soft:disabled { opacity: 1; color: var(--text-muted); }\n@media (hover: hover) and (pointer: fine) {\n  .primary:hover:not(:disabled) { opacity: .91; box-shadow: var(--shadow-resting); }\n  .secondary:hover:not(:disabled) { background: var(--surface-muted); box-shadow: var(--shadow-resting); }\n  .ghost:hover:not(:disabled) { color: var(--foreground); background: var(--surface-muted); }\n  .danger:hover:not(:disabled) { border-color: var(--danger); background: var(--surface-muted); }\n  .soft:hover:not(:disabled) { background: var(--surface-pressed); }\n}\n/* Color feedback on press, so touch and menu triggers (which never scale) still answer the finger. */\n.primary:active:not(:disabled) { opacity: .84; }\n.secondary:active:not(:disabled), .ghost:active:not(:disabled) { color: var(--foreground); background: var(--surface-muted); }\n.danger:active:not(:disabled) { border-color: var(--danger); background: var(--surface-muted); }\n.soft:active:not(:disabled) { background: var(--surface-pressed); }\n.xs { min-height: var(--control-height-xs); gap: var(--space-tight); padding-inline: var(--space-related); font-size: var(--text-xs); letter-spacing: var(--tracking-body); }\n/* A compact icon-only button is a square, with the icon at its usual 16px. */\n.xs[data-icon-only] { min-width: var(--control-height-xs); padding-inline: 0; }\n.xs svg { width: 16px; height: 16px; }\n.sm { min-height: var(--control-height-sm); padding-inline: var(--space-group); font-size: var(--text-sm); }\n.md { min-height: var(--control-height-md); }\n.lg { min-height: var(--control-height-lg); padding-inline: var(--space-comfort); font-size: var(--text-sm); }\n/* link: text with an underline, no box. The underline is light at rest (--button-link-underline, default --border-strong;\n   transparent shows it on hover only) and takes the text's colour on hover and focus. After the sizes, so it drops their\n   height and padding but keeps their font size. */\n.button.link { min-width: 0; min-height: 0; padding: 0; gap: var(--space-tight); border: 0; background: transparent; color: var(--text-secondary); }\n.link .labelPhase { text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--button-link-underline, var(--border-strong)); transition: text-decoration-color var(--duration-fast) var(--ease-standard); }\n@media (hover: hover) and (pointer: fine) { .link:hover:not(:disabled) { color: var(--foreground); } .link:hover:not(:disabled) .labelPhase { text-decoration-color: currentColor; } }\n.link:focus-visible, .link:active:not(:disabled) { color: var(--foreground); }\n.link:focus-visible .labelPhase, .link:active:not(:disabled) .labelPhase { text-decoration-color: currentColor; }\n.link:disabled { opacity: 1; color: var(--text-muted); }\n.loader { position: absolute; left: 50%; top: 50%; display: grid; width: var(--space-inset); height: var(--space-inset); margin: calc(var(--space-inset) / -2); }\n.spinner { border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; corner-shape: round; animation: spin .7s linear infinite; }\n.loadingLabel { opacity: 0; }\n@keyframes spin { to { transform: rotate(360deg); } }\n@media (prefers-reduced-motion: reduce) { .button { transition: none; } .labelSlot { transition: opacity var(--duration-instant) linear; } .spinner { animation-duration: .01ms; animation-iteration-count: 1; } }\n"},{"path":"lib/fluid-hover.tsx","type":"registry:lib","target":"@components/silicon-ui/lib/fluid-hover.tsx","content":"\"use client\";\n\n/**\n * Fluid hover: in a set of items (a menu, a list, tabs, a grid), the item nearest the pointer is lit, even while the\n * pointer is in a gap, the padding or past the last item, and one highlight springs between items. A click in a gap goes\n * to the lit item, so what is lit is what a click hits. A new pointer entry fades the highlight in where it lands instead\n * of sliding it over from the last item. The keyboard moves it without travel, and reduced motion keeps the fade but\n * drops the travel.\n *\n *   const list = useRef<HTMLUListElement>(null);\n *   const hover = useFluidHover(list, { items: \"[data-item]\" });\n *   <ul ref={list} className={styles.list} {...hover.handlers}>      // .list { position: relative }\n *     <FluidHoverHighlight hover={hover} className={styles.highlight} />\n *     …items…\n *   </ul>\n *\n * Adapted from Fluid Functionalism's use-fluid-hover and fluid-hover-highlight by Micka Touillaud (MIT),\n * https://github.com/mickadesign/fluid-functionalism. Items are found by a selector instead of registering themselves,\n * so a component adopts it without changing its items.\n */\nimport { useEffect, useEffectEvent, useRef, useState } from \"react\";\nimport type { FocusEvent, MouseEvent, PointerEvent, RefObject } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { motionTokens } from \"./motion-tokens\";\n\n/** An item's box in the container's own layout space (unaffected by transforms or scrolling). */\nexport interface FluidRect { top: number; left: number; width: number; height: number }\n\nexport interface FluidHoverState {\n  /** Where the highlight sits, or null when nothing is lit. */\n  rect: FluidRect | null;\n  /** The lit item. */\n  item: HTMLElement | null;\n  /** False when the highlight should jump (keyboard, a resize) rather than travel. */\n  glide: boolean;\n  /** Steps on each new pointer entry, so the highlight fades in where it lands. */\n  session: number;\n}\n\nexport interface FluidHoverOptions {\n  /** Selector for the items inside the container. */\n  items: string;\n  /** \"y\" for lists (default), \"x\" for a row of tabs, \"xy\" for grids. */\n  axis?: \"x\" | \"y\" | \"xy\";\n  /** Items the highlight skips (and a gap click never activates). Defaults to disabled or aria-disabled items. */\n  isItemDisabled?: (item: HTMLElement) => boolean;\n  /** \"skip\" (default) lights the nearest enabled item even over a disabled one; \"clear\" lights nothing over a disabled item (a calendar's unavailable days). */\n  disabled?: \"skip\" | \"clear\";\n  /** Route a click in a gap to the lit item. On by default; turn it off where empty space should stay inert. */\n  gapClick?: boolean;\n  /** Light the item that receives keyboard focus. On by default. */\n  followFocus?: boolean;\n}\n\nconst defaultDisabled = (item: HTMLElement) =>\n  item.matches(\":disabled, [aria-disabled='true'], [data-disabled]\");\n\n/** Controls that sit between items keep their own clicks. */\nconst CONTROL = \"input, textarea, select, button, a, summary, [contenteditable], [role='textbox'], [role='searchbox'], [role='button']\";\n\n/** The item's box relative to the container, summing offsets through positioned ancestors in between. */\nexport function rectOf(item: HTMLElement, container: HTMLElement): FluidRect {\n  let top = item.offsetTop, left = item.offsetLeft;\n  let parent = item.offsetParent as HTMLElement | null;\n  while (parent && parent !== container && container.contains(parent)) {\n    top += parent.offsetTop + parent.clientTop;\n    left += parent.offsetLeft + parent.clientLeft;\n    parent = parent.offsetParent as HTMLElement | null;\n  }\n  return { top, left, width: item.offsetWidth, height: item.offsetHeight };\n}\n\n/**\n * The item the pointer is inside, or else the one whose edge is nearest along the axis (both axes for a grid). Edges, not\n * centres, so a gap next to a wide item still lights the item the pointer is closer to.\n */\nexport function pickNearest(items: HTMLElement[], x: number, y: number, axis: \"x\" | \"y\" | \"xy\"): HTMLElement | null {\n  let nearest: HTMLElement | null = null, best = Infinity;\n  for (const item of items) {\n    const r = item.getBoundingClientRect();\n    if (!r.width && !r.height) continue;\n    if (x >= r.left && x <= r.right && y >= r.top && y <= r.bottom) return item;\n    const dx = Math.max(r.left - x, 0, x - r.right), dy = Math.max(r.top - y, 0, y - r.bottom);\n    const distance = axis === \"x\" ? dx : axis === \"y\" ? dy : Math.hypot(dx, dy);\n    if (distance < best) { best = distance; nearest = item; }\n  }\n  return nearest;\n}\n\n/** Hands a gap click to the item as a real mouse click (detail, modifiers and coordinates kept), so the item reads it as a pointer press, not a keyboard one. */\nfunction forwardClick(item: HTMLElement, event: MouseEvent<HTMLElement>) {\n  const { detail, clientX, clientY, screenX, screenY, ctrlKey, shiftKey, altKey, metaKey, button, buttons } = event;\n  item.dispatchEvent(new globalThis.MouseEvent(\"click\", { bubbles: true, cancelable: true, composed: true, view: window, detail, clientX, clientY, screenX, screenY, ctrlKey, shiftKey, altKey, metaKey, button, buttons }));\n}\n\n/** Whether an event happened inside the element whose handler hears it, not in a portalled child (a submenu, a tooltip). */\nconst isOwn = (event: { currentTarget: EventTarget; target: EventTarget }) =>\n  !(event.currentTarget instanceof Node) || !(event.target instanceof Node) || event.currentTarget.contains(event.target);\n\nexport function useFluidHover<T extends HTMLElement>(container: RefObject<T | null>, options: FluidHoverOptions) {\n  const { items: selector, axis = \"y\", isItemDisabled = defaultDisabled, disabled = \"skip\", gapClick = true, followFocus = true } = options;\n  const [state, setState] = useState<FluidHoverState>({ rect: null, item: null, glide: false, session: 0 });\n  const current = useRef(state);\n  const pointer = useRef(false);\n  const entering = useRef(false);\n  const frame = useRef(0);\n\n  function commit(next: FluidHoverState) {\n    const prev = current.current;\n    if (prev.item === next.item && prev.session === next.session && sameRect(prev.rect, next.rect)) return;\n    current.current = next;\n    setState(next);\n  }\n\n  function light(item: HTMLElement | null, glide: boolean) {\n    const root = container.current;\n    if (!root || !item) return commit({ ...current.current, rect: null, item: null, glide });\n    let session = current.current.session;\n    if (entering.current) { entering.current = false; session += 1; }\n    commit({ rect: rectOf(item, root), item, glide: glide && session === current.current.session, session });\n  }\n\n  const enabledItems = () => {\n    const root = container.current;\n    return root ? [...root.querySelectorAll<HTMLElement>(selector)].filter(item => !isItemDisabled(item)) : [];\n  };\n\n  // The lit item can move under a still highlight (a resize, content above it changing): follow it without travel.\n  const follow = useEffectEvent(() => { const { item } = current.current; if (item?.isConnected) light(item, false); });\n  useEffect(() => {\n    const root = container.current;\n    if (!root || typeof ResizeObserver === \"undefined\") return;\n    const observer = new ResizeObserver(() => follow());\n    observer.observe(root);\n    return () => observer.disconnect();\n  }, [container]);\n  useEffect(() => () => cancelAnimationFrame(frame.current), []);\n\n  const handlers = {\n    onMouseEnter: () => { entering.current = true; },\n    onMouseMove: (event: MouseEvent<T>) => {\n      if (!isOwn(event)) return;\n      pointer.current = true;\n      const { clientX, clientY } = event;\n      cancelAnimationFrame(frame.current);\n      frame.current = requestAnimationFrame(() => {\n        const over = disabled === \"clear\" ? document.elementFromPoint(clientX, clientY)?.closest<HTMLElement>(selector) : null;\n        light(over && isItemDisabled(over) ? null : pickNearest(enabledItems(), clientX, clientY, axis), true);\n      });\n    },\n    onMouseLeave: () => { cancelAnimationFrame(frame.current); entering.current = false; light(null, false); },\n    onKeyDownCapture: () => { pointer.current = false; },\n    onFocus: (event: FocusEvent<T>) => {\n      if (!followFocus || pointer.current || !isOwn(event)) return;\n      const item = event.target instanceof HTMLElement ? event.target.closest<HTMLElement>(selector) : null;\n      if (item && container.current?.contains(item) && !isItemDisabled(item)) light(item, false);\n    },\n    onBlur: (event: FocusEvent<T>) => {\n      if (!pointer.current && !event.currentTarget.contains(event.relatedTarget as Node | null)) light(null, false);\n    },\n    onClick: (event: MouseEvent<T>) => {\n      if (!gapClick || !isOwn(event)) return;\n      const target = event.target as Element;\n      if (!target.isConnected || target.closest(selector) || target.closest(CONTROL)) return;\n      const { item } = current.current;\n      if (item?.isConnected && !isItemDisabled(item)) forwardClick(item, event);\n    },\n  };\n\n  /** Clears the highlight at once, such as when a menu opens again. */\n  const reset = () => { cancelAnimationFrame(frame.current); entering.current = true; light(null, false); };\n\n  return { ...state, handlers, reset, light };\n}\n\nexport interface NearestItemOptions extends Omit<FluidHoverOptions, \"followFocus\"> {\n  /** Called with the nearest enabled item as the mouse moves over the container. */\n  onPick: (item: HTMLElement) => void;\n}\n\n/**\n * Fluid hover's picking without its highlight, for a list that already keeps its own active item and highlight (a listbox\n * with aria-activedescendant, a roving list): the mouse picks the nearest enabled item, gaps and padding included, and a\n * click in a gap goes to that item. Spread the result on the container.\n */\n// A hook only so callbacks that touch refs can be passed during render; it keeps no state.\nexport function useNearestItem<T extends HTMLElement>({ items: selector, axis = \"y\", isItemDisabled = defaultDisabled, gapClick = true, onPick }: NearestItemOptions) {\n  const nearest = (event: MouseEvent<T>) => {\n    if (!isOwn(event)) return null;\n    const items = [...event.currentTarget.querySelectorAll<HTMLElement>(selector)].filter(item => !isItemDisabled(item));\n    return pickNearest(items, event.clientX, event.clientY, axis);\n  };\n  return {\n    onPointerMove: (event: PointerEvent<T>) => { if (event.pointerType !== \"mouse\") return; const item = nearest(event); if (item) onPick(item); },\n    onClick: (event: MouseEvent<T>) => {\n      if (!gapClick) return;\n      const target = event.target as Element;\n      if (!target.isConnected || target.closest(selector) || target.closest(CONTROL)) return;\n      const item = nearest(event);\n      if (item) forwardClick(item, event);\n    },\n  };\n}\n\nconst sameRect = (a: FluidRect | null, b: FluidRect | null) =>\n  a === b || (!!a && !!b && a.top === b.top && a.left === b.left && a.width === b.width && a.height === b.height);\n\nexport interface FluidHoverHighlightProps {\n  /** The state from useFluidHover (or any { rect, glide, session }). */\n  hover: Pick<FluidHoverState, \"rect\" | \"glide\" | \"session\">;\n  /** Radius, fill, z-index. The container must be position: relative; the highlight is placed at its top-left corner. */\n  className?: string;\n  /** Extra attributes for styling, such as data-tone. */\n  tone?: string;\n}\n\n/** The one highlight a fluid hover set renders: it springs between items on transforms, and fades in and out. */\nexport function FluidHoverHighlight({ hover, className, tone }: FluidHoverHighlightProps) {\n  const reduced = useReducedMotion() ?? false;\n  const { rect, glide, session } = hover;\n  const place = rect ? { x: rect.left, y: rect.top, width: rect.width, height: rect.height } : undefined;\n  return (\n    <AnimatePresence initial={false}>\n      {place ? (\n        <motion.span key={session} className={className} data-tone={tone} aria-hidden=\"true\"\n          style={{ position: \"absolute\", top: 0, left: 0, pointerEvents: \"none\" }}\n          initial={{ opacity: 0, ...place }}\n          animate={{ opacity: 1, ...place }}\n          exit={{ opacity: 0, transition: motionTokens.spring.fast.exit }}\n          transition={{ default: glide && !reduced ? motionTokens.spring.fast : { duration: 0 }, opacity: { duration: motionTokens.duration.fast } }} />\n      ) : null}\n    </AnimatePresence>\n  );\n}\n"}],"docs":"Docs and live preview: https://ui.teamofsilicons.com/cta-section","meta":{"tier":"free","kind":"block","docs":"https://ui.teamofsilicons.com/cta-section","markdown":"https://ui.teamofsilicons.com/cta-section.md","status":"stable"}}