/* The page around the emulator. The app draws its own interface; this is
 * only the frame: a full-window stage, a loading screen, and a footer on
 * the home screen. Colours are those of the project site: warm black,
 * bone, console red, gold. */

:root {
  --bg: #0d0c0b;
  --bg-2: #161412;
  --ink: #ede6d9;
  --ink-2: #b3ab9e;
  --ink-3: #8d857a;
  --rule: #2e2a26;
  --red: #f0473b;
  --red-ink: #ff6a5c;
  --gold: #dcae45;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  /* Keep clear of notches and the home indicator when installed. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* --- The stage: two canvases, positioned by gase.js -------------------- */

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #000;
  /* Fingers drive the on-screen controls: no scrolling, no zooming. */
  touch-action: none;
  overscroll-behavior: none;
  outline: none;
}

#stage canvas {
  position: absolute;
  left: 0;
  top: 0;
  /* Whole console pixels, not a blur: the browser enlarges both canvases
     with nearest-neighbour filtering. */
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

#stage canvas[hidden] {
  display: none;
}

/* --- Loading screen ------------------------------------------------------ */

#splash {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  background: var(--bg);
  text-align: center;
}

#splash[hidden] {
  display: none;
}

#splash .mark {
  width: 56px;
  height: 56px;
}

#splash h1 {
  margin: 8px 0 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

#status {
  margin: 0;
  max-width: 34rem;
  color: var(--ink-3);
  font: 13px/1.5 var(--mono);
}

#splash.crashed #status {
  color: var(--red-ink);
}

/* --- Messages and the optional fps meter (?stats) ---------------------- */

#message,
#stats {
  position: absolute;
  margin: 0;
  font: 12px/1.4 var(--mono);
  pointer-events: none;
}

#message {
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 8px 12px;
  background: var(--bg-2);
  border-left: 3px solid var(--red);
  color: var(--ink);
}

#stats {
  right: 8px;
  top: 8px;
  color: var(--gold);
  text-shadow: 0 1px 0 #000;
}

#message[hidden],
#stats[hidden] {
  display: none;
}

/* --- Footer, on the home screen only ------------------------------------- */

#chrome {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 24px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 13px;
}

body.playing #chrome {
  display: none;
}

#chrome p {
  margin: 0;
}

#chrome strong {
  color: var(--ink);
}

#chrome a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-underline-offset: 3px;
}

#chrome a:hover,
#chrome a:focus-visible {
  color: var(--red-ink);
}

.try small {
  display: block;
  color: var(--ink-3);
  font-size: 11px;
}

#test-rom {
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--gold);
  text-underline-offset: 3px;
  cursor: pointer;
}

#test-rom:hover,
#test-rom:focus-visible {
  color: var(--ink);
  outline: none;
}

#test-rom:disabled {
  color: var(--ink-3);
  cursor: progress;
}

/* --- Drag and drop -------------------------------------------------------- */

#drop {
  position: fixed;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--gold);
  background: rgb(13 12 11 / 0.86);
  pointer-events: none;
}

#drop[hidden] {
  display: none;
}

#drop p {
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

@media (max-width: 560px) {
  #chrome {
    font-size: 12px;
    padding: 8px 16px 10px;
  }
  #chrome .about {
    display: none;
  }
}
