/* ==========================================================================
   BONACCI — the film
   The commercial that opens the home page (index.html only; assets/js/film.js).
   It lies beside the page: when it is over it slides away to one side and the page
   comes in from the other, and a swipe brings it back.

   --film-dir says which side it leaves by (1 right, -1 left). It follows
   data-film-exit on <html> in index.html. Colours, type and easing are style.css's.
   ========================================================================== */

:root {
  --film-dir: 1;
  --film-t: 1.15s;                                  /* how long the slide takes (film.js: SLIDE_MS) */
  --film-ease: cubic-bezier(.77, 0, .18, 1);        /* gathers, glides, settles */
  --film-shift: 12vw;                               /* how far the page travels beside the film */
}
html[data-film-exit="left"] { --film-dir: -1; }

/* ---------- The film, in front of the page ---------- */
.film {
  position: fixed; inset: 0; z-index: 90; visibility: hidden;
  background: var(--night); color: var(--bone);
  transform: translate3d(calc(var(--film-dir) * 100%), 0, 0);
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
html.film-on .film { visibility: visible; transform: none; }
html.film-moving .film { visibility: visible; transition: transform var(--film-t) var(--film-ease); will-change: transform; }

/* A soft shadow that travels with the film's edge, over the page beside it */
.film::before {
  content: ""; position: absolute; top: 0; bottom: 0; right: 100%; width: min(18vw, 220px); pointer-events: none;
  background: linear-gradient(to left, rgba(11, 10, 9, .3), rgba(11, 10, 9, 0));
}
html[data-film-exit="left"] .film::before {
  right: auto; left: 100%;
  background: linear-gradient(to right, rgba(11, 10, 9, .3), rgba(11, 10, 9, 0));
}

/* While the film is in front or on its way, the page does not scroll. The room for the
   scrollbar is kept, and painted the film's black, so nothing jumps when it comes back. */
html.film-on, html.film-moving { overflow: hidden; scrollbar-gutter: stable; background: var(--night); }

/* The page beside the film moves too, more slowly, so the two feel like one surface */
html.film-on .nav, html.film-on main, html.film-on .footer {
  transform: translate3d(calc(var(--film-dir) * -1 * var(--film-shift)), 0, 0);
}
html.film-moving .nav, html.film-moving main, html.film-moving .footer {
  transition: transform var(--film-t) var(--film-ease); will-change: transform;
}
/* Under a finger nothing eases: the film is exactly where the finger is (film.js sets it) */
html.film-drag .film, html.film-drag .nav, html.film-drag main, html.film-drag .footer { transition: none; }

.film__video {
  position: absolute; inset: 0; width: 100%; height: 100%; max-width: none;
  object-fit: cover;
}
/* Behind the picture: a wash of the film's own colours. film.js paints it a few pixels
   wide and the blur does the rest. Only seen where the picture leaves room (below). */
.film__glow {
  position: absolute; inset: -14%; width: 128%; height: 128%; max-width: none; display: block;
  opacity: 0; filter: blur(34px) saturate(1.15); pointer-events: none;
  transition: opacity 1.4s var(--ease);
}
/* Upright and squarish screens: the whole frame is shown, so the name at the end is never
   cut, and the room above and below takes the wash instead of plain black */
@media (max-aspect-ratio: 3/2) {
  .film__video { object-fit: contain; }
  html.film-glow .film__glow { opacity: .4; }
}

/* ---------- On the film: enter the site, sound, how far along it is ---------- */
.film__foot {
  position: absolute; inset: auto 0 0 0; z-index: 1;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  padding: 72px var(--pad) max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(11, 10, 9, .5), rgba(11, 10, 9, 0));   /* keeps the words readable over a bright shot */
  opacity: 0; transition: opacity .9s var(--ease) .6s; pointer-events: none;
}
html.film-on .film__foot { opacity: 1; }
html[data-film-exit="left"] .film__foot { flex-direction: row-reverse; }

.film__btn {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 12px; min-height: 44px;
  font-weight: 500; font-size: 11px; letter-spacing: .3em; text-transform: uppercase; white-space: nowrap;
  color: var(--bone); opacity: .85;
  transition: opacity .3s var(--ease), color .3s var(--ease);
}
.film__btn:hover, .film__btn:focus-visible { opacity: 1; color: var(--gold-bright); }
.film__btn svg { width: 18px; height: 18px; transition: transform .35s var(--ease); }
/* The arrow points to where the page is waiting */
.film__btn--enter svg { transform: scaleX(-1); }
.film__btn--enter:hover svg { transform: scaleX(-1) translateX(4px); }
html[data-film-exit="left"] .film__btn--enter { flex-direction: row-reverse; }
html[data-film-exit="left"] .film__btn--enter svg { transform: none; }
html[data-film-exit="left"] .film__btn--enter:hover svg { transform: translateX(4px); }

.film__btn--sound::before {
  content: ""; flex: none; width: 6px; height: 6px; border: 1px solid currentColor; border-radius: 50%;
  transition: background .3s var(--ease), border-color .3s var(--ease);
}
.film__btn--sound[aria-pressed="true"]::before { background: var(--gold-bright); border-color: var(--gold-bright); }

.film__bar { position: absolute; inset: auto 0 0 0; z-index: 2; height: 2px; background: rgba(237, 231, 219, .12); }
.film__bar i { display: block; height: 100%; background: var(--gold-bright); transform: scaleX(0); transform-origin: left center; }

/* ---------- On the page: the way back to the film ----------
   A tab on the edge of the hero, on the side the film left by. Its name is long
   ("Broadway | Time Square commercial"), so it is never taller than the picture: where the
   picture is too short for it, the name runs on in a second line beside the first. */
.filmtab {
  position: absolute; z-index: 2; top: 62%; right: 0; display: none;
  align-items: center; gap: 10px; padding: 16px 10px 16px 11px;
  height: max-content; max-height: calc(100% - 28px);        /* as tall as its one line, unless the picture is shorter */
  writing-mode: vertical-rl; transform: translateY(-50%);
  border-left: 1px solid var(--line); background: rgba(255, 255, 255, .86);   /* reads over the piece when it turns under it */
  font-weight: 500; font-size: 10.5px; line-height: 1.35; letter-spacing: .34em; text-transform: uppercase; text-align: left;
  color: var(--ink);
  transition: color .3s var(--ease), padding .35s var(--ease);
}
/* A picture that is not tall (a low window, a phone on its side): the tab sits half-way up its edge */
@media (max-width: 1150px), (max-height: 660px) {
  .filmtab { top: 50%; }
}
/* A phone held upright: smaller letters set closer, so that the name stays in one line */
@media (max-width: 520px) and (max-aspect-ratio: 6/5) {
  .filmtab { gap: 8px; padding-block: 12px; font-size: 9.5px; letter-spacing: .2em; }
}
html[data-film-ready] .filmtab { display: inline-flex; }
.filmtab svg { width: 16px; height: 16px; }
.filmtab:hover { color: var(--gold-deep); padding-right: 16px; }
html[data-film-exit="left"] .filmtab { right: auto; left: 0; border-left: 0; border-right: 1px solid var(--line); padding: 16px 11px 16px 10px; }
html[data-film-exit="left"] .filmtab svg { transform: scaleX(-1); }
html[data-film-exit="left"] .filmtab:hover { padding-right: 11px; padding-left: 16px; }

/* Once the page has come in for the first time, the tab stirs twice to show where the film went */
@keyframes filmtab-stir {
  0%, 100% { transform: translate(0, -50%); }
  45% { transform: translate(calc(var(--film-dir) * -7px), -50%); }
}
html.film-shown .filmtab { animation: filmtab-stir 1.5s var(--ease) .9s 2; }

@media (prefers-reduced-motion: reduce) {
  :root { --film-t: 1ms; }
  .film__foot, .film__glow { transition: none; }
  html.film-shown .filmtab { animation: none; }
}
