/* Heroes -- the 3D character test.
 *
 * Almost everything is already done by arcade.css: the bars, the buttons, the
 * dialog, the readout, the full screen behaviour. This file is only the bits
 * that a WebGL canvas needs and a 2D one does not.
 *
 * The one real difference: the arcade games letterbox a fixed design box into
 * the canvas, because a well 8 balls wide has to stay 8 balls wide. A camera
 * does not -- a wider window should show MORE of the forest, not the same
 * forest stretched -- so this canvas simply fills whatever it is given and the
 * projection matrix takes the aspect ratio as an input.
 */

.heroes-page .ar-stage {
  /* Tall enough to frame a character head to foot with sky above her. The
     aspect is deliberately not square: a side-scroller is a wide picture. */
  aspect-ratio: 16 / 10;
  max-height: min(72vh, 780px);
  width: 100%;
  padding: 0;
  overflow: hidden;
  border-radius: 10px;
}

.heroes-page .ar-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;

  /* The camera is dragged, so the browser must not try to scroll the page
     with the same gesture. Without this a drag on a phone scrolls the page
     and the camera never moves at all. */
  touch-action: none;
  cursor: grab;
}

.heroes-page .ar-stage canvas:active {
  cursor: grabbing;
}

/* The speed slider sits in the bar with the buttons and has to line up with
   them, which a bare range input does not do on its own. */
.hero-slider {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hero-slider input[type="range"] {
  width: 8.5rem;
  accent-color: var(--accent, #7b1828);
  cursor: pointer;
}

.hero-slider b {
  min-width: 3.1rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Gear buttons. A row that reads as a set rather than four loose buttons. */
.hero-gear {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hero-gear > span:first-child {
  opacity: 0.75;
  font-size: 0.9rem;
  margin-right: 2px;
}

.hero-gear button[aria-pressed="true"] {
  background: var(--accent-soft, rgba(123, 24, 40, 0.16));
  border-color: var(--accent, #7b1828);
  font-weight: 600;
}

/* A note over the stage, for a paused loop or a browser with no WebGL. Both
   sit in the same place because only one of them can ever be showing. */
.hero-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: rgba(12, 14, 18, 0.55);
  color: #fff;
  border-radius: 10px;
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.hero-note[hidden] {
  display: none;
}

.hero-note h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
}

.hero-note p {
  margin: 0;
  max-width: 34ch;
  line-height: 1.5;
  opacity: 0.9;
}

/* The stage needs to be the containing block for those notes. */
.heroes-page .ar-stage {
  position: relative;
}

/* Under the stage: what this page is, in one short paragraph, because
   somebody arriving from the games page will expect a game. */
.hero-blurb {
  margin: 14px auto 0;
  max-width: 68ch;
  line-height: 1.6;
  opacity: 0.88;
}

.hero-blurb b {
  opacity: 1;
}

@media (max-width: 720px) {
  .heroes-page .ar-stage {
    aspect-ratio: 4 / 5;
    max-height: 64vh;
  }

  .hero-slider input[type="range"] {
    width: 6rem;
  }

  /* Picture first on a phone.
   *
   * Four control bars wrap to about nine lines at 375px wide, which on the
   * desktop layout leaves her below the fold on a page whose entire purpose is
   * looking at her. The shell is already a flex column, so it is an order per
   * child and nothing else -- the reading order in the HTML stays the sensible
   * one for a screen reader. */
  .heroes-page .ar-stage { order: 1; }
  .heroes-page .ar-readout { order: 2; }
  .heroes-page .ar-bar--setup { order: 3; }
  .heroes-page .ar-bar--play { order: 4; }
  .heroes-page .hero-blurb { order: 5; }
}
