/* The one-minute film at the top of the page: a canvas stage, captions, and a small control bar. */

.film {
  --film-w: min(60rem, calc(100vw - 2rem));
  width: var(--film-w);
  margin: 1.25rem 0 1.75rem calc(50% - var(--film-w) / 2);
}

.film-stage {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #E9E1D0;
  box-shadow: 4px 4px 0 var(--ink), 0 10px 30px rgba(26, 31, 36, 0.14);
  outline-offset: 4px;
}

.film-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.film:not(.is-ready) .film-canvas { visibility: hidden; }

.film-big {
  position: absolute;
  left: 50%;
  top: 82%;
  transform: translate(-50%, -50%) rotate(-1.5deg);
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1.5rem 0.8rem 1.1rem;
  font: 700 clamp(0.95rem, 2.2vw, 1.25rem)/1.1 var(--font);
  color: #FBF7EE;
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.film-big:hover { transform: translate(-50%, -52%) rotate(-1.5deg); box-shadow: 4px 5px 0 var(--ink); }
.film-big:active { transform: translate(-48%, -48%) rotate(-1.5deg); box-shadow: 1px 1px 0 var(--ink); }
.film-big:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
.film-big-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: #FBF7EE;
  position: relative;
  flex: none;
}
.film-big-icon::after {
  content: "";
  position: absolute;
  inset: 0.55rem 0.5rem 0.55rem 0.72rem;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.film:not(.is-ready) .film-big,
.film.has-started:not(.is-ended) .film-big { display: none; }

.film-subs {
  min-height: 3.4em;
  margin: 0.6rem auto 0;
  max-width: 44rem;
  font-size: clamp(1rem, 2vw, 1.15rem);
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
  color: var(--ink);
}
.film.no-subs .film-subs { visibility: hidden; }
.film:not(.has-started) .film-subs,
.film.is-ended:not(.is-fs):not(:has(.film-seek:active)) .film-subs { display: none; } /* no empty gap under a finished film */

.film-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.1rem;
}

.film-btn {
  position: relative;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 800 0.8rem/1 var(--font);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}
.film-btn:hover { background: #fff; }
.film-btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.film-btn::before, .film-btn::after { content: ""; position: absolute; background: var(--ink); }
.film-btn--text::before, .film-btn--text::after { content: none; }
.film-btn--text[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }

.film-btn--play::before { inset: 0.62rem 0.55rem 0.62rem 0.8rem; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.film-btn--play.is-on::before { inset: 0.62rem 1.25rem 0.62rem 0.68rem; clip-path: none; }
.film-btn--play.is-on::after { inset: 0.62rem 0.68rem 0.62rem 1.25rem; }

.film-btn--sound::before { inset: 0.62rem 1rem 0.62rem 0.5rem; clip-path: polygon(0 32%, 38% 32%, 100% 0, 100% 100%, 38% 68%, 0 68%); }
.film-btn--sound::after { inset: 0.72rem 0.42rem 0.72rem 1.45rem; background: none; border: 2.5px solid var(--ink); border-left: 0; border-radius: 0 999px 999px 0; }
.film-btn--sound[aria-pressed="true"]::after { inset: 0.6rem 0.35rem 0.6rem 1.35rem; border: 0; border-radius: 0; background: var(--rules); clip-path: polygon(15% 0, 50% 35%, 85% 0, 100% 15%, 65% 50%, 100% 85%, 85% 100%, 50% 65%, 15% 100%, 0 85%, 35% 50%, 0 15%); }

.film-btn--fs::before { inset: 0.6rem; background: none; border: 2.5px solid var(--ink); clip-path: polygon(0 0, 38% 0, 38% 12%, 12% 12%, 12% 38%, 0 38%, 0 62%, 12% 62%, 12% 88%, 38% 88%, 38% 100%, 62% 100%, 62% 88%, 88% 88%, 88% 62%, 100% 62%, 100% 38%, 88% 38%, 88% 12%, 62% 12%, 62% 0, 0 0); }
.film-btn--fs::after { content: none; }

.film-seek {
  flex: 1;
  min-width: 4rem;
  height: 2.5rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.film-time {
  flex: none;
  min-width: 5.6rem;
  font: 600 0.85rem/1 var(--font-mono);
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.film-caption {
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  color: var(--muted);
}
.film-caption strong { color: var(--ink); }
.film-transcript { margin-top: 0.35rem; }
.film-transcript summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.film-transcript p { margin: 0.5rem 0 0; max-width: 44rem; line-height: 1.65; }

/* Full screen: the picture as large as the screen allows at 16:9, with subtitles and controls laid
   over its bottom edge so they take no height from it (a landscape phone has ~390px to spare).
   film-engine.js sets is-fs for real fullscreen and for the iPhone stand-in, which has no element
   fullscreen, so this pins the figure over the page itself. */
.film.is-fs {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: auto;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1A1F24;
}
.film.is-fs .film-stage {
  width: min(100vw, 100vh * 16 / 9);
  width: min(100vw, 100dvh * 16 / 9);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.film.is-fs .film-subs {
  position: absolute;
  left: 50%;
  bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: max-content;
  max-width: min(44rem, 100% - 2rem);
  min-height: 0;
  margin: 0;
  padding: 0.25em 0.7em;
  border-radius: 8px;
  background: rgba(26, 31, 36, 0.8);
  color: #F7F4EF;
  pointer-events: none;
}
.film.is-fs .film-subs:empty { display: none; }
.film.is-fs .film-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 2rem max(1rem, env(safe-area-inset-right, 0px)) max(0.75rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  background: linear-gradient(rgba(26, 31, 36, 0), rgba(26, 31, 36, 0.85));
}
.film.is-fs .film-time { color: #C4BDB2; }
.film.is-fs .film-caption { display: none; }
.film-fs-lock { overflow: hidden; }

@media (max-width: 600px) {
  .film-stage { border-radius: 10px; box-shadow: 3px 3px 0 var(--ink); }
  .film-big { top: 84%; gap: 0.5rem; padding: 0.4rem 0.9rem 0.4rem 0.45rem; font-size: 0.85rem; white-space: nowrap; box-shadow: 2px 2px 0 var(--ink); }
  .film-big-icon { width: 1.6rem; height: 1.6rem; }
  .film-big-icon::after { inset: 0.44rem 0.4rem 0.44rem 0.58rem; }
  .film-time { min-width: 0; font-size: 0.75rem; }
  .film-bar { gap: 0.35rem; }
  .film-btn { width: 2.25rem; height: 2.25rem; }
  .film-subs { min-height: 2.9em; margin-top: 0.45rem; }
}
/* 320 px: the four buttons, the clock and a usable seek bar still fit inside the page edge. */
@media (max-width: 350px) {
  .film-bar { gap: 0.25rem; }
  .film-seek { min-width: 2.5rem; }
  .film-time { font-size: 0.6875rem; }
}

.film-backdrop {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  pointer-events: none;
}
.film-canvas { position: relative; }
.film-flicker {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
