/* "The two", reversed — a copy of css/the-two.css, driven by
   js/the-two-reverse.js.

   The page opens on the finished picture, and scrolling takes it apart: the
   marquee sinks away, the wave straightens, the grain fades and the two
   flat halves slide off to either side. Below is the original's note.

   ---

   "The two" — after guillaumezhu.com's trajectory section.

   Two colour fields, pink and gray, meet along a soft grainy seam that drifts
   on its own and leans toward the cursor. Drawn by a WebGL shader in
   js/the-two-reverse.js.

   The section is tall and its stage is sticky, so scrolling through it plays
   the intro: two flat halves slide in from the sides and meet in the middle,
   the shader fades in over them, the straight join relaxes into the wave,
   and the Work marquee from work.html rises in on top. The flat halves are
   also the fallback — with no JavaScript or no WebGL they are simply sitting
   there, already joined.

   Tied to js/the-two-reverse.js through --two-* custom properties it writes on the
   section. */

.two {
  position: relative;
  /* Scroll distance for the break-up. The stage pins for (height - 100vh). */
  height: 300vh;
  background: var(--white);
}

.two__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: grid;
  place-items: center;
  isolation: isolate;
}

.two__panel {
  position: absolute;
  top: 0;
  bottom: 0;
  /* 1px of overlap so no hairline of page shows down the join. */
  width: calc(50% + 1px);
  z-index: 0;
}

.two__panel--left {
  left: 0;
  background: var(--pink);
  /* The extra 2px clears the 1px overlap, so no sliver of colour is left
     on the edge once the halves are out. */
  transform: translateX(calc((-100% - 2px) * (1 - var(--two-in, 1))));
}

.two__panel--right {
  right: 0;
  background: var(--gray);
  transform: translateX(calc((100% + 2px) * (1 - var(--two-in, 1))));
}

.two__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
  /* Starts shown: the page opens on the finished picture. A canvas with
     nothing drawn yet is transparent, so the flat halves show through
     until the first frame. */
  opacity: var(--two-canvas, 1);
}

/* The Work marquee from work.html, laid across the stage. The track itself
   (type, size, loop) is .wordmark__track in main.css, untouched — black
   reads on both halves, and pink is never type on this site. */
.two__marquee {
  position: relative;
  z-index: 2;
  justify-self: stretch;
  color: var(--black);
  pointer-events: none;
  user-select: none;
}

/* Starts in place; the script only ever moves it out. */
.two__marquee {
  opacity: var(--two-text, 1);
  transform: translateY(calc((1 - var(--two-text, 1)) * 12vh));
}

@media (max-width: 860px) {
  .two {
    height: 240vh;
  }
}

/* No pin, no slide: the opening picture, drawn once and left still. */
@media (prefers-reduced-motion: reduce) {
  .two {
    height: auto;
  }

  .two__stage {
    position: relative;
  }
}
