/* Le statistiche che rotolano in un numero solo allo scroll. Colori in :root (la palette del Playground). */
:root {
  --fondo: #fafaf9;
  --inchiostro: #0c0c0f;
  --secondario: #6b6b73;
  --tenue: #a6a6ad;
  --bordo: rgba(12, 12, 20, 0.09);
  --binario: #f0f0ee;
  --pillola: #ffffff;
  --accento: #2f5bff;
  --stella: #f2b01e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--fondo); }
body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.corsa { position: relative; height: 320vh; }
.palco {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  padding: clamp(18px, 7vh, 72px) 16px clamp(16px, 6vh, 60px);
  overflow: hidden;
}
@supports (height: 100lvh) {
  .palco { height: 100lvh; }
}

/* the title over the section */
.testa { text-align: center; }
.testa__nota {
  font-size: clamp(11px, min(1.2vw, 1.8vh), 13px);
  font-weight: 560;
  letter-spacing: 0.01em;
  color: var(--accento);
  margin-bottom: clamp(4px, 1vh, 10px);
}
.testa__titolo {
  font-size: clamp(19px, min(4vw, 5vh), 44px);
  font-weight: 640;
  font-stretch: 106%;
  letter-spacing: -0.028em;
  line-height: 1.06;
  max-width: 16em;
  text-wrap: balance;
}
.testa__titolo span { color: var(--tenue); }

/* the one number */
.dato {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.misura { display: flex; flex-direction: column; align-items: stretch; }
.numero {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.07em;
  --n: clamp(50px, min(19vw, 17vh), 168px);
  font-size: var(--n);
  font-weight: 600;
  font-stretch: 92%;
  letter-spacing: -0.035em;
  line-height: 1;
  white-space: nowrap;
}
.numero__cifre { display: inline-flex; align-items: flex-start; }

/* one wheel per digit: a strip of 0 to 9, three times, inside a window one line tall */
.ruota {
  display: inline-block;
  height: 1.04em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 13%, #000 87%, transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 13%, #000 87%, transparent 100%);
}
.ruota__nastro { display: flex; flex-direction: column; }
.ruota__nastro span { display: flex; justify-content: center; height: 1.04em; line-height: 1.04em; }
.segno {
  display: inline-block;
  height: 1.04em;
  line-height: 1.04em;
  overflow: hidden;
  text-align: center;
}
.segno--piccolo { letter-spacing: -0.06em; }

/* the unit word that rolls beside the number */
.numero__unita {
  position: relative;
  display: inline-block;
  overflow: hidden;
  height: 1.3em;
  /* the word sits on the same baseline as the digits */
  margin-bottom: calc(var(--n) * 0.105 - 0.2em);
  font-size: clamp(14px, min(2.6vw, 3.4vh), 30px);
  font-weight: 520;
  font-stretch: 100%;
  letter-spacing: -0.01em;
  line-height: 1.3em;
  color: var(--secondario);
  margin-left: 0.15em;
}
.numero__unita > span,
.riga__testo > span { display: inline-block; white-space: nowrap; }
.numero__unita > span.esce,
.riga__testo > span.esce { position: absolute; left: 0; top: 0; }

/* the thin line under the number, and its fill */
.filo {
  position: relative;
  display: block;
  align-self: stretch;
  height: 1px;
  margin-top: clamp(8px, 1.6vh, 16px);
  background: var(--bordo);
  overflow: hidden;
}
.filo__pieno {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--inchiostro) 0%, var(--inchiostro) 78%, var(--accento) 100%);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* the grey label and the note under it */
.riga {
  position: relative;
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  line-height: 1.45;
}
.riga--etichetta {
  margin-top: clamp(10px, 2vh, 18px);
  height: 1.45em;
  min-width: 18em;
  font-size: clamp(13px, min(1.6vw, 2.3vh), 17px);
  font-weight: 540;
  color: var(--inchiostro);
}
.riga--nota {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 1.6em;
  font-size: clamp(12px, min(1.3vw, 1.9vh), 14px);
  font-weight: 440;
  color: var(--secondario);
}
.riga__testo { position: relative; display: inline-block; height: 1.45em; overflow: hidden; }
.riga--etichetta > span { position: absolute; left: 0; right: 0; top: 0; display: block; }

.stelle {
  display: inline-block;
  width: 0;
  height: 1.1em;
  overflow: hidden;
  flex: none;
}
.stelle svg { display: block; width: auto; height: 100%; aspect-ratio: 92 / 16; overflow: visible; }
.stelle__contorni path { fill: none; stroke: var(--tenue); stroke-width: 1.1; stroke-linejoin: round; }
.stelle__piene path { fill: var(--stella); }

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

/* the four tabs, a segmented control with a pill that slides */
.schede {
  position: relative;
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--binario);
  box-shadow: inset 0 0 0 1px rgba(12, 12, 20, 0.04);
}
.schede__pillola {
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 0;
  border-radius: 999px;
  background: var(--pillola);
  box-shadow: 0 0 0 1px rgba(12, 12, 20, 0.06), 0 1px 2px rgba(12, 12, 20, 0.06), 0 6px 16px -8px rgba(12, 12, 20, 0.22);
}
.scheda {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: clamp(12px, min(1.3vw, 2vh), 14px);
  font-weight: 540;
  color: var(--secondario);
  padding: clamp(6px, 1.1vh, 9px) clamp(10px, 1.6vw, 18px);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.25s ease, transform 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.scheda[aria-selected="true"] { color: var(--inchiostro); }
.scheda:active { transform: scale(0.96); }
.scheda:focus-visible { outline: 2px solid var(--accento); outline-offset: 1px; }
@media (hover: hover) {
  .scheda:hover { color: var(--inchiostro); }
}

.piede {
  min-height: 32vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  text-align: center;
  color: var(--tenue);
  font-size: 13px;
}

@media (max-width: 560px) {
  .riga--etichetta { min-width: 0; width: 100%; }
  .dato { width: 100%; }
}
@media (max-height: 440px) {
  .palco { padding-top: 14px; padding-bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .scheda:active { transform: none; }
}
