/* KHAVINSON — the legend film.
   Scoped under .cin (set on #cinema-root by js/cinema/index.js). The picture is a cut film; this
   file sets the stage, the two titles over it and the transport. No small words on the picture:
   one huge voice for his line and his name; the site's one type size for the transport only. */

.cin {
  --cin-ink: var(--bone, #ECEAE4);
  --cin-g: var(--gutter, 20px);
  --cin-out: var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
  --cin-foot: 64px;                                   /* the transport's band at the bottom */
  --cin-top: 84px;                                    /* the page's header line runs across the top */
  --cin-signal: var(--signal, #CFE34A);
  position: relative;
  display: block;
  height: 100vh; height: 100svh;
  background: #050505;
}
#cinema-root.cin[data-empty] { display: none; }       /* no film yet: it stays out of the page */

.cin-stage {
  --cin-p: 0;                                         /* 0 → 1 as the film leaves the top of the window */
  --cin-dim: color-mix(in srgb, var(--cin-ink) 46%, transparent);
  --cin-faint: color-mix(in srgb, var(--cin-ink) 22%, transparent);
  position: relative;
  width: 100%; height: 100%;
  overflow: hidden;
  background: #050505;
  color: var(--cin-ink);
  font-family: var(--font-sans, 'Inter Tight', 'Helvetica Neue', Arial, sans-serif);
  font-size: 13px; line-height: 16px; font-weight: 400; letter-spacing: 0;
  outline: none;
  isolation: isolate;
  -webkit-user-select: none; user-select: none;
}
.cin-stage:fullscreen { width: 100vw; height: 100vh; }
.cin-stage:-webkit-full-screen { width: 100vw; height: 100vh; }
.cin-stage[data-chrome="asleep"] { cursor: none; }

/* the picture holds back as the page moves over it, and dims */
.cin-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 50%;
  display: block; background: #050505;
  transform: translate3d(0, calc(var(--cin-p) * 22%), 0);
  filter: brightness(calc(1 - var(--cin-p) * 0.6));
  cursor: pointer;
}
.cin-stage:fullscreen .cin-video { object-fit: contain; transform: none; filter: none; }

/* a low shadow for the transport and the small line to stand on */
.cin-veil {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(5, 5, 5, 0.7) 0, rgba(5, 5, 5, 0.3) 96px, rgba(5, 5, 5, 0) 200px);
}

/* under the name the lower half of the picture steps back, on the same frame */
.cin-veil::after {
  content: ''; position: absolute; inset: 0; opacity: 0;
  background: linear-gradient(to top, rgba(5, 5, 5, 0.86) 0, rgba(5, 5, 5, 0.66) 30%, rgba(5, 5, 5, 0) 62%);
}
.cin-stage:has(.cin-wm[data-on]) .cin-veil::after { opacity: 1; }

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

/* ---------- words ----------
   No z-index and no opacity on the layer or the picture: the huge type blends (difference) with the
   film itself, so nothing between them may form a stacking context. Order is DOM order. */
.cin-layer { position: absolute; inset: 0; pointer-events: none; --cin-gp: 0 0; --cin-fade: calc(1 - var(--cin-p) * 2.2); }
.cin-huge, .cin-ep, .cin-line { opacity: calc(var(--cin-fade) * var(--cin-out, 1)); }
.cin-layer > *, .cin-end > * { margin: 0; }
.cin-layer [data-instant], .cin-layer [data-instant] * { animation: none !important; transition: none !important; }
.cin-accent { color: var(--cin-signal); }

/* huge: uppercase lines, each as wide as the frame; the film's grain in the letters, two echoes behind */
.cin-huge {
  position: absolute; left: var(--cin-g); right: var(--cin-g); bottom: calc(var(--cin-foot) + 18px);
  visibility: hidden;
  font-weight: 600; text-transform: uppercase; letter-spacing: -0.035em; line-height: 0.84;
  mix-blend-mode: difference;
}
.cin-huge[data-on] { visibility: visible; }
.cin-huge__text, .cin-huge__echo { display: block; transform-origin: 0 100%; }
.cin-huge__line {
  display: block; width: max-content; font-size: 100px; white-space: nowrap;
  margin-left: -0.045em; padding: 0.02em 0.05em 0 0;
  color: var(--cin-ink);
}
.cin-huge__text .cin-huge__line {
  background: var(--cin-grain, none) var(--cin-gp) / 192px 192px, var(--cin-ink);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.cin-huge__echo { position: absolute; left: 0; bottom: 0; pointer-events: none; }
.cin-huge__echo--1 { opacity: 0.2; filter: blur(14px); transform: scale(1.3); transform-origin: 30% 60%; }
.cin-huge__echo--2 { opacity: 0.11; filter: blur(30px); transform: scale(1.9); transform-origin: 30% 60%; }
.cin-huge[data-on] .cin-huge__text { animation: cin-hit 0.125s steps(1, end) both; }
.cin-huge[data-on] .cin-huge__echo--1 { animation: cin-echo-1 1.6s linear both; }
.cin-huge[data-on] .cin-huge__echo--2 { animation: cin-echo-2 1.6s linear both; }
@keyframes cin-hit {
  0% { filter: url(#cin-smear-a) brightness(1.5); transform: scaleY(1.32); }
  34% { filter: url(#cin-smear-b); transform: scaleY(1.07); }
  67%, 100% { filter: none; transform: none; }
}
@keyframes cin-echo-1 { from { transform: scale(1.24); } to { transform: scale(1.36); } }
@keyframes cin-echo-2 { from { transform: scale(1.7); } to { transform: scale(2.0); } }
/* his line: to be read at once. Bold, sentence case, half the frame wide in two lines, lower left, above the
   name's place; the film gives it a dark field */
.cin-line {
  visibility: hidden;
  width: max(58%, 320px); max-width: 100%;
  margin: 0 0 clamp(14px, 1.7vw, 30px) !important;
  font-size: clamp(30px, 5.15vw, 106px); line-height: 1.02; font-weight: 700; letter-spacing: -0.032em;
  color: var(--cin-ink); text-wrap: balance;
  text-shadow: 0 0 28px rgba(5, 5, 5, 0.9), 0 0 6px rgba(5, 5, 5, 0.6);
  position: relative; z-index: 0;
}
/* its own dark field, for the bar it shares with the name over a picture */
.cin-line::before {
  content: ''; position: absolute; z-index: -1; inset: -230% -55% -190% -40%;
  background: radial-gradient(closest-side, rgba(5, 5, 5, 0.8) 0, rgba(5, 5, 5, 0.62) 30%, rgba(5, 5, 5, 0.25) 65%, rgba(5, 5, 5, 0) 100%);
}
.cin-line[data-on] { visibility: visible; animation: cin-line-in 0.25s ease-out both; }
@keyframes cin-line-in { from { opacity: 0; transform: translateY(6px); } to { opacity: var(--cin-fade); transform: none; } }

/* the name, and the line under it */
.cin-end { position: absolute; left: var(--cin-g); right: var(--cin-g); bottom: calc(var(--cin-foot) + 18px); }
.cin-end .cin-wm { position: relative; left: 0; right: 0; bottom: auto; mix-blend-mode: normal; letter-spacing: -0.03em; }
.cin-wm[data-on] .cin-huge__echo--1 { animation-duration: 8s; }
.cin-wm[data-on] .cin-huge__echo--2 { animation-duration: 8s; }
.cin-ep {
  display: flex; justify-content: space-between; align-items: baseline; gap: 24px;
  margin-top: 0.5em !important; visibility: hidden;
  font-size: clamp(17px, 2.5vw, 44px); line-height: 1.05; font-weight: 500; letter-spacing: -0.02em;
}
.cin-ep[data-on] { visibility: visible; }
.cin-ep__sub { color: var(--cin-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- transport ---------- */
.cin-tx {
  position: absolute; left: var(--cin-g); right: var(--cin-g); bottom: 14px;
  color: var(--cin-ink); opacity: calc(1 - var(--cin-p) * 2.2);
}
.cin-tx__row { display: flex; justify-content: flex-end; align-items: baseline; gap: 18px; height: 16px; transition: opacity 0.5s linear; }
.cin-stage[data-chrome="asleep"] .cin-tx__row { opacity: 0; }
.cin-tx__btn {
  padding: 8px 0; margin: -8px 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 500;
  cursor: pointer; white-space: nowrap; opacity: 0.9;
}
.cin-tx__btn:hover { opacity: 1; }
.cin-tx__btn[hidden] { display: none; }
.cin-tx__btn:focus-visible, .cin-reel:focus-visible { outline: 1px solid var(--cin-ink); outline-offset: 3px; }
.cin-tx__play { min-width: 2.9em; text-align: left; }
.cin-tx__score-key { color: var(--cin-dim); margin-right: 0.45em; font-weight: 400; }
.cin-tx__code { display: flex; gap: 0.45em; margin: 0 0 0 6px; font-variant-numeric: tabular-nums; }
.cin-tx__of, .cin-tx__len { color: var(--cin-dim); }

/* the scrub line: the edit, one segment a section */
.cin-reel { position: relative; display: flex; gap: 3px; height: 21px; margin-top: 3px; cursor: pointer; touch-action: none; }
.cin-reel__seg { position: relative; flex: 1 1 0; min-width: 0; }
.cin-reel__seg::before, .cin-reel__fill { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 1px; margin-top: -0.5px; }
.cin-reel__seg::before { background: var(--cin-faint); transition: background 0.3s; }
.cin-reel__fill { display: block; background: var(--cin-ink); transform: scaleX(0); transform-origin: left; }
.cin-reel__seg[data-past] .cin-reel__fill { transform: scaleX(1) !important; }
.cin-reel__seg:not([data-past]):not([data-current]) .cin-reel__fill { transform: scaleX(0) !important; }
.cin-reel:hover .cin-reel__seg::before { background: var(--cin-dim); }
.cin-reel__head { position: absolute; top: 50%; left: 0; width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; background: var(--cin-ink); pointer-events: none; }
.cin-reel__ghost { position: absolute; top: 50%; left: 0; width: 1px; height: 7px; margin: -3.5px 0 0 -0.5px; background: var(--cin-dim); pointer-events: none; opacity: 0; transition: opacity 0.2s linear; }
.cin-reel__tip { position: absolute; bottom: 12px; left: 0; transform: translateX(-50%); white-space: pre; font-variant-numeric: tabular-nums; color: var(--cin-ink); }
.cin-reel:hover .cin-reel__ghost { opacity: 1; }
.cin-tx[data-scrub] .cin-reel__ghost { opacity: 0; }
.cin-stage[data-chrome="asleep"] .cin-reel { opacity: 0.4; transition: opacity 0.5s linear; }
@media (hover: none) { .cin-reel__ghost { display: none; } }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .cin { --cin-foot: 60px; --cin-top: 72px; }
  .cin-tx { bottom: max(10px, env(safe-area-inset-bottom)); }
  .cin-tx__row { gap: 12px; }
  .cin-tx__score .cin-tx__score-key, .cin-tx__of, .cin-tx__len { display: none; }
  .cin-tx__film .cin-tx__score-key { margin-right: 0.3em; }
  .cin-ep { margin-top: 10px !important; }
  .cin-line { width: 94%; font-size: clamp(30px, 9.4vw, 46px); }
  .cin-veil::after { background: linear-gradient(to top, rgba(5, 5, 5, 0.88) 0, rgba(5, 5, 5, 0.7) 26%, rgba(5, 5, 5, 0) 50%); }
}

@media (prefers-reduced-motion: reduce) {
  .cin-stage *, .cin-stage *::before, .cin-stage *::after { transition-duration: 0.01s !important; transition-delay: 0s !important; animation: none !important; }
  .cin-video { transform: none; }
}
