/* FE: Border War's title screen background, a paper cutout like UnforgivaBALLS's and Black and
   Blue Friday's: the red city's gate with a red and a blue knight crossing swords in front of it.
   Pre-rendered images only (menu-bg/, built by tools/border-war-menu-art.mjs; the paper grain is
   the site's /assets/menu-bg/paper.webp), so the menu shows at once while the battlefield loads
   behind it. fe-menu-early.js adds the drift; the 3D canvas stays hidden while the menu shows.

   Tune these: */
:root {
  --menu-paper-color: #1e2c29;      /* the paper's colour: Border War's dark slate green */
  --menu-paper-opacity: .32;        /* how strongly the paper grain shows (.2-.4) */
  --menu-paper-blend: multiply;     /* or overlay */
  --menu-text-column: calc(clamp(16px, 6vw, 104px) + 470px); /* the menu; the scene stays right of it */
  /* The scene's height (its frame is 3:2): at most 92% of the screen, and never so wide that its
     left edge reaches the menu. */
  --menu-scene-height: min(92vh, (100vw - var(--menu-text-column) - 2vw) / 1.5);
  --menu-scene-center: 50vh;        /* where the frame's middle sits on the screen */
  --menu-light-color: 255, 205, 130; /* the warm sky behind the keep (RGB) ... */
  --menu-light-strength: .38;       /* ... and how bright its middle is */
  --menu-vignette-color: 8, 14, 13; /* the dark at the screen's edges (RGB) ... */
  --menu-vignette-strength: .7;     /* ... and how dark the very edge gets */
}

.fe-menu-backdrop { position: fixed; inset: 0; overflow: hidden; pointer-events: none; background: var(--menu-paper-color); z-index: 0; }
.fe-menu-backdrop > * { position: absolute; }
.mb-grain {
  inset: -2%; /* a little spare for the drift */
  background: url("/assets/menu-bg/paper.webp") center / cover no-repeat;
  mix-blend-mode: var(--menu-paper-blend); opacity: var(--menu-paper-opacity);
}
.mb-scene {
  right: 1vw;
  top: calc(var(--menu-scene-center) - var(--menu-scene-height) / 2);
  height: var(--menu-scene-height); aspect-ratio: 3 / 2;
}
.mb-layer { position: absolute; inset: 0; width: 100%; height: 100%; will-change: transform; user-select: none; }
.mb-light {
  position: absolute; left: 5%; top: -25%; width: 90%; height: 130%; will-change: transform;
  background: radial-gradient(closest-side,
    rgba(var(--menu-light-color), var(--menu-light-strength)) 0%,
    rgba(var(--menu-light-color), calc(var(--menu-light-strength) * .5)) 35%,
    rgba(var(--menu-light-color), calc(var(--menu-light-strength) * .15)) 65%,
    rgba(var(--menu-light-color), 0) 100%);
}
.mb-vignette {
  inset: 0;
  background: radial-gradient(ellipse 85% 80% at 55% 50%,
    rgba(var(--menu-vignette-color), 0) 45%,
    rgba(var(--menu-vignette-color), calc(var(--menu-vignette-strength) * .45)) 75%,
    rgba(var(--menu-vignette-color), var(--menu-vignette-strength)) 100%);
}

/* In a match the 3D takes over; on the menus the canvas is hidden (and game.js draws nothing). */
body.playing .fe-menu-backdrop { display: none; }
body:not(.playing) #game { visibility: hidden; }
/* The create-game form is wide: the scene steps back behind it rather than under it. */
body:has(#game-setup:not([hidden])) .mb-scene { opacity: .35; }

/* Narrow screens: the menu is centred, so the scene sits under it, at the bottom. */
@media (max-width: 760px) {
  :root { --menu-scene-height: min(32vh, 60vw); }
  .mb-scene { top: auto; right: 50%; transform: translateX(50%); bottom: -1vh; }
}
