/* CJR page head: a Japanese house, its plaster walls given a fresh coat, set
   down as a soft ink wash like the landscape on the home page. Ivory only, at
   partial strength, so the Forest shows through: a tiled irimoya roof, posts
   and beams, plaster upper walls with a slatted window, shoji, a lattice door,
   and the veranda on its stones, its foot dissolving into a drift of mist.

   On load the scene is painted in from the left. Then a roller lays a fresh
   coat on each plaster wall, top to bottom, bay by bay, and last the shoji
   catch a little light. The mist keeps drifting slowly. Under reduced motion
   the house is simply there, painted, with no roller and no drift.

   The drawing lives in source/cjr-house.svg, and the page shows still layers
   rendered from it (assets/cjr/house-*.webp, roller.webp). Where the scene
   stands, its stage, and the way it is painted in are in paint.css, which this
   file is loaded after. */

/* Each bay shows its own window onto the fresh coat. */
.bay {
  position: absolute;
  overflow: hidden;
  left: calc(var(--x) / 640 * 100%);
  top: calc(var(--y) / 420 * 100%);
  width: calc(var(--w) / 640 * 100%);
  height: calc(var(--h) / 420 * 100%);
}
.bay img {
  width: calc(640 / var(--w) * 100%);
  height: calc(420 / var(--h) * 100%);
  left: calc(var(--x) / var(--w) * -100%);
  top: calc(var(--y) / var(--h) * -100%);
}

/* The roller image is 136 by 132 units, its axle 62 in and 22 down. */
.pass { position: absolute; left: 0; top: 0; width: calc(136 / 640 * 100%); display: none; }
.pass img { position: static; width: 100%; height: auto; transform-origin: 45.6% 16.7%; }

@keyframes coat-down { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes roll {
  0%   { transform: translate(calc((var(--x) - 62) * 100cqw / 640), calc(150 * 100cqw / 640)); opacity: 0; }
  14%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translate(calc((var(--x) - 62) * 100cqw / 640), calc(234 * 100cqw / 640)); opacity: 0; }
}
/* A hand is never quite level: the roller rocks a little as it is pushed. */
@keyframes rock { 0%, 100% { transform: rotate(-2.5deg); } 50% { transform: rotate(1deg); } }
@keyframes glow { from { opacity: 0.25; } }

@media (prefers-reduced-motion: no-preference) {
  .bay { animation: coat-down 1s cubic-bezier(0.45, 0, 0.3, 1) both; }
  .pass { display: block; animation: roll 1s cubic-bezier(0.45, 0, 0.3, 1) both; will-change: transform, opacity; }
  /* Twelve turns of the rock last until the fourth roller has gone. Left to run
     without end, four unseen rollers kept rocking for as long as the page was open. */
  .pass img { animation: rock 0.5s ease-in-out 12; }
  .bay-0, .pass-0 { animation-delay: 2.3s; }
  .bay-1, .pass-1 { animation-delay: 3.1s; }
  .bay-2, .pass-2 { animation-delay: 3.9s; }
  .bay-3, .pass-3 { animation-delay: 4.7s; }
  .layer-paper { animation: glow 1.6s ease 5.5s both; }
}
