/* ==========================================================================
   SELECTED WORK — encabezado + 4 teasers.
   Las variables --s, --l, --la, --c... las escribe js/selected-work.js
   según el scroll. Aquí solo decidimos QUÉ hace cada valor.
   ========================================================================== */

.sw__head {
  padding: clamp(24px, 5vw, 80px) var(--gutter) clamp(24px, 4vw, 56px);
}
.sw__head-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

/* Títulos grandes (se ajustan al ancho con data-fit) */
.section-title,
.teaser__title,
.seq__closing-text,
.flip__title {
  width: max-content;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-stretch: var(--display-stretch);
  text-transform: var(--display-transform);
  letter-spacing: var(--display-tracking);
  line-height: .84;
  white-space: nowrap;
  visibility: hidden;                /* se muestra cuando ya tiene su tamaño */
}
.is-fitted { visibility: visible; }

.fit-word { display: inline-block; }
@media (max-width: 767px) {
  /* En celular, una palabra por línea: letras más grandes */
  .teaser__title .fit-word,
  .seq__closing-text .fit-word,
  .flip__title .fit-word { display: block; }
}

.teaser__title-link { display: block; }

/* Botón de texto con subrayado que crece */
.teaser__cta {
  position: relative;
  white-space: nowrap;
}
.teaser__cta::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 1px;
  background: currentColor;
  transform-origin: left;
  transition: transform .4s var(--ease-out);
}
@media (hover: hover) {
  .teaser__cta:hover::after { transform: scaleX(.3); }
}

/* Bloque de info común (abajo de la pantalla) */
.teaser__info {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: clamp(20px, 4vw, 44px);
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.teaser__meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 20px;
  flex-wrap: wrap;
}

/* Medios que llenan toda su capa (anulan la proporción del placeholder) */
.teaser__media .media,
.seq__stage .media,
.seq__merch .media,
.reel__clip .media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto !important;
}

/* --------------------------------------------------------------------------
   ① PANTALLA COMPLETA (Alfredo Olivas)
   -------------------------------------------------------------------------- */
.teaser--full {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 560px;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
}
.teaser__media {
  position: absolute;
  inset: 0;
  transform: scale(var(--s, 1.12));
  will-change: transform;
}
.teaser__shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to top, rgba(0,0,0,.75) 0%, rgba(0,0,0,.2) 45%, rgba(0,0,0,0) 70%);
}

/* --------------------------------------------------------------------------
   ② SECUENCIA DE IDENTIDAD (Natanael Cano)
   500svh de alto = 4 pantallas de scroll mientras el interior está fijo
   -------------------------------------------------------------------------- */
.seq {
  position: relative;
  height: 500vh;
  height: 500svh;
  background: var(--paper);
}
.seq__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--paper);   /* necesario para que el blend "difference" del texto funcione */
}
.seq__layer { position: absolute; inset: 0; }

/* El escenario se abre en círculo desde el centro */
.seq__stage { clip-path: circle(calc(var(--l, 0) * 75%) at 50% 50%); }
/* El merch sube como cortina */
.seq__merch { clip-path: inset(calc((1 - var(--l, 0)) * 100%) 0 0 0); }

.seq__logo {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: min(72vw, 560px);
  transform: translate(-50%, -50%) scale(var(--logo-s, 2.4));
  filter: invert(var(--inv, 0));
  opacity: var(--logo-o, 1);
  transition: filter .5s var(--ease-out);
  pointer-events: none;
}
@media (min-width: 768px) { .seq__logo { width: min(40vw, 620px); } }

/* Aplicaciones: la capa sube y cada imagen llega escalonada */
.seq__apps {
  z-index: 4;
  background: var(--paper);
  transform: translateY(calc((1 - var(--l, 0)) * 100%));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 1.6vw, 24px);
  align-items: center;
  padding: calc(var(--nav-h) + 48px) var(--gutter) 110px;
}
.seq__app {
  opacity: var(--dim, 1);
  transform: translateY(calc((1 - var(--la, 0)) * 45vh + var(--i) * 4vh - 4vh));
}
@media (min-width: 768px) {
  .seq__apps { padding-left: 14vw; padding-right: 14vw; }
}

.seq__closing {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 0 var(--gutter);
  pointer-events: none;
}
.seq__closing-text {
  text-align: center;
  opacity: var(--c, 0);
  transform: translateY(calc((1 - var(--c, 0)) * 40px));
}
.seq__closing-text.is-fitted { visibility: visible; }

/* Barra superior: número, paso actual y progreso.
   Se lee sobre cualquier fondo gracias al blend "difference". */
.seq__hud {
  position: absolute;
  top: calc(var(--nav-h) + 8px);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  color: #fff;
  mix-blend-mode: difference;
}
.seq__bar {
  grid-column: 1 / -1;
  height: 1px;
  background: rgba(255,255,255,.3);
}
.seq__bar span {
  display: block;
  height: 100%;
  background: #fff;
  transform-origin: left;
  transform: scaleX(0);
}
.seq__foot {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: clamp(20px, 4vw, 44px);
  z-index: 6;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #fff;
  mix-blend-mode: difference;
}

/* --------------------------------------------------------------------------
   ③ MOTION REEL (fondo negro)
   -------------------------------------------------------------------------- */
.reel {
  position: relative;
  height: calc(var(--n) * 70vh + 100vh);
  height: calc(var(--n) * 70svh + 100svh);
  background: var(--bg);
  color: var(--fg);
}
.reel__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}
.reel__clip {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity .45s var(--ease-out), transform 1.4s var(--ease-out);
}
.reel__clip.is-active { opacity: 1; transform: scale(1); }

.reel__shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.55), rgba(0,0,0,0) 25%),
    linear-gradient(to top, rgba(0,0,0,.75), rgba(0,0,0,0) 50%);
}
.reel__top {
  position: absolute;
  top: calc(var(--nav-h) + 8px);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.reel__top > :first-child { white-space: nowrap; }
.reel__sub { text-align: right; }

.reel__ticks {
  position: absolute;
  right: var(--gutter);
  top: 50%;
  z-index: 3;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.reel__tick {
  width: 14px;
  height: 2px;
  background: currentColor;
  opacity: .3;
  transition: width .4s var(--ease-out), opacity .4s;
}
.reel__tick.is-active { width: 34px; opacity: 1; background: var(--accent); }

.reel__credit { transition: opacity .18s; }
.reel__credit.is-swapping { opacity: 0; }

/* --------------------------------------------------------------------------
   ④ COVER FLIP
   -------------------------------------------------------------------------- */
.flip {
  position: relative;
  height: calc(var(--n) * 45vh + 100vh);
  height: calc(var(--n) * 45svh + 100svh);
}
.flip__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.flip__title-wrap {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
}
.flip__deck {
  position: relative;
  z-index: 2;
  width: min(74vw, 56vh);
  width: min(74vw, 56svh);
  aspect-ratio: 1;
}
.flip__card {
  position: absolute;
  inset: 0;
  will-change: transform;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
}
.flip__card .media { width: 100%; height: 100%; }

.flip__foot {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  bottom: clamp(20px, 4vw, 44px);
  z-index: 3;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: baseline;
}
.flip__credit { text-align: center; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 767px) {
  .flip__foot { grid-template-columns: 1fr auto; }
  .flip__credit { grid-row: 1; grid-column: 1 / -1; text-align: left; }
}

/* --------------------------------------------------------------------------
   MOVIMIENTO REDUCIDO: las secuencias se muestran en su estado final
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .reel__clip { transition: none; }
}
