/* The stage: desk light, lens bloom, room haze, pointer tilt and show mode. Load after styles.css.
   Every rule waits for .has-stage on <html>, which stage.js sets: without the module the page keeps
   its old look. Every layer here is pointer-events: none and sits under the interactive content. */

/* The canvases take over from the two static accent blobs. */
.has-stage body::before { content: none; }
.has-stage .board::after { content: none; }

/* ---------- room: haze behind the page, grain over it ---------- */
.stg-room {
  position: fixed;
  left: -6%; top: -6%; width: 112%; height: 112%;   /* past the edges, so the blur has something to sample */
  z-index: -2;
  pointer-events: none;
  filter: blur(26px);
}
.stg-grain {
  position: fixed; inset: 0;
  z-index: -1;
  pointer-events: none;
  background-repeat: repeat;
}
.stg-grain-in { display: none; position: absolute; }

/* ---------- desk: the light the board throws on the surface it stands on ---------- */
/* Clipped to the band the stage owns (down to main's bottom padding), so it never adds scroll height. */
.stg-clip {
  position: absolute;
  inset: -260px calc(50% - 50vw) -64px;
  z-index: -1;
  overflow: clip;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 110px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 110px), transparent);
}
.stg-desk {
  position: absolute;
  transform-origin: 50% 100%;
  transition: transform 700ms cubic-bezier(.2,.7,.2,1);
}
.stg-light { position: absolute; display: block; }

/* The board lies on the same plane as the desk light: one pose for both, the rest pose plus the tilt. */
@media (min-width: 761px) and (prefers-reduced-motion: no-preference) {
  .has-stage .stage > .board,
  .has-stage .stg-desk {
    transform: perspective(1800px) rotateX(calc(9deg + var(--stg-tx, 0deg))) rotateY(var(--stg-ty, 0deg));
  }
}

/* The old wide drop shadow sat exactly where the desk light lands. What is left is the thin dark line
   where the case meets the desk. */
.has-stage .stage > .board {
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.07),
    inset 0 -2px 0 rgba(0,0,0,.6),
    0 14px 18px -12px rgba(0,0,0,.95),
    0 0 0 1px #0a0908;
}

/* ---------- lens bloom over the caps ---------- */
.stg-bloom {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border-radius: inherit;
  z-index: 2;
  pointer-events: none;
}

/* The line under the board now stands in the desk light: one step brighter, so it reads on any colour. */
.has-stage .under .hint { color: var(--ink-2); }

/* The connect gate veils the board, but only as wide as the stage: desk light and haze would show
   its edges. Same veil, same blur, now as wide as the window and fading out at both ends. */
@media (min-width: 761px) {
  .has-stage .stage > .gate { background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .has-stage .stage > .gate::before {
    content: '';
    position: absolute;
    inset: 0 calc(50% - 50vw) -64px;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg,
      color-mix(in oklab, var(--bg) 35%, transparent),
      color-mix(in oklab, var(--bg) 88%, transparent) calc((100% - 64px) * .7));
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 40px, #000 calc(100% - 64px), transparent);
    mask-image: linear-gradient(to bottom, transparent, #000 40px, #000 calc(100% - 64px), transparent);
  }
}

/* ---------- podium: show mode ---------- */
html.is-podium, .is-podium body { overflow: hidden; }
.is-podium .bar,
.is-podium .deck,
.is-podium .under,
.is-podium .stage > .gate { display: none !important; }
.is-podium .stage {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 0 0 15vh;                                /* the board sits above the middle: the reflection needs the room */
  animation: stg-in 600ms ease both;
}
.is-podium .stage > .board { width: min(86vw, 128vh); }
.is-podium .stg-clip { inset: 0; -webkit-mask-image: none; mask-image: none; }
.is-podium .stg-grain { display: none; }            /* the fixed stage is its own layer: grain moves inside it */
.is-podium .stg-grain-in { display: block; inset: 0; z-index: auto; }
/* What a lens does to the corners: the eye stays on the board. Under the board, over the desk light. */
.is-podium .stage::after {
  content: '';
  position: absolute; inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(115% 95% at 50% 44%, transparent 42%, rgba(0,0,0,.6) 100%);
}
@keyframes stg-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .stg-desk { transition: none; }
}
