/* The Start wash button of a made-up smart washing machine app, alone on white. The pill is one <button> moved by
   GSAP (width, lift, press); its body, the light and the three faces (Start wash, the running programme with the
   time left, Done) sit inside it. The porthole on the left is a canvas (the drum and the water, redrawn every frame)
   under an SVG (the steel ring, the seal, the progress arc and the reflection on the glass). A GSAP element never
   has a transform in the CSS. */
:root {
  --page: #ffffff;            /* the page */
  --pill-top: #2a3039;        /* the top of the pill's body */
  --pill-bottom: #12151a;     /* the bottom of the pill's body */
  --ink: #f3f6f9;             /* the words on the pill */
  --muted: #8f99a6;           /* the small words */
  --water: #4fb6ff;           /* the water, the progress arc, the check */
  --water-deep: #1c6fd6;      /* the bottom of the water */
  --glass: #0b131d;           /* the glass of the porthole, inside */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.wrap {
  position: relative;
  width: min(320px, calc(100vw - 32px));
  height: 120px;
  display: grid;
  place-items: center;
}

/* the soft shadow the pill throws on the white floor */
.floor {
  position: absolute;
  left: 50%;
  top: calc(50% + 24px);
  width: 150px;
  height: 18px;
  margin-left: -75px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(18, 21, 26, 0.26), transparent);
  filter: blur(5px);
  pointer-events: none;
}

/* ---- the pill ---- */
.pill {
  position: relative;
  height: 60px;
  width: 172px;
  border: 0;
  border-radius: 30px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  outline: none;
  --mx: 50%;
  --wet: 0;
}
.pill:focus-visible .pill__edge { opacity: 1; box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px var(--water); }

.pill__body {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  background: linear-gradient(180deg, var(--pill-top), var(--pill-bottom));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(18, 21, 26, 0.9),
    0 1px 2px rgba(18, 21, 26, 0.28),
    0 6px 14px -4px rgba(18, 21, 26, 0.3),
    0 20px 40px -16px rgba(18, 21, 26, 0.42),
    0 26px 50px -24px rgba(28, 111, 214, calc(0.12 + var(--wet) * 0.38));
  isolation: isolate;
}

.pill__grain {
  position: absolute;
  inset: 0;
  opacity: 0.08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
  pointer-events: none;
}

/* the cold light the water throws inside the pill, behind the porthole */
.pill__glow {
  position: absolute;
  left: -30px;
  top: -30px;
  width: 140px;
  height: 120px;
  background: radial-gradient(closest-side, rgba(79, 182, 255, 0.32), rgba(79, 182, 255, 0) 100%);
  opacity: 0;
  pointer-events: none;
}

/* the 1px edge that takes the light where the pointer is */
.pill__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(150px 70px at var(--mx) 0%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.12) 60%, rgba(255, 255, 255, 0.04));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0.45;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.pill.is-hot .pill__edge { opacity: 1; }

/* ---- the porthole ---- */
.port {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  pointer-events: none;
}
/* the dark hollow the door sits in */
.port::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.port__inside {
  position: absolute;
  inset: 0;
  width: 44px;
  height: 44px;
}
.port__ring {
  position: absolute;
  inset: 0;
  width: 44px;
  height: 44px;
  overflow: visible;
  fill: none;
}
.ring__track { stroke: rgba(255, 255, 255, 0.07); stroke-width: 1.3; }
.ring__progress { stroke: var(--water); stroke-width: 1.3; stroke-linecap: round; }
.ring__steel { stroke-width: 3.6; }
.ring__seal { stroke: rgba(0, 0, 0, 0.55); stroke-width: 0.9; }
.ring__glare { stroke-width: 2.2; stroke-linecap: round; opacity: 0.85; }
.ring__glint { stroke: rgba(255, 255, 255, 0.35); stroke-width: 1.1; stroke-linecap: round; }

/* ---- the three faces ---- */
.face {
  position: absolute;
  left: 62px;
  top: 0;
  height: 60px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  pointer-events: none;
}

.face__word {
  font-size: 16px;
  font-weight: 620;
  font-stretch: 100%;
  letter-spacing: -0.01em;
  transition: font-stretch 0.35s cubic-bezier(.3, 1.4, .5, 1);
}
.pill.is-hot .face__word { font-stretch: 108%; }

.run__text {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.run__line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 620;
  letter-spacing: -0.01em;
}
.run__sep { color: var(--muted); }
.run__sub {
  display: block;
  height: 15px;
  overflow: hidden;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  font-stretch: 104%;
}
.run__subin { display: inline-block; }

/* the time left: one rolling strip per digit */
.time {
  display: inline-flex;
  align-items: center;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-stretch: 106%;
}
.time__colon { margin: 0 0.5px; transform: translateY(-1px); }
.dig {
  display: inline-block;
  height: 18px;
  overflow: hidden;
  -webkit-mask: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
  mask: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}
.dig__s {
  display: flex;
  flex-direction: column;
}
.dig__s span {
  height: 18px;
  line-height: 18px;
  text-align: center;
}

/* the pause / resume key at the right end */
.ctrl {
  margin-left: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.ctrl svg { width: 18px; height: 18px; fill: var(--ink); }

.done__ic {
  width: 20px;
  height: 20px;
  margin-right: 7px;
  fill: none;
  stroke: var(--water);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.done__word {
  font-size: 16px;
  font-weight: 640;
  letter-spacing: -0.01em;
}

/* the drawn pointer of the autopilot */
.ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  fill: #12151a;
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  opacity: 0;
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .face__word, .pill__edge { transition: none; }
}
