/*
 * Tela de carregamento (opção B do canvas "Leilão — Tela de carregamento"):
 * placar de lote com o martelo girando em cima. Arquivo estático em public/
 * porque precisa pintar ANTES do bundle e o CSP não aceita <style> inline.
 * O final (lotes correm até 30, placar brilha e desce, martelo arremata e
 * cresce até cobrir a tela) é orquestrado por `carregando.js`.
 */
#carregando {
  position: fixed; inset: 0; z-index: 2147483000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px;
  padding: 16px; box-sizing: border-box; overflow: hidden;
  background: #070B12; color: #F1F3EC;
  font-family: 'Archivo', system-ui, sans-serif;
  /* Rede de segurança: se o jogo nunca avisar que carregou, a tela sai sozinha e mostra o que houver. */
  animation: car-desiste .4s 25s forwards;
}
@keyframes car-desiste { to { opacity: 0; visibility: hidden; } }
#carregando.car-fora { opacity: 0; visibility: hidden; transition: opacity .45s ease, visibility 0s .45s; }

.car-martelo { display: block; width: 96px; height: 96px; object-fit: contain; animation: car-gira 1.6s ease-in-out infinite; }
/* A logo bate o martelo enquanto espera: balança e dá um toque no fim de cada volta. */
@keyframes car-gira {
  0%, 100% { transform: rotate(0) scale(1); }
  40% { transform: rotate(-10deg) scale(1.04); }
  60% { transform: rotate(4deg) scale(.97); }
  75% { transform: rotate(0) scale(1); }
}

.car-placar {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 28px 40px; background: #0B111C; border: 2px solid #243247;
  transition: transform .45s cubic-bezier(.5, 0, .75, 0), opacity .45s, box-shadow .3s, border-color .3s;
}
.car-rotulo { font: 700 13px 'IBM Plex Mono', ui-monospace, monospace; letter-spacing: .16em; text-transform: uppercase; color: #BCC6D6; }
.car-fichas { display: flex; gap: 8px; align-items: center; }
.car-ficha {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 76px; height: 104px; background: #101824; border: 1px solid #243247;
  font: 900 80px/1 'Big Shoulders Display', 'Arial Narrow', sans-serif; color: #F2B22E;
}
.car-ficha::after { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: #070B12; }
.car-ficha.car-fixa { color: #F1F3EC; }
.car-ficha.car-vira { animation: car-vira .14s ease-out; }
@keyframes car-vira { from { transform: perspective(300px) rotateX(-70deg); } to { transform: none; } }
.car-de { width: 18px; }

.car-gramado { position: relative; width: min(560px, 80vw); height: 36px; border-bottom: 2px solid #2F8F4A; }
.car-bola { position: absolute; left: 0; top: 4px; width: 30px; height: 30px; color: #F1F3EC; animation: car-corre 2.4s linear infinite; }
@keyframes car-corre { from { transform: translateX(-10px) rotate(0); } to { transform: translateX(calc(min(560px, 80vw) - 24px)) rotate(720deg); } }

.car-frase { margin: 0; font-size: 17px; font-weight: 700; text-align: center; }
.car-marca { position: absolute; bottom: 28px; font: 900 22px 'Big Shoulders Display', 'Arial Narrow', sans-serif; letter-spacing: .04em; text-transform: uppercase; }
.car-marca span { color: #F2B22E; }

/* ── Final ─────────────────────────────────────────────── */
#carregando.car-brilha .car-placar { border-color: #F2B22E; box-shadow: 0 0 0 4px rgba(242, 178, 46, .35), 0 0 60px rgba(242, 178, 46, .45); }
#carregando.car-brilha .car-ficha { color: #FFD36B; text-shadow: 0 0 18px rgba(242, 178, 46, .8); }
#carregando.car-desce .car-placar { transform: translateY(70vh); opacity: 0; }
#carregando.car-desce .car-gramado, #carregando.car-desce .car-frase { opacity: 0; transition: opacity .25s; }

/* A logo para, vai ao centro da tela (`--car-dy`, medido em carregando.js) e bate. */
#carregando.car-arremata .car-martelo {
  animation: car-bate .5s cubic-bezier(.6, 0, .4, 1) forwards;
  transform-origin: 50% 50%;
}
@keyframes car-bate {
  0% { transform: translateY(var(--car-dy, 30vh)) rotate(-16deg) scale(1.6); }
  55% { transform: translateY(var(--car-dy, 30vh)) rotate(6deg) scale(1.75); }
  70% { transform: translateY(var(--car-dy, 30vh)) rotate(-2deg) scale(1.6); }
  100% { transform: translateY(var(--car-dy, 30vh)) rotate(0) scale(1.6); }
}
.car-onda { position: absolute; left: 50%; top: 50%; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; border: 4px solid #F2B22E; opacity: 0; pointer-events: none; }
#carregando.car-arremata .car-onda { animation: car-onda .6s .26s ease-out forwards; }
@keyframes car-onda { from { transform: scale(.3); opacity: .9; } to { transform: scale(4); opacity: 0; } }

/* Cresce a partir do centro e some no caminho (fade out), enquanto o fundo sai por baixo. */
#carregando.car-cresce { background: transparent; transition: background .5s .2s; }
#carregando.car-cresce .car-martelo { transform-origin: 50% 50%; animation: car-cresce .7s cubic-bezier(.7, 0, .3, 1) forwards; }
@keyframes car-cresce {
  0% { transform: translateY(var(--car-dy, 30vh)) scale(1.6); opacity: 1; }
  100% { transform: translateY(var(--car-dy, 30vh)) scale(9); opacity: 0; }
}
#carregando.car-cresce .car-marca { opacity: 0; transition: opacity .2s; }

/* A tela inicial se monta, peça por peça, quando o martelo sai. */
html.entrada-montando .inicio-palco > * { animation: car-monta .55s cubic-bezier(.2, .8, .2, 1) both; }
html.entrada-montando .inicio-palco > *:nth-child(2) { animation-delay: .06s; }
html.entrada-montando .inicio-palco > *:nth-child(3) { animation-delay: .12s; }
html.entrada-montando .inicio-palco > *:nth-child(4) { animation-delay: .18s; }
html.entrada-montando .inicio-palco > *:nth-child(5) { animation-delay: .24s; }
html.entrada-montando .inicio-palco > *:nth-child(n + 6) { animation-delay: .3s; }
@keyframes car-monta { from { opacity: 0; transform: translateY(28px) scale(.98); } to { opacity: 1; transform: none; } }

@media (max-width: 480px) {
  #carregando { gap: 28px; }
  .car-martelo { width: 72px; height: 72px; }
  .car-placar { padding: 20px 22px; }
  .car-ficha { width: 56px; height: 78px; font-size: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  .car-martelo, .car-bola { animation: none; }
  .car-ficha.car-vira { animation: none; }
  html.entrada-montando .inicio-palco > * { animation: none; }
}
