/* design-ending.css — the end of the home page, as the end of a film.

   The films run out and the credits roll: the stills from #work (on /work/,
   the wall's landscape stills) rise past on either side as the visitor
   scrolls the last screen, faster than the page,
   out of black at the foot and back into black at the top. When the page
   stops they hold, every resting frame in full light with its whole title,
   and one card stays still in the middle: the production mark, the ask, the
   address. No loop, no autoplay; nothing moves unless the visitor does.
   The home page and /work/ (bin-build-work-pages.py lifts the section from
   index.html), so nothing here may lean on the home page's refinement.css. */

/* the last screen is exactly the screen under the bar: at the end of the page
   the section's top edge tucks under the bar, so nothing of the section above
   shows and nothing of this one hides */
.contact.ending {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--line);
  min-height: calc(100vh - 64px);
  min-height: calc(100lvh - 64px);
  padding: 0 var(--gut) clamp(14px, 2.4vh, 24px);
  overflow: hidden;
}

/* ---- the stage: the card in the middle --------------------------------- */
.ending__stage {
  position: relative; flex: 1 0 auto;
  display: grid; place-items: center;
  /* --stage-pad: design-ending.js closes this air up when the card and the
     rows would not otherwise fit the screen under the bar */
  padding: var(--stage-pad, clamp(40px, 7vh, 80px)) 0;
}

/* while the credits are still rolling, a long soft black head over the top
   of the stage, so frames never meet the edge of the section above; it lifts
   as the roll lands (--p runs 0 to 1 over the last screen) and is gone
   before the frames come to rest */
.ending__stage::before {
  content: ""; position: absolute; z-index: 2; top: 0; height: 34%;
  left: calc(-1 * var(--gut)); right: calc(-1 * var(--gut)); pointer-events: none;
  background: linear-gradient(#000 0%, #000 18%, rgba(0,0,0,.82) 42%, rgba(0,0,0,.42) 70%, rgba(0,0,0,0) 100%);
  opacity: calc((1 - var(--p, 1)) * 2.5);
}

/* ---- the roll ----------------------------------------------------------
   Two columns of frames at the content edges. --t is how far below its
   resting place a column starts: the near column travels further than the
   far one, so while the page moves the two drift out of step and read as
   depth. They only fall into line at the very end of the page: three rows
   a side, centred on the ask, like a crawl resolving into its last card.
   The frame size is held to the height too, so the three rows always rest
   between the bar and the colophon. */
.ending__roll {
  --edge: max(var(--gut), calc((100vw - 1320px) / 2));
  --gap: clamp(30px, 5.2vh, 58px);
  --capH: 29px;
  --cw: max(160px, min(clamp(200px, 20.5vw, 330px), calc((100vh - 259px - 2 * var(--gap)) * 16 / 27)));
  --picH: calc(var(--cw) * 9 / 16);
  --row: calc(var(--picH) + var(--capH));
  --mid: 50%;
  --top: calc(var(--mid) - 1.5 * var(--row) - var(--gap));   /* where the resting frame begins */
  --bot: calc(var(--mid) + 1.5 * var(--row) + var(--gap));   /* and where it ends */
  position: absolute; inset: 0 calc(-1 * var(--gut));
  overflow: hidden; pointer-events: none;
}
/* black above and below the resting rows: the frames come up out of the
   dark and go back into it, the way a crawl does, but nothing that rests is
   ever dimmed and no caption is ever left half-lit. The black also takes the
   pointer, so a frame that has rolled out of sight can't be clicked. */
.ending__roll::before, .ending__roll::after {
  content: ""; position: absolute; left: 0; right: 0; z-index: 2; pointer-events: auto;
}
.ending__roll::before {
  top: 0; height: max(0px, var(--top));
  background: linear-gradient(#000 calc(100% - var(--gap)), rgba(0,0,0,.62) calc(100% - var(--gap) * .5), rgba(0,0,0,0) 100%);
}
.ending__roll::after {
  top: var(--bot); bottom: 0;
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.62) 45%, #000 90%);
}
/* anchored from the foot: the bottom frame of each column is the lower
   resting row, whatever the number of films */
.ending__col {
  position: absolute; width: var(--cw);
  bottom: calc(100% - var(--bot));
  display: flex; flex-direction: column; gap: var(--gap);
  pointer-events: auto;
  transform: translate3d(0, calc((1 - var(--p, 1)) * var(--t)), 0);
}
.ending.is-rolling .ending__col { will-change: transform; }
.ending__col--a { left: var(--edge);  --t: 62vh; }
.ending__col--b { right: var(--edge); --t: 30vh; }

/* ---- a frame and its credit ------------------------------------------- */
.ending__frame {
  display: block; color: var(--fg-faint); text-decoration: none;
  opacity: .78; transition: opacity .7s var(--ease);
  container-type: inline-size;
}
.ending__pic {
  display: block; aspect-ratio: 16 / 9; overflow: hidden;
  border: 1px solid var(--line); border-radius: 8px; background: #0b0c0d;
}
.ending__pic picture { display: contents; }   /* a roll built before its tile loaded offers the tile's WebP */
.ending__pic img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transition: transform 1.4s var(--ease);
}
.ending__cap {
  display: flex; align-items: baseline; gap: 10px; margin-top: 12px;
  /* the credit's size follows the frame (a short screen rests smaller
     frames), so the longest title still fits */
  font-size: min(12.5px, calc(var(--cw) / 14.6)); line-height: 17px; height: 17px; letter-spacing: -.005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ending__cap b { font-weight: 400; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; }
.ending__cap span { flex: none; }
/* the kind of film only where the whole credit fits; a title is never cut */
@container (max-width: 279px) { .ending__cap span { display: none; } }
/* the pointer on a frame brings that film up to full light and the others
   step back, the way a room goes quiet for the one on screen */
@media (hover: hover) and (pointer: fine) {
  .ending__frame:hover { opacity: 1; }
  .ending__roll:has(.ending__frame:hover) .ending__frame:not(:hover) { opacity: .34; }
  .ending__frame:hover .ending__pic img { transform: scale(1.04); }
  .ending__frame:hover .ending__cap b { color: var(--fg); }
}

/* ---- the card ---------------------------------------------------------- */
/* "Send the brief." is the chapter's real title; the Contact slate stays for
   the document outline and screen readers, out of sight */
.contact.ending .slate { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.contact.ending .ending__card {
  position: relative; z-index: 3;
  display: flex; flex-direction: column; align-items: center;
  width: min(560px, 100%); max-width: none; margin: 0 auto; text-align: center;
}
.contact.ending .ending__card > * { margin-left: auto; margin-right: auto; text-align: center; }
.contact.ending .lockup {
  height: clamp(66px, 6.6vw, 92px); width: auto;
  margin: 0 auto clamp(26px, 4.2vh, 40px); opacity: .92;
}
.contact.ending .contact__head {
  margin: 0; font-size: clamp(40px, 4.5vw, 66px); line-height: 1.02; letter-spacing: -.035em;
}
.contact.ending .contact__sub {
  margin-top: 18px; max-width: 38ch; font-size: 16px; line-height: 1.6; color: var(--fg-dim);
}
.ending__acts {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 14px 26px; margin-top: 32px;
}
.ending__acts .btn { font-size: 15px; font-weight: 500; padding: 13px 26px; }
.ending__mail { position: relative; }
.contact.ending .contact__mail {
  font-size: 15px; font-weight: 400; letter-spacing: -.005em; line-height: 1.4;
  color: var(--fg); padding: 10px 0 2px; border-bottom: 1px solid rgba(255, 255, 255, .22);
  transition: border-color .35s var(--ease), opacity .35s var(--ease);
}
.contact.ending .contact__mail:hover { opacity: 1; border-bottom-color: var(--fg); }
.contact.ending .contact__mail:focus-visible { outline-offset: 6px; border-radius: 4px; }
/* "Copied" hangs under the address instead of pushing the row about */
.ending__mail .copied {
  position: absolute; top: calc(100% + 10px); left: 50%; margin: 0;
  transform: translateX(-50%); white-space: nowrap;
}
.contact.ending .contact__links {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 26px;
  margin-top: clamp(30px, 5vh, 44px);
}
.contact.ending .contact__links a {
  padding: 8px 0; font-size: 13px; color: var(--fg-faint); text-decoration: none;
  transition: color .35s var(--ease);
}
.contact.ending .contact__links a:hover { color: var(--fg); }
.contact.ending .colophon {
  position: relative; z-index: 3; width: 100%; max-width: 1320px; margin: 0 auto;
}

/* set by design-ending.js on a short wide screen (1366x625 and the like),
   when closing up the air around the card would leave the mark closer than
   40px to the bar: the bar already carries the mark, so the ask leads the
   card and the whole last frame, the visitor's clock included, fits between
   the bar and the colophon */
@media (min-width: 1000px) {
  .ending--nomark .lockup { display: none; }
}

/* ---- narrower screens: the roll above, the card under it ---------------
   The last screen is one frame: rows of films resting in full light, a gap
   above the ask, then the card. Two rows where the screen is tall enough,
   one where it isn't, never a frame under the bar and never a stub of the
   next one peeking out behind the lockup. The film that opens the grid
   waits just below, out of sight, so the rows that rest are the documentary
   and the campaign that follow it. */
@media (max-width: 999px) {
  .ending__stage {
    display: flex; flex-direction: column; justify-content: center; place-items: normal;
    padding: 0 0 26px;
  }
  .ending__roll {
    --cw: min(300px, calc((100vw - 2 * var(--gut) - 14px) / 2));
    --edge: max(var(--gut), calc(50vw - var(--cw) - 7px));
    --gap: 22px; --capH: 25px; --rows: 2;
    --bot: calc(100% - var(--gap) - 8px);
    --top: calc(var(--bot) - var(--rows) * var(--row) - (var(--rows) - 1) * var(--gap));
    position: relative; inset: auto; flex: none;
    height: calc(var(--rows) * (var(--row) + var(--gap)) + var(--gap) + 12px);
    margin: 0 calc(-1 * var(--gut));
  }
  .ending__roll::after { background: linear-gradient(rgba(0,0,0,0), #000 var(--gap)); }
  .ending__col { bottom: calc(100% - var(--bot) - var(--gap) - var(--row)); }
  .ending__stage::before { height: 46%; }
  .ending__col--a { --t: 34svh; }
  .ending__col--b { --t: 16svh; }
  /* the credit's size follows the frame, so the longest title still fits */
  .ending__cap { font-size: 12px; line-height: 16px; height: 16px; gap: 8px; margin-top: 9px; }
  .contact.ending .ending__card { flex: none; margin-top: 0; }
  .contact.ending .lockup { height: 52px; margin-bottom: 16px; }
  .contact.ending .contact__links { margin-top: 20px; }
}
@media (max-width: 999px) and (max-height: 799px) {
  .ending__roll { --rows: 1; }
}
/* set by design-ending.js when not even one row fits above the card (a short
   phone, the card lengthened by the visitor's clock): the card holds the
   screen alone rather than leave a frame under the bar */
@media (max-width: 999px) {
  .ending--bare .ending__roll { display: none; }
}
/* what design-ending.js measures to fit the last frame changes size at once:
   under reduced motion styles.css gives every property a 0.01ms transition,
   and a measurement taken mid-way would read the size before the change */
.ending__stage, .ending__roll, .ending__roll::before { transition-property: none; }
@media (max-width: 560px) {
  .contact.ending .contact__head { font-size: clamp(38px, 11vw, 46px); }
  .contact.ending .contact__sub { margin-top: 12px; font-size: 15px; line-height: 1.55; }
  .ending__acts { flex-direction: column; gap: 6px; margin-top: 24px; }
  .contact.ending .colophon { font-size: 12px; margin-top: 0; }
}

/* ---- reduced motion: the last frame, held ------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .ending__col { transform: none; }
  .ending__stage::before { display: none; }
  .ending__frame, .ending__pic img, .contact.ending .contact__mail { transition: none; }
  .ending__frame:hover .ending__pic img { transform: none; }
}
@media print {
  .ending__roll { display: none; }
  .contact.ending { min-height: 0; }
  .ending__stage { padding: 0; }
}
