/* old life: this note's own layer, on top of /style.css.
   Reading it makes him younger. The marker in the margin runs from 80 to 0 as you scroll, each poster prints in
   when it comes into view, and the marked words in each paragraph fill with that poster's colour.
   Without JavaScript, or with Reduce Motion on, everything is simply there. */

.beat { margin-top: calc(var(--line) * 3); }
h1 + .beat { margin-top: var(--line); }
.beat figure { margin: 0 0 var(--line); background: #0A0A0A; }   /* the posters' own black, so the space is held before the picture loads */
.beat img { display: block; width: 100%; height: auto; }
.beat p { max-width: 62ch; line-height: 1.8; }
.back { margin-top: calc(var(--line) * 2); }

/* Marked words: a marker stroke in the poster's colour under the text, which stays black. */
mark {
  --hl: color-mix(in srgb, var(--c) var(--a, 42%), transparent);
  color: inherit;
  background: linear-gradient(var(--hl), var(--hl)) no-repeat 0 86% / 100% .66em;
  padding: 0 .2em; margin: 0 -.2em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* The age marker. Narrow screens: one line that stays at the top of the screen while you read. */
.rail { display: contents; }
.age { display: none; }
.js .age {
  display: block; position: sticky; top: 0; z-index: 1;
  margin-top: var(--line); padding: 6px 0;
  background: var(--paper); color: var(--soft);
}
.age b { display: flex; align-items: center; gap: 1ch; font-weight: 400; }
.age i { width: 7px; height: 7px; flex: none; background: var(--c, #8E9196); }
.age output { color: var(--ink); font-variant-numeric: tabular-nums; }

/* From 600px: a ruler in the margin column, 80 at the top and 0 at the bottom, one tick per ten years, one text line apart. */
@media (min-width: 600px) {
  .rail { display: block; }
  .js .age {
    top: 48px; margin: calc(var(--line) * 2) 0 0 3px; padding: 0;
    height: calc(var(--line) * 8);
    border-left: 1px solid var(--rule);
    background: none;
  }
  /* Nine ticks, drawn as one line and eight copies of it, so each lands on a whole pixel. */
  .js .age::before {
    content: ""; position: absolute; left: 0; top: 0; width: 6px; height: 1px; background: var(--rule);
    box-shadow: 0 calc(var(--line) * 1) var(--rule), 0 calc(var(--line) * 2) var(--rule), 0 calc(var(--line) * 3) var(--rule),
                0 calc(var(--line) * 4) var(--rule), 0 calc(var(--line) * 5) var(--rule), 0 calc(var(--line) * 6) var(--rule),
                0 calc(var(--line) * 7) var(--rule), 0 calc(var(--line) * 8) var(--rule);
  }
  .age b { position: absolute; left: -4px; top: calc(var(--p, 0) * 100%); transform: translateY(-50%); }
}

/* Motion, only when the reader allows it and the script is running. */
@media (prefers-reduced-motion: no-preference) {
  .js .beat img { clip-path: inset(0 0 100% 0); }
  .js .beat.in img { clip-path: inset(0); transition: clip-path 720ms steps(12, end); }      /* prints top to bottom, like the page's lines */
  .js mark { background-size: 0% .66em; }
  .js .beat.on mark { background-size: 100% .66em; transition: background-size 480ms steps(8, end) 200ms; }
}
