/* A quiet moving cue rides over the real boot-stage progress value. */
html body #loading .loading-stage .loading-progress-track {
  position: relative;
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
}
html body #loading .loading-stage .loading-progress-track progress {
  display: block;
  width: 100%;
  height: 100%;
}
html body #loading .loading-stage .loading-progress-track i {
  position: absolute;
  inset: 0 auto 0 -30%;
  width: 30%;
  background: linear-gradient(90deg, transparent, #d8fff8a8 55%, transparent);
  transform: translateX(0);
  animation: sorvian-loading-scan 2.25s linear infinite;
  pointer-events: none;
}
@keyframes sorvian-loading-scan { to { transform: translateX(440%); } }
html body #loading:has(#loading-retry:not([hidden])) .loading-progress-track i { animation-play-state: paused; opacity: .35; }

/* Reserve separate screen bands for branding, recommendations, and status. */
#scene-loading .travel-stage { isolation: isolate; }
#scene-loading .travel-phase,
#scene-loading .travel-percent,
#scene-loading .travel-progress,
#scene-loading .travel-caption { z-index: 7; }
#scene-loading .travel-phase {
  position: absolute;
  bottom: 19%;
  left: 8%;
  right: 8%;
  color: #b9d8e4;
  font: 600 10px/1.3 system-ui;
  letter-spacing: .2em;
  text-align: center;
  text-transform: uppercase;
}
#scene-loading .travel-percent {
  display: block;
  position: absolute;
  bottom: 12%;
  left: 8%;
  right: 8%;
  margin: 0;
  color: #f1dfbb;
  font: 300 clamp(26px, 4dvh, 38px)/1 system-ui;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
#scene-loading .travel-progress {
  top: auto;
  bottom: 9%;
  left: 18%;
  right: 18%;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
}
#scene-loading .travel-progress::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 -30%;
  width: 30%;
  background: linear-gradient(90deg, transparent, #e8fff3c9 55%, transparent);
  animation: sorvian-loading-scan 2.25s linear infinite;
}
#scene-loading:is([data-stage=countdown],[data-stage=ready],[data-stage=failed]) .travel-progress::after { animation: none; opacity: 0; }
#scene-loading .travel-caption {
  top: auto;
  bottom: 2%;
  left: 8%;
  right: 8%;
  margin: 0;
  font-size: clamp(11px, 1.5dvh, 13px);
  line-height: 1.4;
}
#scene-loading[data-kind=portal] .travel-header {
  top: clamp(22px, 4dvh, 48px);
  left: 8%;
  right: 8%;
}
#scene-loading[data-kind=portal] .travel-logo {
  width: clamp(48px, 7dvh, 68px);
  height: clamp(48px, 7dvh, 68px);
  margin-bottom: 5px;
}
#scene-loading[data-kind=portal] .travel-header strong {
  font-size: clamp(30px, 6dvh, 54px);
  line-height: 1.1;
}
#scene-loading[data-kind=portal] .travel-header p { margin-top: 4px; }
#scene-loading[data-kind=portal] .travel-explore {
  top: auto;
  bottom: 25%;
  transform: translateX(-50%);
  max-height: 22%;
  overflow: auto;
}
/* The existing guide enhancer replaces travel-explore at runtime. Keep its
   replacement in the same reserved band instead of its default top edge. */
#scene-loading .travel-stage > .sorvian-loading-guide[hidden],
#scene-loading[data-stage=failed] .travel-stage > .sorvian-loading-guide { display: none; }
#scene-loading .travel-stage > .sorvian-loading-guide:not([hidden]) {
  position: absolute;
  z-index: 6;
  top: auto;
  bottom: 25%;
  left: 50%;
  transform: translateX(-50%);
  box-sizing: border-box;
  width: min(360px, calc(100% - 32px));
  max-height: 22%;
  overflow: auto;
  padding: 12px 16px;
  border: 1px solid #b7d5d677;
  border-radius: 14px;
  background: #112439f2;
  color: #e8f5f6;
  text-align: center;
  box-shadow: 0 12px 28px #050b1666;
}
#scene-loading .travel-stage > .sorvian-loading-guide small {
  display: block;
  margin-bottom: 6px;
  color: #d9b989;
  font: 600 10px/1.4 system-ui;
  letter-spacing: .1em;
}
#scene-loading .travel-stage > .sorvian-loading-guide strong {
  display: block;
  font: 600 16px/1.3 system-ui;
}
#scene-loading .travel-stage > .sorvian-loading-guide p {
  margin: 5px 0 0;
  font: 400 12px/1.45 system-ui;
}
/* Portal glass stays shut throughout travel and preparation. A countdown is
   emitted only after critical assets and stable rendered frames are ready. */
#scene-loading[data-kind=portal] .travel-doors i {
  animation: none !important;
  transform: translateX(0);
  transition: transform .65s cubic-bezier(.22,.7,.2,1);
}
#scene-loading[data-kind=portal]:is([data-stage=countdown],[data-stage=ready]) .travel-doors i { transform: translateX(-100%); }
#scene-loading[data-kind=portal]:is([data-stage=countdown],[data-stage=ready]) .travel-doors i + i { transform: translateX(100%); }
#scene-loading[data-kind=area] .travel-header { top: 43%; }
#scene-loading[data-kind=area] .travel-progress { top: auto; bottom: 9%; left: 18%; right: 18%; }
#scene-loading[data-kind=area] .travel-caption { top: auto; bottom: 2%; }
#scene-loading[data-kind=lift] .travel-percent,
#scene-loading[data-kind=lift][data-stage=countdown] .travel-percent {
  display: block;
  top: auto;
  bottom: 12%;
  font: 300 clamp(26px, 4dvh, 38px)/1 system-ui;
}
#scene-loading[data-kind=lift] .travel-progress { bottom: 9%; left: 35%; right: 35%; }
#scene-loading[data-kind=lift] .travel-caption { bottom: 2%; }
#scene-loading[data-stage=countdown] .travel-percent { top: auto; bottom: 12%; font: 300 clamp(26px, 4dvh, 38px)/1 system-ui; }
#scene-loading[data-kind=area][data-stage=countdown] .travel-header { top: 43%; }
#scene-loading[data-kind=area][data-stage=countdown] .travel-progress { top: auto; bottom: 9%; }
#scene-loading[data-kind=area][data-stage=countdown] .travel-caption { top: auto; bottom: 2%; }
#scene-loading[data-stage=failed] .travel-percent,
#scene-loading[data-kind=lift][data-stage=failed] .travel-percent,
#scene-loading[data-stage=failed] .travel-progress { display: none; }
#scene-loading[data-stage=failed] .travel-shaft,
#scene-loading[data-stage=failed] .travel-doors { display: none; }
#scene-loading[data-stage=failed] .travel-route { display: none; }
#scene-loading[data-stage=failed] .travel-phase { bottom: 48%; }
#scene-loading[data-stage=failed] .travel-caption { bottom: 39%; }
#scene-loading[data-kind=area][data-stage=failed] .travel-header {
  top: clamp(16px, 5dvh, 52px);
  transform: none;
}
#scene-loading[data-kind=area][data-stage=failed] .travel-logo {
  position: static;
  width: clamp(44px, 9dvh, 72px);
  height: auto;
  margin: 0 auto 7px;
  transform: none;
}
#scene-loading[data-kind=area][data-stage=failed] .travel-header strong {
  font-size: clamp(25px, 5dvh, 38px);
}
#scene-loading[data-kind=area][data-stage=failed] .travel-header p {
  position: static;
  margin: 7px 0 0;
  font-size: 13px;
}

@media(max-width: 500px) {
  #scene-loading[data-kind=lift] .travel-route { display: none; }
  #scene-loading[data-kind=portal] .travel-header strong {
    font-size: clamp(28px, 8vw, 38px);
    letter-spacing: .03em;
    white-space: nowrap;
  }
}
@media(max-height: 560px) {
  html body #loading { overflow: auto; }
  #scene-loading[data-kind=area]:not([data-stage=failed]) .travel-header { top: 30%; }
  #scene-loading[data-kind=area]:not([data-stage=failed]) .travel-logo {
    width: 80px;
    height: 80px;
    bottom: calc(100% + 4px);
  }
  #scene-loading[data-kind=area]:not([data-stage=failed]) .travel-header strong { font-size: 32px; }
  #scene-loading[data-kind=area]:not([data-stage=failed]) .travel-header p { margin-top: 8px; }
  #scene-loading .travel-stage > .sorvian-loading-guide:not([hidden]) {
    bottom: 26%;
    max-height: 26%;
    padding: 7px 12px;
  }
  #scene-loading .travel-stage > .sorvian-loading-guide p { font-size: 11px; }
  #scene-loading[data-kind=portal] .travel-header { top: 2%; }
  #scene-loading[data-kind=portal] .travel-logo { width: 38px; height: 38px; margin-bottom: 2px; }
  #scene-loading[data-kind=portal] .travel-header strong { font-size: clamp(23px, 7dvh, 34px); }
  #scene-loading[data-kind=portal] .travel-header small { font-size: 9px; }
  #scene-loading[data-kind=portal] .travel-header p { font-size: 11px; }
  #scene-loading[data-kind=portal] .travel-explore { bottom: 27%; max-height: 29%; padding: 7px 11px; }
  #scene-loading .travel-phase { bottom: 18%; font-size: 9px; }
  #scene-loading .travel-percent,
  #scene-loading[data-kind=lift][data-stage=countdown] .travel-percent { bottom: 11%; font-size: 22px; }
  #scene-loading .travel-progress { bottom: 8%; }
  #scene-loading .travel-caption { bottom: 1%; font-size: 10px; }
}
@media(prefers-reduced-motion: reduce) {
  html body #loading .loading-progress-track i,
  #scene-loading .travel-progress::after { animation: none; opacity: .35; }
  #scene-loading[data-kind=portal] .travel-doors i { transition: none; }
}
