/* design-compositions.css — the four kinds of work under "Commissions", each
   a composition: three stills from that kind of film pinned at three
   depths around the words, like prints on a board. The stills
   keep each film's real picture shape (a scope film stays a scope strip).

   The idea in the motion is a rack focus. At rest the lead film is sharp and
   the other two sit behind it, softer and darker, as they would on a long
   lens. Point at a still and focus racks to it: it sharpens, brightens and
   comes forward, the others fall soft, and its chip (the film and its reach,
   as its tile states them) comes into focus with it, in its corner, never
   over the picture you are looking at. On a phone the scroll pulls focus
   instead: the still crossing the middle of the screen is the sharp one.
   The lead sits on the focal plane with the words and holds its place; the
   planes behind it lag as the page scrolls, as far things do.
   design-compositions.js drives it; without it the lead is simply in focus.
   Only transform, opacity and filter ever animate. */

.cmps { max-width: 1320px; margin: clamp(72px, 10vh, 120px) auto 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: clamp(110px, 15vh, 190px); }
.cmp { position: relative; }

/* ---- the words ---------------------------------------------------------- */
.cmp__text { position: relative; z-index: 5; pointer-events: none; }
.cmp__text > * { pointer-events: auto; }
.cmp__title { margin: 0; max-width: 11ch; font-size: clamp(30px, 3.1vw, 46px); font-weight: 500; line-height: 1.06; letter-spacing: -.032em; }
.cmp__words { margin: 20px 0 0; max-width: 34ch; font-size: clamp(15px, 1.15vw, 17px); line-height: 1.62; color: var(--fg-dim); }
.cmp__links { display: flex; flex-wrap: wrap; gap: 12px 26px; margin: 26px 0 0; font-size: 14px; }
.cmp__links a { color: var(--fg); text-decoration: none; padding-bottom: 3px; border-bottom: 1px solid var(--line); transition: border-color .35s var(--ease); }
.cmp__links a:hover { border-bottom-color: var(--fg); }

/* ---- the stills --------------------------------------------------------- */
.cmp__art { position: relative; }
.cmp__still {
  --cw: 1; --cx: 0; --cy: 0;
  position: absolute; display: block; aspect-ratio: var(--ar, 16 / 9);
  border-radius: 12px; color: var(--fg); text-decoration: none;
  transform-origin: 50% 50%;
  filter: brightness(1) blur(0px) saturate(1);
  transition: filter .8s var(--ease), opacity .8s var(--ease);
}
.cmp__still--1 { z-index: 3; }
.cmp__still--2 { z-index: 1; filter: brightness(.55) blur(1.5px) saturate(.85); }
.cmp__still--3 { z-index: 2; filter: brightness(.68) blur(.9px) saturate(.9); }
/* the lead is on the grid line: coming forward, it grows away from that edge */
.cmp__still--1 { transform-origin: 100% 50%; }
.cmp--flip .cmp__still--1 { transform-origin: 0 50%; }
/* focus racked away from the lead: the lead falls back into the soft planes */
.cmp.is-racked .cmp__still--1 { filter: brightness(.55) blur(1.8px) saturate(.85); }
.cmp .cmp__still.is-focus { z-index: 4; filter: brightness(1) blur(0px) saturate(1); }
.cmp__still:focus-visible { outline: 2px solid var(--fg); outline-offset: 5px; }

.cmp__frame {
  position: absolute; inset: 0; overflow: hidden; border-radius: inherit;
  background: #000; box-shadow: 0 34px 80px -34px rgba(0, 0, 0, .9);
}
.cmp__frame::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 1px solid rgba(255, 255, 255, .1); pointer-events: none; }
.cmp__frame img {
  position: absolute; display: block; max-width: none; height: auto;
  width: calc(var(--cw) * 100%); left: calc(var(--cx) * 100%); top: calc(var(--cy) * 100%);
}

/* the chip: the film's name and its reach, as its tile states them */
.cmp__chip {
  position: absolute; left: 14px; bottom: 14px; z-index: 2;
  display: inline-flex; align-items: baseline; gap: 9px;
  padding: 9px 15px 10px; border-radius: 999px;
  background: rgba(8, 9, 10, .86); border: 1px solid rgba(255, 255, 255, .1);
  font-size: 13px; line-height: 1.2; white-space: nowrap; pointer-events: none;
  opacity: 0; filter: blur(6px);
  transition: opacity .45s var(--ease), filter .45s var(--ease);
}
.cmp__chip b { font-weight: 500; }
.cmp__chip span { flex: none; color: var(--fg-dim); }
.cmp__chip span::before { content: "·"; margin-right: 9px; color: var(--fg-faint); }
.cmp__still.is-focus .cmp__chip, .cmp:not(.is-racked) .cmp__still--1 .cmp__chip { opacity: 1; filter: blur(0); }
.cmp.is-racked .cmp__still--1:not(.is-focus) .cmp__chip { opacity: 0; filter: blur(6px); }

/* ---- desktop: the words sit inside the composition ---------------------- */
@media (min-width: 960px) {
  /* at least 2:1; the words stay in flow and keep the lowest still's height
     free beneath them, so a longer line can push the composition taller but
     can never run into a picture */
  .cmp { aspect-ratio: 2 / 1; }
  .cmp__text { width: max(33%, 300px); padding-bottom: calc(var(--h3, .5625) * 41% + 44px); }
  .cmp__art { position: absolute; inset: 0; }
  .cmp__still--1 { left: 44%; top: 16%; width: 56%; }
  .cmp__still--2 { left: max(34%, 340px); top: 0; width: 25%; }
  .cmp__still--3 { left: 6%; bottom: 0; width: 41%; }
  .cmp--flip .cmp__text { margin-left: auto; }
  .cmp--flip .cmp__still--1 { left: 0; }
  .cmp--flip .cmp__still--2 { left: 38%; }
  .cmp--flip .cmp__still--3 { left: auto; right: 6%; }
  .cmp--flip .cmp__text { padding-left: 2%; }
  /* two films: the lead and the near plane, tucked under its far corner */
  .cmp--duo { aspect-ratio: 2.15 / 1; }
  .cmp--duo .cmp__text { padding-bottom: calc(var(--h3, .5625) * 34% + 48px); }
  .cmp--duo .cmp__still--1 { top: auto; bottom: 24%; width: 58%; }
  .cmp--duo .cmp__still--3 { left: 52%; right: auto; width: 34%; }
  .cmp--duo:not(.cmp--flip) .cmp__still--1 { left: 42%; }
  .cmp--duo:not(.cmp--flip) .cmp__still--3 { left: 11%; }
}

/* ---- tablet and phone: the words, then the composition ------------------ */
@media (max-width: 959px) {
  .cmp__text { margin-bottom: clamp(34px, 6vw, 56px); }
  .cmp__title { max-width: 16ch; }
  .cmp__art { aspect-ratio: 1 / .78; }
  .cmp__still--1 { left: 30%; top: 0; width: 70%; }
  .cmp__still--2 { left: 0; top: 36%; width: 40%; }
  .cmp__still--3 { left: 15%; bottom: 0; width: 55%; }
  .cmp--flip .cmp__still--1 { left: 0; }
  .cmp--flip .cmp__still--2 { left: 60%; }
  .cmp--flip .cmp__still--3 { left: 30%; }
  .cmp--duo .cmp__art { aspect-ratio: 1 / .55; }
  .cmp--duo .cmp__still--1 { width: 72%; }
  .cmp--duo .cmp__still--3 { width: 50%; }
  .cmp--duo.cmp--flip .cmp__still--3 { left: 50%; }
}
@media (max-width: 699px) {
  .cmps { gap: 104px; margin-top: 56px; }
  .cmp__art { aspect-ratio: 1 / 1.15; }
  .cmp__still--1 { left: 8%; width: 92%; }
  .cmp__still--2 { top: 40%; width: 64%; }
  .cmp__still--3 { left: 20%; width: 80%; }
  .cmp--flip .cmp__still--1 { left: 0; }
  .cmp--flip .cmp__still--2 { left: 36%; }
  .cmp--flip .cmp__still--3 { left: 0; }
  .cmp--duo .cmp__art { aspect-ratio: 1 / .76; }
  .cmp--duo .cmp__still--1 { width: 92%; }
  .cmp--duo .cmp__still--3 { width: 76%; }
  .cmp--duo.cmp--flip .cmp__still--3 { left: 24%; }
  /* two lines, inside the still's corner: never over its neighbour */
  .cmp__chip { display: grid; gap: 2px; left: 8px; bottom: 8px; max-width: calc(100% - 16px); padding: 7px 11px 8px; border-radius: 10px; font-size: 12px; white-space: normal; }
  .cmp__chip span::before { content: none; }
  /* where the film carries its own words in that corner (bin-build-home-art.py,
     PHONE_CHIP): the lower right instead, or, under the lowest still, just
     below the picture, so its burned-in title stays whole */
  .cmp__still--chip-end .cmp__chip { left: auto; right: 8px; }
  .cmp__still--chip-under .cmp__chip { top: calc(100% + 10px); bottom: auto; left: 0; }
  /* a small screen reads blur as a picture still loading: keep it lighter */
  .cmp__still--2 { filter: brightness(.46) blur(.7px) saturate(.8); }
  .cmp__still--3 { filter: brightness(.52) blur(.5px) saturate(.85); }
  .cmp.is-racked .cmp__still--1 { filter: brightness(.5) blur(.6px) saturate(.8); }
}

/* ---- arrival: out of focus, back plane first ---------------------------- */
.cmps.is-live .cmp.is-near .cmp__still { will-change: transform; }
.cmps.is-live .cmp:not(.is-in) .cmp__still { opacity: 0; filter: brightness(.6) blur(18px) saturate(.85); }
.cmps.is-live .cmp.is-in:not(.is-settled) .cmp__still { transition-duration: 1.3s, 1.1s; }
.cmps.is-live .cmp.is-in:not(.is-settled) .cmp__still--3 { transition-delay: .14s; }
.cmps.is-live .cmp.is-in:not(.is-settled) .cmp__still--1 { transition-delay: .28s; }
.cmps.is-live .cmp.is-in:not(.is-settled) .cmp__chip { transition-delay: .9s; }

@media (prefers-reduced-motion: reduce) {
  .cmp__still, .cmp__chip { transition: none; }
  .cmp__still--2, .cmp__still--3, .cmp.is-racked .cmp__still--1 { filter: brightness(.62); }
  .cmp .cmp__still.is-focus { filter: none; }
  .cmp__chip { filter: none; }
}
@media print { .cmp__art { display: none; } }
