{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"login-centered","type":"registry:block","title":"Centered login","description":"A passkey-first login card on a quiet ring backdrop that morphs through email and code.","categories":["blocks"],"dependencies":["lucide-react","motion"],"registryDependencies":["https://uiarc.dev/r/arc-motion-tokens.json","https://uiarc.dev/r/button.json","https://uiarc.dev/r/input.json","https://uiarc.dev/r/otp-input.json"],"files":[{"path":"registry/blocks/login-centered/login-centered.tsx","type":"registry:component","target":"@components/arc/blocks/login-centered/login-centered.tsx","content":"\"use client\";\n\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type FormEvent, type PointerEvent } from \"react\";\nimport { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useSpring, useTransform, type MotionStyle, type Transition, type Variants } from \"motion/react\";\nimport { Check, FingerprintPattern, Mail } from \"lucide-react\";\nimport { Button } from \"../../button/button\";\nimport { Input } from \"../../input/input\";\nimport { OtpInput } from \"../../otp-input/otp-input\";\nimport { motionTokens } from \"../../lib/motion-tokens\";\nimport styles from \"./login-centered.module.css\";\n\ntype Step = \"passkey\" | \"email\" | \"code\" | \"done\";\ntype Mode = \"sign-in\" | \"sign-up\";\ntype Provider = \"Google\" | \"Apple\" | \"GitHub\";\ntype PasskeyPhase = \"idle\" | \"waiting\" | \"verified\";\nexport type LoginMethod = \"Passkey\" | \"Email code\" | Provider;\nexport interface LoginCenteredProps {\n  /** The code the simulated email contains. */\n  demoCode?: string;\n  /** Fill the viewport (100dvh, no frame) when the block is the whole page. */\n  fullScreen?: boolean;\n  /** The account a simulated passkey or single sign-on resolves to. */\n  demoEmail?: string;\n  termsHref?: string;\n  privacyHref?: string;\n  /** Called once the simulated sign in or sign up succeeds. */\n  onSignIn?: (email: string, method: LoginMethod, mode: Mode) => void;\n  className?: string;\n}\ntype StepCustom = { direction: number; reduce: boolean };\n\nconst RESEND_SECONDS = 30;\n/** The official four-colour Google \"G\"; Apple and GitHub ship monochrome marks, drawn in currentColor. */\nfunction GoogleLogo({ className }: { className?: string }) {\n  return <svg className={className} width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n    <path fill=\"#4285F4\" d=\"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z\" />\n    <path fill=\"#34A853\" d=\"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z\" />\n    <path fill=\"#FBBC05\" d=\"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z\" />\n    <path fill=\"#EA4335\" d=\"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z\" />\n  </svg>;\n}\n\nconst providers: Provider[] = [\"Google\", \"Apple\", \"GitHub\"];\n/** Monochrome provider marks in currentColor, so they stay neutral in both themes. */\nconst providerMarks: Record<Provider, string> = {\n  Google: \"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z\",\n  Apple: \"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701\",\n  GitHub: \"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\",\n};\n/** Concentric rings behind the card. Outer rings drift further, so the set reads as depth rather than a flat pattern. */\nconst rings = Array.from({ length: 14 }, (_, index) => ({ r: 224 + index * 60, k: 1 + index * .34, major: index % 3 === 2 }));\nconst isEmail = (value: string) => /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/.test(value.trim());\n\n/** Steps rise into place out of a small blur; going back, they settle down from above. */\nconst stepMotion: Variants = {\n  enter: ({ direction, reduce }: StepCustom) => reduce ? { opacity: 0 } : { opacity: 0, y: direction * 12, filter: `blur(${motionTokens.blur.soft}px)` },\n  center: ({ reduce }: StepCustom) => ({ opacity: 1, y: 0, filter: \"blur(0px)\", transition: reduce ? { duration: motionTokens.duration.instant } : { y: motionTokens.spring.smooth, opacity: { duration: motionTokens.duration.standard, ease: motionTokens.ease.enter, delay: .06 }, filter: { duration: motionTokens.duration.standard, ease: motionTokens.ease.enter, delay: .04 } } }),\n  exit: ({ direction, reduce }: StepCustom) => reduce ? { opacity: 0, transition: { duration: 0 } } : { opacity: 0, y: direction * -8, filter: `blur(${motionTokens.blur.soft}px)`, transition: { duration: motionTokens.duration.exit, ease: motionTokens.ease.standard } },\n};\nconst swap = (reduce: boolean) => ({\n  initial: reduce ? { opacity: 0 } : { opacity: 0, y: 6, filter: `blur(${motionTokens.blur.soft}px)` },\n  animate: { opacity: 1, y: 0, filter: \"blur(0px)\" },\n  exit: reduce ? { opacity: 0, transition: { duration: 0 } } : { opacity: 0, y: -4, filter: `blur(${motionTokens.blur.subtle}px)`, transition: { duration: motionTokens.duration.fast } },\n  transition: (reduce ? { duration: motionTokens.duration.instant } : { duration: motionTokens.duration.standard, ease: [...motionTokens.ease.enter] }) as Transition,\n});\n/** Both header labels share one cell and cross-fade in place, so the switch never changes width when the mode flips. */\nconst labelState = (active: boolean, reduce: boolean) => active ? { opacity: 1, y: 0, filter: \"blur(0px)\" } : { opacity: 0, y: reduce ? 0 : -6, filter: `blur(${reduce ? 0 : motionTokens.blur.subtle}px)` };\nconst labelTransition = (reduce: boolean): Transition => reduce ? { duration: motionTokens.duration.instant } : { duration: motionTokens.duration.standard, ease: [...motionTokens.ease.enter] };\n/** Seconds roll down while the timer runs and back up when a new code restarts it. */\nconst roll: Variants = {\n  enter: (direction: number) => ({ opacity: 0, y: `${-0.7 * direction}em`, filter: `blur(${motionTokens.blur.subtle}px)` }),\n  center: { opacity: 1, y: 0, filter: \"blur(0px)\" },\n  exit: (direction: number) => ({ opacity: 0, y: `${0.7 * direction}em`, filter: `blur(${motionTokens.blur.subtle}px)` }),\n};\n\nfunction RollingTime({ seconds, reduce }: { seconds: number; reduce: boolean }) {\n  const [shown, setShown] = useState({ seconds, direction: 1 });\n  if (shown.seconds !== seconds) setShown({ seconds, direction: seconds < shown.seconds ? 1 : -1 });\n  const text = `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, \"0\")}`;\n  const transition: Transition = reduce ? { duration: 0 } : { y: motionTokens.spring.snappy, opacity: { duration: motionTokens.duration.fast }, filter: { duration: motionTokens.duration.fast } };\n  return <span className={styles.time}>{text.split(\"\").map((character, index) => <span key={index} className={styles.timeColumn}>\n    <AnimatePresence initial={false} mode=\"popLayout\" custom={shown.direction}><motion.span key={character} custom={shown.direction} variants={roll} initial=\"enter\" animate=\"center\" exit=\"exit\" transition={transition}>{character}</motion.span></AnimatePresence>\n  </span>)}</span>;\n}\n\n/** Two rings leave the fingerprint while the device is asked, then stop on their own. */\nfunction PasskeyPulse({ reduce }: { reduce: boolean }) {\n  return <span className={styles.pulse}>\n    {/* motion: pulse rings are ambient, so they keep their own slower timing. */}\n    {!reduce && [0, 1].map(index => <motion.span key={index} className={styles.pulseRing} initial={{ scale: .7, opacity: 0 }} animate={{ scale: [.7, 2.1], opacity: [.6, 0] }} transition={{ duration: 1.2, ease: [...motionTokens.ease.standard], delay: index * .6 }} />)}\n    <FingerprintPattern size={16} strokeWidth={1.75} aria-hidden=\"true\" />\n  </span>;\n}\n\n/** The card follows its content on a spring only while the view changes; otherwise it stays auto, so field messages open without lag. */\nfunction useViewHeight(view: string, reduce: boolean) {\n  const track = useRef<HTMLDivElement>(null);\n  const height = useMotionValue<number | \"auto\">(\"auto\");\n  const measured = useRef(0);\n  const gliding = useRef(false);\n  const lastView = useRef(view);\n  const glide = useCallback((to: number) => {\n    gliding.current = true;\n    animate(height, to, { ...motionTokens.spring.smooth, onComplete: () => { gliding.current = false; height.jump(\"auto\"); } });\n  }, [height]);\n  useEffect(() => {\n    const node = track.current;\n    if (!node || typeof ResizeObserver === \"undefined\") return;\n    const observer = new ResizeObserver(([entry]) => {\n      if (!entry) return;\n      measured.current = entry.borderBoxSize?.[0]?.blockSize ?? node.offsetHeight;\n      if (gliding.current) glide(measured.current);\n    });\n    observer.observe(node);\n    return () => observer.disconnect();\n  }, [glide]);\n  useLayoutEffect(() => {\n    if (lastView.current === view) return;\n    lastView.current = view;\n    const current = height.get();\n    const from = typeof current === \"number\" ? current : measured.current;\n    const to = track.current?.offsetHeight ?? 0;\n    if (reduce || !from || !to) { gliding.current = false; height.jump(\"auto\"); return; }\n    if (current === \"auto\") height.jump(from);\n    glide(to);\n  }, [view, reduce, height, glide]);\n  return { track, height };\n}\n\n/** Pointer drift for the line backdrop: fine pointers with hover only, never under reduced motion. */\nfunction useDrift(reduce: boolean) {\n  const pointerX = useMotionValue(0);\n  const pointerY = useMotionValue(0);\n  // motion: ambient backdrop drift trails the pointer slowly on purpose; it is not interface feedback.\n  const x = useSpring(pointerX, { visualDuration: .9, bounce: 0 });\n  const y = useSpring(pointerY, { visualDuration: .9, bounce: 0 });\n  const dx = useTransform(x, value => `${value.toFixed(2)}px`);\n  const dy = useTransform(y, value => `${value.toFixed(2)}px`);\n  const canHover = useRef(false);\n  useEffect(() => {\n    if (typeof window === \"undefined\" || !window.matchMedia) return;\n    const query = window.matchMedia(\"(hover: hover) and (pointer: fine)\");\n    const sync = () => { canHover.current = query.matches; };\n    sync();\n    query.addEventListener(\"change\", sync);\n    return () => query.removeEventListener(\"change\", sync);\n  }, []);\n  const onPointerMove = (event: PointerEvent<HTMLElement>) => {\n    if (reduce || !canHover.current || event.pointerType !== \"mouse\") return;\n    const box = event.currentTarget.getBoundingClientRect();\n    pointerX.set(((event.clientX - box.left) / box.width - .5) * -2);\n    pointerY.set(((event.clientY - box.top) / box.height - .5) * -2);\n  };\n  const onPointerLeave = () => { pointerX.set(0); pointerY.set(0); };\n  return { style: { \"--dx\": dx, \"--dy\": dy } as MotionStyle, onPointerMove, onPointerLeave };\n}\n\nexport function LoginCentered({ demoCode = \"482913\", fullScreen = false, demoEmail = \"maya@northwind.studio\", termsHref = \"#terms\", privacyHref = \"#privacy\", onSignIn, className }: LoginCenteredProps) {\n  const reduce = !!useReducedMotion();\n  const [step, setStep] = useState<Step>(\"passkey\");\n  const [mode, setMode] = useState<Mode>(\"sign-in\");\n  const [direction, setDirection] = useState(1);\n  const [passkey, setPasskey] = useState<PasskeyPhase>(\"idle\");\n  const [busy, setBusy] = useState<null | \"email\" | \"code\" | Provider>(null);\n  const [verified, setVerified] = useState(false);\n  const [email, setEmail] = useState(\"\");\n  const [touched, setTouched] = useState(false);\n  const [attempted, setAttempted] = useState(false);\n  const [code, setCode] = useState(\"\");\n  const [codeError, setCodeError] = useState(\"\");\n  const [resendIn, setResendIn] = useState(RESEND_SECONDS);\n  const [account, setAccount] = useState(demoEmail);\n  const [method, setMethod] = useState<LoginMethod>(\"Passkey\");\n  const [status, setStatus] = useState(\"\");\n  const passkeyRef = useRef<HTMLButtonElement>(null);\n  const emailRef = useRef<HTMLInputElement>(null);\n  const codeRef = useRef<HTMLDivElement>(null);\n  const doneRef = useRef<HTMLHeadingElement>(null);\n  const focusNext = useRef<Step | null>(null);\n  const timers = useRef<number[]>([]);\n  const view = step === \"email\" ? `email-${mode}` : step;\n  const { track, height } = useViewHeight(view, reduce);\n  const drift = useDrift(reduce);\n\n  const emailError = (touched || attempted) && !isEmail(email) ? (email.trim() ? \"Enter a full address, like name@example.com.\" : \"Enter your email address.\") : \"\";\n  const custom: StepCustom = { direction, reduce };\n  const signingUp = mode === \"sign-up\";\n\n  useEffect(() => { const pending = timers; return () => pending.current.forEach(window.clearTimeout); }, []);\n  useEffect(() => {\n    if (step !== \"code\" || resendIn <= 0) return;\n    const timer = window.setTimeout(() => setResendIn(seconds => Math.max(0, seconds - 1)), 1000);\n    return () => window.clearTimeout(timer);\n  }, [step, resendIn]);\n  useEffect(() => {\n    const target = focusNext.current;\n    focusNext.current = null;\n    if (target === \"passkey\") passkeyRef.current?.focus();\n    if (target === \"email\") emailRef.current?.focus();\n    if (target === \"done\") doneRef.current?.focus();\n  }, [view]);\n\n  function later(run: () => void, ms: number) { timers.current.push(window.setTimeout(run, ms)); }\n  /** Any new direction cancels whatever the previous one was still waiting on. */\n  function settle() { timers.current.forEach(window.clearTimeout); timers.current = []; setBusy(null); setVerified(false); }\n  function go(next: Step, towards: number, focus: Step | null = next === \"code\" ? null : next) {\n    focusNext.current = focus;\n    setDirection(towards);\n    if (next === \"passkey\") setPasskey(\"idle\");\n    setStep(next);\n  }\n  const focusCode = () => codeRef.current?.querySelector(\"input\")?.focus();\n\n  function complete(address: string, how: LoginMethod) {\n    settle();\n    setAccount(address);\n    setMethod(how);\n    go(\"done\", 1);\n    setStatus(`${signingUp ? \"Account created\" : \"Signed in\"} with ${how === \"Email code\" ? \"an email code\" : how === \"Passkey\" ? \"a passkey\" : how}`);\n    onSignIn?.(address, how, mode);\n  }\n\n  function startPasskey() {\n    if (passkey !== \"idle\" || busy) return;\n    setPasskey(\"waiting\");\n    setStatus(\"Waiting for your passkey\");\n    later(() => {\n      setPasskey(\"verified\");\n      setStatus(\"Passkey verified\");\n      later(() => complete(demoEmail, \"Passkey\"), 640);\n    }, 1700);\n  }\n\n  function cancelPasskey() {\n    settle();\n    setPasskey(\"idle\");\n    setStatus(\"Passkey request canceled\");\n    passkeyRef.current?.focus();\n  }\n\n  function switchToEmail() {\n    if (passkey === \"verified\" || busy) return;\n    settle();\n    setPasskey(\"idle\");\n    setAttempted(false);\n    go(\"email\", 1);\n    setStatus(\"We will email you a sign in code\");\n  }\n\n  function signInWith(provider: Provider) {\n    if (busy || passkey !== \"idle\") return;\n    setBusy(provider);\n    setStatus(`Opening ${provider}`);\n    later(() => complete(demoEmail, provider), 900);\n  }\n\n  function submitEmail(event: FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (busy) return;\n    setAttempted(true);\n    if (!isEmail(email)) { emailRef.current?.focus(); return; }\n    setBusy(\"email\");\n    setStatus(\"Sending a code\");\n    later(() => {\n      const address = email.trim().toLowerCase();\n      setBusy(null);\n      setAccount(address);\n      setCode(\"\");\n      setCodeError(\"\");\n      setResendIn(RESEND_SECONDS);\n      go(\"code\", 1);\n      setStatus(`Code sent to ${address}`);\n    }, 800);\n  }\n\n  function verify(value: string) {\n    if (busy || verified) return;\n    if (value.length < 6) { setCodeError(\"Enter all 6 digits.\"); focusCode(); return; }\n    setBusy(\"code\");\n    setStatus(\"Checking code\");\n    later(() => {\n      setBusy(null);\n      if (value !== demoCode) {\n        setCode(\"\");\n        setCodeError(\"That code didn't match. Check the latest email and try again.\");\n        setStatus(\"Code didn't match\");\n        focusCode();\n        return;\n      }\n      setVerified(true);\n      setStatus(\"Code verified\");\n      later(() => complete(account, \"Email code\"), 600);\n    }, 700);\n  }\n\n  function changeCode(value: string) {\n    if (busy || verified) return;\n    setCode(value);\n    if (codeError && value) setCodeError(\"\");\n    if (value.length === 6) verify(value);\n  }\n\n  function resend() {\n    if (busy || verified || resendIn > 0) return;\n    setResendIn(RESEND_SECONDS);\n    setCode(\"\");\n    setCodeError(\"\");\n    setStatus(\"New code sent\");\n    focusCode();\n  }\n\n  function changeEmail() {\n    settle();\n    setAttempted(false);\n    go(\"email\", -1);\n    setStatus(\"Edit your email\");\n  }\n\n  function switchToPasskey() {\n    settle();\n    setMode(\"sign-in\");\n    go(\"passkey\", -1);\n    setStatus(\"Sign in with your passkey\");\n  }\n\n  function switchMode() {\n    settle();\n    setAttempted(false);\n    setCode(\"\");\n    if (signingUp) { setMode(\"sign-in\"); go(\"passkey\", -1); setStatus(\"Sign in to your account\"); return; }\n    setMode(\"sign-up\");\n    go(\"email\", 1);\n    setStatus(\"Create an account with your email\");\n  }\n\n  function signOut() {\n    settle();\n    setEmail(\"\");\n    setTouched(false);\n    setAttempted(false);\n    setCode(\"\");\n    setMode(\"sign-in\");\n    go(\"passkey\", -1);\n    setStatus(\"Signed out\");\n  }\n\n  function openLegal(href: string, label: string) {\n    return (event: { preventDefault: () => void }) => {\n      if (!href.startsWith(\"#\")) return;\n      event.preventDefault();\n      setStatus(`${label} opens here in your app (demo)`);\n    };\n  }\n\n  const passkeyLabel = passkey === \"waiting\" ? <><PasskeyPulse reduce={reduce} />Waiting for your device</> : passkey === \"verified\" ? <><Check size={16} strokeWidth={2} aria-hidden=\"true\" />Passkey verified</> : <><FingerprintPattern size={16} strokeWidth={1.75} aria-hidden=\"true\" />Sign in with passkey</>;\n\n  return (\n    <section className={[styles.screen, fullScreen ? styles.fullScreen : \"\", className].filter(Boolean).join(\" \")} aria-label={signingUp ? \"Create an account\" : \"Sign in\"} onPointerMove={drift.onPointerMove} onPointerLeave={drift.onPointerLeave}>\n      <motion.div className={styles.backdrop} style={drift.style} aria-hidden=\"true\">\n        <svg className={styles.lines}>\n          <svg x=\"50%\" y=\"50%\" overflow=\"visible\">\n            <line className={styles.axis} x1=\"-2400\" x2=\"2400\" y1=\"0\" y2=\"0\" />\n            <line className={styles.axis} x1=\"0\" x2=\"0\" y1=\"-2400\" y2=\"2400\" />\n            {rings.map(ring => <circle key={ring.r} className={ring.major ? `${styles.ring} ${styles.ringMajor}` : styles.ring} r={ring.r} cx=\"0\" cy=\"0\" style={{ \"--k\": ring.k } as CSSProperties} />)}\n          </svg>\n        </svg>\n      </motion.div>\n\n      <header className={styles.bar}>\n        <span className={styles.mark}><svg width=\"20\" height=\"20\" viewBox=\"0 0 20 20\" fill=\"none\" aria-hidden=\"true\"><path d=\"M3 15a7 7 0 0 1 14 0\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" /><circle cx=\"10\" cy=\"15\" r=\"1.75\" fill=\"currentColor\" /></svg>Arc</span>\n        <p className={styles.switch}>\n          <span className={styles.switchPrompt}>{([\"sign-in\", \"sign-up\"] as const).map(option => <motion.span key={option} aria-hidden={option !== mode || undefined} initial={false} animate={labelState(option === mode, reduce)} transition={labelTransition(reduce)}>{option === \"sign-up\" ? \"Have an account?\" : \"No account?\"}</motion.span>)}</span>\n          <button type=\"button\" className={styles.switchButton} aria-label={signingUp ? \"Sign in\" : \"Sign up\"} onClick={switchMode}>{([\"sign-in\", \"sign-up\"] as const).map(option => <motion.span key={option} aria-hidden=\"true\" initial={false} animate={labelState(option === mode, reduce)} transition={labelTransition(reduce)}>{option === \"sign-up\" ? \"Sign in\" : \"Sign up\"}</motion.span>)}</button>\n        </p>\n      </header>\n\n      <div className={styles.stage}>\n        <div className={styles.card}>\n          <motion.div className={styles.viewport} style={{ height }}>\n            <div ref={track} className={styles.track}>\n              <AnimatePresence mode=\"popLayout\" initial={false} custom={custom}>\n                {step === \"passkey\" && <motion.div key=\"passkey\" className={styles.step} custom={custom} variants={stepMotion} initial=\"enter\" animate=\"center\" exit=\"exit\">\n                  <div className={styles.heading}><h2>Sign in to Arc</h2><p>Use the passkey saved on this device. No password needed.</p></div>\n                  <div className={styles.actions}>\n                    <Button ref={passkeyRef} type=\"button\" className={styles.wide} aria-busy={passkey === \"waiting\" || undefined} aria-disabled={passkey !== \"idle\" || !!busy || undefined} onClick={startPasskey}>{passkeyLabel}</Button>\n                    <Button type=\"button\" variant=\"secondary\" className={styles.wide} aria-disabled={passkey === \"verified\" || !!busy || undefined} onClick={passkey === \"waiting\" ? cancelPasskey : switchToEmail}>{passkey === \"waiting\" ? \"Cancel\" : <><Mail size={16} strokeWidth={1.75} aria-hidden=\"true\" />Use email instead</>}</Button>\n                  </div>\n                  <div className={styles.divider}>or</div>\n                  <div className={styles.sso} role=\"group\" aria-label=\"Single sign-on\">\n                    {providers.map(provider => <Button key={provider} type=\"button\" variant=\"secondary\" className={styles.ssoButton} aria-label={`Continue with ${provider}`} aria-disabled={passkey !== \"idle\" || (!!busy && busy !== provider) || undefined} loading={busy === provider} onClick={() => signInWith(provider)}>{provider === \"Google\" ? <GoogleLogo /> : <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\"><path d={providerMarks[provider]} /></svg>}{provider}</Button>)}\n                  </div>\n                </motion.div>}\n\n                {step === \"email\" && <motion.div key={`email-${mode}`} className={styles.step} custom={custom} variants={stepMotion} initial=\"enter\" animate=\"center\" exit=\"exit\">\n                  <div className={styles.heading}>{signingUp ? <><h2>Create your account</h2><p>Enter your work email. We will send a code to confirm it.</p></> : <><h2>Sign in with email</h2><p>We will send a 6 digit code to your inbox.</p></>}</div>\n                  <form className={styles.form} onSubmit={submitEmail} noValidate>\n                    <Input ref={emailRef} label={signingUp ? \"Work email\" : \"Email\"} type=\"email\" name=\"email\" inputMode=\"email\" autoComplete=\"email\" autoCapitalize=\"none\" spellCheck={false} placeholder=\"name@example.com\" value={email} readOnly={busy === \"email\"} error={emailError} onChange={event => setEmail(event.target.value)} onBlur={() => { if (email.trim()) setTouched(true); }} />\n                    <Button type=\"submit\" className={styles.wide} loading={busy === \"email\"}>{signingUp ? \"Create account\" : \"Send code\"}</Button>\n                  </form>\n                  {!signingUp && <button type=\"button\" className={styles.textButton} onClick={switchToPasskey}><FingerprintPattern size={14} strokeWidth={1.75} aria-hidden=\"true\" />Use a passkey instead</button>}\n                </motion.div>}\n\n                {step === \"code\" && <motion.div key=\"code\" className={styles.step} custom={custom} variants={stepMotion} initial=\"enter\" animate=\"center\" exit=\"exit\">\n                  <div className={styles.heading}><h2>Check your email</h2><p>Enter the code sent to <span className={styles.address}>{account}</span>. <button type=\"button\" className={styles.inlineButton} onClick={changeEmail}>Change</button></p></div>\n                  <form className={styles.form} onSubmit={event => { event.preventDefault(); verify(code); }} noValidate>\n                    <div ref={codeRef}><OtpInput label=\"Verification code\" description={`Demo code: ${demoCode}`} value={code} onChange={changeCode} error={codeError} autoFocus /></div>\n                    <Button type=\"submit\" className={styles.wide} loading={busy === \"code\"} aria-disabled={verified || undefined}>{verified ? <><Check size={16} strokeWidth={2} aria-hidden=\"true\" />Verified</> : signingUp ? \"Verify and create account\" : \"Verify\"}</Button>\n                  </form>\n                  <button type=\"button\" className={styles.textButton} aria-disabled={resendIn > 0 || verified || undefined} aria-label={resendIn > 0 ? `Resend code, available in ${resendIn} seconds` : \"Resend code\"} onClick={resend}>\n                    <AnimatePresence mode=\"popLayout\" initial={false}>\n                      <motion.span key={resendIn > 0 ? \"wait\" : \"ready\"} className={styles.resendLabel} {...swap(reduce)}>{resendIn > 0 ? <>Resend code in <RollingTime seconds={resendIn} reduce={reduce} /></> : \"Resend code\"}</motion.span>\n                    </AnimatePresence>\n                  </button>\n                </motion.div>}\n\n                {step === \"done\" && <motion.div key=\"done\" className={styles.step} custom={custom} variants={stepMotion} initial=\"enter\" animate=\"center\" exit=\"exit\">\n                  <svg className={styles.success} viewBox=\"0 0 48 48\" aria-hidden=\"true\">\n                    <g transform=\"rotate(-90 24 24)\"><motion.circle cx=\"24\" cy=\"24\" r=\"22.25\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" initial={reduce ? false : { pathLength: 0, opacity: 0 }} animate={{ pathLength: 1, opacity: 1 }} transition={{ pathLength: { duration: motionTokens.duration.considered, ease: [...motionTokens.ease.inOut], delay: .16 }, opacity: { duration: motionTokens.duration.instant, delay: .16 } }} /></g>\n                    <motion.path d=\"M15.5 24.5l5.5 5.5 11.5-12\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" initial={reduce ? false : { pathLength: 0, opacity: 0 }} animate={{ pathLength: 1, opacity: 1 }} transition={{ pathLength: { duration: motionTokens.duration.standard + .08, ease: [...motionTokens.ease.enter], delay: .52 }, opacity: { duration: motionTokens.duration.instant, delay: .52 } }} />\n                  </svg>\n                  <div className={styles.heading}><h2 ref={doneRef} tabIndex={-1}>{signingUp ? \"Welcome to Arc\" : \"Welcome back\"}</h2><p>{signingUp ? \"Your account is ready. \" : \"You are signed in as \"}<span className={styles.address}>{account}</span>{signingUp ? \"\" : \".\"}</p></div>\n                  <dl className={styles.details}>\n                    <div><dt>Method</dt><dd>{method}</dd></div>\n                    <div><dt>This device</dt><dd>Remembered for 30 days</dd></div>\n                  </dl>\n                  <Button type=\"button\" variant=\"secondary\" className={styles.wide} onClick={signOut}>Sign out</Button>\n                </motion.div>}\n              </AnimatePresence>\n            </div>\n          </motion.div>\n        </div>\n      </div>\n\n      <footer className={styles.foot}>\n        <p className={styles.srOnly} role=\"status\" aria-live=\"polite\">{status}</p>\n        <span className={styles.status} aria-hidden=\"true\"><AnimatePresence mode=\"popLayout\" initial={false}><motion.span key={status} {...swap(reduce)}>{status}</motion.span></AnimatePresence></span>\n        <nav className={styles.legal} aria-label=\"Legal\">\n          <a href={termsHref} onClick={openLegal(termsHref, \"Terms\")}>Terms</a>\n          <a href={privacyHref} onClick={openLegal(privacyHref, \"Privacy policy\")}>Privacy</a>\n        </nav>\n      </footer>\n    </section>\n  );\n}\n\nexport default LoginCentered;\n"},{"path":"registry/blocks/login-centered/login-centered.module.css","type":"registry:component","target":"@components/arc/blocks/login-centered/login-centered.module.css","content":"/* The screen fills its container like a viewport. Bars share one height, so the stage center and the ring center stay the same point. */\n.screen { --bar: 64px; container: login-centered / inline-size; position: relative; isolation: isolate; display: grid; grid-template-rows: var(--bar) minmax(0, 1fr) var(--bar); width: 100%; min-width: 0; min-height: 640px; justify-self: stretch; align-self: stretch; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--background); color: var(--foreground); font-family: var(--font-body); letter-spacing: var(--tracking-body); }\n.fullScreen { min-height: 100dvh; border: 0; border-radius: 0; }\n\n/* Quiet line backdrop. The mask only fades the outer rings into the canvas; nothing here is filled. */\n.backdrop { position: absolute; inset: 0; z-index: -1; pointer-events: none; -webkit-mask-image: radial-gradient(ellipse 72% 78% at 50% 50%, #000 38%, transparent 100%); mask-image: radial-gradient(ellipse 72% 78% at 50% 50%, #000 38%, transparent 100%); }\n.lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }\n.ring, .axis { fill: none; stroke: var(--border-subtle); stroke-width: 1; }\n.ring { transform: translate(calc(var(--dx, 0px) * var(--k, 1)), calc(var(--dy, 0px) * var(--k, 1))); }\n.ringMajor { stroke: var(--border); }\n.axis { transform: translate(var(--dx, 0px), var(--dy, 0px)); }\n\n.bar, .foot { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: var(--space-4); padding: 0 var(--space-6); }\n.mark { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-base); font-weight: 500; line-height: 1; }\n.switch { display: inline-flex; min-width: 0; align-items: center; gap: var(--space-1); margin: 0; color: var(--text-secondary); font-size: var(--text-sm); line-height: var(--leading-body); white-space: nowrap; }\n.switchPrompt { position: relative; display: inline-grid; justify-items: end; }\n.switchPrompt > span, .switchButton > span { grid-area: 1 / 1; }\n.switchButton { position: relative; display: inline-grid; min-height: var(--control-height-sm); align-items: center; justify-items: center; border: 0; border-radius: var(--radius-pill); padding: 0 var(--space-3); background: none; color: var(--foreground); font: inherit; font-weight: 500; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color var(--duration-fast) var(--ease-standard); }\n.switchButton:active { background: var(--surface-muted); }\n\n.stage { display: grid; min-width: 0; place-items: center; padding: var(--space-6) var(--space-4); }\n.card { width: min(100%, 420px); min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-surface); background: var(--surface); box-shadow: var(--shadow-resting); }\n/* Clips the leaving step while the height glides; steps carry their own padding. */\n.viewport { overflow: hidden; }\n.track { position: relative; }\n.step { display: grid; min-width: 0; padding: var(--space-8); }\n\n.heading { display: grid; gap: var(--space-2); margin-bottom: var(--space-6); }\n.heading h2 { margin: 0; font-family: var(--font-display); font-size: var(--text-3xl); font-weight: 400; letter-spacing: var(--tracking-display); line-height: var(--leading-display); text-wrap: balance; }\n.heading p { margin: 0; color: var(--text-secondary); font-size: var(--text-sm); line-height: var(--leading-body); text-wrap: pretty; }\n.address { color: var(--foreground); overflow-wrap: anywhere; }\n\n.actions, .form { display: grid; gap: var(--space-3); }\n.form { gap: var(--space-4); }\n.wide { width: 100%; }\n/* Rings leave the fingerprint while the device is asked. They sit in the label, so they take the button's text color. */\n.pulse { position: relative; display: inline-grid; place-items: center; }\n.pulseRing { position: absolute; inset: -2px; border: 1.5px solid currentColor; border-radius: var(--radius-pill); pointer-events: none; }\n\n.divider { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-5) 0; color: var(--text-muted); font-size: var(--text-xs); line-height: 1; }\n.divider::before, .divider::after { flex: 1; height: 1px; background: var(--border); content: \"\"; }\n.sso { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }\n.sso .ssoButton { min-width: 0; padding-inline: var(--space-2); }\n\n.textButton { position: relative; display: inline-flex; min-height: var(--control-height-sm); align-items: center; justify-self: center; gap: var(--space-2); margin: var(--space-4) 0 calc(var(--space-2) * -1); border: 0; border-radius: var(--radius-pill); padding: 0 var(--space-3); background: none; color: var(--text-secondary); font: inherit; font-size: var(--text-sm); font-weight: 500; line-height: var(--leading-body); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard); }\n.textButton:active:not([aria-disabled=\"true\"]) { color: var(--foreground); background: var(--surface-muted); }\n.textButton[aria-disabled=\"true\"] { color: var(--text-muted); font-weight: 400; cursor: default; }\n.inlineButton { border: 0; border-radius: 4px; padding: 0; background: none; color: var(--foreground); font: inherit; font-weight: 500; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; cursor: pointer; transition: text-decoration-color var(--duration-fast) var(--ease-standard); }\n.resendLabel { display: inline-flex; align-items: baseline; gap: .3em; white-space: nowrap; }\n.time { display: inline-flex; font-variant-numeric: tabular-nums; }\n.timeColumn { position: relative; display: inline-flex; justify-content: center; }\n.timeColumn > span { display: inline-block; }\n\n.success { display: block; width: 48px; height: 48px; margin-bottom: var(--space-6); overflow: visible; color: var(--success); }\n.details { display: grid; margin: calc(var(--space-2) * -1) 0 var(--space-6); border-top: 1px solid var(--border); padding: 0; }\n.details div { display: flex; justify-content: space-between; gap: var(--space-4); border-bottom: 1px solid var(--border); padding: var(--space-3) 0; font-size: var(--text-sm); line-height: var(--leading-body); }\n.details dt { color: var(--text-secondary); }\n.details dd { margin: 0; text-align: right; }\n\n.foot { color: var(--text-muted); font-size: var(--text-xs); line-height: var(--leading-body); }\n.status { position: relative; display: block; min-width: 0; flex: 1; }\n.status > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.legal { display: flex; flex: none; gap: var(--space-1); }\n.legal a { display: inline-flex; min-height: 32px; align-items: center; border-radius: var(--radius-pill); padding: 0 var(--space-2); color: var(--text-secondary); text-decoration: none; transition: color var(--duration-fast) var(--ease-standard), background-color var(--duration-fast) var(--ease-standard); }\n.legal a:active { color: var(--foreground); }\n.srOnly { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n\n@media (hover: hover) and (pointer: fine) {\n  .switchButton:hover { background: var(--surface-muted); }\n  .textButton:not([aria-disabled=\"true\"]):hover { color: var(--foreground); background: var(--surface-muted); }\n  .inlineButton:hover { text-decoration-color: currentColor; }\n  .legal a:hover { color: var(--foreground); background: var(--surface-muted); }\n}\n\n@container login-centered (max-width: 520px) {\n  .bar, .foot { padding-inline: var(--space-4); }\n  .stage { padding: var(--space-4); }\n  .card { border-radius: var(--radius-panel); }\n  .step { padding: var(--space-6); }\n}\n@container login-centered (max-width: 400px) {\n  .stage { padding-inline: var(--space-3); }\n  .step { padding-inline: var(--space-5); }\n  .heading h2 { font-size: var(--text-2xl); }\n  .sso .ssoButton { gap: 6px; padding-inline: var(--space-1); font-size: var(--text-xs); }\n  .switchButton { padding-inline: var(--space-2); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .switchButton, .textButton, .inlineButton, .legal a { transition: none; }\n  .ring, .axis { transform: none; }\n}\n/* The product mark takes the accent: the one spot of color before a person signs in. */\n.mark svg { color: var(--accent); }\n"}],"docs":"Use this as a full screen sign in page (pass fullScreen). Connect the passkey button to WebAuthn, the email step to your magic code sender, the code step to verification, and the SSO buttons to your OAuth routes; onSignIn receives the email, method and mode.","meta":{"tier":"free","kind":"block","builtFrom":["Button","Input","OTP input"],"docs":"https://uiarc.dev/components/blocks/login-centered"}}