/* ============================================
   Motion layer — additive, loaded after style.css, kept small.

   Everything is scoped under `.js-motion`, a class set on <html> by a
   one-line script in <head> only when the visitor hasn't asked for
   reduced motion. Without it, none of this applies and the page is the
   plain static site underneath.

   Four moves: headings wipe up out of a mask, hairlines draw across,
   images unveil, and track rows slide in one after another.
   ============================================ */

/* ---------- Headings wipe up out of a mask ---------- */
.js-motion .mw {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: 0.12em;
  margin-bottom: -0.12em;
}

.js-motion .mw-i {
  display: inline-block;
  transform: translateY(115%);
  transition: transform 1.1s var(--ease);
  transition-delay: calc(0.1s + var(--w, 0) * 70ms);
}

.js-motion .is-visible .mw-i { transform: none; }

/* ---------- Hairlines draw across ----------
   The rule under each heading is a background that grows from the left,
   in place of the static border. */
.js-motion .section-toggle summary .section-head,
.js-motion .subhead {
  border-bottom-color: transparent;
  background-image: linear-gradient(var(--line, var(--rule)), var(--line, var(--rule)));
  background-repeat: no-repeat;
  background-position: left bottom;
  background-origin: border-box;
  background-size: 0% 1px;
  transition:
    opacity 0.9s var(--ease),
    transform 0.9s var(--ease),
    background-size 1.5s var(--ease) 0.2s;
}

.js-motion .subhead-prominent { --line: var(--accent); }

.js-motion .section-toggle summary .section-head.is-visible,
.js-motion .subhead.is-visible { background-size: 100% 1px; }

/* ---------- Images unveil ----------
   A top-down wipe. `backwards` fill means that once finished the element
   returns to its ordinary styles, so hover effects keep working. */
@keyframes mo-wipe {
  from { clip-path: inset(0 0 100% 0); }
  to   { clip-path: inset(0 0 0 0); }
}

.js-motion .about-portrait,
.js-motion .press-photo,
.js-motion .ost-cover,
.js-motion .gallery-item,
.js-motion .credit-card .embed-wrap,
.js-motion .media-card .embed-wrap {
  clip-path: inset(0 0 100% 0);
}

.js-motion .is-visible .about-portrait,
.js-motion .is-visible .press-photo,
.js-motion .is-visible .ost-cover,
.js-motion .gallery-item.is-visible,
.js-motion .is-visible .credit-card .embed-wrap,
.js-motion .credit-card.is-visible .embed-wrap,
.js-motion .media-card.is-visible .embed-wrap {
  clip-path: none;
  animation: mo-wipe 1.5s var(--ease) 0.15s backwards;
}

/* ---------- Track rows slide in one after another ---------- */
@keyframes mo-row {
  from { opacity: 0; transform: translateX(-22px); }
  to   { opacity: 1; transform: none; }
}

.js-motion .reel-track { opacity: 0; }

.js-motion .is-visible .reel-track {
  opacity: 1;
  animation: mo-row 0.95s var(--ease) backwards;
  animation-delay: calc(0.15s + var(--r, 0) * 75ms);
}

/* ---------- Film credits: the three posters come alive ----------
   Layout and the shared frame live in style.css; this is the motion. */

/* A slow, endless push-in on each frame once it has arrived. Uses the
   individual `scale` property so it stacks with the hover zoom (which is
   a `transform`) instead of fighting it. */
@keyframes mo-drift {
  from { scale: 1.02; }
  to   { scale: 1.12; }
}

.js-motion .credit-card.is-visible .yt-thumb {
  animation: mo-drift 16s ease-in-out infinite alternate;
}

/* The index number and the text beneath arrive in sequence. */
@keyframes mo-rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}
@keyframes mo-slide {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: none; }
}

.js-motion .credit-card.is-visible .credit-no {
  animation: mo-slide 0.9s var(--ease) 0.7s backwards;
}

.js-motion .credit-card.is-visible .credit-card-body > * {
  animation: mo-rise 0.95s var(--ease) backwards;
}
.js-motion .credit-card.is-visible .credit-card-body > :nth-child(1) { animation-delay: 0.55s; }
.js-motion .credit-card.is-visible .credit-card-body > :nth-child(2) { animation-delay: 0.65s; }
.js-motion .credit-card.is-visible .credit-card-body > :nth-child(3) { animation-delay: 0.75s; }
.js-motion .credit-card.is-visible .credit-card-body > :nth-child(4) { animation-delay: 0.85s; }
.js-motion .credit-card.is-visible .credit-card-body > :nth-child(n+5) { animation-delay: 0.95s; }

/* A soft light follows the cursor across the frame (position set by
   js/motion.js). */
.js-motion .credit-card .embed-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s linear;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%),
              rgba(255,255,255,0.22), rgba(255,255,255,0) 55%);
}
.js-motion .credit-card:hover .embed-wrap::after { opacity: 1; }

/* The label button slides up as the card settles. */
.js-motion .credit-card.is-visible .yt-play {
  animation: mo-rise 0.9s var(--ease) 0.9s backwards;
}
