/*
 * loader.css — the loading screen (datafiles/js/loader.js).
 * Opaque and above everything, including the menu: until the game is running
 * nothing underneath it works, so nothing underneath it should be visible.
 */

#game-loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #e6e6ee;
  background:
    radial-gradient(78% 86% at 50% 16%, rgb(28, 32, 56), rgb(4, 5, 12) 72%);
  transition: opacity 0.4s ease;
}
#game-loader.is-done { opacity: 0; pointer-events: none; }
#game-loader[hidden] { display: none; }

.gl-card {
  width: min(460px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.gl-brand {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #f0c040;
  text-align: center;
}
.gl-brand span { color: #e6e6ee; font-weight: 300; margin: 0 3px; }

.gl-headline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13px;
  color: rgba(230, 230, 238, 0.7);
}
.gl-pct {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.gl-rate { font-variant-numeric: tabular-nums; }

.gl-bar {
  position: relative;
  height: 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.gl-bar-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, #c8901c, #f0c040);
  transition: transform 0.25s linear;
}
/* A sheen that keeps moving even when the bytes are not, so a slow stretch
   still looks alive rather than frozen. */
.gl-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: gl-sheen 1.4s linear infinite;
}
@keyframes gl-sheen {
  from { background-position: -40% 0; }
  to   { background-position: 140% 0; }
}
#game-loader.is-failed .gl-bar-fill { background: #b8473a; }
#game-loader.is-failed .gl-bar-fill::after { animation: none; }

.gl-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.gl-step {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(230, 230, 238, 0.35);
}
.gl-step-icon {
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  border: 2px solid currentColor;
  box-sizing: border-box;
}
.gl-step-name { flex: 1; }
.gl-step-detail { font-variant-numeric: tabular-nums; }

.gl-step[data-state="active"] { color: #e6e6ee; }
.gl-step[data-state="active"] .gl-step-icon {
  border-color: rgba(240, 192, 64, 0.25);
  border-top-color: #f0c040;
  animation: gl-spin 0.8s linear infinite;
}
.gl-step[data-state="done"] { color: rgba(230, 230, 238, 0.6); }
.gl-step[data-state="done"] .gl-step-icon {
  border-color: #5fbf6a;
  background: #5fbf6a;
}
.gl-step[data-state="failed"] { color: #ff8a7a; }
.gl-step[data-state="failed"] .gl-step-icon { border-color: #ff8a7a; }
@keyframes gl-spin { to { transform: rotate(360deg); } }

.gl-note {
  min-height: 1.4em;
  font-size: 13px;
  line-height: 1.45;
  color: #f0c040;
}
#game-loader.is-failed .gl-note { color: #ff8a7a; }
.gl-note:empty { display: none; }

.gl-retry {
  align-self: center;
  background: rgba(240, 192, 64, 0.16);
  border: 1px solid rgba(240, 192, 64, 0.45);
  color: #f0c040;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 18px;
  border-radius: 8px;
  cursor: pointer;
}
.gl-retry:hover { background: rgba(240, 192, 64, 0.26); }
.gl-retry[hidden] { display: none; }

/* Landscape phone (touch.js marks <body> while the loader is still up). The
   card is ~300px tall at desktop spacing, which a 360px screen only just holds
   and a browser toolbar does not; tighter gaps and a bigger Reload button,
   since a failed load on a phone is a thumb looking for that button. */
@media (max-height: 520px) {
  body.touch-mode .gl-card { gap: 10px; width: min(420px, calc(100vw - 48px)); }
  body.touch-mode .gl-brand { font-size: 22px; letter-spacing: 2px; }
  body.touch-mode .gl-pct { font-size: 17px; }
  body.touch-mode .gl-steps { gap: 4px; font-size: 12px; }
  body.touch-mode .gl-note { font-size: 12px; }
}
body.touch-mode .gl-retry { min-height: 44px; padding: 10px 26px; font-size: 14px; }

@media (prefers-reduced-motion: reduce) {
  .gl-bar-fill::after { animation: none; }
  .gl-step[data-state="active"] .gl-step-icon { animation-duration: 2.4s; }
}
