pstzx

Button Sign Up Water Effect

Component

About

LiquidWaterSignUp is a self-contained, monochrome React TypeScript component featuring a borderless, pill-shaped liquid-glass Sign Up button filled with animated SVG metaball water beads.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Button Sign Up Water Effect to your project and fits it to your theme.

Code

How Button Sign Up Water Effect is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import React, { useCallback, useEffect, useId, useRef, useState } from 'react';

export interface SignUpFormValues {
  fullName: string;
  email: string;
  password: string;
}

export interface LiquidWaterSignUpProps {
  /** Optional callback triggered when the Create Account form is submitted */
  onSubmit?: (values: SignUpFormValues) => void | Promise<void>;
  /** Optional custom class name for the root container */
  className?: string;
}

interface SprayDroplet {
  x: number;
  y: number;
  vx: number;
  vy: number;
  r: number;
  alpha: number;
  decay: number;
  drag: number;
  gravity: number;
  stretchFactor: number;
}

interface RippleRing {
  x: number;
  y: number;
  r: number;
  maxR: number;
  speed: number;
  alpha: number;
  lineWidth: number;
}

interface EdgeDroplet {
  u: number;
  baseR: number;
  phase: number;
  freq: number;
  driftSpeed: number;
  outwardBias: number;
}

interface MicroTear {
  u: number;
  r: number;
  phase: number;
  hang: number;
}

interface SatelliteBead {
  u: number;
  offsetOut: number;
  r: number;
  phase: number;
  alpha: number;
}

interface RisingBubble {
  x: number;
  y: number;
  r: number;
  vy: number;
  wobbleAmp: number;
  wobbleFreq: number;
  phase: number;
  squishPhase: number;
  alpha: number;
  maxAlpha: number;
  state: 'rising' | 'flattening';
  flattenProgress: number;
  flatScaleX: number;
  flatScaleY: number;
}

interface PanelMetrics {
  w: number;
  h: number;
  pad: number;
  svgW: number;
  svgH: number;
  radius: number;
}

interface RoundedRectPoint {
  x: number;
  y: number;
  nx: number;
  ny: number;
}

type StageState = 'button' | 'spraying' | 'panel' | 'resetting';

const SCOPED_STYLES = `
.lws-root {
  --bg-obsidian: #070709;
  --glass-fill: rgba(255, 255, 255, 0.045);
  --glass-shield: rgba(12, 12, 15, 0.84);
  --glass-shield-focus: rgba(18, 18, 22, 0.92);
  --text-primary: #f5f5f7;
  --text-secondary: rgba(245, 245, 247, 0.56);
  --text-muted: rgba(245, 245, 247, 0.34);

  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.01) 36%, transparent 68%),
    radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.025) 0%, transparent 55%),
    var(--bg-obsidian);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

.lws-root *,
.lws-root *::before,
.lws-root *::after {
  box-sizing: border-box;
}

.lws-svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
}

.lws-spray-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}

/* =========================================================
   STAGE 1: PILL-SHAPED LIQUID-WATER SIGN UP BUTTON
   ========================================================= */
.lws-button-stage {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.45s ease;
}

.lws-button-stage.is-hidden {
  opacity: 0;
  transform: scale(0.84);
  filter: blur(6px);
  pointer-events: none;
}

.lws-pill-btn {
  position: relative;
  width: 220px;
  height: 68px;
  border: none;
  outline: none;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(18px) saturate(135%);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow:
    0 22px 46px -12px rgba(0, 0, 0, 0.88),
    0 6px 18px rgba(0, 0, 0, 0.65),
    inset 0 1.5px 2px rgba(255, 255, 255, 0.42),
    inset 0 -2px 5px rgba(255, 255, 255, 0.12),
    inset 0 0 18px rgba(255, 255, 255, 0.06);
  transition:
    transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.34s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.34s ease;
}

.lws-pill-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  padding: 1.25px;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.62) 0%,
    rgba(255, 255, 255, 0.14) 36%,
    rgba(255, 255, 255, 0.03) 64%,
    rgba(255, 255, 255, 0.28) 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 4;
}

.lws-pill-btn::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 22px;
  right: 22px;
  height: 18px;
  border-radius: 9999px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.32) 0%,
    rgba(255, 255, 255, 0.0) 100%
  );
  pointer-events: none;
  z-index: 4;
  transition: opacity 0.3s ease;
}

.lws-pill-btn:hover {
  transform: translateY(-2px) scale(1.028);
  background: rgba(255, 255, 255, 0.065);
  box-shadow:
    0 28px 56px -12px rgba(0, 0, 0, 0.92),
    0 0 34px rgba(255, 255, 255, 0.11),
    inset 0 1.5px 2.5px rgba(255, 255, 255, 0.56),
    inset 0 -2px 6px rgba(255, 255, 255, 0.16),
    inset 0 0 22px rgba(255, 255, 255, 0.09);
}

.lws-pill-btn:active,
.lws-pill-btn.is-pressing {
  transform: scale(0.93);
  transition: transform 0.12s cubic-bezier(0.2, 0, 0, 1);
}

.lws-pill-liquid-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.lws-btn-bead {
  fill: rgba(255, 255, 255, 0.24);
  transition: transform 0.4s ease, fill 0.4s ease;
}

.lws-pill-btn:hover .lws-btn-bead {
  fill: rgba(255, 255, 255, 0.34);
}

.lws-btn-bead-1 { animation: lws-bead-drift-1 5.6s ease-in-out infinite alternate; transform-origin: 48px 34px; }
.lws-btn-bead-2 { animation: lws-bead-drift-2 6.4s ease-in-out infinite alternate; transform-origin: 96px 38px; }
.lws-btn-bead-3 { animation: lws-bead-drift-3 5.1s ease-in-out infinite alternate; transform-origin: 148px 31px; }
.lws-btn-bead-4 { animation: lws-bead-drift-4 6.9s ease-in-out infinite alternate; transform-origin: 182px 37px; }
.lws-btn-bead-5 { animation: lws-bead-drift-5 4.8s ease-in-out infinite alternate; transform-origin: 72px 26px; }
.lws-btn-bead-6 { animation: lws-bead-drift-6 5.9s ease-in-out infinite alternate; transform-origin: 125px 42px; }
.lws-btn-bead-7 { animation: lws-bead-drift-7 6.2s ease-in-out infinite alternate; transform-origin: 164px 25px; }

.lws-pill-btn:hover .lws-btn-bead-1 { animation-duration: 2.8s; transform: scale(1.16); }
.lws-pill-btn:hover .lws-btn-bead-2 { animation-duration: 3.1s; transform: scale(1.18); }
.lws-pill-btn:hover .lws-btn-bead-3 { animation-duration: 2.6s; transform: scale(1.15); }
.lws-pill-btn:hover .lws-btn-bead-4 { animation-duration: 3.3s; transform: scale(1.17); }
.lws-pill-btn:hover .lws-btn-bead-5 { animation-duration: 2.4s; transform: scale(1.2); }
.lws-pill-btn:hover .lws-btn-bead-6 { animation-duration: 2.9s; transform: scale(1.18); }
.lws-pill-btn:hover .lws-btn-bead-7 { animation-duration: 3.0s; transform: scale(1.16); }

@keyframes lws-bead-drift-1 {
  0%   { transform: translate(0px, 0px) scale(1); }
  50%  { transform: translate(18px, -7px) scale(1.12); }
  100% { transform: translate(34px, 6px) scale(0.94); }
}
@keyframes lws-bead-drift-2 {
  0%   { transform: translate(0px, 0px) scale(1.05); }
  50%  { transform: translate(-20px, 6px) scale(0.92); }
  100% { transform: translate(22px, -8px) scale(1.14); }
}
@keyframes lws-bead-drift-3 {
  0%   { transform: translate(0px, 0px) scale(0.96); }
  50%  { transform: translate(-24px, -6px) scale(1.15); }
  100% { transform: translate(16px, 8px) scale(1.02); }
}
@keyframes lws-bead-drift-4 {
  0%   { transform: translate(0px, 0px) scale(1); }
  50%  { transform: translate(-26px, 5px) scale(1.12); }
  100% { transform: translate(-12px, -7px) scale(0.92); }
}
@keyframes lws-bead-drift-5 {
  0%   { transform: translate(0px, 0px) scale(0.9); }
  50%  { transform: translate(26px, 11px) scale(1.16); }
  100% { transform: translate(48px, 3px) scale(0.95); }
}
@keyframes lws-bead-drift-6 {
  0%   { transform: translate(0px, 0px) scale(1.04); }
  50%  { transform: translate(-18px, -11px) scale(0.92); }
  100% { transform: translate(-38px, -3px) scale(1.14); }
}
@keyframes lws-bead-drift-7 {
  0%   { transform: translate(0px, 0px) scale(0.94); }
  50%  { transform: translate(-22px, 10px) scale(1.14); }
  100% { transform: translate(-44px, 2px) scale(0.96); }
}

.lws-pill-label {
  position: relative;
  z-index: 5;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #ffffff;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

/* =========================================================
   STAGE 2: ROUNDED-RECTANGLE LIQUID-GLASS SIGN UP PANEL
   ========================================================= */
.lws-panel-stage {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92) translateY(16px);
  filter: blur(10px);
  transition:
    opacity 0.72s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.78s cubic-bezier(0.16, 1, 0.3, 1),
    filter 0.72s cubic-bezier(0.16, 1, 0.3, 1);
}

.lws-panel-stage.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
  filter: blur(0px);
}

.lws-panel-wrapper {
  position: relative;
  width: min(420px, 90vw);
}

/* Perimeter Liquid Water-Droplet Edge Layer */
.lws-panel-edge-layer {
  position: absolute;
  inset: -24px;
  pointer-events: none;
  z-index: 4;
}

.lws-panel-edge-svg,
.lws-panel-rim-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.lws-panel-rim-canvas {
  z-index: 2;
}

.lws-liquid-panel {
  position: relative;
  width: 100%;
  border-radius: 28px;
  background: var(--glass-fill);
  backdrop-filter: blur(28px) saturate(135%);
  -webkit-backdrop-filter: blur(28px) saturate(135%);
  padding: 36px 32px 32px;
  overflow: hidden;
  box-shadow:
    0 34px 80px -16px rgba(0, 0, 0, 0.92),
    0 12px 30px -8px rgba(0, 0, 0, 0.72),
    inset 0 1.5px 2px rgba(255, 255, 255, 0.38),
    inset 0 -2px 6px rgba(255, 255, 255, 0.08),
    inset 0 0 36px rgba(255, 255, 255, 0.04);
}

.lws-liquid-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 28px;
  padding: 1.25px;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.56) 0%,
    rgba(255, 255, 255, 0.14) 30%,
    rgba(255, 255, 255, 0.02) 68%,
    rgba(255, 255, 255, 0.22) 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 6;
}

.lws-liquid-panel::after {
  content: "";
  position: absolute;
  top: 0;
  left: 28px;
  right: 28px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.65) 50%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 6;
}

/* Interior Rising Droplet Layers (Strictly Behind Input Column) */
.lws-panel-goo-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.78;
}

.lws-panel-meniscus {
  fill: rgba(255, 255, 255, 0.085);
}

.lws-goo-riser {
  fill: rgba(255, 255, 255, 0.14);
}

.lws-goo-riser-1 { animation: lws-goo-rise-1 7.2s cubic-bezier(0.35, 0, 0.25, 1) infinite; }
.lws-goo-riser-2 { animation: lws-goo-rise-2 8.6s cubic-bezier(0.35, 0, 0.25, 1) infinite 1.4s; }
.lws-goo-riser-3 { animation: lws-goo-rise-3 6.8s cubic-bezier(0.35, 0, 0.25, 1) infinite 2.9s; }
.lws-goo-riser-4 { animation: lws-goo-rise-4 9.1s cubic-bezier(0.35, 0, 0.25, 1) infinite 0.7s; }
.lws-goo-riser-5 { animation: lws-goo-rise-5 7.9s cubic-bezier(0.35, 0, 0.25, 1) infinite 3.8s; }
.lws-goo-riser-6 { animation: lws-goo-rise-6 8.2s cubic-bezier(0.35, 0, 0.25, 1) infinite 2.1s; }
.lws-goo-riser-7 { animation: lws-goo-rise-7 7.5s cubic-bezier(0.35, 0, 0.25, 1) infinite 4.6s; }
.lws-goo-riser-8 { animation: lws-goo-rise-8 8.9s cubic-bezier(0.35, 0, 0.25, 1) infinite 1.9s; }

@keyframes lws-goo-rise-1 {
  0%   { transform: translate(0px, 16px) scale(1.18, 0.86); opacity: 0; }
  12%  { opacity: 0.95; }
  30%  { transform: translate(-6px, -65px) scale(0.92, 1.12); }
  65%  { transform: translate(8px, -230px) scale(1.04, 0.96); opacity: 0.85; }
  90%  { transform: translate(-4px, -370px) scale(1.22, 0.76); opacity: 0.35; }
  100% { transform: translate(-2px, -415px) scale(1.35, 0.65); opacity: 0; }
}
@keyframes lws-goo-rise-2 {
  0%   { transform: translate(0px, 18px) scale(1.15, 0.88); opacity: 0; }
  14%  { opacity: 0.9; }
  35%  { transform: translate(9px, -85px) scale(0.9, 1.14); }
  70%  { transform: translate(-7px, -260px) scale(1.05, 0.95); opacity: 0.8; }
  92%  { transform: translate(5px, -385px) scale(1.25, 0.72); opacity: 0.3; }
  100% { transform: translate(3px, -425px) scale(1.38, 0.62); opacity: 0; }
}
@keyframes lws-goo-rise-3 {
  0%   { transform: translate(0px, 14px) scale(1.12, 0.9); opacity: 0; }
  12%  { opacity: 0.95; }
  32%  { transform: translate(-8px, -75px) scale(0.94, 1.1); }
  68%  { transform: translate(6px, -245px) scale(1.02, 0.98); opacity: 0.82; }
  90%  { transform: translate(-3px, -375px) scale(1.2, 0.75); opacity: 0.32; }
  100% { transform: translate(0px, -420px) scale(1.34, 0.64); opacity: 0; }
}
@keyframes lws-goo-rise-4 {
  0%   { transform: translate(0px, 18px) scale(1.2, 0.85); opacity: 0; }
  15%  { opacity: 0.88; }
  38%  { transform: translate(7px, -90px) scale(0.91, 1.13); }
  72%  { transform: translate(-9px, -270px) scale(1.06, 0.94); opacity: 0.78; }
  92%  { transform: translate(4px, -390px) scale(1.26, 0.7); opacity: 0.28; }
  100% { transform: translate(2px, -430px) scale(1.4, 0.6); opacity: 0; }
}
@keyframes lws-goo-rise-5 {
  0%   { transform: translate(0px, 15px) scale(1.14, 0.88); opacity: 0; }
  12%  { opacity: 0.92; }
  34%  { transform: translate(-7px, -80px) scale(0.93, 1.11); }
  68%  { transform: translate(8px, -250px) scale(1.03, 0.97); opacity: 0.8; }
  91%  { transform: translate(-5px, -380px) scale(1.22, 0.74); opacity: 0.3; }
  100% { transform: translate(-2px, -422px) scale(1.36, 0.62); opacity: 0; }
}
@keyframes lws-goo-rise-6 {
  0%   { transform: translate(0px, 16px) scale(1.16, 0.87); opacity: 0; }
  13%  { opacity: 0.9; }
  36%  { transform: translate(8px, -88px) scale(0.92, 1.12); }
  70%  { transform: translate(-6px, -255px) scale(1.04, 0.96); opacity: 0.82; }
  91%  { transform: translate(4px, -382px) scale(1.24, 0.73); opacity: 0.32; }
  100% { transform: translate(1px, -424px) scale(1.36, 0.63); opacity: 0; }
}
@keyframes lws-goo-rise-7 {
  0%   { transform: translate(0px, 14px) scale(1.12, 0.9); opacity: 0; }
  12%  { opacity: 0.94; }
  32%  { transform: translate(-6px, -72px) scale(0.94, 1.1); }
  66%  { transform: translate(7px, -240px) scale(1.02, 0.98); opacity: 0.84; }
  90%  { transform: translate(-4px, -372px) scale(1.2, 0.75); opacity: 0.34; }
  100% { transform: translate(-1px, -418px) scale(1.32, 0.65); opacity: 0; }
}
@keyframes lws-goo-rise-8 {
  0%   { transform: translate(0px, 17px) scale(1.18, 0.86); opacity: 0; }
  14%  { opacity: 0.88; }
  37%  { transform: translate(6px, -86px) scale(0.91, 1.13); }
  71%  { transform: translate(-8px, -262px) scale(1.05, 0.95); opacity: 0.78; }
  92%  { transform: translate(3px, -386px) scale(1.24, 0.72); opacity: 0.28; }
  100% { transform: translate(1px, -428px) scale(1.38, 0.61); opacity: 0; }
}

.lws-panel-bubble-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 28px;
  pointer-events: none;
  z-index: 2;
}

/* =========================================================
   ELEVATED FRONT INPUT COLUMN (STRICTLY IN FRONT OF BUBBLES)
   ========================================================= */
.lws-panel-content {
  position: relative;
  z-index: 10;
  isolation: isolate;
}

.lws-panel-header {
  text-align: center;
  margin-bottom: 26px;
}

.lws-panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 9999px;
  background: rgba(14, 14, 18, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.22);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.lws-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.lws-panel-title {
  margin: 0;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72);
}

.lws-panel-subtitle {
  margin: 6px 0 0;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
}

.lws-form-column {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.lws-field-group {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lws-field-label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: rgba(245, 245, 247, 0.78);
  padding-left: 4px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.lws-input-shield {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  border-radius: 14px;
  background: var(--glass-shield);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  box-shadow:
    0 8px 20px -6px rgba(0, 0, 0, 0.72),
    inset 0 1px 1.5px rgba(255, 255, 255, 0.24),
    inset 0 -1px 2px rgba(255, 255, 255, 0.06);
  transition:
    background 0.25s ease,
    box-shadow 0.25s ease,
    transform 0.25s ease;
}

.lws-input-shield:focus-within {
  background: var(--glass-shield-focus);
  box-shadow:
    0 10px 24px -6px rgba(0, 0, 0, 0.82),
    0 0 0 1px rgba(255, 255, 255, 0.36),
    inset 0 1px 2px rgba(255, 255, 255, 0.38),
    0 0 22px rgba(255, 255, 255, 0.1);
}

.lws-input-shield input {
  width: 100%;
  height: 46px;
  padding: 0 16px;
  border: none;
  outline: none;
  background: transparent;
  color: #ffffff;
  font-family: inherit;
  font-size: 14.5px;
  letter-spacing: 0.01em;
}

.lws-input-shield input::placeholder {
  color: var(--text-muted);
}

.lws-input-shield input.has-toggle {
  padding-right: 44px;
}

.lws-eye-toggle {
  position: absolute;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.lws-eye-toggle:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.09);
}

.lws-submit-btn {
  position: relative;
  z-index: 10;
  margin-top: 6px;
  width: 100%;
  height: 48px;
  border: none;
  border-radius: 9999px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.96) 0%,
    rgba(222, 222, 228, 0.92) 100%
  );
  color: #09090b;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow:
    0 14px 30px -8px rgba(0, 0, 0, 0.82),
    inset 0 1.5px 1px #ffffff,
    inset 0 -2px 4px rgba(0, 0, 0, 0.16);
  transition:
    transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.25s ease,
    filter 0.25s ease;
}

.lws-submit-btn:hover {
  transform: translateY(-1.5px);
  box-shadow:
    0 18px 36px -8px rgba(0, 0, 0, 0.88),
    0 0 24px rgba(255, 255, 255, 0.24),
    inset 0 1.5px 1px #ffffff;
}

.lws-submit-btn:active {
  transform: scale(0.975);
}

.lws-submit-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* Confirmation View */
.lws-confirmation-view {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 16px 8px 10px;
  animation: lws-fade-scale-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes lws-fade-scale-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.lws-confirm-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(16, 16, 20, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow:
    inset 0 1.5px 2px rgba(255, 255, 255, 0.48),
    0 12px 26px rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.lws-confirm-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.72);
}

.lws-confirm-desc {
  margin: 8px 0 22px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
}

.lws-confirm-desc strong {
  color: #ffffff;
  font-weight: 500;
}

.lws-secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 22px;
  border: none;
  border-radius: 9999px;
  background: rgba(14, 14, 18, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow:
    inset 0 1px 1.5px rgba(255, 255, 255, 0.28),
    0 8px 20px rgba(0, 0, 0, 0.55);
  transition: background 0.25s ease, transform 0.25s ease;
}

.lws-secondary-btn:hover {
  background: rgba(24, 24, 30, 0.92);
  transform: translateY(-1px);
}

/* Reset Pill Below Panel */
.lws-reset-pill {
  margin-top: 28px;
  height: 36px;
  padding: 0 18px;
  border: none;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.6),
    inset 0 1px 1px rgba(255, 255, 255, 0.24);
  transition:
    color 0.25s ease,
    background 0.25s ease,
    transform 0.25s ease;
}

.lws-reset-pill:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.11);
  transform: translateY(-1px);
}

.lws-reset-pill:active {
  transform: scale(0.95);
}
`;

function pointOnRoundedRect(
  u: number,
  x: number,
  y: number,
  w: number,
  h: number,
  r: number
): RoundedRectPoint {
  const rad = Math.min(r, w / 2, h / 2);
  const topLen = Math.max(0, w - 2 * rad);
  const rightLen = Math.max(0, h - 2 * rad);
  const bottomLen = topLen;
  const leftLen = rightLen;
  const cornerArc = (Math.PI / 2) * rad;
  const totalPerimeter = topLen + rightLen + bottomLen + leftLen + 4 * cornerArc;

  let d = (((u % 1) + 1) % 1) * totalPerimeter;

  if (d <= topLen) {
    return { x: x + rad + d, y, nx: 0, ny: -1 };
  }
  d -= topLen;

  if (d <= cornerArc) {
    const a = -Math.PI / 2 + d / rad;
    return {
      x: x + w - rad + Math.cos(a) * rad,
      y: y + rad + Math.sin(a) * rad,
      nx: Math.cos(a),
      ny: Math.sin(a),
    };
  }
  d -= cornerArc;

  if (d <= rightLen) {
    return { x: x + w, y: y + rad + d, nx: 1, ny: 0 };
  }
  d -= rightLen;

  if (d <= cornerArc) {
    const a = d / rad;
    return {
      x: x + w - rad + Math.cos(a) * rad,
      y: y + h - rad + Math.sin(a) * rad,
      nx: Math.cos(a),
      ny: Math.sin(a),
    };
  }
  d -= cornerArc;

  if (d <= bottomLen) {
    return { x: x + w - rad - d, y: y + h, nx: 0, ny: 1 };
  }
  d -= bottomLen;

  if (d <= cornerArc) {
    const a = Math.PI / 2 + d / rad;
    return {
      x: x + rad + Math.cos(a) * rad,
      y: y + h - rad + Math.sin(a) * rad,
      nx: Math.cos(a),
      ny: Math.sin(a),
    };
  }
  d -= cornerArc;

  if (d <= leftLen) {
    return { x, y: y + h - rad - d, nx: -1, ny: 0 };
  }
  d -= leftLen;

  const a = Math.PI + d / rad;
  return {
    x: x + rad + Math.cos(a) * rad,
    y: y + rad + Math.sin(a) * rad,
    nx: Math.cos(a),
    ny: Math.sin(a),
  };
}

function drawGlossyDroplet(
  ctx: CanvasRenderingContext2D,
  x: number,
  y: number,
  r: number,
  alpha: number,
  vx = 0,
  vy = 0,
  stretchFactor = 0,
  squishX = 1,
  squishY = 1
): void {
  if (alpha <= 0.01 || r <= 0.25) return;

  const speed = Math.hypot(vx, vy);
  const stretch = Math.min(1.85, 1 + speed * stretchFactor);
  const angle = speed > 0.05 ? Math.atan2(vy, vx) : 0;

  ctx.save();
  ctx.translate(x, y);
  if (stretch > 1.02) {
    ctx.rotate(angle);
    ctx.scale(stretch, 1 / Math.sqrt(stretch));
  } else if (squishX !== 1 || squishY !== 1) {
    ctx.scale(squishX, squishY);
  }

  // 1. Soft refractive shadow
  ctx.beginPath();
  ctx.arc(r * 0.14, r * 0.2, r * 1.04, 0, Math.PI * 2);
  ctx.fillStyle = `rgba(0, 0, 0, ${(0.45 * alpha).toFixed(3)})`;
  ctx.fill();

  // 2. Monochrome liquid-silver droplet body
  const bodyGrad = ctx.createRadialGradient(
    -r * 0.32,
    -r * 0.34,
    r * 0.06,
    0,
    0,
    r
  );
  bodyGrad.addColorStop(0, `rgba(255, 255, 255, ${(0.72 * alpha).toFixed(3)})`);
  bodyGrad.addColorStop(0.32, `rgba(215, 215, 222, ${(0.28 * alpha).toFixed(3)})`);
  bodyGrad.addColorStop(0.75, `rgba(120, 120, 130, ${(0.12 * alpha).toFixed(3)})`);
  bodyGrad.addColorStop(1, `rgba(255, 255, 255, ${(0.34 * alpha).toFixed(3)})`);

  ctx.beginPath();
  ctx.arc(0, 0, r, 0, Math.PI * 2);
  ctx.fillStyle = bodyGrad;
  ctx.fill();

  // 3. Internal bottom-right caustic crescent bounce
  const causticGrad = ctx.createRadialGradient(
    r * 0.34,
    r * 0.38,
    r * 0.02,
    r * 0.26,
    r * 0.3,
    r * 0.65
  );
  causticGrad.addColorStop(0, `rgba(255, 255, 255, ${(0.56 * alpha).toFixed(3)})`);
  causticGrad.addColorStop(1, 'rgba(255, 255, 255, 0)');

  ctx.beginPath();
  ctx.arc(0, 0, r * 0.92, 0, Math.PI * 2);
  ctx.fillStyle = causticGrad;
  ctx.fill();

  // 4. Crisp top-left specular pinpoint
  if (r >= 1.5) {
    ctx.beginPath();
    ctx.ellipse(
      -r * 0.34,
      -r * 0.34,
      Math.max(0.7, r * 0.24),
      Math.max(0.5, r * 0.15),
      -Math.PI / 4,
      0,
      Math.PI * 2
    );
    ctx.fillStyle = `rgba(255, 255, 255, ${(0.92 * alpha).toFixed(3)})`;
    ctx.fill();
  }

  ctx.restore();
}

export const LiquidWaterSignUp: React.FC<LiquidWaterSignUpProps> = ({
  onSubmit,
  className = '',
}) => {
  const uid = useId().replace(/:/g, '');
  const btnGooId = `lws-btn-goo-${uid}`;
  const panelGooId = `lws-panel-goo-${uid}`;
  const panelEdgeGooId = `lws-panel-edge-goo-${uid}`;

  const [stage, setStage] = useState<StageState>('button');
  const [isPressing, setIsPressing] = useState(false);
  const [showPassword, setShowPassword] = useState(false);
  const [isSubmitting, setIsSubmitting] = useState(false);
  const [isSubmitted, setIsSubmitted] = useState(false);

  const [fullName, setFullName] = useState('');
  const [email, setEmail] = useState('');
  const [password, setPassword] = useState('');

  // DOM & Canvas Refs
  const pillBtnRef = useRef<HTMLButtonElement | null>(null);
  const sprayCanvasRef = useRef<HTMLCanvasElement | null>(null);
  const liquidPanelRef = useRef<HTMLDivElement | null>(null);

  const edgeSvgRef = useRef<SVGSVGElement | null>(null);
  const edgeBaseRectRef = useRef<SVGRectElement | null>(null);
  const edgeDropsGroupRef = useRef<SVGGElement | null>(null);
  const rimCanvasRef = useRef<HTMLCanvasElement | null>(null);
  const bubbleCanvasRef = useRef<HTMLCanvasElement | null>(null);

  // Mutable Simulation Refs
  const stageRef = useRef<StageState>('button');
  stageRef.current = stage;

  const sprayDropletsRef = useRef<SprayDroplet[]>([]);
  const rippleRingsRef = useRef<RippleRing[]>([]);
  const panelPointerRef = useRef({ x: -999, y: -999, active: false });

  const panelMetricsRef = useRef<PanelMetrics>({
    w: 420,
    h: 460,
    pad: 24,
    svgW: 468,
    svgH: 508,
    radius: 28,
  });

  const edgeDropletsRef = useRef<EdgeDroplet[]>([]);
  const edgeDropElsRef = useRef<SVGCircleElement[]>([]);
  const microTearsRef = useRef<MicroTear[]>([]);
  const microTearElsRef = useRef<SVGEllipseElement[]>([]);
  const satelliteBeadsRef = useRef<SatelliteBead[]>([]);
  const bubblesRef = useRef<RisingBubble[]>([]);

  // Spawn outward water-droplet spray from pill perimeter
  const spawnOutwardSpray = useCallback((rect: DOMRect) => {
    const cx = rect.left + rect.width / 2;
    const cy = rect.top + rect.height / 2;
    const rx = rect.width / 2;
    const ry = rect.height / 2;

    rippleRingsRef.current.push(
      {
        x: cx,
        y: cy,
        r: Math.max(rx, ry) * 0.75,
        maxR: Math.max(window.innerWidth, window.innerHeight) * 0.42,
        speed: 7.5,
        alpha: 0.42,
        lineWidth: 2.2,
      },
      {
        x: cx,
        y: cy,
        r: Math.max(rx, ry) * 0.55,
        maxR: Math.max(window.innerWidth, window.innerHeight) * 0.34,
        speed: 5.4,
        alpha: 0.28,
        lineWidth: 1.4,
      }
    );

    const count = 92;
    for (let i = 0; i < count; i++) {
      const baseAngle = (i / count) * Math.PI * 2 + (Math.random() - 0.5) * 0.14;
      const cosA = Math.cos(baseAngle);
      const sinA = Math.sin(baseAngle);

      const perimeterFactor = 0.72 + Math.random() * 0.28;
      const startX = cx + cosA * rx * perimeterFactor;
      const startY = cy + sinA * ry * perimeterFactor;

      const isMist = i % 3 === 0;
      const speed = isMist ? 4.2 + Math.random() * 7.2 : 5.8 + Math.random() * 10.4;
      const radius = isMist ? 1.4 + Math.random() * 2.1 : 2.8 + Math.random() * 4.4;

      sprayDropletsRef.current.push({
        x: startX,
        y: startY,
        vx: cosA * speed,
        vy: sinA * speed - (0.6 + Math.random() * 1.4),
        r: radius,
        alpha: 0.88 + Math.random() * 0.12,
        decay: isMist ? 0.014 + Math.random() * 0.008 : 0.011 + Math.random() * 0.007,
        drag: 0.958 + Math.random() * 0.014,
        gravity: 0.14 + Math.random() * 0.09,
        stretchFactor: 0.065,
      });
    }
  }, []);

  // Spawn inward reverse droplets when resetting
  const spawnResetBurst = useCallback(() => {
    const panelEl = liquidPanelRef.current;
    if (!panelEl) return;

    const rect = panelEl.getBoundingClientRect();
    const cx = rect.left + rect.width / 2;
    const cy = rect.top + rect.height / 2;

    const count = 48;
    for (let i = 0; i < count; i++) {
      const angle = (i / count) * Math.PI * 2 + Math.random() * 0.15;
      const dist = 140 + Math.random() * 110;
      const sx = cx + Math.cos(angle) * dist;
      const sy = cy + Math.sin(angle) * dist;
      const speed = 5.5 + Math.random() * 5.0;

      sprayDropletsRef.current.push({
        x: sx,
        y: sy,
        vx: -Math.cos(angle) * speed,
        vy: -Math.sin(angle) * speed,
        r: 2.2 + Math.random() * 3.4,
        alpha: 0.85,
        decay: 0.018,
        drag: 0.96,
        gravity: 0,
        stretchFactor: 0.06,
      });
    }
  }, []);

  const handleSignUpClick = () => {
    if (stage !== 'button') return;
    setIsPressing(true);

    const btnEl = pillBtnRef.current;
    const rect = btnEl
      ? btnEl.getBoundingClientRect()
      : new DOMRect(window.innerWidth / 2 - 110, window.innerHeight / 2 - 34, 220, 68);

    window.setTimeout(() => {
      setIsPressing(false);
      setStage('spraying');
      spawnOutwardSpray(rect);

      window.setTimeout(() => {
        setStage('panel');
      }, 220);
    }, 95);
  };

  const handleReset = () => {
    if (stage !== 'panel') return;
    setStage('resetting');
    spawnResetBurst();

    window.setTimeout(() => {
      setIsSubmitted(false);
      setFullName('');
      setEmail('');
      setPassword('');
      setShowPassword(false);
      setStage('button');
    }, 340);
  };

  const handleFormSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault();
    if (!fullName.trim() || !email.trim() || password.length < 6) return;

    setIsSubmitting(true);
    try {
      if (onSubmit) {
        await onSubmit({
          fullName: fullName.trim(),
          email: email.trim(),
          password,
        });
      }
      setIsSubmitted(true);
    } finally {
      setIsSubmitting(false);
    }
  };

  // Spawn interactive cluster of micro-bubbles on panel click
  const handlePanelClick = (e: React.MouseEvent<HTMLDivElement>) => {
    const target = e.target as HTMLElement;
    if (target.closest('input, button, label')) return;

    const panelEl = liquidPanelRef.current;
    if (!panelEl) return;

    const rect = panelEl.getBoundingClientRect();
    const clickX = e.clientX - rect.left;
    const clickY = e.clientY - rect.top;

    for (let i = 0; i < 6; i++) {
      const r = 2.0 + Math.random() * 3.8;
      bubblesRef.current.push({
        x: clickX + (Math.random() - 0.5) * 18,
        y: clickY + (Math.random() - 0.5) * 12,
        r,
        vy: 0.65 + (r / 7) * 0.95 + Math.random() * 0.4,
        wobbleAmp: 4 + Math.random() * 8,
        wobbleFreq: 0.02 + Math.random() * 0.02,
        phase: Math.random() * Math.PI * 2,
        squishPhase: Math.random() * Math.PI * 2,
        alpha: 0.85,
        maxAlpha: 0.85,
        state: 'rising',
        flattenProgress: 0,
        flatScaleX: 1,
        flatScaleY: 1,
      });
    }
  };

  const handlePanelPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
    const panelEl = liquidPanelRef.current;
    if (!panelEl) return;
    const rect = panelEl.getBoundingClientRect();
    panelPointerRef.current = {
      x: e.clientX - rect.left,
      y: e.clientY - rect.top,
      active: true,
    };
  };

  const handlePanelPointerLeave = () => {
    panelPointerRef.current.active = false;
  };

  // Master Initialization & 60fps Animation Loop
  useEffect(() => {
    const sprayCanvas = sprayCanvasRef.current;
    const panelEl = liquidPanelRef.current;
    const edgeSvg = edgeSvgRef.current;
    const edgeBaseRect = edgeBaseRectRef.current;
    const edgeDropsGroup = edgeDropsGroupRef.current;
    const rimCanvas = rimCanvasRef.current;
    const bubbleCanvas = bubbleCanvasRef.current;

    if (
      !sprayCanvas ||
      !panelEl ||
      !edgeSvg ||
      !edgeBaseRect ||
      !edgeDropsGroup ||
      !rimCanvas ||
      !bubbleCanvas
    ) {
      return;
    }

    const sprayCtx = sprayCanvas.getContext('2d');
    const rimCtx = rimCanvas.getContext('2d');
    const bubbleCtx = bubbleCanvas.getContext('2d');
    if (!sprayCtx || !rimCtx || !bubbleCtx) return;

    const svgNS = 'http://www.w3.org/2000/svg';

    // 1. Initialize Perimeter Edge Droplets, Lower Micro-Teardrops, and Satellite Beads
    edgeDropsGroup.innerHTML = '';
    const edgeDroplets: EdgeDroplet[] = [];
    const edgeDropEls: SVGCircleElement[] = [];
    const edgeCount = 30;

    for (let i = 0; i < edgeCount; i++) {
      const u = (i / edgeCount + (Math.random() - 0.5) * 0.012 + 1) % 1;
      const baseR = 3.2 + Math.random() * 4.4;
      const circle = document.createElementNS(svgNS, 'circle');
      circle.setAttribute('fill', 'rgba(255, 255, 255, 0.24)');
      edgeDropsGroup.appendChild(circle);

      edgeDroplets.push({
        u,
        baseR,
        phase: Math.random() * Math.PI * 2,
        freq: 0.014 + Math.random() * 0.016,
        driftSpeed: (Math.random() - 0.5) * 0.00018,
        outwardBias: 0.35 + Math.random() * 0.35,
      });
      edgeDropEls.push(circle);
    }

    const microTears: MicroTear[] = [];
    const microTearEls: SVGEllipseElement[] = [];
    const tearAnchors = [0.43, 0.47, 0.51, 0.55, 0.59, 0.63, 0.67];
    tearAnchors.forEach((uBase, idx) => {
      const u = uBase + (Math.random() - 0.5) * 0.012;
      const r = 2.4 + (idx % 3) * 0.85;
      const el = document.createElementNS(svgNS, 'ellipse');
      el.setAttribute('fill', 'rgba(255, 255, 255, 0.28)');
      edgeDropsGroup.appendChild(el);

      microTears.push({
        u,
        r,
        phase: Math.random() * Math.PI * 2,
        hang: 2.2 + Math.random() * 2.6,
      });
      microTearEls.push(el);
    });

    const satelliteBeads: SatelliteBead[] = [];
    for (let i = 0; i < 26; i++) {
      satelliteBeads.push({
        u: Math.random(),
        offsetOut: 4.5 + Math.random() * 9.5,
        r: 1.0 + Math.random() * 1.9,
        phase: Math.random() * Math.PI * 2,
        alpha: 0.45 + Math.random() * 0.42,
      });
    }

    edgeDropletsRef.current = edgeDroplets;
    edgeDropElsRef.current = edgeDropEls;
    microTearsRef.current = microTears;
    microTearElsRef.current = microTearEls;
    satelliteBeadsRef.current = satelliteBeads;

    // 2. Initialize Interior Upward-Bubbling Droplets
    const createBubble = (initialY?: number): RisingBubble => {
      const m = panelMetricsRef.current;
      const r = 2.1 + Math.random() * 5.2;
      return {
        x: 22 + Math.random() * Math.max(80, m.w - 44),
        y: initialY !== undefined ? initialY : m.h - 10 - Math.random() * 26,
        r,
        vy: 0.48 + (r / 7.5) * 0.88 + Math.random() * 0.32,
        wobbleAmp: 5 + Math.random() * 11,
        wobbleFreq: 0.015 + Math.random() * 0.018,
        phase: Math.random() * Math.PI * 2,
        squishPhase: Math.random() * Math.PI * 2,
        alpha: initialY !== undefined ? 0.55 + Math.random() * 0.35 : 0,
        maxAlpha: 0.52 + Math.random() * 0.38,
        state: 'rising',
        flattenProgress: 0,
        flatScaleX: 1,
        flatScaleY: 1,
      };
    };

    const initialBubbles: RisingBubble[] = [];
    for (let i = 0; i < 52; i++) {
      initialBubbles.push(createBubble(28 + Math.random() * 410));
    }
    bubblesRef.current = initialBubbles;

    // 3. Resize & Sync Canvases and Panel Geometry
    const syncDimensions = () => {
      const dpr = Math.min(window.devicePixelRatio || 1, 2);

      // Spray Canvas
      sprayCanvas.width = Math.floor(window.innerWidth * dpr);
      sprayCanvas.height = Math.floor(window.innerHeight * dpr);
      sprayCtx.setTransform(dpr, 0, 0, dpr, 0, 0);

      // Panel & Perimeter Layers
      const rect = panelEl.getBoundingClientRect();
      const w = rect.width || 420;
      const h = rect.height || 460;
      const pad = 24;
      const svgW = w + pad * 2;
      const svgH = h + pad * 2;

      panelMetricsRef.current = { w, h, pad, svgW, svgH, radius: 28 };

      edgeSvg.setAttribute('viewBox', `0 0 ${svgW} ${svgH}`);
      edgeBaseRect.setAttribute('x', String(pad));
      edgeBaseRect.setAttribute('y', String(pad));
      edgeBaseRect.setAttribute('width', String(w));
      edgeBaseRect.setAttribute('height', String(h));
      edgeBaseRect.setAttribute('rx', '28');

      rimCanvas.width = Math.floor(svgW * dpr);
      rimCanvas.height = Math.floor(svgH * dpr);
      rimCtx.setTransform(dpr, 0, 0, dpr, 0, 0);

      bubbleCanvas.width = Math.floor(w * dpr);
      bubbleCanvas.height = Math.floor(h * dpr);
      bubbleCtx.setTransform(dpr, 0, 0, dpr, 0, 0);
    };

    syncDimensions();
    window.addEventListener('resize', syncDimensions);

    const resizeObserver = new ResizeObserver(() => {
      syncDimensions();
    });
    resizeObserver.observe(panelEl);

    // 4. Unified 60fps Animation Loop
    let rafId = 0;
    let tick = 0;

    const animate = () => {
      tick += 1;

      // --- A. Full-Viewport Spray & Ripple Canvas ---
      sprayCtx.clearRect(0, 0, window.innerWidth, window.innerHeight);

      for (let i = rippleRingsRef.current.length - 1; i >= 0; i--) {
        const ring = rippleRingsRef.current[i];
        ring.r += ring.speed;
        ring.speed *= 0.985;
        ring.alpha *= 0.968;

        if (ring.alpha <= 0.01 || ring.r >= ring.maxR) {
          rippleRingsRef.current.splice(i, 1);
          continue;
        }

        sprayCtx.save();
        sprayCtx.beginPath();
        sprayCtx.arc(ring.x, ring.y, ring.r, 0, Math.PI * 2);
        sprayCtx.strokeStyle = `rgba(255, 255, 255, ${ring.alpha.toFixed(3)})`;
        sprayCtx.lineWidth = ring.lineWidth;
        sprayCtx.stroke();
        sprayCtx.restore();
      }

      for (let i = sprayDropletsRef.current.length - 1; i >= 0; i--) {
        const drop = sprayDropletsRef.current[i];
        drop.vx *= drop.drag;
        drop.vy = drop.vy * drop.drag + drop.gravity;
        drop.x += drop.vx;
        drop.y += drop.vy;
        drop.alpha -= drop.decay;

        if (drop.alpha <= 0.01) {
          sprayDropletsRef.current.splice(i, 1);
          continue;
        }

        drawGlossyDroplet(
          sprayCtx,
          drop.x,
          drop.y,
          drop.r,
          drop.alpha,
          drop.vx,
          drop.vy,
          drop.stretchFactor
        );
      }

      // --- B. Panel Perimeter & Interior Droplet Simulations (Active when Panel Visible) ---
      const currentStage = stageRef.current;
      if (currentStage === 'panel' || currentStage === 'resetting') {
        const m = panelMetricsRef.current;
        const ptr = panelPointerRef.current;

        // B1. Perimeter Water-Droplet Edge Layer
        rimCtx.clearRect(0, 0, m.svgW, m.svgH);

        for (let i = 0; i < edgeDropletsRef.current.length; i++) {
          const d = edgeDropletsRef.current[i];
          const el = edgeDropElsRef.current[i];
          d.u = (d.u + d.driftSpeed + 1) % 1;

          const pt = pointOnRoundedRect(d.u, m.pad, m.pad, m.w, m.h, m.radius);
          const breathe = 1 + 0.16 * Math.sin(tick * d.freq + d.phase);
          let r = d.baseR * breathe;

          if (ptr.active) {
            const localX = pt.x - m.pad;
            const localY = pt.y - m.pad;
            const dist = Math.hypot(localX - ptr.x, localY - ptr.y);
            if (dist < 72) {
              r *= 1 + (1 - dist / 72) * 0.34;
            }
          }

          const cx = pt.x + pt.nx * (r * d.outwardBias);
          const cy = pt.y + pt.ny * (r * d.outwardBias);

          el.setAttribute('cx', cx.toFixed(2));
          el.setAttribute('cy', cy.toFixed(2));
          el.setAttribute('r', r.toFixed(2));

          drawGlossyDroplet(rimCtx, cx, cy, r * 0.94, 0.84);
        }

        // Lower-rim micro-teardrops
        for (let i = 0; i < microTearsRef.current.length; i++) {
          const t = microTearsRef.current[i];
          const el = microTearElsRef.current[i];
          const pt = pointOnRoundedRect(t.u, m.pad, m.pad, m.w, m.h, m.radius);

          const pulse = Math.sin(tick * 0.022 + t.phase);
          const ry = t.r * (1.28 + 0.24 * pulse);
          const rx = t.r * (0.86 - 0.08 * pulse);
          const cx = pt.x;
          const cy = pt.y + t.hang + pulse * 1.1;

          el.setAttribute('cx', cx.toFixed(2));
          el.setAttribute('cy', cy.toFixed(2));
          el.setAttribute('rx', rx.toFixed(2));
          el.setAttribute('ry', ry.toFixed(2));

          drawGlossyDroplet(rimCtx, cx, cy, t.r * 0.92, 0.88, 0, 1, 0.05, 0.88, 1.24);
        }

        // Tiny satellite condensation micro-beads
        for (let i = 0; i < satelliteBeadsRef.current.length; i++) {
          const s = satelliteBeadsRef.current[i];
          const pt = pointOnRoundedRect(s.u, m.pad, m.pad, m.w, m.h, m.radius);
          const shimmer = 0.72 + 0.28 * Math.sin(tick * 0.025 + s.phase);
          let r = s.r * shimmer;

          if (ptr.active) {
            const dist = Math.hypot(pt.x - m.pad - ptr.x, pt.y - m.pad - ptr.y);
            if (dist < 64) {
              r *= 1 + (1 - dist / 64) * 0.45;
            }
          }

          const cx = pt.x + pt.nx * s.offsetOut;
          const cy = pt.y + pt.ny * s.offsetOut;
          drawGlossyDroplet(rimCtx, cx, cy, r, s.alpha * shimmer);
        }

        // B2. Interior Upward-Bubbling Droplets
        bubbleCtx.clearRect(0, 0, m.w, m.h);

        for (let i = bubblesRef.current.length - 1; i >= 0; i--) {
          const b = bubblesRef.current[i];

          if (b.state === 'rising') {
            b.y -= b.vy;
            const wobbleX = Math.sin(tick * b.wobbleFreq + b.phase) * b.wobbleAmp;
            const currentX = b.x + wobbleX;

            if (b.alpha < b.maxAlpha) {
              b.alpha = Math.min(b.maxAlpha, b.alpha + 0.028);
            }

            if (ptr.active) {
              const dx = currentX - ptr.x;
              const dy = b.y - ptr.y;
              const dist = Math.hypot(dx, dy);
              if (dist > 0.1 && dist < 76) {
                const push = (1 - dist / 76) * 1.45;
                b.x += (dx / dist) * push;
                b.y += (dy / dist) * push * 0.6;
              }
            }

            b.x = Math.max(16, Math.min(m.w - 16, b.x));

            const breathe = 0.07 * Math.sin(tick * 0.055 + b.squishPhase);
            const sx = 1 - breathe;
            const sy = 1 + breathe;

            if (b.y <= 15 + b.r) {
              b.state = 'flattening';
              b.y = 14 + b.r * 0.65;
            }

            drawGlossyDroplet(bubbleCtx, currentX, b.y, b.r, b.alpha, 0, 0, 0, sx, sy);
          } else {
            b.flattenProgress += 0.045;
            const p = b.flattenProgress;
            const currentX = b.x + Math.sin(tick * b.wobbleFreq + b.phase) * b.wobbleAmp;
            const sx = 1 + p * 0.65;
            const sy = Math.max(0.28, 1 - p * 0.68);
            const fadeAlpha = b.alpha * Math.max(0, 1 - p);

            drawGlossyDroplet(bubbleCtx, currentX, b.y, b.r, fadeAlpha, 0, 0, 0, sx, sy);

            if (p >= 1) {
              if (bubblesRef.current.length > 52) {
                bubblesRef.current.splice(i, 1);
              } else {
                bubblesRef.current[i] = createBubble();
              }
            }
          }
        }
      }

      rafId = window.requestAnimationFrame(animate);
    };

    rafId = window.requestAnimationFrame(animate);

    return () => {
      window.cancelAnimationFrame(rafId);
      window.removeEventListener('resize', syncDimensions);
      resizeObserver.disconnect();
    };
  }, []);

  const isPanelVisible = stage === 'panel';
  const isButtonHidden = stage !== 'button';

  return (
    <div className={`lws-root ${className}`.trim()}>
      <style>{SCOPED_STYLES}</style>

      {/* Hidden SVG Liquid Metaball Gooey Filters */}
      <svg className="lws-svg-defs" aria-hidden="true">
        <defs>
          <filter id={btnGooId}>
            <feGaussianBlur in="SourceGraphic" stdDeviation="6.5" result="blur" />
            <feColorMatrix
              in="blur"
              mode="matrix"
              values="
                1 0 0 0 0
                0 1 0 0 0
                0 0 1 0 0
                0 0 0 22 -9"
              result="goo"
            />
            <feComposite in="SourceGraphic" in2="goo" operator="atop" />
          </filter>

          <filter id={panelGooId}>
            <feGaussianBlur in="SourceGraphic" stdDeviation="9" result="blur" />
            <feColorMatrix
              in="blur"
              mode="matrix"
              values="
                1 0 0 0 0
                0 1 0 0 0
                0 0 1 0 0
                0 0 0 20 -8"
              result="goo"
            />
            <feComposite in="SourceGraphic" in2="goo" operator="atop" />
          </filter>

          <filter id={panelEdgeGooId} x="-15%" y="-15%" width="130%" height="130%">
            <feGaussianBlur in="SourceGraphic" stdDeviation="3.4" result="blur" />
            <feColorMatrix
              in="blur"
              mode="matrix"
              values="
                1 0 0 0 0
                0 1 0 0 0
                0 0 1 0 0
                0 0 0 24 -9"
              result="goo"
            />
            <feComposite in="SourceGraphic" in2="goo" operator="atop" />
          </filter>
        </defs>
      </svg>

      {/* Full-Viewport 60fps Outward Water-Droplet Spray Canvas */}
      <canvas ref={sprayCanvasRef} className="lws-spray-canvas" aria-hidden="true" />

      {/* STAGE 1: Borderless Pill-Shaped Liquid-Water Sign Up Button */}
      <div className={`lws-button-stage ${isButtonHidden ? 'is-hidden' : ''}`}>
        <button
          ref={pillBtnRef}
          type="button"
          className={`lws-pill-btn ${isPressing ? 'is-pressing' : ''}`}
          aria-label="Sign Up"
          onClick={handleSignUpClick}
        >
          <svg
            className="lws-pill-liquid-svg"
            viewBox="0 0 220 68"
            preserveAspectRatio="none"
            aria-hidden="true"
          >
            <g filter={`url(#${btnGooId})`}>
              <circle className="lws-btn-bead lws-btn-bead-1" cx="48" cy="34" r="15" />
              <circle className="lws-btn-bead lws-btn-bead-2" cx="96" cy="38" r="18" />
              <circle className="lws-btn-bead lws-btn-bead-3" cx="148" cy="31" r="16" />
              <circle className="lws-btn-bead lws-btn-bead-4" cx="182" cy="37" r="13" />
              <circle className="lws-btn-bead lws-btn-bead-5" cx="72" cy="26" r="11" />
              <circle className="lws-btn-bead lws-btn-bead-6" cx="125" cy="42" r="14" />
              <circle className="lws-btn-bead lws-btn-bead-7" cx="164" cy="25" r="10" />
            </g>
          </svg>
          <span className="lws-pill-label">Sign Up</span>
        </button>
      </div>

      {/* STAGE 2: Rounded-Rectangle Liquid-Glass Create Account Panel */}
      <section
        className={`lws-panel-stage ${isPanelVisible ? 'is-visible' : ''}`}
        aria-hidden={!isPanelVisible}
      >
        <div className="lws-panel-wrapper">
          {/* Synchronized Clinging Water-Droplet Edges Around the 28px Rounded Rectangle */}
          <div className="lws-panel-edge-layer" aria-hidden="true">
            <svg
              ref={edgeSvgRef}
              className="lws-panel-edge-svg"
              viewBox="0 0 468 508"
              preserveAspectRatio="none"
            >
              <g filter={`url(#${panelEdgeGooId})`}>
                <rect
                  ref={edgeBaseRectRef}
                  x="24"
                  y="24"
                  width="420"
                  height="460"
                  rx="28"
                  fill="none"
                  stroke="rgba(255, 255, 255, 0.22)"
                  strokeWidth="2.5"
                />
                <g ref={edgeDropsGroupRef} />
              </g>
            </svg>
            <canvas ref={rimCanvasRef} className="lws-panel-rim-canvas" />
          </div>

          <div
            ref={liquidPanelRef}
            className="lws-liquid-panel"
            onClick={handlePanelClick}
            onPointerMove={handlePanelPointerMove}
            onPointerLeave={handlePanelPointerLeave}
          >
            {/* Layer A: Interior Gooey Bottom Meniscus + Rising Viscous Globules */}
            <svg
              className="lws-panel-goo-svg"
              viewBox="0 0 420 460"
              preserveAspectRatio="none"
              aria-hidden="true"
            >
              <g filter={`url(#${panelGooId})`}>
                <path
                  className="lws-panel-meniscus"
                  d="M-10,446 Q105,436 210,445 T430,444 L430,480 L-10,480 Z"
                />
                <circle className="lws-goo-riser lws-goo-riser-1" cx="46" cy="452" r="15" />
                <circle className="lws-goo-riser lws-goo-riser-2" cx="102" cy="456" r="19" />
                <circle className="lws-goo-riser lws-goo-riser-3" cx="164" cy="450" r="13" />
                <circle className="lws-goo-riser lws-goo-riser-4" cx="224" cy="455" r="20" />
                <circle className="lws-goo-riser lws-goo-riser-5" cx="282" cy="451" r="14" />
                <circle className="lws-goo-riser lws-goo-riser-6" cx="338" cy="456" r="18" />
                <circle className="lws-goo-riser lws-goo-riser-7" cx="384" cy="450" r="12" />
                <circle className="lws-goo-riser lws-goo-riser-8" cx="136" cy="458" r="16" />
              </g>
            </svg>

            {/* Layer B: High-DPI Rising Water Droplets Canvas */}
            <canvas
              ref={bubbleCanvasRef}
              className="lws-panel-bubble-canvas"
              aria-hidden="true"
            />

            {/* Elevated Front Input Column (z-index: 10 — Strictly in Front of Bubbles) */}
            <div className="lws-panel-content">
              {!isSubmitted ? (
                <div>
                  <header className="lws-panel-header">
                    <div className="lws-panel-badge">
                      <span className="lws-badge-dot" />
                      <span>Pure Liquid Access</span>
                    </div>
                    <h1 className="lws-panel-title">Create Account</h1>
                    <p className="lws-panel-subtitle">
                      Enter your details to step into the monochrome workspace.
                    </p>
                  </header>

                  <form className="lws-form-column" onSubmit={handleFormSubmit} noValidate>
                    <div className="lws-field-group">
                      <label className="lws-field-label" htmlFor={`${uid}-full-name`}>
                        Full Name
                      </label>
                      <div className="lws-input-shield">
                        <input
                          id={`${uid}-full-name`}
                          name="fullName"
                          type="text"
                          placeholder="Alex Mercer"
                          autoComplete="name"
                          required
                          value={fullName}
                          onChange={(e) => setFullName(e.target.value)}
                        />
                      </div>
                    </div>

                    <div className="lws-field-group">
                      <label className="lws-field-label" htmlFor={`${uid}-email`}>
                        Email Address
                      </label>
                      <div className="lws-input-shield">
                        <input
                          id={`${uid}-email`}
                          name="email"
                          type="email"
                          placeholder="alex@domain.com"
                          autoComplete="email"
                          required
                          value={email}
                          onChange={(e) => setEmail(e.target.value)}
                        />
                      </div>
                    </div>

                    <div className="lws-field-group">
                      <label className="lws-field-label" htmlFor={`${uid}-password`}>
                        Password
                      </label>
                      <div className="lws-input-shield">
                        <input
                          id={`${uid}-password`}
                          name="password"
                          type={showPassword ? 'text' : 'password'}
                          className="has-toggle"
                          placeholder="Minimum 6 characters"
                          autoComplete="new-password"
                          minLength={6}
                          required
                          value={password}
                          onChange={(e) => setPassword(e.target.value)}
                        />
                        <button
                          type="button"
                          className="lws-eye-toggle"
                          aria-label={showPassword ? 'Hide password' : 'Show password'}
                          aria-pressed={showPassword}
                          onClick={() => setShowPassword((prev) => !prev)}
                        >
                          {!showPassword ? (
                            <svg
                              width="17"
                              height="17"
                              viewBox="0 0 24 24"
                              fill="none"
                              stroke="currentColor"
                              strokeWidth="1.8"
                              strokeLinecap="round"
                              strokeLinejoin="round"
                            >
                              <path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z" />
                              <circle cx="12" cy="12" r="3" />
                            </svg>
                          ) : (
                            <svg
                              width="17"
                              height="17"
                              viewBox="0 0 24 24"
                              fill="none"
                              stroke="currentColor"
                              strokeWidth="1.8"
                              strokeLinecap="round"
                              strokeLinejoin="round"
                            >
                              <path d="M17.94 17.94A10.94 10.94 0 0 1 12 19c-6.5 0-10-7-10-7a21.77 21.77 0 0 1 5.06-5.94" />
                              <path d="M9.9 4.24A9.12 9.12 0 0 1 12 4c6.5 0 10 7 10 7a21.8 21.8 0 0 1-3.17 4.27" />
                              <path d="M14.12 14.12a3 3 0 1 1-4.24-4.24" />
                              <line x1="2" y1="2" x2="22" y2="22" />
                            </svg>
                          )}
                        </button>
                      </div>
                    </div>

                    <button type="submit" className="lws-submit-btn" disabled={isSubmitting}>
                      {isSubmitting ? 'Creating Account...' : 'Create Account'}
                    </button>
                  </form>
                </div>
              ) : (
                <div className="lws-confirmation-view" role="status" aria-live="polite">
                  <div className="lws-confirm-icon">
                    <svg
                      width="26"
                      height="26"
                      viewBox="0 0 24 24"
                      fill="none"
                      stroke="currentColor"
                      strokeWidth="2.2"
                      strokeLinecap="round"
                      strokeLinejoin="round"
                    >
                      <polyline points="20 6 9 17 4 12" />
                    </svg>
                  </div>
                  <h2 className="lws-confirm-title">Account Created</h2>
                  <p className="lws-confirm-desc">
                    Welcome, <strong>{fullName.trim()}</strong>. Your credentials have been
                    registered under <strong>{email.trim()}</strong>.
                  </p>
                  <button
                    type="button"
                    className="lws-secondary-btn"
                    onClick={() => setIsSubmitted(false)}
                  >
                    Back to Form
                  </button>
                </div>
              )}
            </div>
          </div>
        </div>

        {/* Reset Pill Below Panel */}
        <button
          type="button"
          className="lws-reset-pill"
          aria-label="Reset transition"
          onClick={handleReset}
        >
          <svg
            width="13"
            height="13"
            viewBox="0 0 24 24"
            fill="none"
            stroke="currentColor"
            strokeWidth="2"
            strokeLinecap="round"
            strokeLinejoin="round"
          >
            <path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
            <path d="M3 3v5h5" />
          </svg>
          <span>Reset</span>
        </button>
      </section>
    </div>
  );
};

export default LiquidWaterSignUp;

More by pstzx

View all
  • Button Payment

    Button Payment

    106
  • Contour Land Map

    Contour Land Map

    29
  • Sign In Water Effect Glass

    Sign In Water Effect Glass

    25
  • Contour line Mountain

    Contour line Mountain

    22
  • 21 st Contour Line

    21 st Contour Line

    12
  • Contour line map

    Contour line map

    11
  • Card Dashboard Analytic

    Card Dashboard Analytic

    9
  • Loading Screen Glass

    Loading Screen Glass

    8