:root {
  /* the colours of Animorio: paper, ink, petrol and tungsten */
  --carta: #eef3ef;
  --campo: #f7f8f4;
  --inchiostro: #07201f;
  --tenue: #3f5452;
  --linea: rgba(7, 32, 31, 0.14);
  --petrolio: #072a29;
  --petrolio-chiaro: #0b3b39;
  --bianco: #f6f7f3;
  --menta: #86cfc4;
  --tungsteno: #ff8a3d;
  --tungsteno-ombra: #d9602a;
  --tungsteno-chiaro: #ffb27a;
  --tungsteno-testo: #a8440c;
  --pesca: #ffc896;
  --e-elastico: cubic-bezier(0.34, 1.9, 0.45, 1);
  --e-uscita: cubic-bezier(0.22, 1, 0.36, 1);
  --f: 'Mona Sans Variable', system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--carta);
  color: var(--inchiostro);
  font-family: var(--f);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

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

/* ---------------------------------------------------------------- the frame: hud, field, cross */
.gioco {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(14px, 3vw, 28px) 4px;
  min-height: 62px;
}
.hud__blocco {
  display: grid;
  line-height: 1;
}
.hud__etichetta {
  font-size: 0.72rem;
  font-weight: 560;
  font-stretch: 112%;
  letter-spacing: 0.01em;
  color: var(--tenue);
}
.hud__numero {
  display: inline-block;
  margin-top: 4px;
  font-size: clamp(1.35rem, 1rem + 1.4vw, 1.9rem);
  font-weight: 700;
  font-stretch: 100%;
  letter-spacing: -0.03em;
  transform-origin: 0% 80%;
}
.hud__numero--piccolo {
  font-size: clamp(1.05rem, 0.9rem + 0.7vw, 1.3rem);
  font-weight: 640;
  color: var(--tenue);
}
.hud__parola {
  display: flex;
  gap: 2px;
  font-size: clamp(1.05rem, 0.85rem + 0.9vw, 1.45rem);
  font-weight: 640;
  font-stretch: 104%;
  letter-spacing: -0.01em;
}
.hud__lettera {
  position: relative;
  display: grid;
  place-items: center;
  width: 1.12em;
  height: 1.38em;
  color: color-mix(in srgb, var(--inchiostro) 26%, transparent);
  isolation: isolate;
}
.hud__lettera::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 0.24em;
  background: var(--tungsteno);
  transform: scale(0.4);
  opacity: 0;
  transition: transform 0.5s var(--e-elastico), opacity 0.2s ease;
}
.hud__lettera.fatta {
  color: var(--inchiostro);
}
.hud__lettera.prossima {
  color: var(--inchiostro);
}
.hud__lettera.prossima::before {
  transform: none;
  opacity: 1;
}
.hud__lettera.festa {
  color: var(--tungsteno-testo);
}
.hud__lettera > span {
  display: block;
}
.hud__destra {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.hud__blocco--record {
  margin-right: 10px;
  text-align: right;
}

/* round buttons in the hud: a thin ring, the drawing in the middle */
.tondo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--inchiostro);
  box-shadow: inset 0 0 0 1px var(--linea);
  cursor: pointer;
  transition: box-shadow 0.25s ease, background-color 0.25s ease;
}
.tondo svg {
  width: 20px;
  height: 20px;
  transition: transform 0.5s var(--e-elastico);
}
.tondo .tondo__muto { display: none; }
.tondo[aria-pressed='true'] .tondo__onde { display: none; }
.tondo[aria-pressed='true'] .tondo__muto { display: inline; }
@media (hover: hover) and (pointer: fine) {
  .tondo:hover {
    box-shadow: inset 0 0 0 1px var(--inchiostro);
  }
  .tondo:hover svg {
    transform: scale(1.12);
  }
}
.tondo:active svg {
  transform: scale(0.9);
}
.tondo:focus-visible,
.croce__tasto:focus-visible {
  outline: 2px solid var(--tungsteno-ombra);
  outline-offset: 2px;
}

.palco {
  position: relative;
  min-height: 0;
  touch-action: none;
}
.tela {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------------------------------------------------------------- the cross (only with a touch screen) */
.croce {
  display: none;
}
.tocco .croce {
  display: grid;
  grid-template-columns: repeat(3, 50px);
  grid-template-rows: repeat(3, 50px);
  gap: 5px;
  justify-content: center;
  padding: 6px 0 calc(12px + env(safe-area-inset-bottom));
  touch-action: none;
}
.croce__tasto {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--inchiostro);
  box-shadow: inset 0 0 0 1px var(--linea);
  cursor: pointer;
  touch-action: none;
}
.croce__tasto svg {
  width: 26px;
  height: 26px;
}
.croce__tasto.premuto {
  background: color-mix(in srgb, var(--inchiostro) 7%, transparent);
  box-shadow: inset 0 0 0 1px var(--inchiostro);
}
.croce__tasto--su { grid-area: 1 / 2; }
.croce__tasto--sinistra { grid-area: 2 / 1; }
.croce__tasto--destra { grid-area: 2 / 3; }
.croce__tasto--giu { grid-area: 3 / 2; }
.croce__centro {
  grid-area: 2 / 2;
  display: grid;
  place-items: center;
}
.croce__centro svg {
  width: 22px;
  height: 22px;
}
/* a phone on its side: the cross moves to the right of the field */
@media (orientation: landscape) and (max-height: 520px) {
  .tocco .gioco {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .tocco .hud { grid-column: 1 / -1; }
  .tocco .croce {
    grid-row: 2;
    grid-column: 2;
    align-content: center;
    padding: 0 calc(14px + env(safe-area-inset-right)) 0 4px;
  }
}

/* ---------------------------------------------------------------- the shutter */
.otturatore {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  pointer-events: none;
}
.otturatore__colonna {
  display: block;
  height: 100%;
  margin-right: -1px;
  background: var(--petrolio);
  will-change: transform;
}

/* ---------------------------------------------------------------- the start and the end screens, on the shutter */
.schermo {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px 18px;
  color: var(--bianco);
  text-align: center;
  overflow: hidden;
}
.schermo[hidden] {
  display: none;
}
.schermo__dentro {
  display: grid;
  justify-items: center;
  gap: clamp(10px, 2.2svh, 20px);
  max-width: 640px;
}
.segno {
  display: flex;
  align-items: center;
  gap: 0.06em;
  font-size: clamp(1.25rem, 0.9rem + 1.6vw, 1.9rem);
  font-weight: 640;
  font-stretch: 108%;
  letter-spacing: -0.01em;
  color: var(--menta);
}
.segno__rombo {
  width: 1.15em;
  height: 1.15em;
  margin-right: 0.18em;
  flex: none;
}
.segno__lettera {
  display: inline-block;
}
.titolo {
  margin: 0;
  font-size: clamp(2.5rem, min(11.5vw, 13svh), 6.8rem);
  font-weight: 680;
  font-stretch: 112%;
  line-height: 0.9;
  letter-spacing: -0.045em;
  text-wrap: balance;
}
.titolo__riga {
  display: inline-block;
  overflow: clip;
  padding: 0.04em 0.03em 0.12em;
  margin: -0.04em -0.03em -0.12em;
  vertical-align: top;
}
.titolo__parola {
  display: inline-block;
}
.come {
  margin: 0;
  max-width: 30ch;
  font-size: clamp(0.98rem, 0.9rem + 0.4vw, 1.18rem);
  font-weight: 460;
  line-height: 1.38;
  color: color-mix(in srgb, var(--bianco) 82%, transparent);
  text-wrap: pretty;
}
.parola-marchio {
  font-weight: 650;
  font-stretch: 108%;
  color: var(--tungsteno-chiaro);
}
.tasti {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 540;
  font-stretch: 108%;
  color: var(--menta);
}
.tasti svg {
  width: 50px;
  height: 34px;
  flex: none;
}
.tasti__dito { display: none; }
.tocco .tasti__frecce { display: none; }
.tocco .tasti__dito { display: block; }
.record-riga,
.stat {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 520;
  font-stretch: 106%;
  color: color-mix(in srgb, var(--bianco) 64%, transparent);
}
.causa {
  margin: 0;
  font-size: clamp(1.05rem, 0.9rem + 0.8vw, 1.4rem);
  font-weight: 600;
  font-stretch: 110%;
  color: var(--menta);
}
.fine__etichetta {
  margin: 4px 0 -6px;
  font-size: 0.8rem;
  font-weight: 560;
  font-stretch: 114%;
  color: color-mix(in srgb, var(--bianco) 64%, transparent);
}
.fine__numero {
  margin: 0;
  font-size: clamp(4rem, min(22vw, 20svh), 9rem);
  font-weight: 700;
  font-stretch: 100%;
  line-height: 0.9;
  letter-spacing: -0.05em;
}
.nuovo {
  margin: -2px 0 0;
  font-size: 0.95rem;
  font-weight: 660;
  font-stretch: 116%;
  letter-spacing: 0.01em;
  color: var(--tungsteno);
}
.nuovo[hidden] { display: none; }

/* ---------------------------------------------------------------- the pause veil */
.velo {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--carta) 82%, transparent);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.velo[hidden] { display: none; }
.velo__dentro {
  display: grid;
  justify-items: center;
  gap: 16px;
  text-align: center;
}
.velo__titolo {
  margin: 0;
  font-size: clamp(2.2rem, 1.4rem + 4vw, 4.4rem);
  font-weight: 680;
  font-stretch: 112%;
  line-height: 0.9;
  letter-spacing: -0.04em;
}
.velo__nota {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 520;
  font-stretch: 106%;
  color: var(--tenue);
}
.tocco .velo__nota { display: none; }

/* ---------------------------------------------------------------- the elastic pill of the site */
.pillola {
  --pb: var(--inchiostro);
  --pt: var(--bianco);
  --gonfia: 7px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--pt);
  font: inherit;
  font-size: 1.02rem;
  font-weight: 640;
  font-stretch: 100%;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  isolation: isolate;
  touch-action: manipulation;
}
.pillola::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--pb);
  transition: inset 0.6s var(--e-elastico), transform 0.16s 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: 125%;
}
.pillola--chiara {
  --pb: var(--bianco);
  --pt: var(--inchiostro);
}
.pillola--piena {
  --pb: var(--inchiostro);
  --pt: var(--bianco);
}
@media (hover: hover) and (pointer: fine) {
  .pillola:hover::before {
    inset: -2px calc(var(--gonfia) * -1);
  }
  .pillola:hover .pillola__testo {
    font-stretch: 125%;
  }
}
.pillola:active::before {
  transform: scale(1.03, 0.88);
}
.pillola:focus-visible {
  outline: 2px solid var(--tungsteno);
  outline-offset: 5px;
}
.velo .pillola:focus-visible {
  outline-color: var(--tungsteno-ombra);
}

/* ---------------------------------------------------------------- small windows */
@media (max-width: 560px) {
  .hud__blocco--record { display: none; }
  .hud { gap: 8px; padding-top: 10px; min-height: 56px; }
  .tondo { width: 38px; height: 38px; }
  .hud__parola { gap: 1px; }
}
@media (max-height: 600px) {
  .schermo__dentro { gap: 10px; }
  .pillola { min-height: 50px; }
}

/* ---------------------------------------------------------------- the preview tile of the section */
.anteprima .hud__destra .tondo,
.anteprima .hud__blocco--record,
.anteprima .croce,
.anteprima .schermo,
.anteprima .velo {
  display: none !important;
}
.anteprima .hud {
  grid-template-columns: 1fr auto;
  padding: 18px 26px 2px;
}
.anteprima .hud__destra { display: none; }
.anteprima .hud__parola { justify-self: end; }

@media (prefers-reduced-motion: reduce) {
  .pillola::before,
  .pillola__testo,
  .tondo svg,
  .hud__lettera::before {
    transition: none;
  }
}
