html.boot-loading,
html.boot-loading body {
  width: 100%;
  height: 100%;
  margin: 0;
}

html.boot-loading body {
  overflow: hidden;
  background:
    radial-gradient(
      circle at 50% 36%,
      var(--boot-glow),
      transparent var(--boot-glow-stop)
    ),
    linear-gradient(145deg, var(--boot-bg) 0%, var(--boot-bg-alt) 100%);
}

#preboot-global-loading {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: grid;
  place-items: center;
  font-family: Inter, 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
  color: var(--boot-text);
  --loading-cycle: 2.8s;
}

#preboot-global-loading .loader {
  display: grid;
  justify-items: center;
  gap: 26px;
}

#preboot-global-loading .logo-stage {
  width: 220px;
  height: 270px;
  display: grid;
  place-items: center;
  position: relative;
}

#preboot-global-loading .logo-stage::before {
  content: '';
  position: absolute;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    var(--boot-stage-glow-1),
    var(--boot-stage-glow-2) 58%,
    transparent 70%
  );
  animation: pxm-pulse var(--loading-cycle) ease-in-out infinite;
}

#preboot-global-loading .pxm-logo {
  width: 108px;
  height: auto;
  overflow: visible;
  position: relative;
  z-index: 1;
  transform-origin: 50% 50%;
  animation:
    pxm-rubber-band var(--loading-cycle) ease-in-out infinite,
    pxm-swing var(--loading-cycle) ease-in-out infinite;
}

#preboot-global-loading .pxm-piece {
  fill-rule: evenodd;
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  animation: pxm-bounce-in var(--loading-cycle)
    cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

/* 品牌色：业务上要求 logo 始终保持原色，不跟随主题切换。
   色值由 preboot-loading.js 注入到 --pxm-* 变量。 */
#preboot-global-loading .pxm-red {
  fill: var(--pxm-red);
  --from-x: 32px;
  --from-y: -42px;
  --from-r: 16deg;
  animation-delay: 0s;
}

#preboot-global-loading .pxm-green {
  fill: var(--pxm-green);
  --from-x: -38px;
  --from-y: -16px;
  --from-r: -14deg;
  animation-delay: 0.14s;
}

#preboot-global-loading .pxm-blue {
  fill: var(--pxm-blue);
  --from-x: 36px;
  --from-y: 18px;
  --from-r: 13deg;
  animation-delay: 0.28s;
}

#preboot-global-loading .pxm-yellow {
  fill: var(--pxm-yellow);
  --from-x: -32px;
  --from-y: 42px;
  --from-r: -12deg;
  animation-delay: 0.42s;
}

#preboot-global-loading .loading-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 24px;
  color: var(--boot-text-muted);
  font-size: 14px;
  font-weight: 650;
}

#preboot-global-loading .loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
}

#preboot-global-loading .loading-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.3;
  animation: dot-bounce 1.05s ease-in-out infinite;
}

#preboot-global-loading .loading-dots i:nth-child(2) {
  animation-delay: 0.12s;
}

#preboot-global-loading .loading-dots i:nth-child(3) {
  animation-delay: 0.24s;
}

@keyframes pxm-bounce-in {
  0% {
    opacity: 0;
    transform: translate(var(--from-x), var(--from-y)) rotate(var(--from-r))
      scale3d(0.28, 0.28, 0.28);
  }

  16% {
    opacity: 0.95;
    transform: translate(
        calc(var(--from-x) * 0.32),
        calc(var(--from-y) * 0.32)
      )
      rotate(calc(var(--from-r) * 0.32)) scale3d(1.08, 1.08, 1.08);
  }

  28% {
    opacity: 1;
    transform: translate(-3px, 2px) rotate(-1deg) scale3d(0.96, 0.96, 0.96);
  }

  40%,
  72% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale3d(1, 1, 1);
  }

  86% {
    opacity: 0.92;
    transform: translate(0, 0) rotate(0deg) scale3d(1.02, 1.02, 1.02);
  }

  100% {
    opacity: 0;
    transform: translate(
        calc(var(--from-x) * -0.18),
        calc(var(--from-y) * -0.18)
      )
      rotate(calc(var(--from-r) * -0.18)) scale3d(0.78, 0.78, 0.78);
  }
}

@keyframes pxm-rubber-band {
  0%,
  42%,
  72%,
  100% {
    transform: scale3d(1, 1, 1);
  }

  48% {
    transform: scale3d(1.12, 0.9, 1);
  }

  56% {
    transform: scale3d(0.94, 1.07, 1);
  }

  64% {
    transform: scale3d(1.035, 0.985, 1);
  }
}

@keyframes pxm-swing {
  0%,
  44%,
  100% {
    rotate: 0deg;
  }

  54% {
    rotate: 4deg;
  }

  64% {
    rotate: -3deg;
  }

  74% {
    rotate: 1.5deg;
  }

  82% {
    rotate: 0deg;
  }
}

@keyframes pxm-pulse {
  0%,
  100% {
    opacity: 0.6;
    transform: scale(0.88);
  }

  48% {
    opacity: 1;
    transform: scale(1.08);
  }

  72% {
    opacity: 0.72;
    transform: scale(0.98);
  }
}

@keyframes dot-bounce {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }

  40% {
    opacity: 0.95;
    transform: translateY(-5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #preboot-global-loading .logo-stage::before,
  #preboot-global-loading .pxm-logo,
  #preboot-global-loading .pxm-piece,
  #preboot-global-loading .loading-dots i {
    animation: none;
  }

  #preboot-global-loading .pxm-piece {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 520px) {
  #preboot-global-loading .logo-stage {
    width: 190px;
    height: 244px;
  }

  #preboot-global-loading .pxm-logo {
    width: 92px;
  }
}
