/* Full-screen loading overlay (index.html #boot-overlay). It must look exactly like components/common/LoadingScreen (logo, knight vs
   guardian canvas animation, message line, same background), so that the hand-over between the two is seamless: keep the layout in sync with LoadingScreen.module.css (the animation itself is shared, src/lib/loadingAnimation.ts).
   A plain stylesheet on purpose: it must paint before the bundle loads, and the CSS Modules / theme tokens only exist once React has
   mounted, so the few token values it needs are copied here (literal values noted in the comments). */
/* Same declaration as styles/utilities.css (that sheet only exists once the bundle is loaded). Fetched only while the overlay is shown. */
@font-face {
  font-family: 'Retro gaming';
  font-style: normal;
  src: url('/fonts/retrogaming.ttf') format('truetype');
}

#boot-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px; /* --spacing-lg */
  background-color: #282319; /* --color-parchment-bg */
  color: #bdb1a0; /* --color-parchment-accent-light */
  font-family: 'Retro gaming', sans-serif;
  font-size: 12px; /* --font-size-sm, like LoadingScreen's message */
  line-height: 1.5; /* the app's body line-height, so the message line is as tall as LoadingScreen's */
  opacity: 1;
  transition: opacity 200ms ease-out;
}

html[data-boot-stage] #boot-overlay {
  display: flex;
}

html[data-boot-fade] #boot-overlay {
  opacity: 0;
  pointer-events: none;
}

/* Same box as LoadingScreen's logo (280px wide, height from the 900x390 image ratio) */
#boot-overlay .boot-logo {
  width: 280px;
  aspect-ratio: 900 / 390;
  background: center / contain no-repeat;
}

/* The logo is only fetched when the overlay is shown (a display:none <img> would still be downloaded on the web) */
html[data-boot-stage] #boot-overlay .boot-logo {
  background-image: url("/logo.webp");
}

/* Knight vs guardian animation, drawn by src/bootOverlayEntry.ts (same 280x80 canvas as LoadingScreen) */
#boot-overlay .boot-canvas {
  display: block;
  width: 280px;
  height: 80px;
  image-rendering: pixelated;
}

#boot-overlay .boot-stage {
  text-align: center;
}

#boot-overlay .boot-stage > span {
  display: none;
}

html[data-boot-stage="starting-server"] #boot-overlay [data-stage="starting-server"],
html[data-boot-stage="preparing-tutorial"] #boot-overlay [data-stage="preparing-tutorial"],
html[data-boot-stage="creating-lobby"] #boot-overlay [data-stage="creating-lobby"],
html[data-boot-stage="connecting-host"] #boot-overlay [data-stage="connecting-host"],
html[data-boot-stage="loading-game"] #boot-overlay [data-stage="loading-game"],
html[data-boot-stage="returning"] #boot-overlay [data-stage="returning"] {
  display: inline;
}

/* After 12 s of the whole sequence (--boot-elapsed is set by boot-overlay.js / bootOverlay.ts for a sequence that spans a reload):
   a negative delay makes the fade-in start from the right point, with no JavaScript timer */
#boot-overlay .boot-slow {
  position: absolute; /* out of the flow: the logo and canvas stay where LoadingScreen puts them */
  left: 0;
  right: 0;
  bottom: 24px;
  text-align: center;
  font-size: 12px;
  opacity: 0;
  animation: boot-slow-in 400ms ease-out calc(12s - var(--boot-elapsed, 0s)) forwards;
}

@keyframes boot-slow-in {
  to { opacity: 1; }
}
