/* The home page in motion: the mill, the clip that is scrubbed through, the
   workflow timeline that is laid clip by clip, and the pictures that follow
   the scroll position (the browser moves those itself; js/motion.js does the rest).
   Everything here is the still page plus motion: without scripts, and for
   those who asked for less motion, the page stands as site.css draws it. */

/* ---------- The mill ---------- */

/* SceneMill's mark as an object: sails of film strip round a lens. The wheel
   is one picture, seen from the front, that js/motion.js turns. */
.mill {
  position: absolute;
  aspect-ratio: 1;
  pointer-events: none;
}

.mill__wheel {
  display: block;
  width: 100%;
  height: 100%;
}

/* The haze of the room the mill stands in, and the dust in its light. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: min(100%, 64rem);
  background: radial-gradient(58% 62% at 80% 36%, rgb(58 68 100 / 0.3), transparent 72%);
  pointer-events: none;
}

.hero__dust {
  position: absolute;
  top: 0;
  right: 0;
  width: min(100%, 70rem);
  height: min(100%, 56rem);
  pointer-events: none;
}

/* Beside the headline, larger than the page's head and cut by its right edge. */
.mill--hero {
  --size: clamp(19rem, 54vw, 56rem);
  top: calc(var(--header-height) - var(--size) * 0.07);
  right: calc(var(--size) * -0.24);
  width: var(--size);
  opacity: 0.3;
  /* Seen a little from the left and from below, as it would stand in a room. */
  transform: perspective(90rem) rotateY(-26deg) rotateX(12deg);
}

.hero__stage {
  z-index: 1;
}

@media (min-width: 1000px) {
  .mill--hero {
    opacity: 1;
  }

  /* The words keep to the left, where the mill is not. */
  .hero__copy {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .hero__headline {
    max-width: 50rem;
  }

  .hero__intro {
    max-width: 38rem;
  }

  .hero {
    padding-top: calc(var(--header-height) + clamp(1.5rem, 5svh, 4rem));
  }

  .hero__stage {
    margin-top: clamp(1.25rem, 3svh, 2.5rem);
  }
}

/* At the download the mill stands again, below the headline and half below the page's end. */
.download {
  position: relative;
  overflow: hidden;
  padding-bottom: calc(var(--mill) * 0.5);
  --mill: clamp(17rem, 36vw, 36rem);
}

.download > .wrap {
  position: relative;
}

.mill--download {
  bottom: calc(var(--mill) * -0.46);
  left: max(var(--gutter), (100% - var(--page-width)) / 2);
  width: var(--mill);
}

@media (min-width: 900px) {
  .download__inner {
    align-items: start;
  }
}

/* ---------- A clip to scrub through ---------- */

/* Only where it can be scrubbed: it shows what scrolling does to it. */
.film {
  display: none;
}

.film__inner {
  display: grid;
  gap: clamp(1rem, 2.5vh, 2rem);
}

.film__head {
  display: grid;
  gap: 1rem;
  align-content: center;
}

.film__head p {
  max-width: 30rem;
  color: var(--text-soft);
}

.film kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05em 0.45em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-small);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85em;
  line-height: 1.5;
  text-align: center;
}

/* The viewer: as wide as its column, and no taller than the screen leaves room for. */
.film__stage {
  --room: calc(100svh - var(--header-height) - 15rem);
  position: relative;
  justify-self: end;
  width: min(100%, var(--room) * 16 / 9);
  margin: 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-window);
  background: #000;
  box-shadow: var(--shadow-window);
}

.film__still,
.film__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.film__canvas {
  visibility: hidden;
}

.film.is-live .film__canvas {
  visibility: visible;
}

.film__time {
  position: absolute;
  bottom: 0.9rem;
  left: 0.9rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-small);
  background: rgb(13 14 19 / 0.75);
  color: var(--text);
  font-size: var(--text-small);
  font-variant-numeric: tabular-nums;
}

/* The clip on its track, under the ruler, with the playhead that scrolling moves. */
.film__timeline {
  position: relative;
  padding-top: 1.5rem;
  background-image: repeating-linear-gradient(90deg, var(--border-strong) 0 1px, transparent 1px 12.5%),
    repeating-linear-gradient(90deg, var(--border) 0 1px, transparent 1px 2.5%);
  background-size: 100% 0.9rem, 100% 0.45rem;
  background-position: 0 0.1rem, 0 0.55rem;
  background-repeat: no-repeat;
}

.film__clip {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  height: clamp(2.75rem, 8svh, 4.75rem);
  overflow: hidden;
  border: 1px solid var(--clip-video-edge);
  border-radius: 5px;
  background: var(--clip-video);
}

.film__clip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.film__playhead {
  --at: 0;
  position: absolute;
  top: 0.1rem;
  bottom: -0.4rem;
  left: 0;
  width: 100%;
  pointer-events: none;
  transform: translateX(calc(var(--at) * 100%));
  will-change: transform;
}

.film__playhead::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: var(--accent);
}

.film__playhead::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -6px;
  width: 12px;
  height: 14px;
  border-radius: 3px 3px 6px 6px;
  background: var(--accent);
}

@media (min-width: 1000px) {
  .film__inner {
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    column-gap: 3.5rem;
  }

  .film__timeline {
    grid-column: 1 / -1;
  }
}

/* ---------- Effects on one clip ---------- */

/* As written: the pictures side by side, each with its effect's name. */
.reel {
  display: grid;
  gap: 1.25rem;
}

.reel__list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 1.25rem;
}

.reel__list img {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.reel__list span {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-soft);
  font-size: var(--text-small);
}

.reel__note {
  color: var(--text-muted);
  font-size: var(--text-small);
}

/* With the script: one viewer, and the names choose what it shows. */
.reel.is-live .reel__list {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-content: center;
  align-self: center;
}

.reel.is-live .reel__list img {
  display: none;
}

.reel__stage {
  position: relative;
  margin: 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-window);
  background: #000;
  box-shadow: var(--shadow-window);
}

.reel__stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reel__stage img.is-above {
  z-index: 1;
}

/* The edge of the wipe is the playhead. */
.reel__cut {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: var(--accent);
  opacity: 0;
}

.reel__list button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0.42rem 0 0.42rem 1.75rem;
  border: 0;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 1.02rem;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: color var(--duration-fast) ease;
}

/* The names run along a film strip's edge; light falls through the sprocket hole of the one that is shown. */
.reel.is-live .reel__list::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0.8rem;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand-amber), var(--brand-coral) 55%, var(--brand-magenta));
}

.reel__list button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0.2rem;
  width: 0.4rem;
  height: 0.58rem;
  margin-top: -0.29rem;
  border-radius: 1.5px;
  background: var(--ink);
  transition: background-color var(--duration) ease;
}

.reel__list button:hover {
  color: var(--text-soft);
}

.reel__list button[aria-pressed="true"] {
  color: var(--text);
  font-weight: 600;
}

.reel__list button[aria-pressed="true"]::before {
  background: #fff6e0;
}

.reel__list button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (min-width: 900px) {
  .reel.is-live {
    grid-template-columns: minmax(0, 8fr) minmax(0, 4fr);
    column-gap: 3.5rem;
  }

  .reel.is-live .reel__note {
    grid-column: 1 / -1;
  }
}

/* ---------- Transitions between two clips ---------- */

.cuts {
  display: grid;
  gap: 1.25rem;
}

.cuts__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem 1.25rem;
}

/* A transition's sixteen pictures lie in one file, four in a row: the frame shows one of them. */
.cuts__frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #000;
}

.cuts__frame img {
  width: 400%;
  max-width: none;
  transform: translate(-50%, -25%);
}

.cuts__frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  visibility: hidden;
}

.cuts__frame.is-live canvas {
  visibility: visible;
}

/* The playhead under the pointer that scrubs through the transition. */
.cuts__frame::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: var(--x, 0%);
  width: 2px;
  margin-left: -1px;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--duration-fast) ease;
  pointer-events: none;
}

.cuts__frame.is-scrubbed::before {
  opacity: 1;
}

.cuts__list span {
  display: block;
  margin-top: 0.6rem;
  color: var(--text-soft);
  font-family: var(--font-display);
  font-size: 1.05rem;
}

@media (min-width: 900px) {
  .cuts__list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2rem 1.5rem;
  }
}

/* ---------- Pictures of the program that come alive ---------- */

/* A recording of the program lies on its picture and takes over once it runs. */
[data-live] {
  position: relative;
}

.live {
  position: absolute;
  inset: 1px;
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  border-radius: calc(var(--radius-window) - 1px);
  object-fit: cover;
  opacity: 0;
  transition: opacity 280ms ease;
  pointer-events: none;
}

.live.is-running {
  opacity: 1;
}

/* ---------- The facts: the row at the middle of the screen is the one in focus ---------- */

.js .specs dt,
.js .specs dd {
  transition: color var(--duration) ease;
}

.js .specs dt {
  position: relative;
}

/* The playhead stands on the row. */
.js .specs dt::before {
  content: "";
  position: absolute;
  top: 0.2em;
  left: -1.3rem;
  width: 0.6rem;
  height: 0.8rem;
  border-radius: 2px 2px 4px 4px;
  background: var(--accent);
  opacity: 0;
  transform: translateY(-0.5rem);
  transition: opacity var(--duration) ease, transform var(--duration) var(--ease-out);
}

.js .specs.is-read .specs__row:not(.is-current) dt {
  color: var(--text-soft);
}

.js .specs.is-read .specs__row:not(.is-current) dd {
  color: var(--text-muted);
}

/* (Beside the page's edge on a phone there is less room for it.) */
@media (max-width: 639px) {
  .js .specs dt::before {
    left: -0.95rem;
    width: 0.45rem;
    height: 0.65rem;
  }
}

.js .specs .specs__row.is-current dd {
  color: var(--text);
}

.js .specs .specs__row.is-current dt::before {
  opacity: 1;
  transform: none;
}

/* ---------- What moves ---------- */

@media (prefers-reduced-motion: no-preference) {
  .js .mill__wheel {
    will-change: transform;
  }

  /* The page opens: the words rise, the mill comes out of the dark. */
  .js .hero__headline,
  .js .hero__intro {
    animation: hero-rise 900ms var(--ease-out) both;
  }

  .js .hero__intro {
    animation-delay: 140ms;
  }

  .js .mill--hero,
  .js .hero__dust {
    animation: hero-light 1600ms ease-out both;
  }

  /* The clip stays on the screen while the page scrolls through its length. */
  .js .film {
    display: block;
    height: 290vh;
    margin-top: var(--space-section);
  }

  .js .film__pin {
    position: sticky;
    top: var(--header-height);
    display: grid;
    align-content: center;
    height: calc(100svh - var(--header-height));
    overflow-x: clip; /* the playhead's box reaches past the page's edge at the end of its way */
  }

}

/* ---------- What follows the scrolling ---------- */

/* These movements are tied to the scroll position by the browser itself (scroll-driven
   animations): they are drawn in step with the scrolling, not a frame behind it as a
   script's would be. A browser that does not know them shows the page at rest. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    /* The program's window lies back and stands up as the page is scrolled to it. */
    .hero__stage {
      perspective: 1800px;
      view-timeline: --stage block;
    }

    .hero__window {
      transform-origin: 50% 0;
      animation: stand-up linear both;
      animation-timeline: --stage;
      animation-range: entry 0% cover 42%;
    }

    /* (The smaller picture of a pair has further to come, so the two do not arrive as one.) */
    .pair__detail.rise {
      animation-name: rise-far;
      animation-range: entry 0% entry 150%;
    }

    /* The film opens to its full width. */
    .player {
      transform-origin: 50% 0;
      animation: open-wide linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 38%;
    }
  }
}

@keyframes stand-up {
  from {
    transform: rotateX(16deg) scale(0.92);
  }
}

@keyframes rise-far {
  from {
    opacity: 0;
    transform: translateY(9rem) scale(0.93);
  }

  45% {
    opacity: 1;
  }
}

@keyframes open-wide {
  from {
    transform: scale(0.84);
  }
}

/* The workflow stays on the screen while the playhead crosses it; a clip is
   laid on its track when the playhead reaches it, and cut where it is cut. */
@media (min-width: 1000px) and (min-height: 640px) and (prefers-reduced-motion: no-preference) {
  .js .workflow {
    height: 300vh;
    padding-block: 0;
  }

  .js .workflow__pin {
    position: sticky;
    top: var(--header-height);
    display: grid;
    align-content: center;
    height: calc(100svh - var(--header-height));
    overflow-x: clip; /* the playhead's box reaches past the page's edge at the end of its way */
  }

  .js .flow .clip {
    transition: opacity var(--duration) ease, filter var(--duration) ease, box-shadow var(--duration) ease, transform var(--duration) var(--ease-out);
  }

  .js .flow__step p {
    transition: opacity var(--duration) ease, color var(--duration) ease;
  }

  .js .flow__step:not(.is-placed) .clip {
    opacity: 0;
    transform: translateY(-1.5rem);
  }

  .js .flow__step:not(.is-placed) p {
    opacity: 0;
  }

  .js .clip--split:not(.is-cut) {
    background-image: none;
  }
}

@keyframes hero-rise {
  from {
    opacity: 0;
    transform: translateY(1.5rem);
  }
}

@keyframes hero-light {
  from {
    opacity: 0;
  }
}
