:root {
  --fondo: #ffffff;
  --inchiostro: #14161c;
  --crema: #f5efe4;
  --ottone: #d4ad68;
  --champagne: #ecd5a4;
  --telo: #f3ede1;
  --telo-retro: #e8dfcd;
  --grigio: #8b8a91;
}

*, *::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 shell for the swell, the layers inside for CSS */
.k {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  height: 60px;
  padding: 0 26px 0 15px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--crema);
  font: inherit;
  font-size: 16px;
  font-weight: 580;
  letter-spacing: -0.005em;
  cursor: pointer;
  isolation: isolate;
  max-width: 92vw;
  -webkit-tap-highlight-color: transparent;
}
.k:focus-visible { outline: 2px solid var(--ottone); outline-offset: 4px; }

.k__shell {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 999px;
  overflow: hidden;
  pointer-events: none;
  box-shadow:
    0 1px 1px rgba(20, 22, 28, 0.16),
    0 6px 14px -6px rgba(20, 22, 28, 0.32),
    0 24px 42px -22px rgba(20, 22, 28, 0.58);
}
.k__skin, .k__done, .k__glow, .k__sheen, .k__grain, .k__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.k__skin {
  background: linear-gradient(180deg, #262931 0%, var(--inchiostro) 56%, #0b0c10 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), inset 0 -1px 0 rgba(0, 0, 0, 0.55);
}
/* checked out: the pill warms up a shade, as if lit by the lobby */
.k__done {
  opacity: 0;
  background:
    radial-gradient(120% 140% at 18% 0%, rgba(236, 213, 164, 0.2), transparent 60%),
    linear-gradient(180deg, #2c2a26 0%, #191814 60%, #0e0d0b 100%);
  box-shadow: inset 0 1px 0 rgba(255, 236, 200, 0.2), inset 0 -1px 0 rgba(0, 0, 0, 0.55);
}
.k__glow {
  opacity: 0;
  background: radial-gradient(130px 80px at var(--gx, 50%) var(--gy, 50%), rgba(255, 232, 196, 0.16), transparent 70%);
}
.k__sheen {
  opacity: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 238, 210, 0.26) 48%, transparent 64%);
  background-size: 260% 100%;
  background-position: 120% 0;
}
.k__grain {
  opacity: 0.14;
  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");
}
.k__rim {
  opacity: 0;
  box-shadow: inset 0 0 0 1px rgba(236, 213, 164, 0.42);
}

/* the window: the folded towel at rest; opened, the sheet that folds itself; at the end the towel with its band */
.k__win {
  position: relative;
  flex: none;
  width: 32px;
  height: 30px;
  overflow: hidden;
}
.tw {
  position: absolute;
  left: 9px;
  top: 3px;
  width: 44px;
  height: 24px;
}
.tw__shadow {
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: -3px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.55), transparent);
  filter: blur(1px);
}
.tw__tilt, .tw__a, .tw__b { position: absolute; inset: 0; }
.tw__a, .tw__b { perspective: 80px; }
.tw__a { visibility: hidden; }
.tw__al { right: auto; width: 22px; }
.tw__ar, .tw__bt {
  position: absolute;
  transform-style: preserve-3d;
}
.tw__ar { left: 22px; top: 0; width: 22px; height: 24px; }
.tw__b .tw__bb { top: 12px; bottom: auto; width: 22px; height: 12px; }
.tw__bt { left: 0; top: 0; width: 22px; height: 12px; }

/* terry cloth: a fine rib, a woven champagne band near the hem, cream on the front, a warmer cream behind */
.face {
  position: absolute;
  inset: 0;
  border-radius: 1.6px;
  -webkit-backface-visibility: hidden;
          backface-visibility: hidden;
  --rib: repeating-linear-gradient(90deg, rgba(90, 70, 40, 0.07) 0 1px, transparent 1px 2px);
  --band: linear-gradient(180deg, transparent 17px, var(--ottone) 17px, var(--champagne) 18px, var(--ottone) 19px, transparent 19px, transparent 20px, rgba(212, 173, 104, 0.55) 20px, rgba(212, 173, 104, 0.55) 20.6px, transparent 20.6px);
  box-shadow: inset 0 0 0 0.5px rgba(120, 96, 60, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.face--front { background: var(--rib), var(--band), linear-gradient(180deg, #fbf8f1, var(--telo) 70%, #e6ddcc); }
.face--back { background: var(--rib), var(--band), linear-gradient(180deg, #f2ebdd, var(--telo-retro) 70%, #dacfb9); transform: rotateY(180deg); }
.tw__b .face--back { transform: none; }
.tw__b .tw__bb, .tw__b .face--top, .tw__b .face--under {
  --band: linear-gradient(180deg, transparent 5px, var(--ottone) 5px, var(--champagne) 6px, var(--ottone) 7px, transparent 7px, transparent 8px, rgba(212, 173, 104, 0.55) 8px, rgba(212, 173, 104, 0.55) 8.6px, transparent 8.6px);
}
.tw__b .face--top { --band: linear-gradient(transparent, transparent); }
.tw__b .face--under { transform: rotateX(180deg); }
.tw__ar { transform-origin: 0 50%; }
.tw__bt { transform-origin: 50% 100%; }
.tw__dim {
  position: absolute;
  inset: 0;
  border-radius: 1.6px;
  background: linear-gradient(90deg, rgba(40, 28, 12, 0.5), rgba(40, 28, 12, 0.15));
  opacity: 0;
  pointer-events: none;
}

/* the paper band round the folded towel, like fresh linen in a good hotel */
.tw__band {
  position: absolute;
  left: 8px;
  top: 11px;
  width: 6px;
  height: 14px;
  border-radius: 0.8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.45) 0 0.6px, transparent 0.6px calc(100% - 0.6px), rgba(90, 64, 24, 0.4) calc(100% - 0.6px)),
    linear-gradient(180deg, #f6e3b8, var(--ottone) 60%, #a77d3c);
  box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.35);
  transform-origin: 50% 0;
  transform: scaleY(0);
}
.tw__sheen {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.7) 50%, transparent 70%);
  background-size: 260% 100%;
  background-position: 120% 0;
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.k__labels {
  position: relative;
  display: block;
  height: 22px;
  overflow: hidden;
}
.k__label {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: center;
  width: max-content;
  height: 22px;
  line-height: 22px;
  white-space: nowrap;
  font-variation-settings: "wdth" 100;
  opacity: 0;
}
.k__label[data-l="idle"] { opacity: 1; }
.k__sep { margin: 0 0.42em; opacity: 0.45; }
.k__sum { color: var(--champagne); font-weight: 640; font-variant-numeric: tabular-nums; }

.note {
  position: relative;
  width: 100%;
  height: 18px;
  margin: 0;
  font-size: 13px;
  font-weight: 460;
  color: var(--grigio);
}
.note__line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  text-align: center;
  white-space: nowrap;
}
.note__line[data-n="done"] { opacity: 0; }

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

/* the open sheet is one cloth: no rounded corners along the fold */
.tw__al { border-radius: 1.6px 0 0 1.6px; }
.tw__ar .face { border-radius: 0 1.6px 1.6px 0; }
