/* ══════════════════════════════════════════
   FIRE SITE KIT: THE HERO CUBE
   A hero (hero.css) that opens on something drawn rather than a picture:
   a canvas, .hero__visual, where hero-cube.js draws a polished black cube
   a visitor can turn. Linked after hero.css.

     <section class="hero hero-drawn">
       <canvas class="hero__visual hero-cube" role="img"
         aria-label="A polished black cube, lit from the upper left." data-hero-cube></canvas>
       <div class="hero__container"><div class="hero__content">...</div></div>
     </section>

   On a desktop (at least 1280px wide and wider than 3:2) the canvas fills
   the hero behind the words, which stand in the middle of its height on
   the left, and the cube stands in the room to their right. Anywhere else
   the canvas stands above the words, the cube centred in it, and the
   words follow on the page's ground.

   With no words (hero-alone), the canvas fills the hero at every width and
   the cube stands in its middle, in a room darker than the page's ground,
   --hero-cube-room; a page that wants the whole page that dark sets its
   --bg to it.
   ══════════════════════════════════════════ */

:root {
  --hero-cube-room: #050506;
}

.hero-drawn {
  align-items: center;
}

.hero__visual {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* The words keep to their own width, so the room beside them is the
   cube's; their column runs the hero's width, but only the words take
   the pointer, so the cube beside them can be held. */
.hero-drawn .hero__content {
  width: fit-content;
}

.hero__visual ~ .hero__container {
  pointer-events: none;
}

.hero__visual ~ .hero__container .hero__content {
  pointer-events: auto;
}

/* ── The cube ──────────────────────────────
   hero-cube.js draws the focus ring around the cube, in the colour the
   canvas is given here, so the canvas shows no outline of its own. */
.hero-cube {
  color: var(--accent);
}

.hero-cube:focus-visible {
  outline: none;
}

/* Once it can draw, a drag turns the cube rather than scrolling the
   page, and the pointer says so over the cube itself. */
.hero-cube-live {
  touch-action: none;
}

.hero-cube-over {
  cursor: grab;
}

/* A cube that opens something (data-hero-cube-opens) reads as a button
   under the pointer; it still turns when dragged. */
.hero-cube-opens.hero-cube-over {
  cursor: pointer;
}

/* Held, it is being turned, whatever it opens. */
.hero-cube.hero-cube-held {
  cursor: grabbing;
}

/* ── The cube alone ────────────────────── */
.hero-alone {
  background: var(--hero-cube-room);
}

/* ── Narrower or boxier screens ────────────
   The canvas stands above the words, under the header, never more than
   45% of the screen, and the words follow. The hero still fills the first
   screen, so what follows it starts below the fold. */
@media (max-width: 1279px), (max-aspect-ratio: 3/2) {
  .hero-drawn {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: var(--nav-height) 0 var(--space-16);
  }

  .hero-drawn .hero__visual {
    position: static;
    height: 45vh;
    height: 45svh;
  }

  .hero-drawn .hero__container {
    margin-top: calc(-1 * var(--space-8));
  }
}

/* Alone, it keeps the whole hero at every width. */
@media (max-width: 1279px), (max-aspect-ratio: 3/2) {
  .hero-drawn.hero-alone .hero__visual {
    position: absolute;
    height: 100%;
  }
}

@media (max-width: 768px) {
  .hero-drawn {
    padding: var(--nav-height) 0 var(--space-12);
  }

  .hero-drawn .hero__container {
    width: auto;
    padding: 0 var(--space-6);
  }
}
