/* Page shell for the MLU 2 web port: the 20-pixel menu bar above the 800x600 game, centred on a
   black page.

   Fit to window: the canvas keeps its 800x600 drawing size and is scaled by CSS to height --h at
   4:3, the largest that fits under the menu bar. That is the crisp mode (the default). In integer
   mode (?scale=integer), viewport.js overrides --h on <html> with the largest whole multiple of
   600 device pixels that fits. Both draw hard-edged pixels. */

:root {
  --menu-h: 20px;
  --status-bg: rgb(0 0 0 / 70%);
  --status-fg: #fff;
  --warn-fg: #ff6b6b;
  --menu-bg: #eeeeee;
  --menu-fg: #000;
  --menu-hi: #b8cfe5;
  --dlg-bg: #eeeeee;
  --dlg-border: #6382bf;
  --h: min(100vh - var(--menu-h), 100vw * 3 / 4);
}

@supports (height: 100dvh) {
  :root { --h: min(100dvh - var(--menu-h), 100vw * 3 / 4); }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: #000;
  color: var(--status-fg);
  font: 14px/1.4 Arial, Helvetica, sans-serif;
}

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.window { width: calc(var(--h) * 4 / 3); }

/* The menu bar, in the plain look of the original's Swing menu. */
.menubar {
  height: var(--menu-h);
  background: var(--menu-bg);
  color: var(--menu-fg);
  font: 12px/20px "Segoe UI", Tahoma, Arial, sans-serif;
  position: relative;
  z-index: 2;
}

/* Beside the Game menu: the game speed and the frames drawn a second. */
.meter { display: inline-block; vertical-align: top; margin-left: 8px; opacity: 0.8; white-space: nowrap; }

/* While the autopilot plays: its name and what it is doing, at the right of the menu bar. */
.autopilot {
  position: absolute;
  right: 8px;
  top: 0;
  max-width: calc(100% - 260px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.autopilot::before { content: "Autopilot: "; font-weight: bold; }

.menu { position: relative; display: inline-block; }

.menubar button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  margin: 0;
  cursor: default;
  text-align: left;
  white-space: nowrap;
}

.menu-title { height: var(--menu-h); padding: 0 8px; }

.menu-title[aria-expanded="true"], .menu-title:hover { background: var(--menu-hi); }

.menu-items {
  position: absolute;
  top: var(--menu-h);
  left: 0;
  margin: 0;
  padding: 2px 0;
  list-style: none;
  background: var(--menu-bg);
  border: 1px solid #999;
  box-shadow: 2px 2px 4px rgb(0 0 0 / 40%);
  min-width: 150px;
}

.menu-items button {
  display: block;
  width: 100%;
  padding: 1px 12px 1px 24px;
  position: relative;
}

.menu-items button:hover, .menu-items button:focus { background: var(--menu-hi); outline: none; }

.menu-sep { border-top: 1px solid #bbb; margin: 2px 0; }

.menu-items [aria-checked="true"]::before {
  content: "\2713";
  position: absolute;
  left: 8px;
}

.screen { position: relative; }

#game {
  display: block;
  image-rendering: pixelated;
  height: var(--h);
  width: calc(var(--h) * 4 / 3);
  background: #000;
  outline: none;
}

/* Message boxes and the restart question, over the game screen. */
.dialog {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.dialog[hidden] { display: none; }

.dialog-box {
  background: var(--dlg-bg);
  color: #000;
  border: 1px solid var(--dlg-border);
  box-shadow: 3px 3px 8px rgb(0 0 0 / 50%);
  font: 12px/1.35 "Segoe UI", Tahoma, Arial, sans-serif;
  max-width: 95%;
  max-height: 95%;
  overflow: auto;
}

.dialog-title {
  background: var(--dlg-border);
  color: #fff;
  font-weight: bold;
  padding: 3px 8px;
}

.dialog-body { display: flex; gap: 12px; padding: 12px 14px 6px; align-items: flex-start; }

.dialog-icon {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #3b6fc4;
  color: #fff;
  font: bold 18px/28px Georgia, serif;
  text-align: center;
}

.dialog-icon::before { content: "i"; }

.dialog-text { margin: 0; white-space: pre; tab-size: 8; }

.dialog-buttons { display: flex; justify-content: center; gap: 8px; padding: 6px 14px 12px; }

.dialog-buttons button {
  font: inherit;
  min-width: 64px;
  padding: 2px 10px;
}

.status {
  position: absolute;
  inset: auto 0 0 0;
  margin: 0;
  padding: 4px 8px;
  background: var(--status-bg);
  font-size: 12px;
  z-index: 3;
}

.status.warn { color: var(--warn-fg); }

.status:empty { display: none; }
