:root {
  --fondo: #ffffff;
  --inchiostro: #141318;
  --crema: #f4f2fb;
  --viola: #5a48ee;
  --viola-scuro: #3a2bb8;
  --lilla: #d9d3ff;
  --sabbia: #f2dcbc;
  --menta: #cfeedd;
  --grigio: #85838f;
}

@property --hw {
  syntax: "<number>";
  inherits: true;
  initial-value: 100;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.frame {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 16px;
  width: min(340px, 92vw);
  height: min(150px, 40vh);
}

/* the pill: the button for GSAP (scale), the body inside for CSS (the elastic swell on hover) */
.c {
  --ring: #1b1a21;
  --hw: 100;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  height: 60px;
  padding: 0 24px 0 15px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--crema);
  font: inherit;
  font-size: 16px;
  font-weight: 590;
  letter-spacing: -0.005em;
  cursor: pointer;
  isolation: isolate;
  max-width: 92vw;
  -webkit-tap-highlight-color: transparent;
  transition: --hw 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}
.c:focus-visible { outline: 2px solid var(--viola); outline-offset: 5px; }

.c__body {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  transition: inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}
.c__skin, .c__ok, .c__prog, .c__glow, .c__sheen {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.c__skin {
  background: linear-gradient(180deg, #2a2932 0%, #19181e 52%, #0e0d12 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.55),
    0 1px 1px rgba(20, 19, 24, 0.18),
    0 6px 14px -6px rgba(20, 19, 24, 0.32),
    0 24px 40px -22px rgba(20, 19, 24, 0.6);
}
/* the violet of the merged state, with its own deeper shadow */
.c__ok {
  opacity: 0;
  background:
    radial-gradient(120% 140% at 30% 0%, rgba(255, 255, 255, 0.22), transparent 55%),
    linear-gradient(180deg, #6d5cff 0%, var(--viola) 50%, var(--viola-scuro) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -1px 0 rgba(20, 10, 80, 0.45),
    0 1px 1px rgba(58, 43, 184, 0.2),
    0 8px 16px -6px rgba(90, 72, 238, 0.42),
    0 26px 44px -20px rgba(58, 43, 184, 0.6);
}
/* the progress band that fills the pill while the records merge, with a bright leading edge */
.c__prog { overflow: hidden; }
.c__prog-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(160, 148, 255, 0.04), rgba(160, 148, 255, 0.15) 86%, rgba(200, 192, 255, 0.42) 97%, rgba(214, 208, 255, 0.12) 100%);
  transform: translateX(-101%);
}
.c__glow {
  overflow: hidden;
  opacity: 0;
  background: radial-gradient(110px 70px at var(--gx, 50%) var(--gy, 50%), rgba(222, 216, 255, 0.18), transparent 70%);
}
.c__sheen {
  overflow: hidden;
  opacity: 0;
  background: linear-gradient(100deg, transparent 32%, rgba(255, 255, 255, 0.34) 48%, transparent 62%);
  background-size: 260% 100%;
  background-position: 120% 0;
}

/* the three copies of the same contact: an avatar stack, centred in its window */
.c__stack {
  position: relative;
  flex: none;
  width: 54px;
  height: 30px;
}
.av {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
}
.av__in {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 9.5px;
  font-weight: 680;
  letter-spacing: 0.02em;
  font-variation-settings: "wdth" 110;
  color: #2a2338;
  box-shadow:
    0 0 0 2px var(--ring),
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    inset 0 -1px 2px rgba(0, 0, 0, 0.12);
}
.av--a { z-index: 3; }
.av--b { z-index: 2; }
.av--c { z-index: 1; }
.av--a .av__in { background: radial-gradient(120% 120% at 30% 20%, #fff, var(--lilla) 60%, #bdb3ff); }
.av--b .av__in { background: radial-gradient(120% 120% at 30% 20%, #fff, var(--sabbia) 60%, #e4c497); color: #3a2a17; }
.av--c .av__in { background: radial-gradient(120% 120% at 30% 20%, #fff, var(--menta) 60%, #a9dcc2); color: #173a2a; }

/* the check of the contact that is left */
.av__badge {
  position: absolute;
  right: -4px;
  bottom: -3px;
  width: 14px;
  height: 14px;
  overflow: visible;
  filter: drop-shadow(0 1px 1px rgba(20, 10, 80, 0.35));
  opacity: 0;
}
.av__badge circle {
  fill: #fff;
  stroke: var(--viola);
  stroke-width: 1.4;
}
.av__badge path {
  fill: none;
  stroke: var(--viola);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the labels: measured at their widest, centred, narrowed on the wdth axis while they swap */
.c__labels {
  position: relative;
  display: block;
  height: 22px;
  overflow: hidden;
}
.c__label {
  --sq: 0;
  position: absolute;
  left: 50%;
  top: 0;
  width: max-content;
  height: 22px;
  line-height: 22px;
  white-space: nowrap;
  opacity: 0;
  font-variation-settings: "wdth" calc(var(--hw) - var(--sq) * 24);
}
.c__label[data-l="idle"] { opacity: 1; }

/* the line under the pill */
.note {
  position: relative;
  height: 18px;
  width: 100%;
  font-size: 13px;
  font-weight: 470;
  color: var(--grigio);
  white-space: nowrap;
}
.note__line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: block;
  text-align: center;
  height: 18px;
  line-height: 18px;
}
.note__line[data-n="done"] { opacity: 0; visibility: hidden; color: #4a4857; }
.note__sep { margin: 0 0.45em; opacity: 0.55; }
.note__roll {
  display: inline-block;
  height: 18px;
  line-height: 18px;
  overflow: hidden;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--inchiostro);
}
.note__roll span { display: inline-block; }
.note__undo {
  padding: 2px 8px;
  margin: -2px -8px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-weight: 620;
  color: var(--viola);
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease;
}
.note__undo:focus-visible { outline: 2px solid var(--viola); outline-offset: 1px; }

@media (hover: hover) and (pointer: fine) {
  .c:hover { --hw: 108; }
  .c:hover .c__body { inset: -2px -6px; }
  .note__undo:hover { background: rgba(90, 72, 238, 0.09); color: var(--viola-scuro); }
}
.c:active .c__body { inset: 1px 2px; }

@media (max-width: 400px) {
  .c { height: 56px; font-size: 15px; padding: 0 20px 0 13px; gap: 9px; }
  .note { font-size: 12px; }
}
