/*
 * themes/alder/css/alder-eugene.css
 * The Eugene band under the footer (partials/_foot-eugene.tpl.php): its box,
 * the crop on narrow screens, and every motion in it. Linked in the head by
 * partials/_shell-head.tpl.php so the band's height is known before first
 * paint (no layout shift). The drawing is img/footer-eugene.svg
 * (tools/footer-eugene/build.mjs, a solid isometric model in the section
 * figures' style); js/alder-eugene.js turns the still image
 * into the moving layers and the birds styled below.
 *
 * The scene is 2400 by 480 and is never squashed: the band's height sets the
 * stage's width, and the band runs edge to edge at every width. A screen
 * narrower than the stage sees its west end (the forest, Hayward Field, the
 * campus), where things are drawn largest. Eastward the town shrinks into
 * the distance to specks and ends; there is no fade.
 *
 * Who moves what: on a mouse the script slides the layers against the pointer
 * (no rule here; it writes transform itself). Everywhere else the band
 * carries .is-drift and the layers drift on the slow clock below. Lit windows
 * fade by the drawing's own transition; the script only picks which. Motion
 * runs only while the band carries .is-on (on screen, tab visible) and never
 * under reduced motion, where the script leaves the still image alone.
 * Flat shaded fills and thin ink edges only, no glow, no gradient.
 */
.al-eugene {
  --h: max(200px, 20vw);
  position: relative; height: var(--h); overflow: hidden;
  background: var(--al-page);
  pointer-events: none; user-select: none; -webkit-user-select: none;
  contain: layout paint;
}
/* Stage: the whole scene at the band's height. 5 = 2400 / 480. It starts at
   the band's left edge, so a narrow screen keeps the large west end. */
.al-eugene__stage {
  position: absolute; top: 0; left: 0; height: 100%; width: max(100%, calc(var(--h) * 5));
}
.al-eugene__still, .al-eugene__p { position: absolute; top: 0; height: 100%; display: block; max-width: none; }
.al-eugene__still { left: 0; width: 100%; }
/* A moving layer is drawn 80 units past each end of the scene (3.333% of its
   width), which is the room a slide may use: the drift below and the pointer
   shift (alder-eugene.js) both stay inside it. */
.al-eugene__p { left: -3.3333%; width: 106.6667%; overflow: hidden; will-change: transform; }

/* Touch and anything without a hovering pointer: the camera trucks sideways,
   every layer on one clock, the near ones furthest. The -45s start puts each
   slide at its middle, exactly where the still image sat, so the swap shows
   no jump. */
.al-eugene.is-drift .al-eugene__p { animation: al-eugene-drift 90s ease-in-out -45s infinite alternate; }
.al-eugene__p--0 { --k: .1%; }
.al-eugene__p--1 { --k: .35%; }
.al-eugene__p--2 { --k: .7%; }
.al-eugene__p--3 { --k: 1.1%; }
@keyframes al-eugene-drift {
  from { transform: translate3d(calc(var(--k) * -1), 0, 0); }
  to   { transform: translate3d(var(--k), 0, 0); }
}
/* Birds (made by alder-eugene.js). The track is as wide as the band and
   slides its own width, so the bird at its centre crosses from just off one
   edge to just off the other; the bird bobs on its own slower clock; each
   wing turns about the shoulder: three beats, then a long glide. */
.al-eugene__fly {
  position: absolute; left: 0; width: 100%; height: 0; top: var(--y);
  animation: al-eugene-fly var(--d) linear var(--t) infinite;
  will-change: transform;
}
.al-eugene__fly--back { animation-direction: reverse; }
.al-eugene__bird {
  position: absolute; left: 50%; top: 0; width: var(--s); margin-left: calc(var(--s) / -2);
  animation: al-eugene-bob 7s ease-in-out var(--t) infinite alternate;
}
.al-eugene__bird svg { display: block; width: 100%; height: auto; overflow: visible; fill: none; stroke: var(--al-moss); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.al-eugene__bird path { transform-origin: 0 0; animation: al-eugene-flap var(--f) ease-in-out var(--t) infinite; }
@keyframes al-eugene-fly {
  from { transform: translate3d(-58%, 0, 0); }
  to   { transform: translate3d(58%, 0, 0); }
}
@keyframes al-eugene-bob {
  from { transform: translate3d(0, -4px, 0); }
  to   { transform: translate3d(0, 5px, 0); }
}
@keyframes al-eugene-flap {
  0%, 44%, 100% { transform: rotate(6deg); }
  7%, 21%, 35%  { transform: rotate(-26deg); }
  14%, 28%      { transform: rotate(24deg); }
}

/* Off screen or in a hidden tab nothing runs. */
.al-eugene:not(.is-on) *, .al-eugene:not(.is-on) { animation-play-state: paused !important; }
/* Reduced motion: the script never starts; this covers a setting that is
   switched on while the page is open. */
@media (prefers-reduced-motion: reduce) {
  .al-eugene, .al-eugene * { animation: none !important; transition: none !important; }
  .al-eugene__fly { display: none; }
}
@media print {
  .al-eugene { display: none; }
}
