/* andrewphan.com, home only: the opening film on one photograph, the full-screen story bands, and the header
   sitting over the photograph. From the landing page v5 (2026-10-18), unchanged. */

/* ---------- The opening, still (no motion) ---------- */
.opening { position: relative; }
.op-stage { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); grid-template-areas: "words print" "words cap";
  column-gap: clamp(24px, 5vw, 80px); align-content: center; max-width: 1320px; margin: 0 auto;
  padding: clamp(24px, 5vw, 64px) var(--gut) clamp(56px, 8vw, 112px); }
.op-frame { grid-area: print; justify-self: center; width: min(100%, 520px); position: relative; background: var(--mat); padding: var(--pad);
  box-shadow: 0 0 0 1px var(--hair), 0 40px 80px -50px rgba(var(--shadow), .55); }
.op-inner { position: relative; aspect-ratio: 4 / 5; overflow: hidden; background: #14100e; }
.op-inner img { width: 100%; height: 100%; object-fit: cover; }
.op-mat { grid-area: cap; justify-self: center; width: min(100%, 520px); }
.sp-cap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin: 12px 0 0; font: 500 11px/1.4 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sp-cap span { white-space: nowrap; }
@media (max-width: 420px) { .sp-cap span { white-space: normal; } } /* a long caption wraps instead of pushing the page wider than a 320px phone */
.op-title { grid-area: words; display: grid; gap: 22px; align-content: center; }
.op-lines { margin: 0; display: grid; font: 400 clamp(44px, 5.4vw, 80px)/1.02 var(--display); letter-spacing: .005em; }
.q { margin: 0; max-width: 26rem; font: italic 400 20px/1.45 var(--serif); color: var(--muted); }
.op-go { margin: 6px 0 0; }
.on-paper, .qs, .cue, .op-paper, .op-matte, .op-glow, .op-veil, .op-marks, .op-shade, .op-black, .intro-wm { display: none; }
@media (max-width: 860px) {
  .op-stage { grid-template-columns: minmax(0, 1fr); grid-template-areas: "print" "cap" "words"; row-gap: 0; }
  .op-frame, .op-mat { justify-self: start; width: min(100%, 460px); }
  .op-title { margin-top: 36px; }
}

/* ---------- The opening, in motion ---------- */
html.motion .opening { height: 460svh; z-index: 1; }
html.motion .op-stage { display: block; position: sticky; top: 0; height: 100svh; max-width: none; padding: 0; overflow: hidden; background: var(--night); }
html.motion .op-paper { display: block; position: absolute; inset: 0; z-index: 1; background: var(--paper); opacity: 0; }
html.motion .op-mat { position: absolute; left: 0; top: 0; z-index: 2; width: 0; height: 0; background: var(--mat); opacity: 0;
  box-shadow: 0 0 0 1px var(--hair), 0 40px 80px -50px rgba(var(--shadow), .55); will-change: transform, opacity; }
html.motion .op-mat .sp-cap { position: absolute; left: 0; right: 0; top: 100%; margin-top: 14px; }
html.motion .op-frame { position: absolute; top: 0; left: 0; z-index: 3; width: 100%; height: 100%; padding: 0; overflow: hidden; background: none; box-shadow: none;
  transform-origin: 0 0; will-change: transform, clip-path; }
html.motion .op-matte { display: block; position: absolute; inset: 0; background: var(--mat); opacity: 0; }
html.motion .op-inner { position: absolute; left: 0; top: 0; aspect-ratio: auto; overflow: visible; background: none; transform-origin: 0 0; will-change: transform; }
/* The photograph is the largest thing on the first screen, so it paints as soon as it arrives. The warm-black cover
   (.op-black) stays over it until the intro is done, then fades away: the photograph is not held at opacity 0. */
html.motion .op-glow { display: block; position: absolute; left: 43.2%; top: 6%; width: 64%; aspect-ratio: 1; translate: -50% -50%; pointer-events: none; mix-blend-mode: screen; }
html.motion .op-glow::before { content: ""; position: absolute; inset: 0; border-radius: 50%; opacity: 0; transition: opacity 2.6s var(--sine) 1.4s;
  background: radial-gradient(closest-side, rgba(255, 222, 176, .55), rgba(255, 196, 128, .18) 45%, rgba(255, 190, 120, 0) 100%); }
html.motion.ready .op-glow::before { opacity: 1; }
/* Crop marks and the shade outside them move by transform and clip-path only */
html.motion .op-veil { display: block; position: absolute; inset: 0; background: rgba(14, 11, 10, .45); opacity: 0; pointer-events: none; }
html.motion .op-marks { display: block; position: absolute; inset: 0; opacity: 0; pointer-events: none; }
html.motion .op-marks i { position: absolute; left: 0; top: 0; width: 18px; height: 18px; border: 0 solid rgba(251, 248, 242, .92); will-change: transform; }
html.motion .op-marks i:nth-child(1) { border-left-width: 1.5px; border-top-width: 1.5px; }
html.motion .op-marks i:nth-child(2) { border-right-width: 1.5px; border-top-width: 1.5px; }
html.motion .op-marks i:nth-child(3) { border-left-width: 1.5px; border-bottom-width: 1.5px; }
html.motion .op-marks i:nth-child(4) { border-right-width: 1.5px; border-bottom-width: 1.5px; }
html.motion .op-shade { display: block; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: var(--footage), linear-gradient(to bottom, rgba(20, 16, 15, .5), rgba(20, 16, 15, 0) 20%); }
html.motion .op-black { display: block; position: absolute; inset: 0; z-index: 6; background: var(--night); pointer-events: none; transition: opacity 2.4s var(--sine); }
html.motion.ready .op-black { opacity: 0; }

/* Titles over the photograph (acts one and two) and on paper (act three) */
html.motion .op-title { position: absolute; z-index: 5; display: grid; gap: 18px; }
html.motion .on-image { left: var(--edge); right: var(--gut); bottom: max(10vh, 64px); max-width: 46rem; color: var(--on); }
html.motion .on-paper { display: grid; left: var(--edge); top: 50%; translate: 0 -50%; width: min(40vw, 34rem); color: var(--ink); }
html.motion .op-lines { font-size: clamp(52px, 7.2vw, 108px); }
html.motion .op-lines .line { grid-area: 1 / 1; }
html.motion .op-lines .still, html.motion .still-q { display: none; }
html.motion .op-lines .wi { transform: translateY(112%); transition: transform 1.15s var(--ease); transition-delay: calc(var(--w, 0) * 70ms); }
html.motion.titles .opening[data-stage="0"] .line[data-i="0"] .wi,
html.motion.titles .opening[data-stage="1"] .line[data-i="1"] .wi,
html.motion.titles .opening[data-stage="2"] .on-paper .line .wi { transform: none; transition-delay: calc(var(--w, 0) * 70ms + .2s); }
html.motion .opening[data-stage="1"] .line[data-i="0"] .wi,
html.motion .opening:is([data-stage="cut"], [data-stage="2"]) .on-image .line .wi { transform: translateY(-112%); transition-delay: calc(var(--w, 0) * 40ms); }
html.motion .on-image .q { color: var(--on-2); }
html.motion .on-image .cap { color: var(--on-2); }
html.motion .qs { display: grid; }
html.motion .qs .q { grid-area: 1 / 1; opacity: 0; transition: opacity var(--fade) var(--sine); }
html.motion.titles .opening[data-stage="0"] .q[data-i="0"],
html.motion.titles .opening[data-stage="1"] .q[data-i="1"] { opacity: 1; transition-delay: .6s; }
html.motion .op-title .op-cap, html.motion .op-title .rail, html.motion .op-title .op-go, html.motion .on-paper .q { opacity: 0; transition: opacity var(--fade) var(--sine); }
html.motion.titles .opening:is([data-stage="0"], [data-stage="1"]) .on-image .op-cap,
html.motion.titles .opening[data-stage="2"] .on-paper .op-cap { opacity: 1; }
/* The line under the title is on the page from the first paint (it sits under the warm-black cover until the intro
   ends) and leaves with the title when the camera cuts to the hands. */
html.motion .on-image .op-q { transition: opacity var(--fade) var(--sine); }
html.motion .opening:is([data-stage="cut"], [data-stage="2"]) .on-image .op-q { opacity: 0; }
html.motion.titles .opening:is([data-stage="0"], [data-stage="1"]) .on-image :is(.rail, .op-go),
html.motion.titles .opening[data-stage="2"] .on-paper :is(.rail, .op-go, .q) { opacity: 1; transition-delay: .8s; }
html.motion .op-title .op-go:focus-within { opacity: 1; } /* a keyboard user lands on the link before the title has faded up */
.op-go a:focus-visible { outline: 2px solid #fffaf2; outline-offset: 6px; box-shadow: 0 0 0 8px rgba(28, 23, 23, .55); } /* light ring + warm-black halo: visible on the photo and on paper */
html.motion .on-image .op-go a:focus-visible { outline-color: var(--on); }
html.motion .on-paper .op-go a { pointer-events: none; }
html.motion.titles .opening[data-stage="2"] .on-paper .op-go a { pointer-events: auto; }

.rail { display: flex; gap: 14px; margin: 4px 0 0; padding: 0; list-style: none; font: 500 10.5px/1.3 var(--ui); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.rail li { position: relative; flex: 1 1 0; max-width: 150px; padding-top: 12px; transition: color .6s var(--sine); }
.rail li::before, .rail li::after { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: var(--hair); }
.rail li::after { background: currentColor; transform: scaleX(var(--f, 0)); transform-origin: left; }
html.motion .on-image .rail { color: rgba(241, 235, 226, .55); }
html.motion .on-image .rail li::before { background: rgba(241, 235, 226, .22); }
html.motion .opening[data-stage="0"] .on-image .rail li:nth-child(1),
html.motion .opening[data-stage="1"] .on-image .rail li:nth-child(2) { color: var(--on); }
html.motion .on-paper .rail li:nth-child(3) { color: var(--ink); }

html.motion .cue { display: flex; flex-direction: column; align-items: center; gap: 10px; position: absolute; z-index: 5; right: var(--edge); bottom: max(28px, env(safe-area-inset-bottom, 0px)); margin: 0;
  font: 500 10px/1 var(--ui); letter-spacing: .24em; text-transform: uppercase; color: var(--on-2); opacity: 0; transition: opacity .6s var(--sine); }
html.motion .cue::after { content: ""; width: 1px; height: 30px; background: linear-gradient(currentColor, transparent); transform-origin: top; animation: cue 2.4s var(--sine) infinite; }
html.motion.titles .opening[data-cue] .cue { opacity: 1; transition-delay: 1.4s; }
@keyframes cue { 0% { transform: scaleY(0); } 45% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }

/* The header sits over the photograph while the page is at the top */
html.motion .top { position: absolute; top: 0; left: 0; right: 0; color: var(--on); }
html.motion .bar nav { opacity: 0; transition: opacity var(--fade) var(--sine) .3s; }
html.motion.seq-done .bar nav { opacity: 1; }
html.motion:not(.seq-done) .bar .wm { opacity: 0; }

/* The title sequence: the name on warm black, tracking open, then flying up into the header */
html.motion.seq .intro-wm { display: block; position: fixed; left: 50%; top: 46%; translate: -50% -50%; z-index: 6; margin: 0; pointer-events: none; white-space: nowrap;
  font: 400 clamp(30px, 6.4vw, 96px)/1 var(--display); letter-spacing: .12em; color: var(--on); opacity: 0;
  transition: opacity var(--fade) var(--sine), letter-spacing 1.8s var(--drift); }
html.motion.seq.seq-on .intro-wm { opacity: 1; letter-spacing: .24em; }
html.motion.seq.seq-done .intro-wm { display: none; }

@media (max-width: 860px) {
  html.motion .on-image { bottom: max(7vh, 40px); }
  html.motion .on-paper { top: auto; bottom: max(36px, 5vh); translate: none; left: var(--gut); right: var(--gut); width: auto; gap: 14px; }
  html.motion .op-lines { font-size: clamp(42px, 11.5vw, 60px); }
  html.motion .q { font-size: 17px; }
  html.motion .cue { display: none; }
}

/* ---------- Story bands: each photograph on the full screen, its title set over it, the whole band a link ---------- */
.band { position: relative; margin: clamp(48px, 7vw, 104px) auto 0; width: min(100%, calc(var(--nw) * 1.25px / var(--dpr))); height: 88svh; min-height: 520px; max-height: 1100px; color: var(--on); }
.band-win { position: absolute; inset: 0; overflow: hidden; background: var(--night); }
.band-win img { position: absolute; left: 0; top: -10%; width: 100%; height: 120%; max-width: none; object-fit: cover; object-position: var(--fx, 50%) var(--fy, 50%); }
.band-win::after { content: ""; position: absolute; inset: 0; background: var(--footage); pointer-events: none; }
.band-title { position: absolute; z-index: 1; left: var(--edge); right: var(--gut); bottom: clamp(32px, 8vh, 80px); display: grid; gap: 12px; max-width: 50rem; }
.band-title .cap { color: var(--on-2); }
.band-title h3 { font: 400 clamp(40px, 5.6vw, 84px)/1.02 var(--display); letter-spacing: .005em; text-wrap: balance; }
.logline { margin: 0; font: italic 400 clamp(19px, 1.6vw, 23px)/1.4 var(--serif); color: var(--on-2); }
a.band { display: block; text-decoration: none; }
a.band:focus-visible { outline-offset: -8px; }
.band + .band { margin-top: clamp(16px, 2vw, 28px); }
.band-go { margin: 6px 0 0; font: 500 14px/1.2 var(--ui); }
.band-go { display: inline-block; padding-bottom: 5px; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size .55s var(--ease); }
.band-go span { display: inline-block; transition: transform .5s var(--ease); }
a.band:hover .band-go, a.band:focus-visible .band-go { background-size: 100% 1px; }
a.band:hover .band-go span, a.band:focus-visible .band-go span { transform: translateX(5px); }
@media (max-width: 860px) {
  .band { height: 72svh; min-height: 440px; }
}

html.motion .band-title > :not(h3) { opacity: 0; transform: translateY(14px); transition: opacity var(--fade) var(--sine), transform 1.2s var(--ease); }
html.motion .band.in .band-title > :not(h3) { opacity: 1; transform: none; transition-delay: .5s; }
html.motion .band.in .band-title > .cap { transition-delay: 0s; }
html.motion .band-win img { transform: scale(1.1); }
html.motion .band.live .band-win { will-change: clip-path; } /* GPU layers only while a band is on screen */
html.motion .band.live .band-win img { will-change: transform; }

html.motion:not(.seq-done) .menu-btn { opacity: 0; pointer-events: none; }

/* Borrowed 2026-10-16 (docs/references-andrewphan.md, v3): a cinemagraph, the bulb flickering faintly while
   the opening holds (eyecannndy "Cinemagraph"). */
html.motion .op-glow::after { content: ""; position: absolute; inset: 18%; border-radius: 50%; opacity: 0; mix-blend-mode: screen;
  background: radial-gradient(closest-side, rgba(255, 226, 184, .5), rgba(255, 200, 140, 0)); }
html.motion.ready .op-glow::after { animation: tungsten 6.5s var(--sine) infinite 3.4s; }
@keyframes tungsten {
  0% { opacity: .55; } 7% { opacity: .38; } 9% { opacity: .6; } 31% { opacity: .5; } 33% { opacity: .22; } 34% { opacity: .58; }
  58% { opacity: .5; } 71% { opacity: .62; } 72% { opacity: .34; } 74% { opacity: .55; } 100% { opacity: .5; } }
