:root {
  /* the page: pure white, pure black with the Black night bricks (script.js fades --n from 0 to 1) */
  --carta: #ffffff;
  --notte: #000000;
  --inchiostro: #16130f;
  --inchiostro-notte: #f4efe6;
  --tenue: #8a8278;
  --tenue-notte: #8e93a6;
  --linea: rgba(22, 19, 15, 0.12);
  --linea-notte: rgba(244, 239, 230, 0.16);
  --pieno: #16130f;
  --pieno-notte: #f4efe6;
  --fuoco: #d22a22;
  --e-elastico: cubic-bezier(0.34, 1.8, 0.64, 1);
  --e-uscita: cubic-bezier(0.22, 1, 0.36, 1);
  --n: 0;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: color-mix(in srgb, var(--notte) calc(var(--n) * 100%), var(--carta));
  color: color-mix(in srgb, var(--inchiostro-notte) calc(var(--n) * 100%), var(--inchiostro));
  font-family: 'Fredoka Variable', ui-rounded, system-ui, sans-serif;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

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

.studio {
  --testo: color-mix(in srgb, var(--inchiostro-notte) calc(var(--n) * 100%), var(--inchiostro));
  --sbiadito: color-mix(in srgb, var(--tenue-notte) calc(var(--n) * 100%), var(--tenue));
  --filo: color-mix(in srgb, var(--linea-notte) calc(var(--n) * 100%), var(--linea));
  --fondo-pieno: color-mix(in srgb, var(--pieno-notte) calc(var(--n) * 100%), var(--pieno));
  --sfondo: color-mix(in srgb, var(--notte) calc(var(--n) * 100%), var(--carta));
  width: min(680px, 100%);
  display: grid;
  gap: 18px;
}

/* ------------------------------------------------------------------ the stage */
.palco {
  display: grid;
  gap: 6px;
}
.tavola {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 0.86;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  outline: none;
}
.tavola:focus-visible {
  box-shadow: 0 0 0 2px var(--sfondo), 0 0 0 4px var(--testo);
}
.tela {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.cenno {
  margin: 0;
  height: 20px;
  overflow: hidden;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 520;
  font-stretch: 112%;
  letter-spacing: 0.005em;
  color: var(--sbiadito);
}
.cenno__testo {
  display: inline-block;
}

/* ------------------------------------------------------------------ controls */
.comandi {
  width: min(520px, 100%);
  justify-self: center;
  display: grid;
  gap: 12px;
}
.riga {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.riga--azioni {
  justify-content: center;
  gap: 10px;
}
/* the actions: the whole animation on its own line, the other two side by side under it */
.riga--azioni .pillola--piena {
  flex: 1 1 100%;
}
.riga--azioni .pillola--vuota {
  flex: 1 1 0;
  min-width: 0;
}

/* the bricks: three radios on one track, the cursor slides under the chosen one */
.pezzi {
  position: relative;
  display: flex;
  padding: 4px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--filo);
}
.pezzi__cursore {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 60px;
  border-radius: 999px;
  background: var(--fondo-pieno);
  pointer-events: none;
}
.pezzo {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px 0 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--testo);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 540;
  font-stretch: 100%;
  cursor: pointer;
  transition: font-stretch 0.5s var(--e-elastico);
}
.pezzo svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.pezzo[aria-checked='true'] {
  color: var(--sfondo);
}
.pezzo:focus-visible,
.tavolozza:focus-visible,
.pillola:focus-visible {
  outline: 2px solid var(--testo);
  outline-offset: 3px;
}
@media (hover: hover) and (pointer: fine) {
  .pezzo:not([aria-checked='true']):hover {
    font-stretch: 116%;
  }
}

/* the colours: each swatch is a little 2x1 brick, two studs on top and the darker front face below */
.tavolozze {
  display: flex;
  gap: 8px;
}
.tavolozza {
  position: relative;
  width: 32px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background:
    radial-gradient(circle at 29% 38%, var(--s) 0 3.3px, var(--d) 3.7px 4.5px, transparent 5px),
    radial-gradient(circle at 71% 38%, var(--s) 0 3.3px, var(--d) 3.7px 4.5px, transparent 5px),
    linear-gradient(to bottom, var(--a) 0 72%, var(--d) 72% 100%);
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.18);
  cursor: pointer;
  transition: transform 0.5s var(--e-elastico);
}
.tavolozza--pastello {
  background:
    radial-gradient(circle at 29% 38%, #fbe2e9 0 3.3px, #d48ca1 3.7px 4.5px, transparent 5px),
    radial-gradient(circle at 71% 38%, #e6f6ef 0 3.3px, #6fb39b 3.7px 4.5px, transparent 5px),
    linear-gradient(to bottom, transparent 0 72%, #b9879d 72% 100%),
    linear-gradient(90deg, #f3a6ba 0 50%, #95d5bf 50% 100%);
}
.tavolozza::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1.5px var(--testo);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.5s var(--e-elastico);
}
.tavolozza[aria-checked='true']::after {
  opacity: 1;
  transform: none;
}
@media (hover: hover) and (pointer: fine) {
  .tavolozza:hover {
    transform: translateY(-3px) rotate(-5deg);
  }
}
.tavolozza:active {
  transform: translateY(1px) scale(0.92, 0.86);
}

/* the address */
.indirizzo {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
  padding: 4px 4px 4px 14px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--filo);
}
.indirizzo:focus-within {
  box-shadow: inset 0 0 0 1.5px var(--testo);
}
.indirizzo__segno {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--sbiadito);
}
.indirizzo__campo {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--testo);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  font-stretch: 96%;
  outline: none;
}
.indirizzo__campo::selection {
  background: color-mix(in srgb, var(--fuoco) 30%, transparent);
}

/* the elastic pill: the fill swells with a bounce, the label widens on the wdth axis */
.pillola {
  --pb: var(--fondo-pieno);
  --pt: var(--sfondo);
  --pbordo: 0 0 0 transparent;
  --gonfia: 6px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--pt);
  font: inherit;
  font-size: 0.94rem;
  font-weight: 560;
  font-stretch: 100%;
  letter-spacing: -0.005em;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  flex: none;
}
.pillola::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--pb);
  box-shadow: var(--pbordo);
  transition: inset 0.6s var(--e-elastico), transform 0.25s var(--e-uscita);
}
.pillola__testo {
  display: inline-grid;
  text-align: center;
  transition: font-stretch 0.6s var(--e-elastico);
}
/* the label at its widest, invisible: it keeps the room */
.pillola__testo::before {
  content: attr(data-testo);
  grid-area: 1 / 1;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 122%;
}
.pillola__segno {
  width: 18px;
  height: 18px;
  flex: none;
  transition: transform 0.6s var(--e-elastico);
}
.pillola--vuota {
  --pb: transparent;
  --pt: var(--testo);
  --pbordo: inset 0 0 0 1px var(--filo);
}
.pillola--piena {
  height: 48px;
}
.pillola[hidden] {
  display: none;
}
/* while the zip is being made */
.pillola[aria-busy='true'] {
  cursor: progress;
}
.pillola[aria-busy='true'] .pillola__testo {
  opacity: 0.6;
}
/* dentro al campo la pillola si gonfia solo un poco, senza uscire dal bordo */
.indirizzo .pillola {
  --gonfia: 1px;
}
@media (hover: hover) and (pointer: fine) {
  .pillola:hover::before {
    inset: -2px calc(var(--gonfia) * -1);
  }
  .pillola:hover .pillola__testo {
    font-stretch: 122%;
  }
  .pillola:hover .pillola__segno {
    transform: translateY(2px);
  }
  .pillola:hover .pillola__segno--anima {
    transform: translateX(1px) scale(1.08);
  }
  .pillola--vuota:hover {
    --pbordo: inset 0 0 0 1.5px var(--testo);
  }
}
.pillola:active::before {
  transform: scale(1.03, 0.88);
}

@media (max-width: 460px) {
  .studio { gap: 14px; }
  .riga--scelte { justify-content: center; }
  .pezzo { padding: 0 9px 0 7px; font-size: 0.8rem; font-stretch: 90%; }
  .pillola { padding: 0 18px; }
  .riga--azioni { gap: 8px; }
  .riga--azioni .pillola--vuota { padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .pezzo,
  .tavolozza,
  .tavolozza::after,
  .pillola::before,
  .pillola__testo,
  .pillola__segno {
    transition: opacity 0.2s ease, color 0.2s ease;
  }
}

/* ------------------------------------------------------------------ the preview (?anteprima=1): only the stage, square */
.anteprima body {
  padding: 0;
  overflow: hidden;
}
.anteprima .studio {
  width: 100vw;
  height: 100vh;
  display: block;
}
.anteprima .palco {
  display: block;
  height: 100%;
}
.anteprima .tavola {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  cursor: default;
}
.anteprima .cenno,
.anteprima .comandi {
  display: none;
}

/* ------------------------------------------------------------------ the animation on its own (the downloaded zip:
   class solo-palco on <html>): only the stage and the hint, as big as the window allows, centred, never cut */
.solo-palco,
.solo-palco body {
  height: 100%;
  overflow: hidden;
}
.solo-palco body {
  min-height: 0;
  height: 100vh;
  height: 100svh;
  display: block;
  padding: clamp(10px, 3vmin, 32px);
}
.solo-palco .studio {
  width: 100%;
  height: 100%;
  display: block;
}
.solo-palco .palco {
  height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
}
.solo-palco .tavola {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}
.solo-palco .comandi {
  display: none;
}
