/*
 * Portada inmersiva de Estel: un día en Cadaqués, del alba a la noche.
 * Cada escena es una fotografía a pantalla completa con su texto. Sin JS o con movimiento
 * reducido las escenas se apilan una tras otra; con JS (`voyage-on`) quedan fijas en un único
 * escenario y el scroll mueve la cámara: empuje hacia delante, fundido entre fotos, paralaje,
 * reloj del día y luz tintada por escena.
 */

.voyage {
  position: relative;
  background: var(--abyss);
}
.voyage__pin {
  position: relative;
}

/* ---------- Escena (estática: apiladas) ---------- */
.vscene {
  position: relative;
  display: grid;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
}
.vscene__photo {
  position: absolute;
  inset: 0;
  z-index: -1;
  margin: 0;
  background: var(--avg, #222) var(--lq) center / cover no-repeat;
  transform-origin: 50% 55%;
}
.vscene__photo picture,
.vscene__photo img {
  display: block;
  width: 100%;
  height: 100%;
}
.vscene__photo img {
  object-fit: cover;
  object-position: var(--focus, 50% 50%);
}
/* Velo de lectura: oscurece el lado del texto y los bordes sin apagar la foto */
.vscene__photo::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--sc, 90deg), rgba(8, 7, 6, 0.84) 0%, rgba(8, 7, 6, 0.5) 46%, rgba(8, 7, 6, 0) 78%),
    linear-gradient(0deg, rgba(8, 7, 6, 0.82) 0%, rgba(8, 7, 6, 0.4) 34%, rgba(8, 7, 6, 0) 58%),
    linear-gradient(180deg, rgba(8, 7, 6, 0.55) 0%, rgba(8, 7, 6, 0) 24%);
}
.vscene[data-align='right'] {
  --sc: 270deg;
}
.vscene[data-align='center'] .vscene__photo::after {
  background:
    radial-gradient(70% 62% at 50% 50%, rgba(8, 7, 6, 0.62), rgba(8, 7, 6, 0.12) 100%),
    linear-gradient(0deg, rgba(8, 7, 6, 0.7) 0%, rgba(8, 7, 6, 0) 46%),
    linear-gradient(180deg, rgba(8, 7, 6, 0.55) 0%, rgba(8, 7, 6, 0) 24%);
}

/* ---------- Texto de cada escena ---------- */
.vact {
  position: relative;
  align-self: end;
  display: grid;
  gap: 18px;
  max-width: min(760px, 100%);
  padding: 120px calc(var(--gut) + 56px) clamp(64px, 10vh, 120px);
  text-shadow: 0 2px 28px rgba(0, 0, 0, 0.42);
}
.vscene[data-align='right'] .vact {
  justify-self: end;
  text-align: right;
  justify-items: end;
}
.vscene[data-align='center'] .vact {
  align-self: center;
  justify-self: center;
  justify-items: center;
  text-align: center;
  padding-bottom: 96px;
}
.vact__kicker {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 0;
  color: rgba(236, 230, 218, 0.78);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.vact__kicker b {
  font: italic 400 1.35rem / 1 var(--font-display);
  letter-spacing: 0.02em;
  color: var(--ember-hi);
}
.vact__kicker span::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 1px;
  margin-right: 14px;
  vertical-align: middle;
  background: currentColor;
  opacity: 0.55;
}
.vact__hero {
  margin: 0;
  line-height: 0;
}
.vact__title {
  margin: 0;
  max-width: 15ch;
  font: 400 clamp(2.5rem, 6.8vw, 6.4rem) / 0.98 var(--font-display);
  letter-spacing: -0.015em;
}
.vact__title {
  text-shadow: 0 2px 34px rgba(0, 0, 0, 0.62);
}
.vact__title em {
  font-style: italic;
  color: #f2b189;
}
.vact__sub {
  margin: 0;
  max-width: 44ch;
  font-size: clamp(1.05rem, 1.45vw, 1.28rem);
  line-height: 1.5;
  color: rgba(236, 230, 218, 0.88);
}
.vact__sub--lead {
  font: italic 400 clamp(1.2rem, 2.1vw, 1.75rem) / 1.3 var(--font-display);
}
.vact__ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 0;
}
.vscene[data-align='center'] .vact__ctas {
  justify-content: center;
}
.vact .facts {
  margin-top: 6px;
}
.vhint {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 0;
  color: rgba(236, 230, 218, 0.66);
  font-size: 0.74rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.vhint i {
  position: relative;
  width: 1px;
  height: 44px;
  overflow: hidden;
  background: rgba(236, 230, 218, 0.24);
}
.vhint i::after {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 16px;
  background: var(--ember-hi);
  animation: vhint 2.2s var(--ease) infinite;
}
@keyframes vhint {
  from {
    transform: translateY(-16px);
  }
  to {
    transform: translateY(44px);
  }
}

/* Capas de ambiente y HUD: solo con el recorrido activo */
.voyage__fx,
.vhud {
  display: none;
}

/* ---------- Recorrido activo ---------- */
.voyage-on .voyage {
  height: var(--voyage-h, 700vh);
}
.voyage-on .voyage__pin {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  --tint: 232, 150, 90;
}
.voyage-on .vscene {
  position: absolute;
  inset: 0;
  min-height: 0;
}
.voyage-on .vscene__photo {
  opacity: 0;
  visibility: hidden;
  will-change: transform, opacity;
}
.voyage-on .vscene.is-near .vscene__photo {
  visibility: visible;
}
.voyage-on .vscene__photo img {
  animation: vdrift 38s ease-in-out infinite alternate;
}
.voyage-on .vscene:nth-child(even) .vscene__photo img {
  animation-direction: alternate-reverse;
}
@keyframes vdrift {
  from {
    transform: scale(1) translate3d(-0.6%, 0.3%, 0);
  }
  to {
    transform: scale(1.045) translate3d(0.8%, -0.5%, 0);
  }
}
.voyage-on .vact {
  position: absolute;
  inset: 0;
  align-content: end;
  max-width: none;
  width: 100%;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}
.voyage-on .vscene[data-align='right'] .vact,
.voyage-on .vscene[data-align='left'] .vact,
.voyage-on .vscene[data-align='center'] .vact {
  justify-self: stretch;
}
.voyage-on .vact > * {
  max-width: 760px;
}
.voyage-on .vscene[data-align='right'] .vact > * {
  margin-left: auto;
}
.voyage-on .vscene[data-align='center'] .vact {
  align-content: center;
  justify-items: center;
}
.voyage-on .vscene[data-align='center'] .vact > * {
  margin-inline: auto;
}
.voyage-on .vact.is-live {
  pointer-events: auto;
}

.voyage-on .voyage__fx,
.voyage-on .vhud {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
/* Luz tintada que sigue al puntero y cambia con la hora del día */
.voyage__light {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(46% 52% at var(--lx, 62%) var(--ly, 38%), rgba(var(--tint), 0.16), transparent 70%);
}
.voyage__grain {
  position: absolute;
  inset: -8%;
  opacity: 0.06;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: vgrain 0.9s steps(6) infinite;
}
@keyframes vgrain {
  0% {
    transform: translate(0, 0);
  }
  20% {
    transform: translate(-3%, 2%);
  }
  40% {
    transform: translate(2%, -3%);
  }
  60% {
    transform: translate(-2%, -1%);
  }
  80% {
    transform: translate(3%, 3%);
  }
  100% {
    transform: translate(0, 0);
  }
}
.voyage__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 95% at 50% 46%, transparent 52%, rgba(6, 5, 4, 0.55) 100%);
}

/* Reloj del día y progreso */
.vhud {
  font-variant-numeric: tabular-nums;
}
.vhud__clock {
  position: absolute;
  right: var(--gut);
  top: calc(var(--head-h) + 36px);
  margin: 0;
  font: italic 400 clamp(1.4rem, 2.6vw, 2.2rem) / 1 var(--font-display);
  color: rgba(236, 230, 218, 0.9);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5);
}
.vhud__where {
  position: absolute;
  right: var(--gut);
  top: calc(var(--head-h) + 36px + 2.6rem);
  margin: 0;
  color: rgba(236, 230, 218, 0.62);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.5);
}
.vhud__bar {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: rgba(236, 230, 218, 0.12);
}
.vhud__bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--ember-btn), var(--ember-hi));
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* El raíl del día reutiliza el de la plantilla; aquí lleva el número de escena */
.rail {
  gap: 14px;
}
.rail i {
  font-style: normal;
  font-family: var(--font-body);
  font-size: 0.7rem;
  width: 26px;
  height: 26px;
  font-variant-numeric: tabular-nums;
}

.voyage-on .rail span {
  display: none;
}
.vhud__clock,
.vhud__where {
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7), 0 2px 22px rgba(0, 0, 0, 0.7);
}

/* ---------- Banda fotográfica de la casa ---------- */
.casa__photo {
  position: relative;
  margin: 0 0 clamp(36px, 6vw, 72px);
  overflow: hidden;
  border-radius: var(--r-panel);
  border: 1px solid var(--hair);
}
.casa__photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 21 / 9;
  object-fit: cover;
  object-position: 50% 78%;
}
.casa__photo figcaption {
  position: absolute;
  left: clamp(16px, 3vw, 32px);
  bottom: clamp(14px, 2.4vw, 26px);
  right: 16px;
  font: italic 400 clamp(1rem, 1.7vw, 1.4rem) / 1.2 var(--font-display);
  color: var(--salt);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.65);
}
.casa__photo::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(0deg, rgba(8, 7, 6, 0.55), transparent 45%);
}

@media (max-width: 760px) {
  .rail {
    display: none;
  }
  .vact {
    padding: 96px var(--gut) calc(168px + env(safe-area-inset-bottom, 0px));
    gap: 14px;
  }
  .vscene[data-align='right'] .vact {
    text-align: left;
    justify-items: start;
    justify-self: start;
  }
  .voyage-on .vscene[data-align='right'] .vact > * {
    margin-left: 0;
  }
  .vact__title {
    font-size: clamp(2.3rem, 11.5vw, 3.6rem);
  }
  .vact__kicker span::before {
    width: 18px;
    margin-right: 10px;
  }
  .vhud__where {
    display: none;
  }
  .vhud__clock {
    top: calc(var(--head-h) + 20px);
  }
  .vscene__photo::after {
    background:
      linear-gradient(0deg, rgba(8, 7, 6, 0.86) 0%, rgba(8, 7, 6, 0.4) 46%, rgba(8, 7, 6, 0) 74%),
      linear-gradient(180deg, rgba(8, 7, 6, 0.55) 0%, rgba(8, 7, 6, 0) 24%);
  }
  .vscene[data-align='center'] .vscene__photo::after {
    background:
      radial-gradient(90% 60% at 50% 55%, rgba(8, 7, 6, 0.66), rgba(8, 7, 6, 0.2) 100%),
      linear-gradient(0deg, rgba(8, 7, 6, 0.7) 0%, rgba(8, 7, 6, 0) 46%);
  }
  .casa__photo img {
    aspect-ratio: 4 / 3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vscene__photo img,
  .voyage__grain,
  .vhint i::after {
    animation: none;
  }
}
