/* ------------------------------------------------------- The short film */

/* Still on the ground, still in cream: the film is the next thing the page
   shows you, not a new room. The screen carries its own light instead. The
   film's opening dusk bleeds out around it, so the section borrows the film's
   colour without the page taking on a new palette. */
.film {
  position: relative;
  z-index: 1;
  background-color: var(--z-canvas);
  padding: clamp(var(--z-space-8), 4vw, var(--z-space-16)) var(--z-space-6) clamp(var(--z-space-16), 9vw, 128px);
  font-family: var(--z-font-body);
}

.film__inner {
  max-width: 1120px;
  margin: 0 auto;
}

.film__heading {
  max-width: 40rem;
  margin: 0 auto clamp(var(--z-space-10), 5vw, var(--z-space-16));
  text-align: center;
}

.film__kicker {
  color: var(--z-muted);
  margin-bottom: var(--z-space-4);
}

/* Same beat as the ground heading: the first clause sits back, the second
   lands. */
.film__title {
  font-size: clamp(1.875rem, 3.4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.028em;
  line-height: 1.1;
  color: var(--z-muted);
  text-wrap: balance;
}

.film__lands {
  color: var(--z-ink-strong);
}

.film__intro {
  margin-top: var(--z-space-4);
  font-size: clamp(1.0625rem, 1.15vw, 1.1875rem);
  line-height: 1.6;
  color: var(--z-ink);
  text-wrap: pretty;
}

/* ------------------------------------------------------------- The screen */

.film__screen {
  --film-radius: var(--z-radius-lg);
  --film-ink: var(--z-shell-ink);
  position: relative;
  isolation: isolate;
  aspect-ratio: 16 / 9;
  border-radius: var(--film-radius);
  background-color: var(--z-shell);
  box-shadow: var(--z-elev-3), 0 40px 80px -32px rgba(36, 18, 6, 0.45);
  color: var(--film-ink);
}

/* The dusk glow. A 48px thumbnail scaled up is already a blur. */
.film__screen::before {
  content: '';
  position: absolute;
  inset: -7% -5%;
  z-index: -1;
  border-radius: 50%;
  background: url('../assets/images/photos/film-glow.webp') center / 100% 100% no-repeat;
  opacity: 0.42;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent);
  mask-image: radial-gradient(closest-side, #000 55%, transparent);
}

.film__stage,
.film__poster,
.film__end {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
}

.film__stage {
  background-color: #000;
  cursor: pointer;
}

.film__stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Every click on the picture is ours. Without this shield Vimeo gets the
   pointer and shows its own hover chrome. */
.film__stage::after {
  content: '';
  position: absolute;
  inset: 0;
}

/* ------------------------------------------------------------- The poster */

.film__poster {
  display: grid;
  place-items: center;
  z-index: 2;
  background-color: var(--z-shell);
  transition:
    opacity var(--z-settle) var(--z-ease),
    visibility 0s linear var(--z-settle);
}

.film__poster img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 900ms var(--z-ease);
}

/* Lifts the pill off the lit doorway without greying the whole frame. */
.film__poster::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(38% 30% at 50% 50%, rgba(20, 12, 6, 0.32), transparent 70%);
}

.film__play {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: var(--z-space-3);
  padding: var(--z-space-2) var(--z-space-6) var(--z-space-2) var(--z-space-2);
  border-radius: var(--z-radius-pill);
  background-color: rgba(250, 247, 242, 0.94);
  box-shadow: var(--z-elev-2);
  color: var(--z-ink-strong);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition:
    transform var(--z-settle) var(--z-ease),
    box-shadow var(--z-settle) var(--z-ease);
}

.film__play-disc {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--z-primary);
  color: var(--z-primary-foreground);
  transition: background-color var(--z-quick) var(--z-ease);
}

.film__play-disc svg {
  width: 20px;
  height: 20px;
  margin-left: 2px;
  fill: currentColor;
}

.film__play-time {
  color: var(--z-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.film__poster:hover img {
  transform: scale(1.025);
}

.film__poster:hover .film__play {
  transform: translateY(-2px);
  box-shadow: var(--z-elev-3);
}

.film__poster:hover .film__play-disc {
  background-color: var(--z-primary-hover);
}

.film__poster:active .film__play {
  transform: translateY(0);
}

.film__poster:focus-visible {
  outline: none;
}

.film__poster:focus-visible .film__play {
  outline: 2px solid var(--z-primary);
  outline-offset: 4px;
}

/* The poster acknowledges the click while Vimeo loads across the iframe. */
.film__screen[data-state='loading'] .film__poster {
  cursor: progress;
}

.film__screen[data-state='loading'] .film__play-disc svg,
.film__screen[data-state='loading'] .film__play-time {
  display: none;
}

.film__screen[data-state='loading'] .film__play-disc::after {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: film-spin 800ms linear infinite;
}

@keyframes film-spin {
  to { transform: rotate(360deg); }
}

.film__screen:is([data-state='playing'], [data-state='paused'], [data-state='ended']) .film__poster {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ----------------------------------------------------------- The controls */

.film__controls {
  position: absolute;
  inset: auto 0 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: var(--z-space-2);
  padding: var(--z-space-16) var(--z-space-4) var(--z-space-3);
  border-radius: 0 0 var(--film-radius) var(--film-radius);
  background: linear-gradient(180deg, transparent, rgba(16, 11, 8, 0.72));
  transition: opacity var(--z-settle) var(--z-ease);
}

.film__controls[hidden] {
  display: none;
}

/* Out of the way while the film plays and nobody is reaching for it. */
.film__screen[data-idle] .film__controls {
  opacity: 0;
}

/* Keep the sound switch visible while iPhone's first-tap autoplay is muted. */
.film__screen[data-idle][data-muted] .film__controls {
  opacity: 1;
}

.film__screen[data-idle] .film__stage {
  cursor: none;
}

.film__button {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--z-control-touch);
  height: var(--z-control-touch);
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background-color var(--z-quick) var(--z-ease);
}

.film__button:hover {
  background-color: rgba(245, 237, 225, 0.14);
}

.film__button:focus-visible {
  outline: 2px solid var(--film-ink);
  outline-offset: 0;
}

.film__button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.film__stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.film__icon-play,
.film__icon-muted,
.film__icon-collapse,
.film__screen[data-state='paused'] .film__icon-pause,
.film__screen[data-muted] .film__icon-sound,
.film__screen[data-fullscreen] .film__icon-expand {
  display: none;
}

.film__screen[data-state='paused'] .film__icon-play,
.film__screen[data-muted] .film__icon-muted,
.film__screen[data-fullscreen] .film__icon-collapse {
  display: block;
}

.film__time {
  flex: none;
  padding-inline: var(--z-space-1) var(--z-space-2);
  font-size: 0.8125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.film__time-total {
  color: color-mix(in srgb, var(--film-ink) 64%, transparent);
}

/* The scrubber is a native range, restyled: keyboard, touch and screen
   readers all come with it. --progress is written by js/film.js. */
.film__scrub {
  --progress: 0%;
  flex: 1;
  min-width: 0;
  height: var(--z-control-touch);
  margin-inline: var(--z-space-2);
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.film__scrub::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--z-radius-pill);
  background: linear-gradient(90deg, var(--film-ink) var(--progress), rgba(245, 237, 225, 0.28) var(--progress));
  transition: height var(--z-quick) var(--z-ease);
}

.film__scrub::-moz-range-track {
  height: 4px;
  border-radius: var(--z-radius-pill);
  background: rgba(245, 237, 225, 0.28);
}

.film__scrub::-moz-range-progress {
  height: 4px;
  border-radius: var(--z-radius-pill);
  background: var(--film-ink);
}

.film__scrub::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--film-ink);
  box-shadow: 0 1px 4px rgba(16, 11, 8, 0.4);
  transform: scale(0);
  transition: transform var(--z-quick) var(--z-ease);
  -webkit-appearance: none;
  appearance: none;
}

.film__scrub::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--film-ink);
  transform: scale(0);
  transition: transform var(--z-quick) var(--z-ease);
}

.film__scrub:is(:hover, :focus-visible)::-webkit-slider-thumb {
  transform: scale(1);
}

.film__scrub:is(:hover, :focus-visible)::-moz-range-thumb {
  transform: scale(1);
}

.film__scrub:focus-visible {
  outline: none;
}

.film__scrub:focus-visible::-webkit-slider-runnable-track {
  outline: 2px solid var(--film-ink);
  outline-offset: 6px;
}

/* ------------------------------------------------------------ The end card */

.film__end {
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--z-space-6);
  padding: var(--z-space-6);
  /* The dusk thumbnail again: the film's light without its lettering
     competing with ours. */
  background:
    linear-gradient(rgba(20, 14, 10, 0.5), rgba(20, 14, 10, 0.5)),
    url('../assets/images/photos/film-glow.webp') center / cover no-repeat;
  text-align: center;
}

.film__end[hidden] {
  display: none;
}

.film__end-line {
  font-size: clamp(1.375rem, 2.6vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-wrap: balance;
}

.film__end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--z-space-3);
}

.film__replay {
  border-color: rgba(245, 237, 225, 0.5);
  background-color: transparent;
  color: var(--film-ink);
}

.film__replay:hover {
  border-color: var(--film-ink);
  background-color: rgba(245, 237, 225, 0.1);
}

/* ------------------------------------------------------------ Full screen */

/* Native full screen takes the whole screen element, so our controls come
   with it. iPhone Safari only lets a <video> go full screen, so there the
   same element fills the viewport instead. */
.film__screen:fullscreen,
.film__screen[data-theater] {
  --film-radius: 0;
  aspect-ratio: auto;
  width: 100%;
  height: 100%;
  background-color: #000;
  box-shadow: none;
}

.film__screen[data-theater] {
  position: fixed;
  inset: 0;
  z-index: 1000;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.film__screen:fullscreen::before,
.film__screen[data-theater]::before {
  display: none;
}

.film__screen:fullscreen .film__controls,
.film__screen[data-theater] .film__controls {
  padding-inline: var(--z-space-6);
  padding-bottom: max(var(--z-space-4), env(safe-area-inset-bottom));
}

.film-theater-open {
  overflow: hidden;
}

.film__visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------ Small screens */

@media (max-width: 640px) {
  .film {
    padding-left: var(--z-space-5);
    padding-right: var(--z-space-5);
  }

  .film__screen {
    --film-radius: var(--z-radius-md);
    box-shadow: var(--z-elev-2);
  }

  .film__play {
    padding-right: var(--z-space-5);
    font-size: 0.9375rem;
  }

  .film__play-disc {
    width: 40px;
    height: 40px;
  }

  .film__play-time {
    display: none;
  }

  .film__controls {
    gap: 0;
    padding: var(--z-space-10) var(--z-space-1) 0;
  }

  .film__time-total {
    display: none;
  }

  .film__end {
    gap: var(--z-space-4);
    padding: var(--z-space-4);
  }

  .film__end-line {
    font-size: 1.125rem;
  }

  .film__end .z-btn {
    --z-btn-height: var(--z-control-standard);
    font-size: 0.875rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .film__poster img,
  .film__play {
    transition: none;
  }

  .film__poster:hover img {
    transform: none;
  }

  .film__screen[data-state='loading'] .film__poster {
    cursor: default;
  }

  .film__screen[data-state='loading'] .film__play-disc::after {
    animation: none;
  }
}
