:root {
  /* the page stays pure white; the mosaic brings the colour */
  --carta: #ffffff;
  --inchiostro: #17140f;
  --tenue: #8a8278;
  --linea: rgba(23, 20, 15, 0.13);
  --pieno: #17140f;
  --fuoco: #1f44a8;
  --e-elastico: cubic-bezier(0.34, 1.8, 0.64, 1);
  --e-uscita: cubic-bezier(0.22, 1, 0.36, 1);
}

* { 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: var(--carta);
  color: var(--inchiostro);
  font-family: 'Bricolage Grotesque Variable', system-ui, sans-serif;
  font-optical-sizing: auto;
  font-stretch: 92%;
  -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: var(--inchiostro);
  --sbiadito: var(--tenue);
  --filo: var(--linea);
  --fondo-pieno: var(--pieno);
  --sfondo: 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.88rem;
  font-weight: 520;
  font-stretch: 96%;
  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;
}
/* with the zip button (only inside the site): the animation on a row of its own, the other two share the row
   below; when they no longer fit side by side, each takes a whole row */
.riga--zip > .pillola {
  flex: 1 1 0;
}
.riga--zip > [data-scarica-animazione] {
  flex-basis: 100%;
}

/* the tile shape: three radios on one track, the cursor slides under the chosen one */
.forme {
  position: relative;
  display: flex;
  padding: 4px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--filo);
}
.forme__cursore {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 60px;
  border-radius: 999px;
  background: var(--fondo-pieno);
  pointer-events: none;
}
.forma {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px 0 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--testo);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 620;
  font-stretch: 88%;
  cursor: pointer;
  transition: font-stretch 0.5s var(--e-elastico), color 0.25s ease;
}
.forma svg {
  width: 16px;
  height: 16px;
  flex: none;
  transition: transform 0.6s var(--e-elastico);
}
.forma[aria-checked='true'] {
  color: var(--sfondo);
}
.forma[aria-checked='true'] svg {
  transform: rotate(-8deg);
}
.forma:focus-visible,
.smalto:focus-visible,
.pillola:focus-visible {
  outline: 2px solid var(--testo);
  outline-offset: 3px;
}
@media (hover: hover) and (pointer: fine) {
  .forma:not([aria-checked='true']):hover {
    font-stretch: 100%;
  }
  .forma:not([aria-checked='true']):hover svg {
    transform: rotate(10deg) scale(1.08);
  }
}

/* the glazes: small glossy tiles, each with its own enamel */
.smalti {
  display: flex;
  gap: 9px;
}
.smalto {
  position: relative;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.5) 0 14%, rgba(255, 255, 255, 0) 38%),
    radial-gradient(120% 120% at 30% 25%, var(--a) 0%, var(--b) 92%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18), inset 0 -2px 3px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transform: rotate(var(--r, 0deg));
  transition: transform 0.5s var(--e-elastico);
}
.smalto:nth-child(1) { --r: -3deg; }
.smalto:nth-child(2) { --r: 2deg; }
.smalto:nth-child(3) { --r: -1.5deg; }
.smalto:nth-child(4) { --r: 3deg; }
.smalto:nth-child(5) { --r: -2deg; }
.smalto::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 9px;
  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);
}
.smalto[aria-checked='true']::after {
  opacity: 1;
  transform: none;
}
@media (hover: hover) and (pointer: fine) {
  .smalto:hover {
    transform: translateY(-2px) rotate(calc(var(--r, 0deg) * -2.5));
  }
}
.smalto:active {
  transform: scale(0.9) rotate(var(--r, 0deg));
}

/* 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: 90%;
  outline: none;
}
.indirizzo__campo::selection {
  background: color-mix(in srgb, var(--fuoco) 26%, 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.96rem;
  font-weight: 640;
  font-stretch: 80%;
  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: 100%;
}
.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;
}
/* inside the field the pill swells only a little, without leaving the border */
.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: 100%;
  }
  .pillola:hover .pillola__segno {
    transform: translateY(2px);
  }
  .pillola--vuota:hover {
    --pbordo: inset 0 0 0 1.5px var(--testo);
  }
}
.pillola:active::before {
  transform: scale(1.03, 0.88);
}
/* the display of the pill would beat the hidden attribute: outside the site the zip button is not there */
.pillola[hidden] {
  display: none;
}
/* while the zip is being packed the arrow keeps dropping into the box */
.pillola[aria-busy='true'] {
  cursor: progress;
}
.pillola[aria-busy='true'] .pillola__segno path:last-child {
  animation: cala 0.9s var(--e-uscita) infinite;
}
@keyframes cala {
  0% { transform: translateY(-3px); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translateY(2px); opacity: 0.2; }
}

@media (max-width: 460px) {
  .studio { gap: 14px; }
  .tavola { aspect-ratio: 1 / 0.97; }
  .riga--scelte { justify-content: center; }
  .forma { padding: 0 11px 0 9px; font-size: 0.82rem; }
  .pillola { padding: 0 18px; }
}

/* the downloaded animation: only the stage. The frame can be any size (a square, a wide banner, a phone): the
   stage keeps its shape, as large as fits, centred, with the hint underneath */
.solo-palco body {
  --margine: clamp(8px, 3vmin, 32px);
  min-height: 0;
  height: 100vh;
  height: 100svh;
  padding: var(--margine);
  overflow: hidden;
}
.solo-palco .studio {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  gap: 0;
}
.solo-palco .palco {
  justify-items: center;
}
.solo-palco .tavola {
  aspect-ratio: 1 / 0.86;
  width: min(calc(100vw - 2 * var(--margine)), calc((100vh - 2 * var(--margine) - 26px) / 0.86));
  width: min(calc(100vw - 2 * var(--margine)), calc((100svh - 2 * var(--margine) - 26px) / 0.86));
}
.solo-palco .comandi {
  display: none;
}

/* the preview tile of the section: only the stage, square, filling the window */
.anteprima body {
  padding: 0;
  overflow: hidden;
}
.anteprima .studio {
  width: min(100vw, 100vh);
  gap: 0;
}
.anteprima .tavola {
  aspect-ratio: 1 / 1;
  border-radius: 0;
  cursor: default;
}
.anteprima .cenno,
.anteprima .comandi {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .forma,
  .forma svg,
  .smalto,
  .smalto::after,
  .pillola::before,
  .pillola__testo,
  .pillola__segno {
    transition: opacity 0.2s ease, color 0.2s ease;
  }
  .forma[aria-checked='true'] svg { transform: none; }
  .pillola[aria-busy='true'] .pillola__segno path:last-child {
    animation: none;
    opacity: 0.5;
  }
}
