/* The Transfer ticket button with the ticket tearing off its stub and passing to a friend */
:root {
  --fondo: #000000;
  --pillola: #141417;          /* the graphite of the pill */
  --pillola-alta: #1f1f24;     /* its lit top */
  --testo: #f4f2ee;
  --tenue: #8d8b93;
  --biglietto: #ff6b3d;        /* the ticket, coral */
  --biglietto-caldo: #ffb44a;  /* the warm end of the ticket */
  --accettato: #6fe0a6;        /* the green of the accepted transfer */
  --volto: #4b4f6b;            /* the friend's avatar */
  --volto-chiaro: #8d90b3;
}

* { box-sizing: border-box; margin: 0; }
html { font-size: clamp(14px, min(1.9vw, 3.1vh), 20px); }
html, body { height: 100%; }
body {
  background: var(--fondo);
  color: var(--testo);
  font-family: 'Mona Sans Variable', 'Mona Sans', 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(23rem, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.95rem;
  padding: 1.4rem 0 0.6rem;
}

/* ---- the pill: GSAP animates the width of this element ---- */
.pill {
  position: relative;
  width: 16rem;
  height: 3.75rem;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--pillola-alta), var(--pillola) 62%);
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.07),
    inset 0 1px 0 rgba(255,255,255,0.13),
    inset 0 -1px 0 rgba(0,0,0,0.5),
    0 1px 0 rgba(255,255,255,0.03),
    0 18px 34px -20px rgba(255,107,61,0.42),
    0 30px 60px -30px rgba(255,180,74,0.22);
  overflow: hidden;
  isolation: isolate;
}
.pill__glow {
  position: absolute; left: 8%; right: 8%; bottom: -60%; height: 90%;
  background: radial-gradient(closest-side, rgba(255,120,70,0.16), transparent);
  pointer-events: none;
}
.pill__light {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(8rem 5rem at var(--lx, 50%) var(--ly, 50%), rgba(255,255,255,0.09), transparent 70%);
  opacity: 0;
}
/* the light that runs round the rim while the ticket is on its way */
.pill__beam {
  position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: conic-gradient(from var(--a, 0deg), transparent 0 62%, rgba(255,180,74,0.0) 66%, rgba(255,180,74,0.9) 80%, rgba(255,107,61,0.9) 86%, transparent 92%);
  -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 exclude, linear-gradient(#000 0 0);
  opacity: 0;
}
.pill__sweep {
  position: absolute; top: 0; bottom: 0; left: 0; width: 40%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(111,224,166,0.16) 45%, rgba(255,255,255,0.12) 50%, transparent 60%);
  opacity: 0;
}

/* ---- the closed button ---- */
.rest {
  position: absolute; inset: 0;
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0 1.25rem 0 4.15rem;
  background: none; border: 0; cursor: pointer; text-align: left;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}
.rest:focus-visible { outline: 2px solid var(--biglietto-caldo); outline-offset: -5px; }
.rest__label { flex: 1; font-size: 1.02rem; font-weight: 590; font-stretch: 104%; letter-spacing: -0.005em; white-space: nowrap; }
.rest__arrow { width: 1.15rem; height: 1.15rem; fill: none; stroke: rgba(244,242,238,0.72); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---- the ticket ---- */
.ticket {
  position: absolute; left: 1rem; top: 50%;
  height: 1.55rem; width: calc(1.55rem * 44 / 28);
  margin-top: -0.775rem;
  pointer-events: none;
  z-index: 3;
}
.ticket__stub, .ticket__body { position: absolute; top: 0; height: 100%; display: block; }
.ticket__stub { left: 0; width: calc(1.55rem * 12.4 / 28); }
.ticket__body { left: calc(1.55rem * 12.4 / 28); width: calc(1.55rem * 31.6 / 28); }
.ticket svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 3px 5px rgba(255,107,61,0.28)); }
.stop-a { stop-color: var(--biglietto); }
.stop-b { stop-color: var(--biglietto-caldo); }
.ticket__rim { fill: none; stroke: rgba(255,255,255,0.55); stroke-width: 0.8; stroke-linecap: round; }
.ticket__mark { fill: rgba(40,14,4,0.55); }
.ticket__mark--soft { fill: rgba(40,14,4,0.3); }
.ticket__code rect { fill: rgba(40,14,4,0.5); }
.ticket__perf { fill: none; stroke: rgba(40,14,4,0.45); stroke-width: 0.9; stroke-dasharray: 1.4 1.6; stroke-linecap: round; }
.ticket__glint {
  position: absolute; inset: 0; border-radius: 3px; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.55) 45%, transparent 60%);
  background-size: 300% 100%; background-position: 100% 0;
  mix-blend-mode: soft-light;
}
/* the stub after the transfer: hatched, the proof that it went */
.ticket__void {
  position: absolute; inset: 0; border-radius: 3px 0 0 3px; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(20,20,23,0.72) 0 1.5px, rgba(20,20,23,0.25) 1.5px 3px);
  opacity: 0;
}

/* ---- the lane ---- */
.lane { position: absolute; inset: 0; visibility: hidden; }
.track {
  position: absolute; top: 50%; height: 2px; margin-top: -1px;
  left: calc(1rem + 1.55rem * 12.4 / 28 + 0.6rem);
  right: 3.85rem;
}
.track__dots {
  position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(244,242,238,0.26) 0.9px, transparent 1.3px) 0 50% / 7px 2px repeat-x;
  transform-origin: 0 50%;
}
.track__trail {
  position: absolute; inset: 0; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255,107,61,0), rgba(255,107,61,0.7) 40%, var(--biglietto-caldo));
  box-shadow: 0 0 8px rgba(255,150,70,0.5);
  transform-origin: 0 50%; transform: scaleX(0);
}
.who {
  position: absolute; right: 0.6rem; top: 50%;
  width: 2.65rem; height: 2.65rem; margin-top: -1.325rem;
  z-index: 2;
}
.who__ring { position: absolute; inset: -0.22rem; width: calc(100% + 0.44rem); height: calc(100% + 0.44rem); transform: rotate(-90deg); overflow: visible; }
.who__track { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 1.6; }
.who__run { fill: none; stroke: var(--biglietto-caldo); stroke-width: 1.8; stroke-linecap: round; }
.who__face {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, var(--volto-chiaro), var(--volto) 62%, #2c2e40);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), inset 0 0 0 1px rgba(255,255,255,0.08), 0 4px 10px rgba(0,0,0,0.5);
}
.who__shine { position: absolute; left: 12%; top: 6%; width: 60%; height: 40%; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,255,255,0.22), transparent); }
.who__initials { position: relative; font-size: 0.82rem; font-weight: 650; font-stretch: 110%; letter-spacing: 0.02em; color: #fff; }
.who__badge {
  position: absolute; right: -0.18rem; bottom: -0.18rem;
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accettato);
  box-shadow: 0 0 0 2px var(--pillola), 0 2px 8px rgba(111,224,166,0.45);
  opacity: 0;
}
.who__badge svg { width: 0.72rem; height: 0.72rem; fill: none; stroke: #07301c; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---- the caption under the pill ---- */
.cap {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  height: 1.3rem; max-width: 100%;
  font-size: 0.76rem; color: var(--tenue); font-stretch: 102%;
}
.cap__win { position: relative; display: block; height: 1.3rem; line-height: 1.3rem; overflow: hidden; min-width: 0; }
.cap__now, .cap__next { display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; max-width: calc(min(23rem, 92vw) - 8px); }
.cap__next { position: absolute; left: 0; top: 0; }
.cap__win { -webkit-mask: linear-gradient(transparent, #000 22%, #000 78%, transparent); mask: linear-gradient(transparent, #000 22%, #000 78%, transparent); }
.cap b { color: var(--testo); font-weight: 600; }
.cap__cancel {
  flex: none;
  background: none; border: 0; padding: 0.15rem 0.5rem; border-radius: 999px; cursor: pointer;
  font-size: 0.74rem; font-weight: 600; color: var(--testo);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
  opacity: 0; visibility: hidden; width: 0; padding-left: 0; padding-right: 0; overflow: hidden;
}
.cap__cancel:focus-visible { outline: 2px solid var(--biglietto-caldo); outline-offset: 2px; }
@media (hover: hover) {
  .cap__cancel:hover { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.34); background: rgba(255,255,255,0.05); }
}

/* the autopilot's pointer, drawn */
.pointer {
  position: absolute; left: 0; top: 0; width: 1.2rem; height: 1.2rem; z-index: 9; pointer-events: none;
  opacity: 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.6));
}
.pointer svg { width: 100%; height: 100%; fill: #fff; stroke: #000; stroke-width: 1; stroke-linejoin: round; }
