/* La transizione a scorrimento di lato: tre pagine di una piccola rivista inventata (Ferrow) una accanto all'altra,
   su un bianco caldo, con l'inchiostro quasi nero e un solo accento vermiglio sull'indicatore delle pagine. I titoli
   sono in Archivo variabile: lo script stringe la loro larghezza (font-stretch) mentre la striscia corre. */
:root {
  --carta: #f3f0e8;                     /* il fondo delle pagine */
  --inchiostro: #141414;                /* titoli e testi */
  --tenue: #8a857b;                     /* le scritte piccole e i nomi spenti */
  --filo: rgba(20, 20, 20, 0.22);       /* le cuciture e le righe sottili */
  --accento: #e5432a;                   /* l'indicatore della pagina */
  --elastico: cubic-bezier(0.34, 1.9, 0.45, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--carta);
  color: var(--inchiostro);
  font-family: 'Archivo Variable', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  --margine: clamp(16px, 4.4vw, 60px);
  position: relative;
  height: 100svh;
  min-height: 460px;
  overflow: hidden;
  outline: none;
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.stage.is-drag {
  cursor: grabbing;
}

/* ---------------------------------------------------------------- la striscia delle pagine */
.track {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.page {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  overflow: hidden;
}

.page__inner {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  padding: 0 var(--margine) 10vh;
  will-change: transform;
}

.kicker {
  margin: 0 0 18px;
  color: var(--tenue);
  font-size: 14px;
  font-weight: 500;
  font-stretch: 100%;
  letter-spacing: 0.01em;
}

.title {
  margin: 0;
  font-size: clamp(3rem, 1rem + 9vw, 10.5rem);
  font-weight: 640;
  font-stretch: 112%;
  letter-spacing: -0.035em;
  line-height: 0.9;
  white-space: nowrap;
  will-change: transform;
}

.line {
  max-width: 34ch;
  margin: 26px 0 0;
  font-size: clamp(1rem, 0.9rem + 0.4vw, 1.2rem);
  font-weight: 420;
  font-stretch: 100%;
  line-height: 1.45;
}

/* il dettaglio a filo: una riga sottile con una tacca all'inizio */
.rule {
  position: relative;
  width: min(320px, 50vw);
  height: 1px;
  margin-top: 34px;
  background: var(--filo);
}

.rule span {
  position: absolute;
  left: 0;
  top: -5px;
  width: 1px;
  height: 11px;
  background: var(--inchiostro);
}

/* le cuciture fra una pagina e l'altra */
.seams {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.seams path {
  fill: none;
  stroke: var(--filo);
  stroke-width: 1;
}

/* ---------------------------------------------------------------- testata e piede, fermi sopra la striscia */
.bar,
.foot {
  position: absolute;
  left: var(--margine);
  right: var(--margine);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.bar {
  top: clamp(18px, 3vw, 34px);
  align-items: baseline;
}

.brand {
  font-size: 20px;
  font-weight: 680;
  font-stretch: 82%;
}

.bar__note {
  color: var(--tenue);
  font-size: 14px;
  font-weight: 480;
}

.foot {
  bottom: clamp(18px, 3.4vw, 38px);
  align-items: flex-end;
}

.names,
.moves {
  pointer-events: auto;
}

.names {
  position: relative;
  display: flex;
  gap: clamp(14px, 2.4vw, 30px);
  padding-bottom: 10px;
}

.name {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--tenue);
  font: inherit;
  font-size: 14px;
  font-weight: 520;
  font-stretch: 100%;
  cursor: pointer;
  transition: color 0.3s;
  -webkit-tap-highlight-color: transparent;
}

.name.is-on {
  color: var(--inchiostro);
}

.name:focus-visible {
  outline: 2px solid var(--accento);
  outline-offset: 4px;
}

/* l'indicatore: un filo nell'accento che scivola sotto il nome della pagina */
.names__bar {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 10px;
  height: 2px;
  background: var(--accento);
  transform-origin: 0 50%;
  will-change: transform;
}

.moves {
  display: flex;
  gap: 10px;
}

/* ---------------------------------------------------------------- la pillola elastica */
.pillola {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--carta);
  font: inherit;
  font-size: 15px;
  font-weight: 620;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.pillola::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--inchiostro);
  transition: inset 0.6s var(--elastico);
}

.pillola--vuota {
  color: var(--inchiostro);
}

.pillola--vuota::before {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--filo);
}

.pillola__scritta {
  font-stretch: 86%;
  text-align: center;
  transition: font-stretch 0.6s var(--elastico);
}

.pillola__scritta::before {
  content: attr(data-testo);
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 100%;
}

.pillola__freccia {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.6s var(--elastico);
}

@media (hover: hover) and (pointer: fine) {
  .pillola:hover::before {
    inset: -2px -7px;
  }

  .pillola:hover .pillola__scritta {
    font-stretch: 100%;
  }

  .pillola:hover .pillola__freccia {
    transform: translateX(3px);
  }

  .pillola:hover .pillola__freccia--indietro {
    transform: translateX(-3px);
  }

  .name:hover {
    color: var(--inchiostro);
  }
}

.pillola:active::before {
  inset: 2px 3px;
}

.pillola:focus-visible {
  outline: 2px solid var(--accento);
  outline-offset: 4px;
}

/* ---------------------------------------------------------------- telefono */
@media (max-width: 560px) {
  .title {
    font-size: clamp(2.2rem, 11.2vw, 3.6rem);
  }

  .page__inner {
    padding-bottom: 22vh;
  }

  .foot {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .moves {
    justify-content: space-between;
  }

  .pillola {
    min-height: 46px;
  }
}

/* ---------------------------------------------------------------- movimento ridotto: le pagine una sopra l'altra */
@media (prefers-reduced-motion: reduce) {
  .stage {
    cursor: default;
  }

  .seams {
    display: none;
  }

  .pillola::before,
  .pillola__scritta,
  .pillola__freccia {
    transition: none;
  }
}
