/* The Buy now button with one tap and three seconds to undo */
:root {
  --fondo: #ffffff;
  --inchiostro: #16161a;
  --tenue: #77777f;
  --linea: #ebe9e4;
  --carta: #faf9f6;
  --accento: #2f6f4f;          /* the green of the tick and the ordered badge */
  --accento-chiaro: #e7f1ea;
  --anello: #f2b544;            /* the warm ring that counts the seconds */
  --lino: #d9cdb8;              /* the linen of the swatch */
  --lino-scuro: #c3b597;
}

* { box-sizing: border-box; margin: 0; }
html { font-size: clamp(14px, min(1.9vw, 3.1vh), 23px); }
html, body { height: 100%; }
body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: 'Geist Variable', 'Geist', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; }

.stage {
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.wrap {
  position: relative;
  width: min(24rem, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* ---- the product card ---- */
.product {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.95rem 0.7rem 0.7rem;
  border: 1px solid var(--linea);
  border-radius: 18px;
  background: var(--carta);
}
.product__swatch {
  position: relative;
  width: 3.4rem; height: 3.4rem;
  border-radius: 12px;
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.18) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(120,100,70,0.12) 0 1px, transparent 1px 3px),
    linear-gradient(160deg, var(--lino), var(--lino-scuro));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}
.product__fold {
  position: absolute; left: -10%; right: -10%; top: 58%; height: 26%;
  background: linear-gradient(180deg, rgba(255,255,255,0.28), rgba(0,0,0,0.08));
  transform: rotate(-8deg);
}
.product__text { display: flex; flex-direction: column; gap: 0.12rem; min-width: 0; }
.product__brand { font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--tenue); }
.product__name { font-size: 0.95rem; font-weight: 620; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.product__meta { font-size: 0.72rem; color: var(--tenue); }
.product__price { font-size: 1.05rem; font-weight: 640; }
.product__badge {
  position: absolute; right: 0.7rem; top: -0.6rem;
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.18rem 0.5rem 0.18rem 0.4rem;
  border-radius: 999px;
  background: var(--accento-chiaro);
  color: var(--accento);
  font-size: 0.66rem; font-weight: 600;
  opacity: 0;
}
.product__badge svg { width: 0.7rem; height: 0.7rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- the pill / sheet: GSAP animates width, height and radius of this element ---- */
.pill {
  position: relative;
  width: 13.5rem;
  height: 3.6rem;
  border-radius: 999px;
  background: var(--inchiostro);
  color: #fff;
  box-shadow: 0 14px 26px -16px rgba(22,22,26,0.7), 0 2px 5px rgba(22,22,26,0.12), inset 0 1px 0 rgba(255,255,255,0.1);
  overflow: hidden;
}
.pill__light {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(9rem 6rem at var(--lx, 50%) var(--ly, 50%), rgba(255,255,255,0.13), transparent 70%);
  opacity: 0;
}

.closed {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 0.55rem;
  background: none; border: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.closed:focus-visible { outline: 2px solid var(--anello); outline-offset: -4px; border-radius: 999px; }
.closed__icon { width: 1.15rem; height: 1.15rem; fill: none; stroke: #fff; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.closed__label { font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em; }
.closed__sep { width: 1px; height: 1rem; background: rgba(255,255,255,0.22); }
.closed__sub { font-size: 0.8rem; color: rgba(255,255,255,0.6); }

/* ---- the sheet that opens ---- */
.sheet {
  position: absolute; inset: 0;
  padding: 0.85rem 0.95rem 0.8rem;
  display: flex; flex-direction: column; gap: 0.15rem;
  visibility: hidden;
}
.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.38rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.row__icon { width: 1.05rem; height: 1.05rem; fill: none; stroke: rgba(255,255,255,0.75); stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.row__text { display: flex; gap: 0.45rem; align-items: baseline; font-size: 0.82rem; color: rgba(255,255,255,0.65); white-space: nowrap; overflow: hidden; }
.row__text b { color: #fff; font-weight: 600; }
.row__total { font-size: 0.92rem; font-weight: 640; }

.foot {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding-top: 0.55rem;
}
.ring { position: relative; width: 2.1rem; height: 2.1rem; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring__track { fill: none; stroke: rgba(255,255,255,0.12); stroke-width: 2.4; }
.ring__run { fill: none; stroke: var(--anello); stroke-width: 2.4; stroke-linecap: round; }
.ring__tick { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transform: rotate(90deg); transform-origin: 18px 18px; }
.ring__num { position: relative; font-size: 0.82rem; font-weight: 640; }

.status { display: flex; flex-direction: column; gap: 0.08rem; min-width: 0; }
.status__win { position: relative; display: block; height: 1.25rem; overflow: hidden; }
.status__now, .status__next { position: absolute; left: 0; top: 0; line-height: 1.25rem; font-size: 0.9rem; font-weight: 600; white-space: nowrap; }
.status__sub { font-size: 0.72rem; color: rgba(255,255,255,0.55); white-space: nowrap; }

.undo {
  appearance: none; border: 1px solid rgba(255,255,255,0.22); background: rgba(255,255,255,0.06);
  border-radius: 999px; padding: 0.42rem 0.85rem;
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.undo:focus-visible { outline: 2px solid var(--anello); outline-offset: 2px; }
@media (hover: hover) {
  .undo:hover { background: rgba(255,255,255,0.14); }
}

/* the pilot's pointer, drawn */
.pointer {
  position: absolute; left: 0; top: 0; width: 1.25rem; height: 1.25rem; z-index: 9; pointer-events: none;
  opacity: 0; filter: drop-shadow(0 2px 3px rgba(20, 20, 24, 0.3));
}
.pointer svg { width: 100%; height: 100%; fill: #fff; stroke: #141418; stroke-width: 1.3; stroke-linejoin: round; }

@media (max-width: 420px) {
  .row__text { font-size: 0.76rem; }
  .status__now, .status__next { font-size: 0.84rem; }
}
