/* ==========================================================================
   Pyrexia flow: engine layers
   --------------------------------------------------------------------------
   The page is paper throughout. Once the engine is running, paper is the
   background of <html> and one layer sits between it and the page:

     .flow-canvas   the WebGL particle thread, fixed to the window

   Two more exist only when they are needed:

     .flow-ground   bands in document space for any run of scenes (or a footer)
                    that declares ink. A page that is paper throughout has no
                    bands: the layer is empty.
     .flow-curtain  made by js/scroll.js the first time a link jumps several
                    screens: see scrollTo() there.

   All are created by script. Without JavaScript none exists and every scene
   keeps its own ground colour from the scene stylesheet.
   ========================================================================== */

:root {
  --flow-ink: #0A0A0C;
  --flow-paper: #F7F5F0;                 /* the fallback only: flow.css points this at --c-paper (html:root) */
}

.flow-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;          /* the tall viewport: no resize when a phone toolbar retracts */
  z-index: -1;
  display: block;
  pointer-events: none;
  user-select: none;
  contain: strict;
}

/* Ink bands, should a scene ask for ink: placed and sized by the engine (top and height in px). */
.flow-ground {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 0;
  z-index: -2;
  display: none;
  pointer-events: none;
  user-select: none;
}
.flow-ground > i {
  position: absolute;
  left: 0;
  width: 100%;
  background-color: var(--flow-ink);
}

/* The curtain of a far jump: the ground colour of the destination (paper), over the page and the
   thread, under the rail and the nav. It closes fast and opens slowly. */
.flow-curtain {
  position: fixed;
  inset: 0;
  z-index: 30;
  background-color: var(--c-paper, var(--flow-paper));
  opacity: 0;
  pointer-events: none;
  transition: opacity 460ms cubic-bezier(.3, 0, .3, 1);
}
.flow-curtain[data-ground="ink"] { background-color: var(--flow-ink); }
.flow-curtain.is-on { opacity: 1; transition: opacity 180ms linear; }

@media screen {
  /* The engine is running: the scenes go clear so the thread shows through, and the paper they
     stood on becomes the background of the page itself. What shows beyond the scenes (an
     overscroll, a footer that paints nothing of its own) is paper too. */
  html.flow-js {
    background-color: var(--c-paper, var(--flow-paper));     /* the page's own paper token, where it has one */
  }
  html.flow-js body,
  html.flow-js main.flow,
  html.flow-js .scene {
    background-color: transparent !important;
  }
  html.flow-js .flow-ground {
    display: block;
  }

  /* Static mode draws nothing, unless it is showing reduced-motion stills. */
  html.flow-static:not(.flow-still) .flow-canvas {
    display: none;
  }

  /* Wheel easing is on: the browser must not ease on top of it. */
  html.flow-smooth {
    scroll-behavior: auto !important;
  }
}

@media print {
  .flow-ground,
  .flow-curtain,
  .flow-canvas {
    display: none !important;
  }
}

@media (forced-colors: active) {
  .flow-canvas {
    display: none !important;
  }
}
