/* ═══════════════════════════════════════════════════
   El viaje de tu factura — cinematic scene scrubbed by scroll
   The tall wrapper gives scroll distance; the sticky stage stays on screen
   while js/journey.js maps scroll progress to a video frame on the canvas.
   ═══════════════════════════════════════════════════ */

.journey {
  position: relative;
  height: 420vh;
  background: var(--bg-secondary);
}

.journey-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: #050507;
}

.journey-poster,
.journey-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 45% 50%;
}

.journey-canvas { opacity: 0; transition: opacity 0.4s ease; }
.journey.is-ready .journey-canvas { opacity: 1; }

/* Blend the scene into the page above and below, and keep captions readable */
.journey-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, var(--bg-secondary) 0%, rgba(8, 8, 9, 0.55) 12%, rgba(8, 8, 9, 0) 26%),
    linear-gradient(to top, var(--bg-secondary) 0%, rgba(8, 8, 9, 0.75) 22%, rgba(8, 8, 9, 0) 48%);
}

.journey-intro {
  position: absolute;
  top: clamp(4.5rem, 11vh, 7rem);
  left: 0;
  right: 0;
  text-align: center;
  padding-inline: 16px;
  transition: opacity 0.5s ease, transform 0.5s ease;
  isolation: isolate;   /* keeps the ::before veil just behind the title, above the scene */
}
.journey-intro .section-title {
  margin: 0.4rem 0 0;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7), 0 4px 28px rgba(0, 0, 0, 0.85);
}
.journey-intro .section-tag { text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9); }
/* Dark veil behind the title (the scene is bright lime there); it fades out with the title */
.journey-intro::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 50%;
  width: min(900px, 160%);
  height: 260%;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(5, 5, 7, 0.88) 0%, rgba(5, 5, 7, 0.7) 45%, rgba(5, 5, 7, 0) 100%);
  pointer-events: none;
}
.journey.is-past-intro .journey-intro { opacity: 0; transform: translateY(-16px); }

.journey-captions {
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute;
  left: 50%;
  bottom: clamp(2.5rem, 9vh, 5rem);
  width: min(640px, calc(100% - 32px));
  transform: translateX(-50%);
  min-height: 7.5rem;
}

.journey-cap {
  position: absolute;
  inset: auto 0 0 0;
  text-align: center;
  opacity: 0;
  transform: translateY(18px);
  visibility: hidden;   /* hidden captions must not catch taps or keyboard focus */
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}
/* The outgoing caption clears first, then the new one comes in */
.journey-cap.is-active {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition: opacity 0.45s ease 0.2s, transform 0.45s ease 0.2s, visibility 0s;
}

/* Final beat: the call to action, at the emotional peak of the film */
.journey-cta {
  margin-top: 1.1rem;
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transition: opacity 0.4s ease, transform 0.4s ease;
  box-shadow: 0 0 0 1px rgba(214, 255, 0, 0.35), 0 8px 32px rgba(214, 255, 0, 0.28);
}
.journey-cap.is-active .journey-cta {
  opacity: 1;
  transform: none;
  transition-delay: 0.55s;
}

.journey-cap-num {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.journey-cap-title {
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7), 0 4px 24px rgba(0, 0, 0, 0.8);
  display: block;
  margin-top: 0.35rem;
  font-size: clamp(1.5rem, 3.2vw, 2.4rem);
  font-weight: 700;
  line-height: 1.12;
  color: var(--text-primary);
  text-wrap: balance;
}
.journey-cap-text {
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  display: block;
  margin-top: 0.5rem;
  font-size: var(--text-base);
  color: var(--text-muted);
  text-wrap: pretty;
}

.journey-progress {
  position: absolute;
  left: 50%;
  bottom: clamp(1.1rem, 4vh, 2rem);
  width: min(220px, 50%);
  height: 2px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}
.journey-progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--accent);
  transform-origin: left;
  transform: scaleX(0);
}

/* Phones: shorter scroll distance */
@media (max-width: 767px) {
  .journey { height: 340vh; }
  .journey-cap-title { font-size: 1.45rem; }
  .journey-cap-text { font-size: 0.92rem; }
  .journey-captions { min-height: 8.5rem; }
}

/* No motion: a single still with all four steps listed underneath */
@media (prefers-reduced-motion: reduce) {
  .journey { height: auto; }
  .journey-sticky { position: relative; height: auto; overflow: visible; }
  .journey-poster { position: relative; height: 56vw; max-height: 70vh; }
  .journey-canvas, .journey-progress { display: none; }
  .journey-shade { bottom: auto; height: 56vw; max-height: 70vh; }
  .journey-intro { position: static; padding-top: var(--space-12, 3rem); }
  .journey-captions {
    position: static;
    transform: none;
    margin: 1.5rem auto 0;
    display: grid;
    gap: 1.25rem;
    min-height: 0;
  }
  .journey-cap { position: static; opacity: 1; transform: none; visibility: visible; }
  .journey-cta { opacity: 1; transform: none; }
}

/* Portrait phones use the 9:16 frames, already centred on ST Bot */
@media (orientation: portrait) and (max-width: 899px) {
  .journey-poster { object-position: 50% 50%; }
}
