/*
 * emularity-maw.css — myabandonware.com branding for the Emularity splash.
 *
 * Ported from the V3 site (www3 game.scss). The stock Emularity styles its
 * splash inline from loader.js; passing `hasCustomCSS: true` to
 * `emulator.start(...)` makes it skip those inline styles and defer to the
 * classes below instead. Include this stylesheet and pass that flag to get the
 * MAW look: a spinning branded logo, a top title bar, and a bottom progress bar.
 *
 * The splash element (`.emularity-splash-screen`) is appended to the canvas's
 * parent, so give that parent `position: relative` for the overlay to sit over
 * the canvas. The per-game screenshot background is set by the host app on the
 * splash element itself — it is not styled here.
 */

/* Overlay covering the canvas. */
.emularity-splash-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;         /* CSS4 proposed */
  image-rendering: pixelated;           /* CSS4 proposed */
  -ms-interpolation-mode: nearest-neighbor; /* IE8+ */
}

/* The branded logo, centred and spinning on its vertical axis. */
.emularity-splash-image {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 456px;
  height: 92px;
  margin-left: -228px;                  /* half the width */
  margin-top: -46px;                    /* half the height */

  -webkit-perspective: 1200px;
  perspective: 1200px;

  -webkit-animation: spinner 6s ease-in-out infinite;
  animation: spinner 6s ease-in-out infinite;

  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

/* WebKit and Opera browsers */
@-webkit-keyframes spinner {
  from { -webkit-transform: rotateY(0deg); }
  to   { -webkit-transform: rotateY(-360deg); }
}

/* all other browsers */
@keyframes spinner {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(-360deg); }
}

/* Title ("Loading game archive") — top bar. */
.emularity-splash-title {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 70px;
  background: rgba(255, 255, 255, 0.7);
  font-family: 'MetronicProCSB', 'Franklin Gothic Medium', 'Arial Black', sans-serif;
  font-size: 24px;
  text-align: center;
  line-height: 70px;
}

/* Download progress. The engine still builds its per-file table
   (.emularity-progress-indicator); the MAW theme hides it and shows a single
   aggregate loading bar (.c-emulator__progress, built in loader.js) instead. */
.emularity-progress-indicator {
  display: none;
}

/* Aggregate loading bar — bottom strip: a fill that grows with the download,
   with a centred "X / Y (NN%)" label on top. */
.c-emulator__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 70px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
  text-align: center;
}

.c-emulator__progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
  transition: width 0.2s ease-out;
}

.c-emulator__progress-label {
  position: relative;
  z-index: 1;
  line-height: 70px;
  font-family: 'MetronicProCSB', 'Franklin Gothic Medium', 'Arial Black', sans-serif;
  font-size: 24px;
}

/* Unknown total (no Content-Length): sweep a stripe instead of a real fill. */
.c-emulator__progress--indeterminate .c-emulator__progress-fill {
  width: 40%;
  background: linear-gradient(90deg,
              rgba(255, 255, 255, 0) 0%,
              rgba(255, 255, 255, 0.85) 50%,
              rgba(255, 255, 255, 0) 100%);
  animation: c-emulator-progress-sweep 1.2s linear infinite;
}

@keyframes c-emulator-progress-sweep {
  from { left: -40%; }
  to   { left: 100%; }
}

/* ---------------------------------------------------------------------------
   Controls — Start / Stop / Restart / Fullscreen.
   The host owns the button markup; these are generic (no site sprite), so V4
   can override with its own look. Per-button hooks are available for distinct
   icons/colours: .c-emulator__control--start / --stop / --restart / --fullscreen
   --------------------------------------------------------------------------- */
.c-emulator__controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}

.c-emulator__control {
  display: inline-block;
  padding: 0 24px;
  min-height: 44px;
  line-height: 44px;
  border: 0;
  border-radius: 3px;
  background: #4ac4f7;              /* MAW blue */
  color: #fff;
  font-family: 'MetronicProCSB', 'Franklin Gothic Medium', 'Arial Black', sans-serif;
  font-size: 18px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.c-emulator__control:hover {
  background: #2bb4ee;
}

.c-emulator__control--disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

/* Fullscreen button while the CSS-fallback fullscreen is active: keep it
   reachable (top-right) so the user can toggle back out. */
.c-emulator__control--active {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10000;
}

/* ---------------------------------------------------------------------------
   Firefox fullscreen fallback. Native fullscreen misbehaves on the WebGL
   canvas in Firefox, so the wrapper (block .c-emulator) is blown up via CSS
   instead. Toggled by emularity-controls.js. !important defeats any inline
   sizing the host set on the wrapper.
   --------------------------------------------------------------------------- */
.c-emulator--fullscreen {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  z-index: 9999 !important;
  background: rgba(20, 20, 20, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
}

.c-emulator--fullscreen canvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 4 / 3;
  margin: 0 auto;
}
