/* La pillola che vola: i colori di Animorio, petrolio e tungsteno, Mona Sans */
:root {
  --p-900: #041b1a;
  --p-800: #072a29;
  --p-700: #0b3b39;
  --p-600: #0f4f4c;
  --p-500: #146662;
  --tungsteno: #ff8a3d;
  --tungsteno-ombra: #d9602a;
  --tungsteno-chiaro: #ffb27a;
  --menta: #86cfc4;
  --pesca: #ffc896;
  --bianco: #f6f7f3;
  --inchiostro: #07201f;
  /* the colour of the score and the round buttons: script.js turns it dark on the light sky */
  --hud: #f6f7f3;
  --hud-fondo: rgba(4, 27, 26, 0.28);
  --e-elastico: cubic-bezier(0.34, 1.9, 0.45, 1);
  --e-uscita: cubic-bezier(0.23, 1, 0.32, 1);
  --f: 'Mona Sans Variable', system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  background: var(--p-500);
  color: var(--bianco);
  font-family: var(--f);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

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

.gioco:focus {
  outline: none;
}
.gioco {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
}

/* ------------------------------------------------------------------ the world */
.mondo {
  position: absolute;
  inset: 0;
}
.tela {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* the flying pill: a key with its dark base, the orange face that inflates, the word that widens on the wdth axis */
.volante {
  position: absolute;
  left: 0;
  top: 0;
  width: 112px;
  height: 48px;
  pointer-events: none;
  will-change: transform;
  visibility: hidden;
}
.volante__base,
.volante__fondo {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  will-change: transform;
}
.volante__base {
  background: var(--tungsteno-ombra);
}
.volante__fondo {
  background: var(--tungsteno);
  box-shadow: inset 0 1px 0 rgba(255, 216, 182, 0.55);
}
.volante__scritta {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 999px;
  color: var(--inchiostro);
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1;
  will-change: transform;
}
.volante__parola {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  white-space: nowrap;
  will-change: transform;
}

/* ------------------------------------------------------------------ score and buttons on top */
.hud {
  position: absolute;
  inset: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
  pointer-events: none;
}
.punti {
  grid-column: 2;
  margin: 0;
  color: var(--hud);
  font-weight: 720;
  font-stretch: 112%;
  font-size: clamp(2.6rem, min(11vw, 11vh), 5.4rem);
  line-height: 1;
  letter-spacing: -0.045em;
  transform-origin: 50% 60%;
  opacity: 0;
}
/* on the light sky the score turns dark, and light again over a column */
.cielo-chiaro .punti {
  -webkit-text-stroke: 0.1em #fff4e6;
  paint-order: stroke fill;
}
.hud__tasti {
  grid-column: 3;
  justify-self: end;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.tondo {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--hud-fondo);
  color: var(--hud);
  cursor: pointer;
  transition: transform 0.5s var(--e-elastico), background-color 0.3s ease;
}
.tondo svg {
  width: 20px;
  height: 20px;
}
.tondo:active {
  transform: scale(0.9);
}
.tondo:focus-visible,
.pillola:focus-visible {
  outline: 2px solid var(--bianco);
  outline-offset: 3px;
}
.tondo .suono-no,
.tondo[aria-pressed='false'] .suono-si {
  display: none;
}
.tondo[aria-pressed='false'] .suono-no {
  display: block;
}
@media (hover: hover) and (pointer: fine) {
  .tondo:hover {
    transform: scale(1.08);
  }
}
.gioco[data-stato='inizio'] .hud__tasti [data-pausa],
.gioco[data-stato='fine'] .hud__tasti [data-pausa] {
  visibility: hidden;
}

/* the hint under the pill before the first jump */
/* a box zero wide under the pill: the words stay centred on it */
.cenno {
  position: absolute;
  left: 30%;
  top: 0;
  width: 0;
  display: flex;
  justify-content: center;
  margin: 0;
  white-space: nowrap;
  color: var(--hud);
  font-size: clamp(0.95rem, 0.8rem + 0.6vw, 1.15rem);
  font-weight: 560;
  font-stretch: 108%;
  pointer-events: none;
  opacity: 0;
}
.cenno__tocca,
[data-riga-tocca] {
  display: none;
}
.tocco .cenno__tocca {
  display: inline;
}
.tocco [data-riga-tocca] {
  display: block;
}
.tocco .cenno__tasto,
.tocco [data-riga-tasto] {
  display: none;
}

/* a key drawn as a key */
.tasto {
  display: inline-grid;
  place-items: center;
  min-width: 2.2em;
  height: 1.7em;
  padding: 0 0.6em;
  margin: 0 0.12em;
  border-radius: 0.42em;
  background: color-mix(in srgb, currentColor 10%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, currentColor 55%, transparent), inset 0 -3px 0 color-mix(in srgb, currentColor 18%, transparent);
  color: inherit;
  font-family: inherit;
  font-size: 0.86em;
  font-weight: 640;
  font-stretch: 112%;
  line-height: 1;
  vertical-align: 0.06em;
}

/* ------------------------------------------------------------------ screens: start, game over, pause */
.schermo {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 72px 16px 28px;
  background: rgba(4, 27, 26, 0.5);
  cursor: default;
  text-align: center;
}
.schermo[hidden] {
  display: none;
}
.schermo--inizio {
  background: linear-gradient(rgba(4, 27, 26, 0.18), rgba(4, 27, 26, 0.5));
}
/* game over and pause: a petrol card in the middle, the sky stays visible around it */
.schermo--fine,
.schermo--pausa {
  background: rgba(4, 27, 26, 0.16);
}
.schermo--fine .schermo__dentro,
.schermo--pausa .schermo__dentro {
  width: min(520px, 100%);
  padding: clamp(24px, 5vh, 44px) clamp(20px, 5vw, 44px);
  border-radius: 24px;
  background: rgba(7, 42, 41, 0.97);
  box-shadow: inset 0 0 0 1px rgba(246, 247, 243, 0.08);
}
.schermo__dentro {
  display: grid;
  justify-items: center;
  gap: clamp(14px, 2.6vh, 24px);
  max-width: 640px;
}
.marchio {
  display: inline-flex;
  align-items: center;
  gap: 0.47em;
  margin: 0;
  font-weight: 700;
  font-stretch: 116%;
  font-size: 1.05rem;
  letter-spacing: -0.035em;
  line-height: 1;
}
.marchio__rombo {
  width: 1.42em;
  height: 1.42em;
  overflow: visible;
}
.titolo {
  margin: 0;
  font-weight: 720;
  font-stretch: 125%;
  font-size: clamp(2.6rem, min(12.5vw, 15vh), 7.6rem);
  line-height: 0.9;
  letter-spacing: -0.045em;
  text-wrap: balance;
}
.titolo .parola-m {
  display: inline-block;
  overflow: clip;
  vertical-align: top;
  padding: 0.04em 0.03em 0.12em;
  margin: -0.04em -0.03em -0.12em;
}
.titolo .parola-m > span {
  display: inline-block;
}
.riga {
  margin: 0;
  max-width: 30em;
  color: rgba(246, 247, 243, 0.86);
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.25rem);
  font-weight: 450;
  line-height: 1.5;
  text-wrap: balance;
}
.riga--piccola {
  font-size: 0.95rem;
  color: rgba(246, 247, 243, 0.7);
}
.record {
  margin: 0;
  color: var(--menta);
  font-size: 1rem;
  font-weight: 560;
  font-stretch: 110%;
}
.record b {
  color: var(--bianco);
  font-weight: 720;
}

/* the site's elastic pill: the word widens on the wdth axis, the orange background inflates with a bounce */
.pillola {
  --gonfia: 7px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 28px 0 24px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--inchiostro);
  font-family: inherit;
  font-weight: 650;
  font-stretch: 100%;
  font-size: 1.06rem;
  letter-spacing: -0.01em;
  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(--tungsteno);
  transition: inset 0.6s var(--e-elastico), transform 0.16s var(--e-uscita);
}
.pillola__segno {
  width: 18px;
  height: 18px;
  flex: none;
  transition: transform 0.6s var(--e-elastico);
}
.pillola__testo {
  display: grid;
  text-align: center;
  transition: font-stretch 0.6s var(--e-elastico);
}
/* the word at its widest, invisible and zero high: it keeps the room, so nothing around moves */
.pillola__testo::before {
  content: attr(data-testo);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 125%;
}
.pillola.gonfia::before {
  inset: -2px calc(var(--gonfia) * -1);
}
.pillola.gonfia .pillola__testo {
  font-stretch: 125%;
}
.pillola.gonfia .pillola__segno {
  transform: translateX(3px) rotate(-14deg);
}
@media (hover: hover) and (pointer: fine) {
  .pillola:hover::before {
    inset: -2px calc(var(--gonfia) * -1);
  }
  .pillola:hover .pillola__testo {
    font-stretch: 125%;
  }
  .pillola:hover .pillola__segno {
    transform: translateX(3px) rotate(-14deg);
  }
}
.pillola:active::before {
  transform: scale(1.03, 0.88);
}

.fine__titolo {
  margin: 0;
  font-weight: 700;
  font-stretch: 118%;
  font-size: clamp(1.9rem, min(7.4vw, 8vh), 3.6rem);
  text-wrap: balance;
  line-height: 0.95;
  letter-spacing: -0.04em;
}
.conti {
  display: flex;
  gap: clamp(28px, 7vw, 72px);
}
.conto {
  display: grid;
  gap: 6px;
  margin: 0;
}
.conto__nome {
  color: var(--menta);
  font-size: 0.95rem;
  font-weight: 560;
  font-stretch: 110%;
}
.conto__numero {
  display: block;
  font-weight: 720;
  font-stretch: 112%;
  font-size: clamp(3rem, min(14vw, 14vh), 6.4rem);
  line-height: 0.9;
  letter-spacing: -0.05em;
}
.conto--record .conto__numero {
  color: var(--tungsteno-chiaro);
}
.bollino {
  display: inline-flex;
  align-items: center;
  height: 28px;
  margin: 0;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--tungsteno);
  color: var(--inchiostro);
  font-size: 0.85rem;
  font-weight: 650;
  font-stretch: 110%;
}
.bollino[hidden] {
  display: none;
}

/* ------------------------------------------------------------------ the shutter */
.otturatore {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  pointer-events: none;
}
.otturatore > span {
  flex: var(--f, 1);
  height: 100%;
  background: var(--p-800);
  box-shadow: inset 1px 0 0 rgba(246, 247, 243, 0.07);
  transform: scaleY(0);
  transform-origin: 50% 0;
  will-change: transform;
}

/* small and low windows */
@media (max-height: 620px) {
  .schermo {
    padding-top: 64px;
    padding-bottom: 16px;
  }
  .schermo__dentro {
    gap: 12px;
  }
  .pillola {
    min-height: 50px;
  }
}

/* ------------------------------------------------------------------ the preview frame: it plays by itself */
.anteprima .gioco {
  cursor: default;
}
.anteprima .hud__tasti,
.anteprima .schermo,
.anteprima .cenno {
  display: none;
}

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