/*
 * Arcade view (ticket 269) -- the #/arcade retro Donkey Kong style screen.
 *
 * The canvas is 384x216 logical pixels. js/arcade/screen.js sizes its drawing buffer and its CSS
 * box (through CSSOM, never a style attribute: the CSP blocks those) to a whole-number multiple of
 * that, and the rules below keep the browser from smoothing it. Everything here is static, so
 * reduced motion needs only the small rule at the end.
 */

/* The arcade wants the full width, not the 80rem reading column the data views use. */
body[data-route="arcade"] .view-root {
  max-width: none;
  padding-inline: 1rem;
}

.arcade {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.arcade__toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
}

/* Black letterbox: the stage fills the available height and centres the whole-number-scaled
   canvas in it, so leftover space is black bars rather than a stretched or blurred picture. */
.arcade__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: calc(100vh - 14rem);
  min-height: 14rem;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
}

/* The frame hugs the canvas so the scanline overlay covers exactly the picture. */
.arcade__frame {
  position: relative;
  flex: none;
  line-height: 0;
}

.arcade__canvas {
  display: block;
  background: #000;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

/* CRT scanlines: a dark line every third pixel, drawn over the canvas and never in the way of
   clicks. On by default. */
.arcade__scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.28) 2px,
    rgba(0, 0, 0, 0.28) 3px
  );
}

@media (prefers-reduced-motion: reduce) {
  .arcade *,
  .arcade *::before,
  .arcade *::after {
    animation: none !important;
    transition: none !important;
  }
}
