/* ============================================================
   Scroll storytelling (homepage). The page is told in chapters:
   a pinned hero that steps back, pauses ("breaths") that stop the
   scroll for one thought, and a sea day told on a sticky stage.
   Motion lives in js/story-scroll.js (GSAP + ScrollTrigger).

   Without JS, or with reduced motion, everything below renders as
   a calm static page: pauses are full-height statements, the day
   falls back to the inline timeline from story.css.
   ============================================================ */

/* ---------- Chapter indicator (fixed, bottom left) ---------- */
.st-chapter { position: fixed; z-index: 30; left: var(--container-pad); bottom: var(--sp-5);
  display: flex; align-items: center; gap: var(--sp-3); padding: 8px 12px;
  background: color-mix(in srgb, #f9fafb 90%, transparent); border: 1px solid var(--line); border-radius: 2px;
  backdrop-filter: blur(10px); font-family: var(--font-mono); font-size: var(--fs-caption); line-height: 1;
  color: var(--text-strong); opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease, background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease; }
.st-chapter.is-on { opacity: 1; transform: none; }
.st-chapter__n { color: var(--teal-ink, var(--teal-500)); }
.st-chapter__bar { position: relative; width: 64px; height: 2px; background: var(--line); overflow: hidden; }
.st-chapter__bar i { position: absolute; inset: 0; background: var(--gold-500); transform-origin: left center; transform: scaleX(var(--p, 0)); }
.st-chapter.is-dark { background: rgba(5, 16, 29, 0.72); border-color: rgba(249, 250, 251, 0.2); color: #f9fafb; }
.st-chapter.is-dark .st-chapter__n { color: var(--teal-500); }
.st-chapter.is-dark .st-chapter__bar { background: rgba(249, 250, 251, 0.2); }

/* ---------- Hero: steps back into a framed picture ---------- */
.st-hero__media { position: absolute; inset: 0; overflow: hidden; }
.st-hero__next { display: none; }
.js-story .st-hero { background: #f9fafb; height: calc(100svh - var(--hdr, 72px)); min-height: 560px; }
.js-story .st-hero__media { will-change: clip-path; }
.js-story .st-hero__next { display: block; position: absolute; z-index: 2; left: 0; right: 0; top: 50%; margin: 0;
  transform: translateY(-50%); padding-inline: var(--container-pad); text-align: center; pointer-events: none; opacity: 0;
  font-family: var(--font-display); font-weight: var(--fw-medium); font-size: clamp(32px, 4.6vw, 64px);
  line-height: 1.1; letter-spacing: -0.02em; color: #f9fafb; text-wrap: balance; }
.js-story .st-hero__next span { display: block; color: rgba(249, 250, 251, 0.62); }

/* ---------- Breaths: one thought, the scroll stops for it ---------- */
.st-breath { position: relative; min-height: 100svh; display: flex; align-items: center; background: var(--bg-page); overflow: hidden; }
.st-breath__inner { position: relative; z-index: 1; width: 100%; padding-block: var(--sp-10); }
.st-breath__big { font-family: var(--font-display); font-weight: var(--fw-medium); font-size: clamp(36px, 5.6vw, var(--fs-display));
  line-height: 1.06; letter-spacing: -0.03em; color: var(--text-strong); max-width: 17ch; text-wrap: balance; }
.st-breath__big .w { display: inline-block; }
.st-breath__small { margin-top: var(--sp-7); max-width: 40ch; color: var(--text-muted); font-size: var(--fs-lead); line-height: var(--lh-h3); }
.st-breath--paper { border-block: 1px solid var(--line); }
.st-breath--paper .st-breath__big { max-width: 16ch; }

.st-breath--photo { background: #05101d; }
.st-breath__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(0.92); }
.st-breath__grade { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(5,16,29,0.84) 0%, rgba(5,16,29,0.5) 42%, rgba(5,16,29,0.08) 78%),
              linear-gradient(0deg, rgba(5,16,29,0.5) 0%, rgba(5,16,29,0) 40%); }
.st-breath__line { font-family: var(--font-display); font-weight: var(--fw-medium); font-size: clamp(34px, 5vw, 72px);
  line-height: 1.08; letter-spacing: -0.03em; color: #f9fafb; }
.st-breath__line--gold { margin-top: var(--sp-5); color: var(--gold-500); }

/* ---------- Cost: one in three, drawn ---------- */
.st-thirds { display: flex; gap: 6px; max-width: 320px; margin-block: var(--sp-2) var(--sp-3); }
.st-thirds i { flex: 1; height: 8px; background: var(--line); }
.st-thirds i.is-on { background: linear-gradient(90deg, var(--gold-500) calc(var(--p, 1) * 100%), var(--line) 0); }

/* ---------- One sea day on a sticky stage (wide screens, JS on) ---------- */
.st-journey__stage { display: none; }
@media (min-width: 1001px) {
  .js-story .st-journey { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr); column-gap: var(--sp-9); }
  .js-story .st-journey__stage { position: sticky; top: calc(var(--hdr, 72px) + var(--sp-5)); align-self: start;
    height: calc(100vh - var(--hdr, 72px) - var(--sp-5) - var(--sp-9)); /* bottom strip stays free for the chapter indicator */ display: flex; flex-direction: column; gap: var(--sp-6); padding-top: var(--sp-6); }
  .js-story .st-journey__frame { position: relative; flex: 1; min-height: 0; border: 1px solid var(--border-card); border-radius: 2px;
    overflow: hidden; background: #e9ecef; }
  .js-story .st-journey__frame::after { content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(0deg, rgba(5,16,29,0.55) 0%, rgba(5,16,29,0) 38%); }
  .js-story .st-journey__frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    opacity: 0; transform: scale(1.05); transition: opacity 0.8s ease, transform 1.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
  .js-story .st-journey__frame img.is-on { opacity: 1; transform: none; }
  .st-journey__clock { position: absolute; z-index: 1; left: var(--sp-6); bottom: var(--sp-5); font-family: var(--font-mono);
    font-size: clamp(44px, 4.4vw, 68px); line-height: 1; color: #f9fafb; letter-spacing: -0.02em; }

  /* the lifeline: her day as one line, filled as it is lived */
  .st-journey__line { position: relative; height: 2px; margin: 0 6px var(--sp-5); background: var(--line); flex: none; }
  .st-journey__line i { position: absolute; inset: 0; background: var(--teal-500); transform-origin: left center; transform: scaleX(var(--p, 0)); }
  .st-journey__line span { position: absolute; left: var(--at); top: 14px; transform: translateX(-50%);
    font-family: var(--font-mono); font-size: var(--fs-caption); line-height: 1; color: var(--text-muted); transition: color 0.4s ease; }
  .st-journey__line span:first-of-type { transform: none; margin-left: -6px; }
  .st-journey__line span:last-of-type { transform: translateX(-100%); margin-left: 6px; }
  .st-journey__line span::before { content: ""; position: absolute; top: -19px; left: 50%; width: 10px; height: 10px; margin-left: -5px;
    background: var(--bg-page); border: 2px solid var(--line-strong); transition: background-color 0.4s ease, border-color 0.4s ease; }
  .st-journey__line span:first-of-type::before { left: 0; margin-left: 1px; }
  .st-journey__line span:last-of-type::before { left: auto; right: 1px; margin-left: 0; }
  .st-journey__line span.is-past { color: var(--text-strong); }
  .st-journey__line span.is-past::before { background: var(--teal-500); border-color: var(--teal-500); }

  .js-story .st-journey__steps { min-width: 0; }
  .js-story .st-journey .st-moment { grid-template-columns: 1fr; gap: var(--sp-5); min-height: 82vh; align-content: center;
    padding: var(--sp-8) 0; border-bottom: 0; opacity: 0.22; transition: opacity 0.5s ease; }
  .js-story .st-journey .st-moment.is-on { opacity: 1; }
  .js-story .st-journey .st-moment > .mk-media { display: none; }
  .js-story .st-journey .st-moment:first-child { min-height: 70vh; align-content: start; padding-top: var(--sp-8); }
}
.st-moment--quiet .st-moment__body h3 { color: var(--text-muted); }

/* ---------- Pilot: one sailing, four stops on a route ---------- */
.st-voyage__pic { --mk-ar: 21 / 9; }
.st-voyage__grade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(0deg, rgba(5,16,29,0.42) 0%, rgba(5,16,29,0) 45%); }
.st-voyage__tag { position: absolute; z-index: 1; left: var(--sp-5); bottom: var(--sp-5); font-family: var(--font-mono);
  font-size: var(--fs-caption); letter-spacing: 0.06em; color: #f9fafb; }
.st-voyage__route { position: relative; height: 2px; margin-top: var(--sp-8); background: var(--line-strong); }
.st-voyage__route i { position: absolute; inset: 0; background: var(--gold-500); transform-origin: left center; transform: scaleX(var(--p, 1)); }
.st-voyage__route b { position: absolute; top: 50%; left: calc(var(--p, 1) * 100%); width: 12px; height: 12px; margin: -6px 0 0 -6px;
  background: var(--gold-500); transform: rotate(45deg); box-shadow: 0 0 0 4px var(--bg-page); }
.st-voyage__steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-6); }
.st-voyage__step { position: relative; padding-top: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); transition: opacity 0.5s ease; }
.st-voyage__step::before { content: ""; position: absolute; top: -6px; left: 0; width: 10px; height: 10px; background: var(--bg-page);
  border: 2px solid var(--line-strong); transition: background-color 0.4s ease, border-color 0.4s ease; }
.st-voyage__step.is-reached::before { background: var(--gold-500); border-color: var(--gold-500); }
.js-story .st-voyage__step:not(.is-reached) { opacity: 0.3; }
.st-voyage__n { font-family: var(--font-mono); font-size: clamp(32px, 3vw, 44px); line-height: 1; color: var(--gold-ink, var(--gold-500)); letter-spacing: -0.02em; }
.st-voyage__step h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); }
.st-voyage__step p { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--text-muted); }
.st-voyage__foot { margin-top: var(--sp-8); display: flex; align-items: center; gap: var(--sp-6); flex-wrap: wrap; }
@media (max-width: 1000px) {
  .st-voyage__steps { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--sp-7); }
}
@media (max-width: 640px) {
  .st-voyage__route { display: none; }
  .st-voyage__steps { grid-template-columns: 1fr; gap: 0; margin-top: var(--sp-7); }
  .st-voyage__step { padding: 0 0 var(--sp-6) var(--sp-6); border-left: 2px solid var(--line-strong); }
  .st-voyage__step.is-reached { border-left-color: var(--gold-500); }
  .st-voyage__step::before { top: 0; left: -6px; }
  .st-voyage__tag { left: var(--sp-4); bottom: var(--sp-4); }
}

@media (max-width: 700px) {
  .st-chapter { display: none; } /* on a phone it would sit on the body text */
  .st-breath__inner { padding-block: var(--sp-9); }
  .st-breath__small { margin-top: var(--sp-6); font-size: var(--fs-body); line-height: var(--lh-body); }
}

@media (prefers-reduced-motion: reduce) {
  .st-chapter, .js-story .st-journey__frame img, .js-story .st-journey .st-moment { transition: none; }
}
