/* ==========================================================================
   HOME — "INSIDE THE DIE": the live surface the hero's dolly lands on.
   js/die.js draws it; this file only places its view. Home page only.

   .die-rail is the first child of .home-die: an absolutely placed track that
   runs the height of the die's face and takes no room in the flow. Inside it
   .die-view is a sticky box one screen tall, so the surface is pinned by
   layout: its edges stay exact while the page scrolls even when a frame is
   late, and die.js never moves it.

   With the hero's dolly the track starts above the zone, far enough for the
   view to be pinned already when the hand-over starts (hero.css:
   .hero-handover fades in from --fill-p − .04), so the surface appears over
   the stage and is simply still there when the zone arrives. Without the
   dolly (short screens, before power-on) it is the zone's own sticky
   background.

   No JS, no WebGL2, a software renderer, Save-Data, a weak CPU: the view never
   shows and the zone keeps its flat Die Blue surface (page-home.css).
   ========================================================================== */

.die-rail {
  display: none;
}

.js .die-rail {
  display: block;
  position: absolute;
  inset: 0 0 var(--die-edge, 0px);   /* the die's face; the strip below it is the board (page-home.css) */
  z-index: -2;                       /* under the zone's pin rows and bond pads (z-index −1) */
  pointer-events: none;
  /* the track is only a place for the view to stick in. Hidden, it is left out of layout-shift scoring when the
     dolly moves its top edge up at power-on (a visible box, even an empty one, scored .31 there) */
  visibility: hidden;
}

/* The dolly: the track starts .36 of the dolly's scroll length above the stage's last screen, so the view is pinned
   from p = .64, before the hand-over starts. */
.js .hero.is-dolly + .home-die .die-rail {
  top: calc(-100svh - var(--dolly-range, 100svh) * .36);
}

.die-view {
  position: sticky;
  top: 0;
  /* the largest viewport: on a phone it still covers when the browser's bars slide away */
  height: 100vh;
  overflow: clip;
  contain: strict;
  visibility: hidden;
}

@supports (height: 100lvh) {
  .die-view { height: 100lvh; }
}

.die-view.is-on {
  visibility: visible;
}

.die-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;                        /* die.js: the hand-over's progress */
}

/* The live surface has its own fine structure: the zone's printed striation would only beat against it. */
.page-home .home-die.is-die-live::before {
  background:
    var(--pad-tile) center bottom 12px / 26px 7px space no-repeat content-box,
    linear-gradient(rgba(8, 14, 60, 0), rgba(8, 14, 60, .45)) bottom / 100% 3rem no-repeat,
    var(--die-pins-l),
    var(--die-pins-r);
}

/* The buses run over the surface's own wiring now: heavier and brighter than on the flat surface, and casting the
   same shadow as the tiles they join, so they read as the layer above it. */
.page-home .home-die.is-die-live .cores {
  --trace-color: rgba(242, 247, 255, .7);
}

.page-home .home-die.is-die-live .cores .trace-path {
  stroke-width: 1.75px;
}

.page-home .home-die.is-die-live .cores .trace-svg {
  filter: drop-shadow(0 2px 2px rgba(3, 4, 16, .55));
}

@media (forced-colors: active) {
  .page-home .home-die.is-die-live .cores .trace-svg { filter: none; }
}

@media (forced-colors: active) {
  .js .die-rail { display: none; }
}

@media (prefers-contrast: more) {
  .js .die-rail { display: none; }
}

@media print {
  .js .die-rail { display: none; }
}
