:root {
  /* the page is pure white; the paper is drawn on the canvas */
  --carta: #ffffff;
  --testo: #1c1915;
  --sbiadito: #8c8378;
  --filo: rgba(28, 25, 21, 0.13);
  --pieno: #1c1915;
  --sigillo: #b5301c;
  /* the chosen ink: script.js changes it, the Build pill and the focus rings follow */
  --tinta: #1c1915;
  --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(--testo);
  font-family: 'Roboto Serif Variable', Georgia, serif;
  font-optical-sizing: auto;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

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

.studio {
  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.84;
  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(--carta), 0 0 0 4px var(--tinta);
}
.tela {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.cenno {
  margin: 0;
  height: 22px;
  overflow: hidden;
  text-align: center;
  font-size: 0.86rem;
  font-weight: 460;
  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;
}
/* the whole animation is the main thing to take away: a full pill on its own line, the other two under it */
.riga--azioni .pillola--piena {
  flex: 1 1 100%;
}
.pillola[aria-busy='true'] {
  cursor: progress;
}
.pillola[aria-busy='true'] .pillola__segno {
  opacity: 0.45;
}

/* the paper: three radios on one track, the cursor slides under the chosen one */
.carte {
  position: relative;
  display: flex;
  padding: 4px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--filo);
}
.carte__cursore {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: 60px;
  border-radius: 999px;
  background: var(--pieno);
  pointer-events: none;
}
.carta {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  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: 560;
  font-stretch: 100%;
  cursor: pointer;
  transition: font-stretch 0.5s var(--e-elastico), color 0.3s ease;
}
.carta svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.carta[aria-checked='true'] {
  color: #fbf7ee;
}
.carta:focus-visible,
.goccia:focus-visible,
.pillola:focus-visible {
  outline: 2px solid var(--tinta);
  outline-offset: 3px;
}
@media (hover: hover) and (pointer: fine) {
  .carta:not([aria-checked='true']):hover {
    font-stretch: 118%;
  }
}

/* the inks: five watercolour drops, lighter in the middle and darker at the rim like a dried wash */
.inchiostri {
  display: flex;
  gap: 9px;
}
.goccia {
  position: relative;
  width: 27px;
  height: 27px;
  padding: 0;
  border: 0;
  border-radius: var(--r);
  background:
    radial-gradient(circle at 38% 34%, rgba(255, 255, 255, 0.34) 0 18%, transparent 44%),
    radial-gradient(closest-side, color-mix(in srgb, var(--c) 74%, #fff) 0 52%, var(--c) 92%, color-mix(in srgb, var(--c) 80%, #000) 100%);
  cursor: pointer;
  transition: transform 0.5s var(--e-elastico);
}
.goccia::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: var(--r);
  box-shadow: inset 0 0 0 1.5px var(--testo);
  opacity: 0;
  transform: scale(0.8) rotate(-20deg);
  transition: opacity 0.2s ease, transform 0.55s var(--e-elastico);
}
.goccia[aria-checked='true']::after {
  opacity: 1;
  transform: none;
}
@media (hover: hover) and (pointer: fine) {
  .goccia:hover {
    transform: translateY(-2px) rotate(-8deg) scale(1.06);
  }
}
.goccia:active {
  transform: scale(0.88);
}

/* 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(--tinta);
}
.indirizzo__segno {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--sbiadito);
}
.indirizzo__campo {
  flex: 1;
  width: 0; /* without it the field asks for its 20 characters and the studio overflows a 357px iframe */
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--testo);
  font: inherit;
  font-size: 1rem;
  font-weight: 420;
  font-stretch: 94%;
  outline: none;
}
.indirizzo__campo::selection {
  background: color-mix(in srgb, var(--sigillo) 26%, transparent);
}

/* the elastic pill: the fill swells with a bounce, the label widens on the wdth axis */
.pillola {
  --pb: var(--tinta);
  --pt: #fbf7ee;
  --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: 620;
  font-stretch: 100%;
  letter-spacing: -0.003em;
  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), background-color 0.6s ease;
}
.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);
}
/* 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: 122%;
  }
  .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);
}

@media (max-width: 460px) {
  .studio { gap: 14px; }
  .riga--scelte { justify-content: center; }
  .carta { padding: 0 11px 0 9px; font-size: 0.82rem; }
  .pillola { padding: 0 18px; }
  .riga--azioni { gap: 8px; }
  .riga--azioni .pillola { padding: 0 13px; font-size: 0.88rem; gap: 6px; }
}

/* on a phone nothing widens on hover: the labels keep only their own room, so the two pills under the main one share a line */
@media (max-width: 460px) and (hover: none) {
  .riga--azioni .pillola__testo::before {
    font-stretch: 100%;
  }
}

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

/* ------------------------------------------------------------------ the preview tile: only the stage, square, full window */
html.anteprima,
html.anteprima body {
  height: 100%;
  overflow: hidden;
}
html.anteprima body {
  min-height: 0;
  padding: 0;
}
html.anteprima .studio {
  width: 100vmin;
  height: 100vmin;
  display: block;
}
html.anteprima .palco {
  display: block;
  width: 100%;
  height: 100%;
}
html.anteprima .tavola {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  pointer-events: none;
}
html.anteprima .cenno,
html.anteprima .comandi {
  display: none;
}

/* ------------------------------------------------------------------ the animation on its own (the zip, class solo-palco):
   only the stage and the hint, as big as the window allows, never cut, centred on the white page */
html.solo-palco,
html.solo-palco body {
  height: 100%;
  overflow: hidden;
}
html.solo-palco body {
  min-height: 0;
  padding: 16px;
}
html.solo-palco .studio {
  width: auto;
  display: block;
}
html.solo-palco .tavola {
  /* 28px: the hint under the stage and its gap; the stage is 1 wide by 0.84 tall */
  width: min(100vw - 32px, (100vh - 60px) / 0.84);
  width: min(100vw - 32px, (100svh - 60px) / 0.84);
}
html.solo-palco .comandi {
  display: none;
}
