/* Schermata di caricamento di Autogo: giallo, logo che apre le ali, furgoncino che percorre la strada.
   È un file a parte (non nel pacchetto del sito) così si vede subito, prima che parta JavaScript. */
html.in-caricamento {
  overflow: hidden;
}

.caricamento {
  --avanzamento: 0;
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #ffee00;
  color: #1d1b1e;
  font-family: 'Archivo Variable', 'Helvetica Neue', Arial, sans-serif;
  clip-path: inset(0 0 0 0);
  /* Rete di sicurezza: se JavaScript non parte, sparisce da sola. */
  animation: car-sicurezza 0.6s 9s forwards;
}

.car-centro {
  display: grid;
  justify-items: center;
  gap: clamp(22px, 4vh, 40px);
  width: min(540px, 84vw);
  transition:
    transform 0.7s cubic-bezier(0.76, 0, 0.18, 1),
    opacity 0.5s;
}

/* Il logo si apre dal centro, come le ali che si spiegano. */
.car-logo {
  position: relative;
  width: 100%;
  overflow: hidden;
  animation: car-ali 1.1s cubic-bezier(0.7, 0, 0.2, 1) 0.1s both;
}

.car-logo img {
  display: block;
  width: 100%;
  height: auto;
}

/* Riflesso di luce che passa sul logo. */
.car-riflesso {
  position: absolute;
  inset: -20% auto -20% 0;
  width: 30%;
  background: linear-gradient(100deg, transparent, rgb(255 255 255 / 0.85), transparent);
  mix-blend-mode: soft-light;
  transform: translateX(-150%) skewX(-18deg);
  animation: car-luce 2.6s ease-in-out 1.1s infinite;
}

/* Strada: asfalto con le righe che scorrono e il furgoncino che avanza. */
.car-strada {
  position: relative;
  width: 100%;
  height: 58px;
  animation: car-su 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.55s both;
}

.car-asfalto {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 12px;
  overflow: hidden;
  border-radius: 6px;
  background: #1d1b1e;
}

.car-righe {
  position: absolute;
  inset: 5px -40px 5px 0;
  background: repeating-linear-gradient(90deg, #ffee00 0 14px, transparent 14px 28px);
  animation: car-corsia 0.45s linear infinite;
}

.car-furgone {
  position: absolute;
  bottom: 9px;
  left: calc(var(--avanzamento) * (100% - 68px));
  width: 68px;
  transition: left 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.car-furgone svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  animation: car-molla 0.32s ease-in-out infinite alternate;
}

.car-carrozzeria {
  fill: #1d1b1e;
}

.car-vetro {
  fill: #ffee00;
}

.car-fascia {
  fill: #ffee00;
  opacity: 0.85;
}

.car-ruota {
  transform-box: fill-box;
  transform-origin: center;
  animation: car-giro 0.5s linear infinite;
}

.car-ruota circle {
  fill: #1d1b1e;
  stroke: #ffee00;
  stroke-width: 1.4;
}

.car-ruota path {
  stroke: #ffee00;
  stroke-width: 1.2;
  stroke-linecap: round;
}

.car-testo {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  animation: car-su 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) 0.7s both;
}

.car-numero {
  min-width: 2.2ch;
  text-align: right;
  font-size: 28px;
  font-weight: 800;
}

.car-frase {
  margin-left: 10px;
  opacity: 0.75;
}

/* Uscita: il pannello giallo sale come una saracinesca e scopre il sito. */
.caricamento.is-via {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 0.95s cubic-bezier(0.76, 0, 0.18, 1) 0.1s;
}

.caricamento.is-via .car-centro {
  transform: translateY(-60px);
  opacity: 0;
}

.caricamento.is-finito {
  display: none;
}

@keyframes car-ali {
  from {
    clip-path: inset(0 50% 0 50%);
    transform: scale(0.92);
  }
  to {
    clip-path: inset(0 0 0 0);
    transform: scale(1);
  }
}

@keyframes car-luce {
  0% {
    transform: translateX(-150%) skewX(-18deg);
  }
  55%,
  100% {
    transform: translateX(420%) skewX(-18deg);
  }
}

@keyframes car-su {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes car-corsia {
  to {
    transform: translateX(-28px);
  }
}

@keyframes car-molla {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-1.5px);
  }
}

@keyframes car-giro {
  to {
    transform: rotate(360deg);
  }
}

@keyframes car-sicurezza {
  to {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .car-logo,
  .car-strada,
  .car-testo,
  .car-righe,
  .car-riflesso,
  .car-furgone svg,
  .car-ruota {
    animation: none;
  }

  .car-riflesso {
    display: none;
  }

  .caricamento.is-via {
    clip-path: inset(0 0 0 0);
    opacity: 0;
    transition: opacity 0.4s;
  }
}
