/* TELA DE CARREGAMENTO (casco novo) e CSS CRÍTICO DA ABERTURA.
   Este arquivo fica em public/ e é ligado no <head> do index.html com <link rel="stylesheet" href="/boot.css"> (em public/ o Vite o copia como está; importado, ele o fundiria no CSS grande). É o PRIMEIRO CSS da página:
   assim a tela aparece igual desde o 1º quadro, sem esperar o CSS grande do jogo e sem depender de JS. A CSP do jogo não aceita <style> nem style="" no HTML
   (style-src 'self'), por isso o CSS crítico é um arquivo. Não depende de variáveis de outros arquivos: tudo aqui tem valor próprio. Textos vêm do HTML
   (marca fixa) e de ui/loading.js (etapa e dica, via i18n). Fundo: arte do Codex em /assets/telas/carregamento/ (desktop 16:9, celular em pé), ligada
   pelo próprio CSS; se a imagem falhar, ui/loading.js marca `data-art="off"` e a tela cai num preto com grão e respingo vermelho. */

/* Famílias próprias ("Boot ...") para não brigar com as do casco (manga-tokens.css): o mesmo arquivo, pré-carregado no <head>, e nada de troca de fonte
   quando o CSS grande chega. `block`: a marca espera a fonte (alguns ms) em vez de aparecer com uma fonte trocada. */
@font-face { font-family: 'Boot Anton'; src: url('/fonts/anton-400.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: 'Boot Brush'; src: url('/fonts/edo-sz.ttf') format('truetype'); font-weight: 400; font-style: normal; font-display: block; }
@font-face { font-family: 'Boot UI'; src: url('/fonts/oswald-variable.ttf') format('truetype'); font-weight: 200 700; font-style: normal; font-display: swap; }

/* Nenhum quadro branco: fundo escuro e esquema escuro (barras de rolagem, campos) já no 1º quadro. Mesma cor do theme-color e do manifest. */
html, body { margin: 0; height: 100%; background: #0d0d12; color: #f7edd5; color-scheme: dark; }

#loading {
  position: fixed; inset: 0; z-index: 50; isolation: isolate; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 16px max(16px, env(safe-area-inset-right)) max(5vh, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: #0d0d12; color: #f7edd5; text-align: center;
  font-family: 'Boot UI', Oswald, 'Arial Narrow', 'Segoe UI', system-ui, sans-serif;
}
#loading[hidden] { display: none; }
#loading * { box-sizing: border-box; }

/* ---- camadas de fundo ---- */
.boot-art, .boot-fallback, .boot-shade { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.boot-art {
  background: #0d0d12 url('/assets/telas/carregamento/carregamento-desktop.webp') center top / cover no-repeat;
  animation: boot-art-in .7s ease-out both; /* aparece sozinha, sem esperar o JS (que no dev chega depois de ~2 s); com movimento reduzido entra direto */
}
@keyframes boot-art-in { from { opacity: 0; } to { opacity: 1; } }
@media (orientation: portrait) { .boot-art { background-image: url('/assets/telas/carregamento/carregamento-mobile.webp'); } }
/* sem a arte: preto de papel com grão, halftone vermelho nos cantos e uma brasa de luz atrás da marca */
.boot-fallback {
  opacity: 0; transition: opacity .6s ease-out;
  background:
    radial-gradient(ellipse 55% 38% at 50% 50%, rgba(237, 24, 43, .22), transparent 72%),
    radial-gradient(circle, rgba(237, 24, 43, .5) 1.3px, transparent 1.8px) 0 0 / 14px 14px,
    #0d0d12 url('/assets/lobby/chrome/paper-grain.webp') center / 430px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,.55) 0%, #000 85%); mask-image: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,.55) 0%, #000 85%);
}
#loading[data-art="off"] .boot-art { display: none; }
#loading[data-art="off"] { justify-content: center; padding-bottom: 16px; } /* sem a cena, o bloco vai para o meio da tela */
#loading[data-art="off"] .boot-fallback { opacity: 1; }
/* escurece o pé da cena para a marca, a barra e a dica ficarem legíveis sobre o chão preto (área calma da arte) */
.boot-shade { background: linear-gradient(to bottom, rgba(13, 13, 18, 0) 38%, rgba(13, 13, 18, .72) 78%, rgba(13, 13, 18, .9)); }

/* ---- bloco central (na área calma da arte: embaixo, no meio) ---- */
.boot-main { position: relative; width: clamp(300px, 44vw, 640px); max-width: 100%; display: flex; flex-direction: column; align-items: center; gap: clamp(8px, 2.2vh, 18px); }

/* marca: ONE PUNCH (Anton, papel) + IDLE (Edo SZ, vermelho) sobre a pincelada vermelha, como no cabeçalho do casco (lobby.css .lb-brand) */
.boot-brand {
  position: relative; isolation: isolate; margin: 0; display: flex; align-items: center; justify-content: center; gap: .16em; white-space: nowrap;
  font-size: clamp(30px, min(5.4vw, 9vh), 84px); line-height: 1; transform: rotate(-2deg);
}
.boot-one { font: 400 1em/1 'Boot Anton', Anton, Impact, 'Arial Narrow Bold', sans-serif; letter-spacing: -.025em; color: #f7edd5; text-shadow: 0 3px 0 rgba(0, 0, 0, .55); }
.boot-idle { position: relative; font: 400 1.23em/1 'Boot Brush', 'Boot Anton', Impact, sans-serif; color: #f32132; transform: rotate(-3deg); text-shadow: 0 3px 0 rgba(0, 0, 0, .55); }
.boot-brand::after {
  content: ''; position: absolute; z-index: -1; left: -2%; bottom: -.2em; width: 104%; height: .52em;
  background: url('/assets/lobby/chrome/brush-red.webp') center / 100% 100% no-repeat; transform: rotate(-3deg); pointer-events: none;
}
@media (orientation: portrait) { .boot-brand { font-size: clamp(28px, 11.2vw, 72px); } .boot-main { width: min(92vw, 520px); } }

/* barra: pincelada amarela que vai sendo "pintada" conforme o progresso real (#load-fill muda a largura; a pincelada fica com a largura cheia da barra) */
#load-bar { position: relative; width: 100%; height: clamp(22px, 4.4vh, 34px); margin-top: clamp(4px, 1.4vh, 12px); container-type: inline-size; border-bottom: 2px solid rgba(209, 197, 169, .4); transform: rotate(-.6deg); }
#load-bar::before { content: ''; position: absolute; inset: 0; background: rgba(247, 237, 213, .07); }
#load-fill { position: relative; height: 100%; width: 0%; overflow: hidden; transition: width .4s ease-out; }
#load-fill::before { content: ''; position: absolute; left: 0; top: 0; width: 100cqw; height: 100%; background: url('/assets/lobby/chrome/pincelada-amarela-larga.png') left center / 100% 100% no-repeat; }
/* ainda em 0% (o JS está chegando): a barra respira em vez de parecer travada */
#load-bar[aria-valuenow="0"]::before { animation: boot-breathe 1.6s ease-in-out infinite; }
@keyframes boot-breathe { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

.boot-label { margin: 0; min-height: 1.3em; font-size: clamp(14px, 2.6vh, 19px); font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: #d0c4a9; }

/* dica: rótulo + texto de i18n (loading.tip.N), reserva 1+2 linhas para a tela não pular quando a dica troca */
.boot-tip { margin: 0; min-height: 4.4em; max-width: 34em; display: flex; flex-direction: column; align-items: center; gap: .15em; font-size: clamp(14px, 2.5vh, 19px); font-weight: 500; line-height: 1.3; color: #f7edd5; text-wrap: balance; transition: opacity .3s ease; }
.boot-tip[data-empty] { visibility: hidden; }
.boot-tip[data-out] { opacity: 0; }
.boot-tip-k { font-size: .82em; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: #ffdc08; }
.boot-tip-k:empty { display: none; }

/* botões: "Tentar de novo" no padrão .mg-cta (manga-ui.css) e "Já tenho conta" como link */
#loading .mg-cta {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 6px 22px; margin-top: 4px;
  border: 3px solid #11120b; border-radius: 0; outline: 2px solid #f5dc69; outline-offset: -1px; color: #090c0c; background: #ffdc08;
  font: 700 22px/1 'Boot UI', Oswald, 'Arial Narrow', sans-serif; letter-spacing: .02em; text-transform: uppercase; cursor: pointer;
}
#loading .mg-cta:hover { background: #ffe85c; }
#loading .mg-cta[hidden], #loading .boot-link[hidden] { display: none; }
#loading :focus-visible { outline: 3px solid #65eaff; outline-offset: 3px; }
.boot-link { min-height: 44px; padding: 8px 12px; border: 0; background: none; color: #d0c4a9; font: 600 16px/1.2 'Boot UI', Oswald, 'Arial Narrow', sans-serif; letter-spacing: .04em; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.boot-link:hover { color: #f7edd5; }

/* celular deitado (altura curta): marca menor, sem folga e dica numa linha só se couber */
@media (max-height: 480px) and (orientation: landscape) {
  #loading { padding-bottom: max(3vh, env(safe-area-inset-bottom)); }
  .boot-main { width: clamp(300px, 52vw, 640px); gap: 6px; }
  .boot-brand { font-size: clamp(26px, 10vh, 48px); }
  #load-bar { height: 18px; margin-top: 2px; }
  .boot-tip { min-height: 3.6em; font-size: 14px; }
  .boot-label { font-size: 13px; }
  #loading .mg-cta { min-height: 40px; font-size: 18px; }
  .boot-link { min-height: 36px; padding: 4px 12px; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  #loading, #loading * { animation: none !important; transition: none !important; }
}

/* paralaxe do mouse (ui/loading.js + ui/parallax.js) */
.boot-art { translate: var(--px-x, 0px) var(--px-y, 0px); scale: 1.05; }
