/* ============================================================================
   The scroll film preview (public/film/). The site's own type, colour and
   controls come from /studio/base.css; this file is the film's page only.

   Two pages in one, chosen before the first paint (index.html):
     - the plain page: the chapters one under the other, with two stills;
     - the live page (html.fm-live): a stage pinned for the length of the film,
       the frames on a canvas behind the chapters, moved by the scrollbar.
   ========================================================================== */

.fm {
  --fm-pad: max(var(--gutter), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px), 4.2vw);
  --fm-ink: #05070a;
  background: var(--fm-ink);
}

/* ------------------------------------------------------------- the words --- */

.fm-display {
  font-stretch: var(--wide); font-weight: 640;
  font-size: clamp(34px, 4.9vw, 70px); line-height: 1; letter-spacing: -0.035em;
  text-wrap: balance;
}
.fm-kicker {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.3;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2);
}
.fm-kicker .ss-num { color: var(--teal); margin-right: 10px; }
.fm-h {
  margin-top: 12px;
  font-stretch: var(--wide); font-weight: 620;
  font-size: clamp(27px, 3.3vw, 46px); line-height: 1.03; letter-spacing: -0.03em;
  text-wrap: balance;
}
.fm-p { margin-top: 14px; max-width: 46ch; font-size: clamp(16px, 1.2vw, 18px); line-height: 1.5; color: var(--ink-2); }
.fm-p strong { color: var(--ink); font-weight: 600; }
.fm-act .ss-lede { margin-top: 18px; max-width: 44ch; }
.fm-value {
  margin-top: 12px;
  font-stretch: var(--wide); font-weight: 660;
  font-size: clamp(44px, 5vw, 72px); line-height: 1; letter-spacing: -0.035em; color: var(--ink);
}
.fm-act--value .fm-p { margin-top: 10px; }
.fm-facts { margin-top: 18px; display: grid; gap: 0; max-width: 46ch; font-size: 15px; }
.fm-facts > div { display: grid; grid-template-columns: 7.2em 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line-strong); }
.fm-facts dt { color: var(--ink-3); }
.fm-facts dd { margin: 0; color: var(--ink); }
.fm-alt { margin-left: 6px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.fm-alt:hover { color: var(--ink); }
.fm-hint { margin-top: 18px; font-size: 13.5px; color: var(--ink-3); }
.fm-hint__live { display: none; }

/* The VIN field, as on the homepage. */
.fm-vin { margin-top: 24px; max-width: 520px; }
.fm-vin__label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--ink-3); }
.fm-vin__row { display: flex; gap: 10px; }
.fm-vin__input {
  flex: 1 1 0; min-width: 0; min-height: 52px;
  background-color: rgba(8, 12, 17, 0.78);
  font-family: var(--font-mono); letter-spacing: 0.05em; text-transform: uppercase;
}
.fm-vin__input::placeholder { font-family: var(--font); letter-spacing: 0; text-transform: none; }
.fm-vin .ss-btn { flex: none; white-space: nowrap; }
.fm-vin__note { margin-top: 8px; font-size: 13.5px; color: var(--bad); }
.fm-vin__note:empty { display: none; }

/* -------------------------------------------------------- the plain page --- */

.fm-track { position: relative; }
.fm-screen { position: relative; background: var(--fm-ink); }
.fm-poster, .fm-still { display: block; width: 100%; height: auto; }
.fm-still { margin-top: 4px; border-radius: var(--r-3); }
#fm-film, .fm-shade, .fm-progress, .fm-loading { display: none; }
.fm-acts {
  width: min(var(--wrap), 100% - 2 * max(var(--gutter), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)));
  margin-inline: auto; padding-block: 36px 64px;
  display: grid; gap: 48px;
}
.fm-act { max-width: 640px; }

/* --------------------------------------------------------- the live page --- */

.fm-live .fm-top {
  position: fixed; left: 0; right: 0; top: 0;
  background: linear-gradient(rgba(5, 7, 10, 0.78), rgba(5, 7, 10, 0));
  border-bottom-color: transparent;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
/* Past the film the bar is glass again, as on every other page. */
.fm-live.fm-past .fm-top {
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  border-bottom-color: var(--line);
  backdrop-filter: saturate(140%) blur(14px); -webkit-backdrop-filter: saturate(140%) blur(14px);
}

/* The film is seven tenths of the track; the last three tenths hold its final frame under the value. */
.fm-live .fm-track { height: 900svh; }
.fm-live .fm-stage { position: sticky; top: 0; height: 100svh; overflow: hidden; background: var(--fm-ink); }
.fm-live .fm-screen { position: absolute; inset: 0; }
.fm-live .fm-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fm-live #fm-film { display: block; position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.fm-live.fm-drawn #fm-film { opacity: 1; }
.fm-live .fm-still { display: none; }

/* The picture is darkened where words stand: along the foot, and a little from the left. */
.fm-live .fm-shade {
  display: block; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to top, rgba(5, 7, 10, 0.80) 0%, rgba(5, 7, 10, 0.46) 24%, rgba(5, 7, 10, 0) 52%),
    linear-gradient(to right, rgba(5, 7, 10, 0.50) 0%, rgba(5, 7, 10, 0.18) 34%, rgba(5, 7, 10, 0) 56%);
}

.fm-live .fm-acts { position: absolute; inset: 0; width: auto; margin: 0; padding: 0; display: block; pointer-events: none; }
/* A chapter that is not the one being shown is clear, not removed: a screen reader still reads every chapter in
   the page's order wherever the scroll stands. The two that hold a VIN field are taken out while clear, so the
   Tab key never lands in a field nobody can see. */
.fm-live .fm-act {
  position: absolute; left: var(--fm-pad); bottom: clamp(44px, 9svh, 104px);
  width: min(600px, 41vw); max-width: none;
  opacity: 0; transform: translate3d(0, 22px, 0);
  transition: opacity 0.5s var(--ease), transform 0.7s var(--ease);
}
.fm-live .fm-act--first, .fm-live .fm-act--last {
  visibility: hidden;
  transition: opacity 0.5s var(--ease), transform 0.7s var(--ease), visibility 0s linear 0.5s;
}
.fm-live .fm-act.is-on { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition-delay: 0s; }
/* Its own soft dark ground, so a line of light in the picture never runs through a sentence. */
.fm-live .fm-act::before {
  content: ''; position: absolute; z-index: -1; inset: -64px -110px -80px -90px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(5, 7, 10, 0.80), rgba(5, 7, 10, 0.50) 55%, rgba(5, 7, 10, 0));
}
.fm-live .fm-act--first { width: min(600px, 37vw); bottom: clamp(40px, 8svh, 96px); }
.fm-live .fm-hint__live { display: inline; }
.fm-live .fm-hint__plain { display: none; }

/* The value and the last view stand over the film's final frame as a pane of glass along the foot of the
   picture: under the car and the marked bays, never over them. The words on the left, the four facts (or the
   VIN field) on the right. Not on a phone held upright, where the words stand under the picture anyway. */
@media (min-aspect-ratio: 801/1000) {
  .fm-live .fm-act--card {
    left: var(--fm-pad); right: var(--fm-pad); bottom: clamp(24px, 4.5svh, 52px);
    width: auto; max-width: 1120px; padding: 22px 30px 24px;
    display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); column-gap: clamp(28px, 4vw, 64px); align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.10); border-radius: 18px;
    background: rgba(8, 11, 16, 0.62);
    backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
  }
  .fm-live .fm-act--card::before { display: none; }
  .fm-live .fm-act--card > * { grid-column: 1; }
  .fm-live .fm-act--card .fm-h { font-size: clamp(22px, 2.1vw, 30px); }
  .fm-live .fm-act--card .fm-p { font-size: 15.5px; max-width: none; }
  .fm-live .fm-act--value .fm-value { font-size: clamp(40px, 4.2vw, 60px); }
  .fm-live .fm-act--value .fm-facts { grid-column: 2; grid-row: 1 / span 4; margin-top: 0; max-width: none; }
  .fm-live .fm-act--last .ss-h1 { font-size: clamp(26px, 2.6vw, 38px); }
  .fm-live .fm-act--last .fm-vin { grid-column: 2; grid-row: 1 / span 3; margin-top: 0; max-width: none; }
}
/* A short window: the pane takes less height, so it still stands under the car. */
@media (min-aspect-ratio: 801/1000) and (max-height: 680px) {
  .fm-live .fm-act--card { padding: 16px 26px 18px; }
  .fm-live .fm-act--card .fm-h { margin-top: 8px; font-size: 21px; }
  .fm-live .fm-act--value .fm-value { margin-top: 8px; font-size: 42px; }
  .fm-live .fm-act--value .fm-p { margin-top: 6px; }
  .fm-live .fm-facts { font-size: 14px; }
  .fm-live .fm-facts > div { padding: 6px 0; }
}
/* A narrow window that is not a phone held upright: the pane's two columns become one. */
@media (min-aspect-ratio: 801/1000) and (max-width: 760px) {
  .fm-live .fm-act--card { grid-template-columns: minmax(0, 1fr); }
  .fm-live .fm-act--value .fm-facts, .fm-live .fm-act--last .fm-vin { grid-column: 1; grid-row: auto; }
  .fm-live .fm-act--value .fm-facts { margin-top: 14px; }
  .fm-live .fm-act--last .fm-vin { margin-top: 18px; }
}

.fm-live .fm-progress { display: block; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255, 255, 255, 0.06); }
.fm-progress i { display: block; height: 100%; background: var(--teal); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); }
.fm-live .fm-loading {
  display: block; position: absolute; right: var(--fm-pad); top: calc(var(--top-h) + env(safe-area-inset-top, 0px) + 14px);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3);
}
.fm-live .fm-loading:empty { display: none; }

/* A window squarer than the film (half a desk screen, a tablet held on its side): cut to fill it the picture
   would lose half its width. It keeps three quarters of it instead, stands at the top of the stage and fades
   into the dark under it, where the words stand with more room than over a wide picture. */
@media (min-aspect-ratio: 801/1000) and (max-aspect-ratio: 4/3) {
  .fm-live .fm-screen { inset: 0 0 auto 0; height: 75vw; }
  .fm-live .fm-screen::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 36%; pointer-events: none;
    background: linear-gradient(to top, var(--fm-ink) 3%, rgba(5, 7, 10, 0));
  }
  .fm-live .fm-act, .fm-live .fm-act--first { width: min(600px, 58vw); }
  .fm-live .fm-act--card { width: auto; }
}

/* A window that is tall and narrow (a phone held upright): the picture is a band under the bar, whole and in
   its own shape (cut to fill a tall window it would lose the gate or the car), and the words stand under it
   instead of over it. */
@media (max-aspect-ratio: 4/5) {
  .fm-live .fm-top { background: var(--fm-ink); }
  .fm-live .fm-screen { inset: calc(var(--top-h) + env(safe-area-inset-top, 0px)) 0 auto 0; height: auto; aspect-ratio: 16 / 9; }
  .fm-live .fm-shade { display: none; }
  .fm-live .fm-acts { inset: calc(var(--top-h) + env(safe-area-inset-top, 0px) + 56.25vw) 0 0 0; }
  .fm-live .fm-act, .fm-live .fm-act--first, .fm-live .fm-act--card {
    left: var(--fm-pad); right: var(--fm-pad); top: 22px; bottom: auto; width: auto;
    padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none;
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  .fm-live .fm-act::before { display: none; }
  .fm-live .fm-display { font-size: clamp(30px, 9.4vw, 44px); }
  .fm-live .fm-act .ss-lede { margin-top: 12px; font-size: 15.5px; }
  .fm-live .fm-vin { margin-top: 16px; }
  .fm-live .fm-vin__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .fm-live .fm-act .hp-fact { margin-top: 12px; font-size: 13px; }
  .fm-live .fm-hint { margin-top: 10px; }
  .fm-live .fm-value { font-size: clamp(40px, 12vw, 56px); }
  .fm-live .fm-facts { font-size: 14px; margin-top: 12px; }
  .fm-live .fm-facts > div { padding: 7px 0; }
  .fm-live .fm-loading { top: auto; bottom: 12px; }
}
/* A short phone: the value and its four facts are the tallest chapter, and take a little less room each so the
   last fact is still in the window. Nothing is left out. */
@media (max-aspect-ratio: 4/5) and (max-height: 700px) {
  .fm-live .fm-act, .fm-live .fm-act--first, .fm-live .fm-act--card { top: 14px; }
  .fm-live .fm-act--value .fm-h { margin-top: 8px; font-size: 22px; }
  .fm-live .fm-value { margin-top: 8px; font-size: 36px; }
  .fm-live .fm-act--value .fm-p { margin-top: 8px; font-size: 14.5px; }
  .fm-live .fm-facts { margin-top: 10px; font-size: 13px; }
  .fm-live .fm-facts > div { grid-template-columns: 6.4em 1fr; padding: 5px 0; }
}

/* --------------------------------------------------- under the film --- */

.fm-after { padding-block: 72px 96px; max-width: 760px; }
/* Under a pinned stage the page's last section fills a window, so the film can leave it whole. */
.fm-live .fm-after { min-height: 100svh; padding-top: calc(var(--top-h) + 72px); }
.fm-after .ss-h2 { margin-top: 12px; }
.fm-list { margin: 20px 0 0; padding: 0; list-style: none; display: grid; gap: 0; }
.fm-list li { padding: 13px 0; border-top: 1px solid var(--line); color: var(--ink-2); line-height: 1.5; }
.fm-credit { margin-top: 20px; font-size: 13px; line-height: 1.5; color: var(--ink-3); }
.fm-credit a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.fm-credit .fm-alt { margin-left: 0; }

@media print {
  .fm-live .fm-track { height: auto; }
  .fm-live .fm-stage { position: static; height: auto; }
}
