:root {
  color-scheme: dark;
  background: #000;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: #000;
  overscroll-behavior-y: none;
  scroll-behavior: auto;
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: #000;
  touch-action: pan-y;
}

#film { position: relative; }

.viewport {
  position: fixed;
  z-index: 1;
  left: 50%;
  top: 50%;
  overflow: hidden;
  transform: translate(-50%, -50%);
  background: #000;
  box-shadow: 0 0 0 1px rgba(255,255,255,.035);
}

html[data-layout="mobile"] .viewport {
  width: min(100vw, calc(100svh * 9 / 16));
  height: min(100svh, calc(100vw * 16 / 9));
}

html[data-layout="desktop"] .viewport {
  width: min(100vw, calc(100svh * 16 / 9));
  height: min(100svh, calc(100vw * 9 / 16));
}

.mobile-cover { display: none; }

html[data-layout="mobile"] .mobile-cover {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(22px, env(safe-area-inset-top)) 21px max(18px, env(safe-area-inset-bottom));
  pointer-events: none;
  color: #f5f3ef;
  background:
    linear-gradient(180deg, rgba(0,0,0,.98) 0%, rgba(0,0,0,.90) 26%, rgba(0,0,0,.38) 47%, rgba(0,0,0,0) 67%),
    linear-gradient(0deg, rgba(0,0,0,.34) 0%, rgba(0,0,0,0) 24%);
  will-change: opacity, transform;
}

.mobile-cover__copy {
  width: min(100%, 360px);
  text-wrap: balance;
  filter: drop-shadow(0 2px 16px rgba(0,0,0,.46));
}

.mobile-cover__eyebrow {
  margin: 0 0 11px;
  color: #ffb347;
  font: 650 10px/1.1 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.mobile-cover h1 {
  margin: 0;
  max-width: 11.2em;
  font: 760 clamp(31px, 8.45vw, 39px)/.91 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: -.055em;
}

.mobile-cover h1 span,
.mobile-cover h1 em { display: block; }

.mobile-cover h1 em {
  margin-top: 9px;
  max-width: 13.6em;
  color: #ffb347;
  font-size: .58em;
  font-style: normal;
  font-weight: 640;
  line-height: 1.04;
  letter-spacing: -.025em;
}

.mobile-cover__intro {
  margin: 14px 0 0;
  max-width: 32ch;
  color: rgba(246,244,240,.84);
  font: 450 clamp(13px, 3.45vw, 15px)/1.34 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: -.01em;
}

.mobile-cover__scroll {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  color: rgba(255,255,255,.78);
  border-radius: 999px;
  background: rgba(0,0,0,.32);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  font: 620 9px/1 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.mobile-cover__scroll i {
  width: 6px;
  height: 6px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  animation: cover-arrow 1.45s ease-in-out infinite;
}

@keyframes cover-arrow {
  0%, 100% { opacity: .36; transform: rotate(45deg) translate(-1px, -2px); }
  50% { opacity: 1; transform: rotate(45deg) translate(2px, 1px); }
}

.film-video {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
  background: #000;
  opacity: 0;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  transition: opacity .055s linear;
}

.film-video.active {
  z-index: 1;
  opacity: 1;
}

.track {
  position: relative;
  width: 1px;
  pointer-events: none;
}

html[data-layout="mobile"] .track {
  height: 3400svh;
  min-height: 27000px;
}

/* Pista 16:9. Escalada con el reloj: los capitulos 03 y 04 remontados suben
   la fuente de 107,60 a 117,16 s, y la pista crece en la misma proporcion
   para conservar los px de scroll por segundo de metraje. */
html[data-layout="desktop"] .track {
  height: 2831svh;
  min-height: 25043px;
}

.loading {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: hidden;
  background: #000;
  transition: opacity .35s ease, visibility .35s ease;
}

.loading::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  margin: -11px;
  border: 1px solid rgba(255,255,255,.14);
  border-top-color: rgba(255,255,255,.8);
  border-radius: 50%;
  animation: spin .85s linear infinite;
}

.loading i {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 2px;
  background: #ffb247;
  box-shadow: 0 0 16px rgba(255,178,71,.7);
  transition: width .1s linear;
}

.loading.ready {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-height: 700px) {
  html[data-layout="mobile"] .mobile-cover { padding-top: 16px; }
  .mobile-cover__eyebrow { margin-bottom: 8px; }
  .mobile-cover h1 { font-size: clamp(28px, 7.7vw, 34px); }
  .mobile-cover__intro { margin-top: 10px; font-size: 12px; line-height: 1.27; }
}

@media (prefers-reduced-motion: reduce) {
  .loading::after { animation-duration: 1.8s; }
  .mobile-cover__scroll i { animation: none; }
}
