/* Shared film slot (home and the product pages): a paper cinema on night paper. Hidden (the hidden attribute) until
   build.py finds the film on disk. The film is our own After Effects cut-paper film
   (film-promo/, docs/FILM.md). A front curtain rises on twos when the stage is first seen; the poster is a lazy image
   inside a link to the MP4 (so the film plays even without script); the video itself loads only on Play.
   Motion: transform and opacity only, stepped "on twos" for paper, springy press feedback for the controls.
   Reduced motion and no-script: the curtain is up, the stars are still. */

.fm { --fm-gold: #FFCB3D; --fm-red: #E2574C; --fm-ink: #1E2A5A; --fm-cream: #FFF4E2; overflow-x: clip; }
.fm[hidden] { display: none !important; }
.fm__wrap { position: relative; z-index: 1; display: grid; justify-items: center; gap: clamp(22px, 3vw, 36px); }

/* heading */
.fm__head { text-align: center; max-width: 46rem; display: grid; gap: 14px; }
.fm__h { font-size: var(--t-h2); letter-spacing: -.02em; }
.fm__lead { font-size: var(--t-lead); line-height: 1.5; color: #E3E9FF; max-width: 38ch; margin-inline: auto; }

/* stars on the night paper (decoration; they twinkle on twos only while the section is seen) */
.fm__sky { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.fm__star { position: absolute; width: auto; height: auto; }
.fm__star--a { top: 9%; left: 7%; width: 46px; }
.fm__star--b { top: 22%; left: 15%; width: 26px; }
.fm__star--c { top: 12%; right: 12%; width: 28px; }
.fm__star--d { top: 30%; right: 5%; width: 40px; }
.fm__star--e { bottom: 18%; left: 4%; width: 24px; }
@keyframes fm-twinkle { 0%, 49.9% { transform: scale(1) rotate(-4deg); } 50%, 100% { transform: scale(.74) rotate(8deg); } }
@media (prefers-reduced-motion: no-preference) {
  html.js:not(.rm) .fm.is-seen .fm__star { animation: fm-twinkle 1.33s steps(1, end) infinite; }
  html.js:not(.rm) .fm.is-seen .fm__star--b { animation-duration: 1.17s; animation-delay: -.4s; }
  html.js:not(.rm) .fm.is-seen .fm__star--c { animation-duration: 1.5s; animation-delay: -.8s; }
  html.js:not(.rm) .fm.is-seen .fm__star--d { animation-duration: 1.25s; animation-delay: -.2s; }
  html.js:not(.rm) .fm.is-seen .fm__star--e { animation-duration: 1.42s; animation-delay: -.6s; }
}

/* ---------- the stage: valance on top, drapes at the sides, the paper screen in the middle */
.fm__stage { position: relative; width: min(100%, 1180px); padding: clamp(42px, 6vw, 74px) clamp(30px, 9.5%, 118px) clamp(18px, 2.4vw, 30px); }
.fm__frame { position: relative; z-index: 1; padding: clamp(7px, .9vw, 12px); border-radius: clamp(10px, 1.3vw, 16px);
  background: var(--fm-cream) url(/assets/art/textures/paper-tile.webp) 0 0 / 512px 512px;
  box-shadow: 0 2px 2px rgba(2, 6, 26, .5), 0 26px 46px -18px rgba(2, 6, 26, .75), inset 0 1px 0 rgba(255, 255, 255, .8); }
.fm__screen { position: relative; aspect-ratio: 16 / 9; border-radius: clamp(5px, .7vw, 9px); overflow: clip; background: #0B1233; isolation: isolate; }
.fm__video { display: block; width: 100%; height: 100%; object-fit: cover; background: #0B1233; }

/* the drapes: our paper drape, tiled sideways, cropped to the stage; the right one is mirrored */
.fm__drape { position: absolute; z-index: 2; top: clamp(30px, 4.6vw, 56px); bottom: 0; width: clamp(34px, 11.2%, 132px);
  background: url(/assets/film/fm-drape.webp) right top / auto 100% repeat-x; pointer-events: none;
  filter: drop-shadow(0 10px 14px rgba(2, 6, 26, .45)); }
@media (min-resolution: 1.5dppx) { .fm__drape, .fm__curtain { background-image: url(/assets/film/fm-drape@2x.webp); } }
.fm__drape--l { left: 0; }
.fm__drape--r { right: 0; transform: scaleX(-1); }
.fm__valance { position: absolute; z-index: 3; top: 0; left: -1%; width: 102%; max-width: none; height: auto; pointer-events: none;
  filter: drop-shadow(0 8px 10px rgba(2, 6, 26, .4)); }

/* "The film": a paper ticket pinned to the valance (decoration; the heading names the section) */
.fm__ticket { position: absolute; z-index: 4; top: clamp(4px, 1vw, 12px); left: 50%; transform: translateX(-50%) rotate(-3deg);
  font: 800 clamp(13px, 1.1vw, 15px)/1 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: #5A3A06;
  padding: 8px 16px 8px 18px; background: var(--fm-gold); border-radius: 6px;
  -webkit-mask: radial-gradient(circle 5px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat, radial-gradient(circle 5px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
  mask: radial-gradient(circle 5px at 0 50%, transparent 98%, #000) left / 51% 100% no-repeat, radial-gradient(circle 5px at 100% 50%, transparent 98%, #000) right / 51% 100% no-repeat;
  box-shadow: 0 1px 1px rgba(90, 42, 0, .35); }

/* ---------- the poster and the Play button (a link to the film: it plays inline with script, in the browser without) */
.fm__poster { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; color: var(--fm-ink); text-decoration: none;
  -webkit-tap-highlight-color: transparent; }
.fm__poster-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fm__poster::after { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 70% at 50% 55%, transparent 40%, rgba(11, 18, 51, .38)); pointer-events: none; }
.fm__play { position: relative; z-index: 1; display: grid; justify-items: center; gap: 12px; transition: transform .45s var(--m-spring, ease-out); }
.fm__btn { position: relative; display: grid; place-items: center; width: clamp(68px, 9.5vw, 112px); aspect-ratio: 1; border-radius: 50%;
  background: var(--fm-gold) url(/assets/art/textures/grain-tile.webp) 0 0 / 256px 256px; background-blend-mode: multiply;
  box-shadow: 0 2px 2px rgba(90, 42, 0, .4), 0 18px 30px -12px rgba(2, 6, 26, .7), inset 0 2px 0 rgba(255, 255, 255, .55), inset 0 -3px 0 rgba(200, 120, 0, .35);
  transition: transform .45s var(--m-spring, ease-out); }
.fm__btn::before { content: ""; position: absolute; inset: -9%; border-radius: 50%; background: conic-gradient(from 0deg, transparent 0 4%, rgba(255, 203, 61, .55) 4% 8%, transparent 8% 12.5%) ;
  -webkit-mask: radial-gradient(circle, transparent 66%, #000 67%); mask: radial-gradient(circle, transparent 66%, #000 67%); z-index: -1; transition: transform .6s var(--m-settle, ease-out); }
.fm__tri { width: 44%; margin-left: 9%; fill: var(--fm-ink); }
.fm__label { display: inline-flex; align-items: center; gap: 10px; padding: 9px 12px 9px 18px; border-radius: 999px; background: var(--fm-cream);
  font: 800 clamp(15px, 1.25vw, 18px)/1 var(--font-body); color: var(--fm-ink); box-shadow: 0 1px 1.5px rgba(90, 42, 0, .3), 0 10px 20px -10px rgba(2, 6, 26, .6); }
.fm__dur { font-variant-numeric: tabular-nums; padding: 5px 9px; border-radius: 999px; background: #DCE4FF; color: var(--blue-deep, #1A35A0); font-size: .88em; }
@media (hover: hover) and (pointer: fine) {
  .fm__poster:hover .fm__btn { transform: translateY(-3px) scale(1.05); }
  .fm__poster:hover .fm__btn::before { transform: rotate(22deg); }
}
.fm__poster:active .fm__btn { transform: scale(.95); transition-duration: .1s; }
.fm__poster:focus-visible { outline: none; }
.fm__poster:focus-visible .fm__label { outline: 3px solid var(--lemon); outline-offset: 3px; }
.fm.is-playing .fm__poster { display: none; }
.fm.is-playing .fm__curtain { display: none; }

/* ---------- the front curtain: down over the screen until the stage is first seen, then it rises on twos */
.fm__curtain { display: none; }
@media (prefers-reduced-motion: no-preference) {
  html.js:not(.rm) .fm__curtain { display: block; position: absolute; inset: -2% -1% 0; z-index: 3; pointer-events: none;
    background: url(/assets/film/fm-drape.webp) 0 100% / auto 104% repeat-x; box-shadow: 0 10px 18px rgba(2, 6, 26, .55);
    animation: fm-failsafe 1ms 6s forwards; }
  html.js:not(.rm) .fm.fm-ready .fm__curtain { animation: none; }
  html.js:not(.rm) .fm.fm-ready.is-open .fm__curtain { animation: fm-rise 900ms forwards; }
}
@keyframes fm-failsafe { to { transform: translateY(-104%); visibility: hidden; } }
/* eight held poses (each holds two frames at 24 fps), eased like a hand-cranked curtain */
@keyframes fm-rise {
  0%      { transform: translateY(0); animation-timing-function: steps(1, end); }
  9.3%    { transform: translateY(-2%); animation-timing-function: steps(1, end); }
  18.5%   { transform: translateY(-7%); animation-timing-function: steps(1, end); }
  27.8%   { transform: translateY(-16%); animation-timing-function: steps(1, end); }
  37%     { transform: translateY(-29%); animation-timing-function: steps(1, end); }
  46.3%   { transform: translateY(-45%); animation-timing-function: steps(1, end); }
  55.6%   { transform: translateY(-62%); animation-timing-function: steps(1, end); }
  64.8%   { transform: translateY(-78%); animation-timing-function: steps(1, end); }
  74%     { transform: translateY(-91%); animation-timing-function: steps(1, end); }
  83.3%   { transform: translateY(-99%); animation-timing-function: steps(1, end); }
  100%    { transform: translateY(-104%); visibility: hidden; }
}

/* ---------- chapters: paper chips that jump the film */
.fm__chapters { width: min(100%, 980px); }
.fm__list { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 12px; }
.fm__ch { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 18px 0 8px; border-radius: 999px; text-decoration: none;
  font: 800 16px/1.15 var(--font-body); color: var(--fm-ink); background: #DCE4FF url(/assets/art/textures/grain-soft-tile.webp) 0 0 / 256px 256px; background-blend-mode: multiply;
  box-shadow: 0 1px 1.5px rgba(2, 6, 26, .45), 0 10px 18px -12px rgba(2, 6, 26, .8), inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: transform .45s var(--m-spring, ease-out), background-color .2s var(--m-settle, ease-out); }
.fm__t { display: inline-grid; place-items: center; min-width: 54px; height: 34px; padding: 0 8px; border-radius: 999px; background: var(--fm-ink); color: #FFF;
  font: 800 15px/1 var(--font-body); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
@media (hover: hover) and (pointer: fine) { .fm__ch:hover { transform: translateY(-2px); background-color: #EEF2FF; } }
.fm__ch:active { transform: scale(.97); transition-duration: .1s; }
.fm__ch[aria-current="true"] { background-color: var(--fm-gold); }
.fm__ch[aria-current="true"] .fm__t { background: #5A3A06; }

/* ---------- transcript (native disclosure) and the small print */
.fm__tr { width: min(100%, 46rem); }
.fm__sum { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; min-height: 44px; margin-inline: auto; padding: 0 6px;
  font: 800 17px/1 var(--font-body); color: var(--lemon); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: .28em; }
.fm__sum::-webkit-details-marker { display: none; }
.fm__sum::before { content: ""; width: 10px; height: 10px; border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: translateY(-2px) rotate(45deg);
  transition: transform .45s var(--m-spring, ease-out); }
.fm__tr[open] .fm__sum::before { transform: translateY(2px) rotate(-135deg); }
.fm__tr { display: grid; justify-items: center; }
.fm__sum-b, .fm__tr[open] .fm__sum-a { display: none; }
.fm__tr[open] .fm__sum-b { display: inline; }
.fm__text { margin-top: 14px; padding: clamp(20px, 3vw, 32px); display: grid; gap: 14px; text-align: left; color: var(--ink); --pk-pad: clamp(20px, 3vw, 32px); }
.fm .fm__text p { color: var(--ink); font-size: var(--t-body); line-height: 1.65; max-width: 68ch; }
@media (prefers-reduced-motion: no-preference) {
  html.js:not(.rm) .fm__tr[open] .fm__text { animation: fm-open .5s var(--m-settle, ease-out); }
}
@keyframes fm-open { from { opacity: 0; transform: translateY(8px); } }
.fm__small { max-width: 52ch; text-align: center; font-size: var(--t-small); line-height: 1.55; color: #E3E9FF; }

/* ---------- smaller screens */
@media (max-width: 760px) {
  .fm__stage { padding-inline: 22px; padding-top: 40px; }
  .fm__drape { width: 30px; top: 26px; }
  .fm__label { padding: 8px 10px 8px 14px; }
  .fm__ch { font-size: 15px; min-height: 46px; }
  /* stars stay in the strip above the heading and at the edges, never over the words (Round 4) */
  .fm__star--a { top: 12px; left: 12px; width: 26px; }
  .fm__star--b { top: 34px; left: 46px; width: 16px; }
  .fm__star--c { top: 14px; right: 18%; width: 18px; }
  .fm__star--d { top: 36px; right: 12px; width: 24px; }
}
@media (max-width: 420px) {
  .fm__btn { width: 62px; }
  .fm__label { font-size: 14px; }
  .fm__list { flex-direction: column; align-items: stretch; }
  .fm__ch { justify-content: flex-start; }
}
