/*
 * Tela de carregamento: aparece assim que o index.html chega e some quando o app termina de
 * carregar (src/lib/loading-screen.ts). Fica num arquivo à parte (e não num <style> dentro do
 * HTML) para a CSP do site poder ser só 'self'.
 * Cores = tokens do site: ink e gold (src/styles.css).
 */
#carregando {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #141210;
  background: oklch(0.18 0.005 60);
  transition:
    opacity 0.45s ease,
    visibility 0.45s ease;
  /* Se o JavaScript falhar, a tela não fica presa para sempre. */
  animation: carregando-desiste 0.4s ease 12s forwards;
}
#carregando.pronto {
  opacity: 0;
  visibility: hidden;
}
#carregando .trilho {
  width: min(14rem, 60vw);
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: oklch(0.24 0.006 60);
}
#carregando .barra {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: oklch(0.72 0.11 80);
  /* Avança rápido no começo e desacelera perto do fim, até o app avisar que terminou. */
  animation: carregando-avanca 2.4s cubic-bezier(0.1, 0.7, 0.3, 1) forwards;
}
#carregando.pronto .barra {
  width: 100%;
  animation: none;
  transition: width 0.25s ease;
}

@keyframes carregando-avanca {
  from {
    width: 0;
  }
  to {
    width: 88%;
  }
}
@keyframes carregando-desiste {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  #carregando .barra {
    animation: none;
    width: 60%;
  }
  #carregando {
    transition: none;
  }
}
