:root {
  --fondo: #ffffff;
  --inchiostro: #141519;
  --crema: #f4f1ea;
  --smeraldo: #16402f;
  --menta: #b8ebcd;
  --grigio: #8b8e94;
}

*, *::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;
}

/* the frame: the pill on top, the order total below, room between them for the token's arc */
.frame {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  width: min(330px, 94vw);
  height: min(150px, 40vh);
  padding-top: 10px;
}

/* the pill: the button for GSAP (scale), the shell for the swell, the layers inside for CSS */
.s {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  padding: 0 9px 0 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--crema);
  font: inherit;
  font-size: 16px;
  font-weight: 580;
  font-variation-settings: "wdth" 100;
  letter-spacing: -0.005em;
  cursor: pointer;
  isolation: isolate;
  max-width: 94vw;
  -webkit-tap-highlight-color: transparent;
}
.s:focus-visible { outline: 2px solid var(--menta); outline-offset: 5px; }

.s__shell {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
  box-shadow:
    0 1px 1px rgba(20, 21, 25, 0.16),
    0 6px 14px -6px rgba(20, 21, 25, 0.3),
    0 22px 40px -22px rgba(20, 21, 25, 0.55);
}
.s__skin, .s__fill, .s__glow, .s__sheen, .s__grain {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.s__skin {
  background: linear-gradient(180deg, #25262c 0%, var(--inchiostro) 58%, #0d0e11 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 -1px 0 rgba(0, 0, 0, 0.5);
}
/* the emerald that spreads from where the balance was */
.s__fill {
  background:
    radial-gradient(120% 140% at 80% 0%, rgba(184, 235, 205, 0.22), transparent 55%),
    linear-gradient(180deg, #1d5440 0%, var(--smeraldo) 60%, #0e2b20 100%);
  box-shadow: inset 0 1px 0 rgba(200, 255, 225, 0.22), inset 0 -1px 0 rgba(0, 0, 0, 0.4);
  clip-path: circle(0px at 85% 50%);
}
.s__glow {
  opacity: 0;
  background: radial-gradient(120px 80px at var(--gx, 50%) var(--gy, 50%), rgba(225, 255, 238, 0.14), transparent 70%);
}
.s__sheen {
  opacity: 0;
  background: linear-gradient(100deg, transparent 32%, rgba(225, 255, 238, 0.26) 48%, transparent 62%);
  background-size: 260% 100%;
  background-position: 120% 0;
}
.s__grain {
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the icon window: the credit tag at rest, a ring that draws while it checks, a tick when it is done */
.s__icon {
  position: relative;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.s__ring {
  position: absolute;
  inset: 0;
  width: 36px;
  height: 36px;
  transform: rotate(-90deg);
  overflow: visible;
}
.s__ring circle { fill: none; stroke-width: 1.4; }
.ring__track { stroke: rgba(255, 255, 255, 0); }
.ring__run { stroke: var(--menta); stroke-linecap: round; stroke-dasharray: 103.67; stroke-dashoffset: 103.67; opacity: 0; }
.s__tag, .s__check {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.s__tag svg, .s__check svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tag__hole { stroke-width: 1.3; }
.tag__line { opacity: 0.5; }
.s__check { color: var(--menta); opacity: 0; }
.s__check svg { stroke-width: 1.8; }

.s__labels {
  position: relative;
  display: block;
  height: 22px;
  overflow: hidden;
}
.s__label {
  position: absolute;
  left: 0;
  top: 0;
  width: max-content;
  height: 22px;
  line-height: 22px;
  white-space: nowrap;
  opacity: 0;
}
.s__label[data-l="idle"] { opacity: 1; }

/* the balance chip: the amount on its wheels, sunk into the pill */
.s__chip {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 640;
  font-variation-settings: "wdth" 104;
  color: #e6f7ec;
  font-feature-settings: "tnum" 1;
}
.chip__skin {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.32), rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 1px 0 rgba(255, 255, 255, 0.08);
}
.chip__left {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  width: 0;
  opacity: 0;
  font-weight: 520;
  color: rgba(230, 247, 236, 0.62);
}

/* the wheels: every digit is a column of 0-9 and a blank, moved with yPercent */
.odo {
  display: inline-flex;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
  white-space: nowrap;
}
.odo__ch { display: inline-block; }
.odo__col {
  display: inline-block;
  overflow: hidden;
  height: 1.2em;
  text-align: center;
}
.odo__stack { display: block; }
.odo__stack > span { display: block; height: 1.2em; }

/* the order total under the pill */
.note {
  position: absolute;
  left: 0;
  right: 0;
  top: 100px;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 480;
  color: var(--grigio);
  white-space: nowrap;
}
.note__total {
  color: var(--inchiostro);
  font-weight: 660;
  font-size: 15px;
  font-variation-settings: "wdth" 108;
  font-feature-settings: "tnum" 1;
}
.note__badge, .token {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 660;
  font-variation-settings: "wdth" 104;
  color: #0f3a29;
  white-space: nowrap;
  font-feature-settings: "tnum" 1;
}
.badge__skin, .token__skin {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, #cdf3dc, var(--menta));
  box-shadow: inset 0 0 0 1px rgba(22, 64, 47, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.note__badge { isolation: isolate; opacity: 0; width: 0; padding: 0; overflow: hidden; }
.badge__txt { padding: 0 8px; }

/* the token that travels: placed by the script over the chip, then over the badge */
.token {
  position: absolute;
  z-index: 3;
  left: 0;
  top: 0;
  isolation: isolate;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 1px 1px rgba(14, 43, 32, 0.12), 0 8px 16px -8px rgba(14, 43, 32, 0.45);
}

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

@media (max-width: 400px) {
  .s { height: 56px; font-size: 15px; gap: 9px; padding: 0 8px 0 10px; }
  .s__chip { height: 38px; padding: 0 11px; font-size: 13px; }
  .note { top: 94px; }
}
