/*
  Sticky storytelling section.

  A two-column split where the left column pins while the right column
  scrolls its steps past it, swapping the pinned image as each step becomes
  active. Built on position:sticky (CSS) with story.js only toggling an
  .is-active class — so if the script fails, the section is still a
  perfectly readable sticky-image-plus-steps layout with the first image
  showing, not a broken pile.

  Under 900px and under reduced-motion it becomes a plain vertical
  narrative: each step carries its own image inline. That is a different
  composition, not the desktop one with the sticky removed.
*/

.m-story{
  padding-block:var(--section-y);
  background:var(--surface-2);
}

.m-story-grid{
  display:grid;
  grid-template-columns:minmax(0,.92fr) minmax(0,1.08fr);
  gap:clamp(var(--s-7), 5vw, var(--s-10));
  align-items:start;
}

/* ---------- Pinned column ---------- */
.m-story-sticky{
  position:sticky;top:clamp(88px, 12vh, 128px);
  display:flex;flex-direction:column;gap:var(--s-6);
}
.m-story-sticky h2{max-width:14ch;}

.m-story-stage{
  position:relative;border-radius:var(--radius-lg);overflow:hidden;
  aspect-ratio:4/3;box-shadow:var(--shadow);background:var(--accent-dark);
}
.m-story-stage figure{
  position:absolute;inset:0;margin:0;
  opacity:0;transform:scale(1.04);
  transition:opacity var(--dur-slow) var(--ease-out),
             transform 1.2s var(--ease-out);
}
.m-story-stage figure.is-active{opacity:1;transform:scale(1);}
.m-story-stage img{width:100%;height:100%;object-fit:cover;object-position:center 25%;}

/* ---------- Steps column ---------- */
.m-story-steps{
  display:flex;flex-direction:column;
  /* Each step gets a tall block so there is scroll distance for the pinned
     image to hold through — this is what gives the section its pace. */
  gap:clamp(var(--s-8), 8vw, 140px);
  padding-block:clamp(var(--s-6), 6vw, 96px);
}

.m-story-step{
  display:flex;flex-direction:column;gap:var(--s-4);
  padding-left:var(--s-7);position:relative;
  opacity:.38;
  transition:opacity var(--dur-slow) var(--ease-out);
}
.m-story-step.is-active{opacity:1;}

/* The marker rail: a hairline down the left with a dot per step that
   fills when the step is active. */
.m-story-step::before{
  content:"";position:absolute;left:0;top:0;bottom:calc(var(--s-8) * -1);
  width:1px;background:var(--line);
}
.m-story-step:last-child::before{bottom:0;}
.m-story-step::after{
  content:"";position:absolute;left:-4px;top:8px;
  width:9px;height:9px;border-radius:50%;
  background:var(--surface-2);border:1px solid var(--accent-line);
  transition:background var(--dur-mid) var(--ease-out),
             border-color var(--dur-mid) var(--ease-out),
             transform var(--dur-mid) var(--ease-out);
}
.m-story-step.is-active::after{
  background:var(--accent);border-color:var(--accent);transform:scale(1.25);
}

.m-story-step h3{margin:0;}
.m-story-step p{margin:0;color:var(--ink-soft);max-width:48ch;}

/* Inline image, desktop-hidden: only the mobile composition uses it. */
.m-story-step-media{display:none;}

.m-story-step-note{
  display:inline-flex;align-items:center;gap:var(--s-3);
  font-family:var(--font-mono);font-size:var(--t-mono);letter-spacing:.1em;
  text-transform:uppercase;color:var(--accent-2-deep);
  padding-top:var(--s-3);border-top:1px solid var(--line);
  align-self:flex-start;
}

/* ---------- Mobile: a different composition, not a collapsed one ---------- */
@media (max-width:900px){
  .m-story-grid{grid-template-columns:1fr;gap:var(--s-7);}
  .m-story-sticky{position:static;}
  .m-story-stage{display:none;}
  .m-story-steps{gap:var(--s-7);padding-block:0;}
  .m-story-step{opacity:1;padding-left:var(--s-6);}
  .m-story-step-media{
    display:block;margin-top:var(--s-3);
    border-radius:var(--radius-md);overflow:hidden;
  }
}

@media (prefers-reduced-motion: reduce){
  .m-story-sticky{position:static;}
  .m-story-stage{display:none;}
  .m-story-step{opacity:1;}
  .m-story-step-media{display:block;margin-top:var(--s-3);border-radius:var(--radius-md);overflow:hidden;}
  .m-story-stage figure{transition:none;}
}
