/* ============================================================
   Bus Escape — WebGL 加载界面（游戏深色调）
   - 移除 Unity Logo
   - 进度条使用 Unity 原版素材 progress-bar-*-dark.png
   ============================================================ */

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: #191A1E;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  color: #F2F3F5;
}

#unity-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #231F20;          /* 与游戏画面底色一致，避免切换时闪白 */
  outline: none;
}

/* ---------------- 加载层 ---------------- */
#unity-loading-bar {
  position: absolute;
  inset: 0;
  display: none;                /* JS 启动时改为 flex */
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(135% 82% at 50% 12%, #3A3D46 0%, #333641 22%, #2B2D34 40%,
                    #26282E 56%, #202126 72%, #1A1B1F 86%, #16171A 100%);
  opacity: 1;
  transition: opacity 0.45s ease;
  z-index: 5;
}

#unity-loading-bar.is-done {
  opacity: 0;
  pointer-events: none;
}

/* 底部压暗，让画面下沉 */
#unity-loading-bar::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 38%;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.42) 100%);
  pointer-events: none;
}

/* 极淡的光带掠过，保留一点呼吸感 */
#unity-loading-bar::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0) 42%,
                              rgba(255, 255, 255, 0.045) 50%,
                              rgba(255, 255, 255, 0) 58%);
  animation: loadingSweep 4.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes loadingSweep {
  0%   { transform: translateX(-26%); }
  100% { transform: translateX(26%); }
}

.loading-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px;
  --bar-w: 141px;               /* 与 Unity 原版进度条尺寸一致 */
  --bar-h: 18px;
}

/* 图标卡片 */
.loading-badge {
  width: 68px;
  height: 68px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, #3C404A 0%, #24262B 100%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.48),
              inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: loadingFloat 2.8s ease-in-out infinite;
}

.loading-badge svg {
  width: 42px;
  height: 42px;
  display: block;
}

@keyframes loadingFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* 标题 */
.loading-title {
  margin-top: 24px;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.34em;
  text-indent: 0.34em;          /* 抵消末位 letter-spacing，视觉居中 */
  color: #F4F5F7;
  white-space: nowrap;
}

.loading-sub {
  margin-top: 10px;
  font-size: 12.5px;
  letter-spacing: 0.16em;
  text-indent: 0.16em;
  color: #8B909C;
}

/* ---------------- Unity 原版进度条 ---------------- */
#unity-progress-bar-empty {
  width: var(--bar-w);
  height: var(--bar-h);
  margin-top: 26px;
  background: url('progress-bar-empty-dark.png') no-repeat center;
  background-size: 100% 100%;
}

#unity-progress-bar-full {
  width: 0%;
  height: var(--bar-h);
  /* 固定背景尺寸：填充宽度变化时不拉伸变形，而是像原版一样从左被裁切 */
  background: url('progress-bar-full-dark.png') no-repeat left center;
  background-size: var(--bar-w) var(--bar-h);
  transition: width 0.22s ease;
}

.loading-percent {
  margin-top: 12px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: #8B909C;
}

.loading-percent i {
  font-style: normal;
  margin-left: 1px;
  opacity: 0.6;
}

/* ---------------- 桌面端适当放大 ---------------- */
@media (min-width: 820px) {
  .loading-inner { --bar-w: 220px; --bar-h: 24px; }
  .loading-badge { width: 84px; height: 84px; border-radius: 26px; }
  .loading-badge svg { width: 52px; height: 52px; }
  .loading-title { font-size: 24px; margin-top: 28px; }
  .loading-sub { font-size: 14px; }
  #unity-progress-bar-empty { margin-top: 30px; }
  .loading-percent { font-size: 13px; }
}

/* ---------------- 警告条 ---------------- */
#unity-warning {
  position: absolute;
  left: 50%;
  top: 4%;
  transform: translateX(-50%);
  display: none;
  max-width: 92vw;
  z-index: 10;
  font-size: 13px;
  line-height: 1.5;
  color: #F2F3F5;
}
