/* Portunus, the movement behind the first sentence: the light that harbour water throws on a wall.

   In the page, as the first child of the first screen (which must be position: relative):
     <div class="eau" aria-hidden="true"><span class="eau-ombre"></span><span class="eau-lumiere"><i></i><i></i></span></div>

   How it works. The first screen is shaded a little (the ink at 7 %), and light is added on top: two layers of the same
   kind of soft picture (eau-a.png, eau-b.png, each repeats in every direction) laid at two sizes and multiplied, so the
   paper gets lighter only where both are bright. The two layers slide slowly in opposite directions, each by exactly one
   of its own pictures, so the light changes in place instead of drifting, and the movement never jumps. The whole thing fades out towards the bottom of the screen, where the
   plain paper of the page takes over.
   Nothing is computed while the page is open: the movement is two transforms, moved 12 times a second instead of 60
   (the steps are under half a pixel, so the eye sees none, and the screen is redrawn five times less often: measured,
   that is what the cost is made of, not the blending). eau.js only stops them when the first
   screen is out of view or the tab is hidden. A computer that asks for less movement gets the same picture, still (so does
   class="eau eau-fixe"). With the pictures missing, the first screen is the plain paper, a little shaded.

   Two colours only: --paper and --ink, from the page. */
.eau {
  --eau-ombre: 0.07;                    /* how much the first screen is shaded before the light is added */
  --eau-force: 1;                       /* how much light: 0 none, 1 as tuned */
  --eau-a: 980px 460px;                 /* size of one picture of the first layer: wider than tall, as on a quay wall */
  --eau-ax: -980px; --eau-ay: -460px;   /* its travel: one picture, to the left and up */
  --eau-b: 700px 330px;                 /* the second layer, smaller; it travels the other way */
  --eau-bx: -700px; --eau-by: -330px;
  position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: var(--paper);
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 58%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0, #000 58%, transparent 100%);
  animation: eau-arrive 1.8s ease-out both;
}
.eau-ombre { position: absolute; inset: 0; background: var(--ink); opacity: var(--eau-ombre); }
.eau-lumiere { position: absolute; inset: 0; overflow: hidden; background: #000; mix-blend-mode: screen; opacity: var(--eau-force); }
.eau-lumiere i { position: absolute; top: 0; left: 0; will-change: transform; }
.eau-lumiere i:first-child {
  width: calc(100% + 980px); height: calc(100% + 460px);
  background: url("/eau/eau-a.png") 0 0 / var(--eau-a) repeat;
  animation: eau-a 200s steps(2400) infinite;      /* 12 small steps a second, each under half a pixel */
}
.eau-lumiere i:last-child {
  width: calc(100% + 700px); height: calc(100% + 330px);
  background: url("/eau/eau-b.png") 0 0 / var(--eau-b) repeat;
  mix-blend-mode: multiply;
  animation: eau-b 150s steps(1800) infinite;      /* the same 12 a second, at the same instants */
}
@keyframes eau-a { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(var(--eau-ax), var(--eau-ay), 0); } }
@keyframes eau-b { from { transform: translate3d(var(--eau-bx), var(--eau-by), 0); } to { transform: translate3d(0, 0, 0); } }
@keyframes eau-arrive { from { opacity: 0; } to { opacity: 1; } }

.eau.eau-arret .eau-lumiere i { animation-play-state: paused; }

@media (max-width: 640px) {
  .eau { --eau-a: 640px 300px; --eau-ax: -640px; --eau-ay: -300px; --eau-b: 460px 216px; --eau-bx: -460px; --eau-by: -216px; }
  .eau-lumiere i:first-child { width: calc(100% + 640px); height: calc(100% + 300px); }
  .eau-lumiere i:last-child { width: calc(100% + 460px); height: calc(100% + 216px); }
}
.eau.eau-fixe, .eau.eau-fixe .eau-lumiere i { animation: none; }
.eau.eau-fixe .eau-lumiere i:last-child { transform: translate3d(-230px, -110px, 0); }
@media (prefers-reduced-motion: reduce) {
  .eau, .eau .eau-lumiere i { animation: none; }
  .eau .eau-lumiere i:last-child { transform: translate3d(-230px, -110px, 0); }
}
