/* video page: the screening room. Owned by its builder, then its auditor. Prefix vd-.
   Default (phones, touch, narrow windows): no stage; each film is its still at its own ratio with the title
   inside the picture's corner. With a mouse and room for two columns: a sticky stage beside the programme.
   Sizes in use: Display (the word), --t-xl (the film on the stage), --t-lg (rows, lede, quote), --t-xs (labels);
   on phones --t-sm for the title inside a still's corner instead of --t-xl. */

.vd {
  padding-block: clamp(0.75rem, 1.4vw, 1.25rem) clamp(3.5rem, 6vw, 5rem);
  /* the unlit screen: a shade darker than the room, so letterboxed frames read as film on a screen */
  --vd-screen: linear-gradient(var(--shade), var(--shade)), linear-gradient(var(--shade), var(--shade)), var(--ink);
}

/* the page word and Gratas's line */
.vd-word { font-size: clamp(2rem, 9.6vw, 6rem); overflow: clip; }
.vd-word__in { display: block; }
.vd-lede { margin-top: 0.75rem; max-width: 36ch; }
.vd-note { margin-top: 0.75rem; }

/* a still never grows past 1.25 times its own width; --w is its natural width */
.vd-still { width: min(100%, calc(var(--w) * 1.25px)); aspect-ratio: var(--r); }
.vd-still--full { aspect-ratio: 16 / 9; }

/* the programme */
.vd-prog { position: relative; margin-top: 2.5rem; }
.vd-group { border-top: 1px solid var(--line); padding-top: 1rem; }
.vd-group + .vd-group { margin-top: 3rem; }
.vd-group__name { font-weight: 640; }
.vd-quote { margin-top: 0.75rem; max-width: 34rem; }
.vd-quote p { font-weight: 350; font-size: var(--t-lg); line-height: 1.25; letter-spacing: -0.008em; text-wrap: pretty; }
.vd-quote footer { margin-top: 0.5rem; font-weight: 500; font-size: var(--t-xs); font-stretch: 108%; line-height: 1.4; color: var(--fog-2); }

/* films as stills: on a phone full bleed, each at its own ratio, a hair apart like a strip of film */
.vd-group__films { display: grid; gap: 0.375rem; margin: 1.25rem calc(-1 * var(--gut)) 0; }
.vd-film { position: relative; display: block; text-decoration: none; }
.vd-film__shot { display: grid; place-items: end start; background: var(--vd-screen); overflow: hidden; }
.vd-film__t { position: absolute; left: 0; bottom: 0; z-index: 2; max-width: 100%; padding: 0.5rem 0.75rem 0.5rem var(--gut); background: var(--veil); font-size: var(--t-sm); font-weight: 560; line-height: 1.25; }
.vd-film__tx { display: block; }
.vd-film:active .vd-film__shot { opacity: 0.86; }
.vd-film:focus-visible { outline-offset: -4px; }
.vd-dot { display: none; }

@media (min-width: 40rem) {
  /* two to a row, each still at its own ratio and standing on one line with its neighbour, so every title stays
     inside its picture's corner (on a shared 16:9 screen the titles of the wide frames fell on the dark band
     under the picture). A group with an odd number of films opens with one still across both columns, so no
     row is left half empty. The list stops where a full-width still would pass 1.25 times its size. */
  .vd-prog { max-width: 62rem; }
  .vd-group__films { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-inline: 0; align-items: end; }
  .vd-group__films > li:first-child:nth-last-child(odd) { grid-column: 1 / -1; }
  .vd-film__t { padding-left: 0.75rem; }
}

/* ---------- the stage: a mouse and room for two columns ---------- */
@media (min-width: 52.01rem) and (hover: hover) and (pointer: fine) {
  .vd { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-template-rows: auto 1fr; column-gap: 1.5rem; }
  .vd-intro { grid-column: 1 / span 7; grid-row: 1; padding-bottom: clamp(1.5rem, 9svh - 2.5rem, 3rem); }
  .vd-note { display: none; }

  .vd-stage { grid-column: 1 / span 7; grid-row: 2; align-self: start; position: sticky; top: calc(var(--top-h) + 1rem); max-width: 50rem; --vd-th: calc(1.08 * var(--t-xl)); }
  /* The film's title in the Title voice, one step down in size so that every title holds one line and the word
     above stays the only big thing. The box is the mask titles travel through; its height is the tallest title's
     (set from script), its padding keeps Ž and ų inside. Should a title ever wrap, it grows upward from the screen. */
  .vd-stage__title { position: relative; box-sizing: content-box; height: var(--vd-th); padding-block: 0.16em; margin-block: -0.16em; overflow: clip; font-size: var(--t-xl); line-height: 1.08; }
  .vd-stage__t { position: absolute; left: 0; right: 0; bottom: 0.16em; visibility: hidden; }
  .vd-stage__t.is-on { visibility: visible; }
  .vd-stage__group { position: relative; height: 1.4em; margin-top: 0.375rem; overflow: clip; }
  .vd-stage__g { position: absolute; left: 0; top: 0; white-space: nowrap; visibility: hidden; }
  .vd-stage__g.is-on { visibility: visible; }
  /* the screen. Kept free of anything but the link, so a player can mount here later.
     Its width also answers to the height of the window, twice over: so the whole stage stays in view while it is
     stuck, and so the screen ends above the fold in the first screen, where it starts lower (--vd-f0, its top
     edge on the unscrolled page, set from script). For the first screen it gives up at most a fifth of its
     width; a window shorter than that cuts the picture at the fold rather than shrink it to a stamp. */
  .vd-stage__frame { position: relative; margin-top: 0.625rem; aspect-ratio: 16 / 9; width: min(100%, max(14rem, calc((100svh - var(--top-h) - var(--vd-th) - 4.75rem) * 16 / 9)), max(80%, calc((100svh - var(--vd-f0, 0px) - 1rem) * 16 / 9))); background: var(--vd-screen); }
  .vd-stage__link { position: absolute; inset: 0; display: block; overflow: hidden; }
  .vd-stage__link:focus-visible { outline-offset: 3px; }
  .vd-stage__layers { position: absolute; inset: 0; isolation: isolate; }
  .vd-layer { position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden; background: var(--vd-screen); }
  .vd-layer img { transition: opacity 0.5s var(--out), scale 1.2s var(--out); }
  .vd-stage__link:hover .vd-layer img { scale: 1.03; }

  .vd-prog { grid-column: 8 / -1; grid-row: 1 / span 2; max-width: none; margin-top: calc(clamp(2rem, 9.6vw, 6rem) * 0.115); padding-bottom: max(0px, calc(var(--top-h) + 1rem + var(--vd-sh, 30rem) - 52svh)); }
  /* every text in the programme shares one edge, one step in from the hairlines. The step is the dot's lane. */
  .vd-group { padding-left: 1.125rem; }
  .vd-group + .vd-group { margin-top: 2.25rem; }
  .vd-quote { margin-bottom: 0.625rem; }
  .vd-group__films { display: block; margin: 0.25rem 0 0; }
  .vd-film { display: flex; align-items: center; min-height: 2.75rem; padding-block: 0.375rem; color: var(--mute); transition: color var(--d-fast) var(--out); }
  .vd-film[aria-current="true"] { color: var(--fog); }
  .vd-film__t { position: static; padding: 0; background: none; font-size: var(--t-lg); font-weight: 520; }
  .vd-film__tx { transform-origin: 0 50%; transition: transform 0.14s var(--out); }
  .vd-film:active .vd-film__tx { transform: scale(0.97); }
  .vd-film:focus-visible { outline-offset: 2px; }
  /* the one red dot: it rests beside the film that is on the stage */
  .vd-dot { display: block; position: absolute; left: 0; top: 0; margin-top: -0.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .vd-film, .vd-film__tx, .vd-layer img { transition: none; }
}
