@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 280ms;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

.carregamento {
  --carregamento-bg: #f1edfb;
  --carregamento-trilho: rgba(124, 87, 247, 0.14);
  --carregamento-brilho: rgba(255, 255, 255, 0.75);
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background: var(--carregamento-bg);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

html[data-theme="dark"] .carregamento {
  --carregamento-bg: #08080c;
  --carregamento-trilho: rgba(255, 255, 255, 0.08);
  --carregamento-brilho: rgba(255, 255, 255, 0.55);
}

html:has(.carregamento:not(.carregamento--oculto)) {
  overflow: hidden;
}

.carregamento--oculto {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.carregamento__marca {
  width: min(220px, 60vw);
}

.carregamento__logo {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.carregamento__logo--escuro {
  display: none;
}

html[data-theme="dark"] .carregamento__logo--escuro {
  display: block;
}

html[data-theme="dark"] .carregamento__logo--claro {
  display: none;
}

.carregamento__trilho {
  position: relative;
  width: min(220px, 60vw);
  height: 4px;
  border-radius: 999px;
  background: var(--carregamento-trilho);
  overflow: hidden;
}

.carregamento__barra {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #05ce93 0%, #4f8ef6 55%, #7c57f7 100%);
  box-shadow: 0 0 12px rgba(124, 87, 247, 0.45);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.carregamento__barra::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, var(--carregamento-brilho) 50%, transparent 100%);
  transform: translateX(-100%);
  animation: carregamento-brilho 1.3s ease-in-out infinite;
}

.carregamento--concluido .carregamento__barra {
  transition-duration: 0.22s;
  transition-timing-function: ease-out;
}

.carregamento--oculto .carregamento__barra::after {
  animation-play-state: paused;
}

@keyframes carregamento-brilho {
  to { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }

  .carregamento__barra::after {
    animation: none;
    display: none;
  }
}
