/* The poster is the default, including when scripts or motion are disabled. */
.film-aperture { display: none; }

@media screen and (prefers-reduced-motion: no-preference) {
  /*
   * A wide theatrical aperture opens beyond the photograph. The two mattes
   * sit behind the title and navigation throughout.
   */
  .cover[data-cinema-state="playing"] .film-aperture {
    display: block;
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
  }

  .film-aperture::before,
  .film-aperture::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    height: 12%;
    background: #0c1520;
    animation: cinema-gate-open 1250ms cubic-bezier(.45, 0, .12, 1) both;
  }

  .film-aperture::before {
    top: 0;
    --gate-exit: -101%;
  }

  .film-aperture::after {
    bottom: 0;
    --gate-exit: 101%;
  }

  .cover[data-cinema-state="playing"] .cover-photo {
    transform-origin: 74% 46%;
    animation: cinema-opening-camera 2180ms cubic-bezier(.16, .6, .19, 1) both;
  }

  .cover[data-cinema-state="playing"] h1 {
    animation: cinema-opening-title 880ms cubic-bezier(.17, .68, .22, 1) both;
  }

  .cover[data-cinema-state="playing"] .cover-copy > p {
    animation: cinema-opening-caption 760ms 110ms cubic-bezier(.2, .68, .23, 1) both;
  }

  @keyframes cinema-gate-open {
    0%, 9% { transform: translateY(0); }
    100% { transform: translateY(var(--gate-exit)); }
  }

  @keyframes cinema-opening-camera {
    from { transform: scale(1.17) translate(1.2%, .65%); }
    to { transform: none; }
  }

  @keyframes cinema-opening-title {
    from { transform: translateY(.24em); opacity: .79; }
    to { transform: none; opacity: 1; }
  }

  @keyframes cinema-opening-caption {
    from { transform: translateY(8px); opacity: .84; }
    to { transform: none; opacity: 1; }
  }

  /*
   * The auditorium starts with its warm house lights up. As they dim, the
   * projector becomes the only light on the couple.
   */
  .screening[data-cinema-state="playing"]::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(112deg, #eeb17270 0%, #ebaa7047 30%, #e5a66b15 58%, transparent 78%);
    animation: cinema-house-lights 1550ms cubic-bezier(.4, .04, .3, 1) both;
  }

  .screening[data-cinema-state="playing"] > img {
    transform-origin: 72% 60%;
    animation: cinema-screening-projector 1840ms cubic-bezier(.18, .61, .23, 1) both;
  }

  .screening[data-cinema-state="playing"] .screening-copy h2 {
    animation: cinema-screening-title 930ms 100ms cubic-bezier(.16, .62, .22, 1) both;
  }

  @keyframes cinema-house-lights {
    0%, 12% { opacity: 1; }
    100% { opacity: 0; }
  }

  @keyframes cinema-screening-projector {
    from { transform: scale(1.075) translateX(-.8%); }
    to { transform: none; }
  }

  @keyframes cinema-screening-title {
    from { transform: translateX(-.15em); opacity: .77; }
    to { transform: none; opacity: 1; }
  }

  .postcard[data-cinema-state="playing"] {
    transform-origin: 53% 72%;
    animation: cinema-postcard-settle 860ms cubic-bezier(.19, .71, .23, 1) both;
  }

  @keyframes cinema-postcard-settle {
    from { transform: translate(13px, 12px) rotate(-6deg); }
    to { transform: rotate(-3deg); }
  }
}

@media screen and (max-width: 700px) and (prefers-reduced-motion: no-preference) {
  .cover[data-cinema-state="playing"] .film-aperture {
    bottom: auto;
    height: 75%;
  }

  .film-aperture::before,
  .film-aperture::after {
    height: 10%;
  }

  .cover[data-cinema-state="playing"] .cover-photo {
    transform-origin: 67% 42%;
  }
}

/* Scrolling past the auditorium pans from the projected screen to the two seats. */
@supports (animation-timeline: view()) {
  @media screen and (prefers-reduced-motion: no-preference) {
    .screening {
      view-timeline-name: --auditorium;
      view-timeline-axis: block;
    }

    .screening > img {
      object-position: 55% 61%;
    }

    .screening[data-cinema-state="settled"] > img {
      animation: cinema-follow-seats 1ms linear both;
      animation-timeline: --auditorium;
      animation-range: entry 10% exit 85%;
    }

    @keyframes cinema-follow-seats {
      from { object-position: 55% 55%; }
      to { object-position: 55% 72%; }
    }
  }
}
