/* Loader page for the MFS WebGL build. Colors match the in-app UI kit (MfsUiKit): the
   page background is the same #F3F5F7 the menu scene draws, so the hand-over from this
   loader to the first Unity frame is seamless. */
:root {
  --mfs-bg: #F3F5F7;
  --mfs-accent: #009BA6;
  --mfs-accent-light: #5CC6CD;
  --mfs-accent-soft: #DCEFF0;
  --mfs-text: #1F2933;
  --mfs-text-2: #52606D;
  --mfs-text-3: #697586;
  --mfs-border: #E4E7EB;
  --mfs-danger: #D92D20;
  --mfs-danger-soft: #FEF3F2;
  --mfs-warn: #8A5200;
  --mfs-warn-soft: #FFF4E0;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--mfs-bg);
  font-family: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#page-bg {
  position: fixed;
  inset: 0;
  background: var(--mfs-bg);
  z-index: -1;
}

#unity-container.unity-desktop,
#unity-container.unity-mobile {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--mfs-bg);
  padding-bottom: 0;
  box-sizing: border-box;
}

#unity-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  background: var(--mfs-bg);
}

/* ── Loader ─────────────────────────────────────────────── */

#unity-loading-bar {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 280px;
  display: none;
  z-index: 9999;
  pointer-events: none;
  text-align: center;
  transition: opacity .35s ease;
}

#unity-loading-bar.mfs-done {
  opacity: 0;
}

#mfs-logo {
  width: 220px;
  height: 84px;
  margin: 0 auto;
  background: url('logomfs.png') no-repeat center / contain;
}

#unity-progress-bar-empty {
  position: relative;
  width: 240px;
  height: 6px;
  margin: 30px auto 0;
  border-radius: 999px;
  background: var(--mfs-accent-soft);
  overflow: hidden;
}

#unity-progress-bar-full {
  position: absolute;
  left: 0;
  top: 0;
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: var(--mfs-accent);
  transition: width .25s ease;
}

/* After the download finishes Unity still has to start up; show a moving stripe
   instead of a bar that looks stuck at the end. */
#unity-progress-bar-full.mfs-starting {
  width: 100% !important;
  background: linear-gradient(90deg, var(--mfs-accent) 0%, var(--mfs-accent-light) 50%, var(--mfs-accent) 100%);
  background-size: 200% 100%;
  animation: mfs-shimmer 1.2s linear infinite;
}

@keyframes mfs-shimmer {
  from { background-position: 200% 0; }
  to { background-position: 0 0; }
}

#mfs-loading-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--mfs-text-3);
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  #unity-loading-bar,
  #unity-progress-bar-full { transition: none; }
  #unity-progress-bar-full.mfs-starting { animation: none; }
}

/* ── Banners from Unity (unityShowBanner) ───────────────── */

#unity-warning {
  position: absolute;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  display: none;
  z-index: 10000;
}

.mfs-banner {
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--mfs-text);
  background: #fff;
  border: 1px solid var(--mfs-border);
  box-shadow: 0 4px 16px rgba(15, 23, 42, .10);
}

.mfs-banner.mfs-warning { background: var(--mfs-warn-soft); border-color: #F5D9A8; color: var(--mfs-warn); }
.mfs-banner.mfs-error { background: var(--mfs-danger-soft); border-color: #F9C9C4; color: var(--mfs-danger); }

/* ── Startup failure card ───────────────────────────────── */

#mfs-load-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  background: var(--mfs-bg);
}

#mfs-load-error[hidden] {
  display: none;
}

.mfs-error-card {
  box-sizing: border-box;
  width: min(440px, calc(100vw - 32px));
  padding: 28px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .14);
  color: var(--mfs-text);
}

.mfs-error-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
}

.mfs-error-card p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--mfs-text-2);
}

.mfs-error-card pre {
  margin: 0 0 20px;
  padding: 10px 12px;
  max-height: 140px;
  overflow: auto;
  border-radius: 8px;
  background: var(--mfs-bg);
  font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--mfs-text-3);
  white-space: pre-wrap;
  word-break: break-word;
}

.mfs-error-card button {
  height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: var(--mfs-accent);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.mfs-error-card button:hover { background: #00868F; }

/* ── Unused default-template parts (footer is commented out in index.html) ── */

#unity-footer { display: none; }
