/* Sticky story, design language v2. Finished state first: steps then artifacts in one vertical sequence. JS adds
   .is-story (wide, motion allowed) for the sticky stage, or .is-inline to tuck each artifact under its own step.
   Markup: section[data-story] > .ix-story__grid > ol.ix-story__steps.ix-ledger > li.ix-box (strong lead + sentence)
           + .ix-story__stage > figure.ix-box.ix-box--edge[data-story-art="1".."n"] built from the .ix-a-* parts below.
   Artifact parts: .ix-a-cap (caption), .ix-a-head (serif title), dl.ix-a-rows > .ix-a-row (dt label, dd value,
   .ix-a-status, .ix-a-total), ol.ix-a-transcript > li.ix-a-line (.ix-label margin + p; --auto is the reply,
   --note is a ruled event line), .ix-a-event (hand-over or list entry), .ix-a-quote, .ix-a-actions.
   Sticky needs every ancestor to leave overflow visible, so the section rule below keeps it so. */

[data-story] { overflow: visible; }

.ix-story__grid {
  display: grid;
  gap: var(--s-6);
}

/* Steps: numbered ruled rows ------------------------------------------------ */
.ix-story__steps {
  display: grid;
  counter-reset: ix-step;
}

.ix-story__steps > li {
  counter-increment: ix-step;
  border-width: 0 0 1px;
  padding: var(--ix-pad) var(--ix-pad) var(--ix-pad) calc(var(--ix-pad) + var(--s-8));
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--text-2);
}

.ix-story__steps > li::after {
  content: counter(ix-step);
  position: absolute;
  left: var(--ix-pad);
  top: var(--ix-pad);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-h2);
  line-height: 1;
  color: var(--text-3);
  transition: color var(--ix-t-fast) var(--ix-ease);
}

.ix-story__steps > li.is-current::after { color: var(--text-1); }

.ix-story__steps > li > strong {
  display: block;
  margin-bottom: var(--s-1);
  font-size: var(--fs-h4);
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-1);
}

/* Stage and artifacts ------------------------------------------------------- */
.ix-story__stage {
  display: grid;
  gap: var(--s-5);
}

[data-story] [data-story-art] {
  margin: 0;
  padding: var(--ix-pad);
}

[data-story].is-inline .ix-story__stage { display: none; }
[data-story].is-inline [data-story-art] { margin-top: var(--s-4); }

/* Inline on phones the step text is indented past the numeral; the artifact reclaims that gutter so its rows have room. */
@media (max-width: 639px) {
  [data-story].is-inline [data-story-art] { margin-left: calc(-1 * var(--s-8)); }
}

.ix-story__rail { display: none; }

.ix-a-cap { margin: 0 0 var(--s-4); }

.ix-a-head {
  margin: 0 0 var(--s-4);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  font-size: var(--fs-h3);
  line-height: 1.2;
  color: var(--text-1);
}

/* Ruled field rows: small-caps label left, tabular value right. */
.ix-a-rows { margin: 0; border-top: 1px solid var(--ix-rule); }

.ix-a-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s-4);
  padding-block: var(--s-3);
  border-bottom: 1px solid var(--ix-hair);
}

.ix-a-row > dt { flex: none; }

.ix-a-row > dd {
  min-width: 0;
  overflow-wrap: anywhere;
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}

.ix-a-status {
  font-size: var(--fs-meta);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.ix-a-status::before {
  content: "";
  display: inline-block;
  width: var(--s-2);
  height: 2px;
  margin-right: var(--s-2);
  vertical-align: middle;
  background: var(--ix-blue);
}

.ix-a-total > dd {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-h3);
}

/* Typeset transcript: speaker in the left margin, customer in sans, automatic reply in serif italic. */
.ix-a-transcript { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--ix-rule); }

.ix-a-line {
  display: grid;
  grid-template-columns: minmax(var(--s-8), 7rem) minmax(0, 1fr);
  gap: var(--s-4);
  padding-block: var(--s-3);
  border-bottom: 1px solid var(--ix-hair);
}

.ix-a-line > p { margin: 0; color: var(--text-1); }

.ix-a-line--auto > p {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-h3);
  line-height: 1.3;
}

.ix-a-line--note { grid-template-columns: minmax(0, 1fr); }

.ix-a-line--note > p {
  font-size: var(--fs-meta);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-text);
}

/* Event line: a hand-over or a list entry on one ruled row. */
.ix-a-events { border-top: 1px solid var(--ix-rule); }
.ix-a-events + .ix-a-transcript { margin-top: var(--s-4); }
.ix-a-event {
  display: grid;
  gap: var(--s-1);
  padding-block: var(--s-3);
  border-bottom: 1px solid var(--ix-hair);
}

.ix-a-event > b { font-weight: 500; color: var(--text-1); }
.ix-a-event > span { color: var(--text-2); font-size: var(--fs-small); }
.ix-a-event--ok { border-left: 1px solid var(--ix-blue); padding-left: var(--s-3); }

.ix-a-quote {
  margin: 0 0 var(--s-3);
  padding-left: var(--s-4);
  border-left: 1px solid var(--ix-blue);
  color: var(--text-1);
}

.ix-a-quote mark {
  background: transparent;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--ix-blue);
  text-underline-offset: 3px;
}

.ix-a-text { margin: 0 0 var(--s-3); color: var(--text-2); }

.ix-a-big {
  margin: 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--fs-h3);
  color: var(--text-1);
}

.ix-a-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin: var(--s-4) 0 0;
  padding: 0;
  list-style: none;
}

.ix-a-actions > li { padding: var(--s-2) var(--s-4); border: 1px solid var(--ix-hair); }

@media (min-width: 1024px) {
  .is-story .ix-story__grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: var(--s-9);
    align-items: start;
  }

  /* Half a viewport minus half a step, so the first and last steps can reach the middle line the stage is centred on. */
  .is-story { --story-step: 24vh; }
  .is-story .ix-story__steps { padding-block: calc(50vh - var(--story-step) / 2); }

  .is-story .ix-story__steps > li {
    min-height: var(--story-step);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity var(--ix-t-swap) var(--ix-ease), background var(--ix-t-fast) var(--ix-ease);
  }

  .is-story .ix-story__steps > li.is-current { opacity: 1; }

  /* The stage is a viewport-tall sticky frame with its content centred, so the artifact sits on the same middle line the
     script reads steps from (READING_BAND in ix-story.js). */
  .is-story .ix-story__stage {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    align-self: start;
    align-content: center;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .is-story [data-story-art] {
    grid-area: 1 / 1;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ix-t-swap) var(--ix-ease), visibility 0s linear var(--ix-t-swap);
  }

  .is-story [data-story-art].is-active {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
  }

  /* Progress rail: one hairline per step, a short blue tick on the current one. */
  .is-story .ix-story__rail {
    grid-area: 2 / 1;
    display: flex;
    gap: var(--s-1);
    height: 0;
    margin-top: var(--s-3);
    overflow: visible;
  }

  .ix-story__dot {
    position: relative;
    flex: 1 1 0;
    height: 44px;
    border-radius: 0;
  }

  .ix-story__dot::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: var(--ix-hair);
    transition: background var(--ix-t-fast) var(--ix-ease);
  }

  .ix-story__dot::after {
    content: "";
    position: absolute;
    left: 0;
    top: calc(50% - 1px);
    width: var(--s-5);
    height: 3px;
    background: var(--ix-blue);
    opacity: 0;
    transition: opacity var(--ix-t-fast) var(--ix-ease);
  }

  .ix-story__dot.is-passed::before { background: var(--ix-rule); }
  .ix-story__dot[aria-current="step"]::after { opacity: 1; }
  .ix-story__dot:focus-visible { outline: 2px solid var(--ix-blue); outline-offset: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .ix-story__steps > li,
  .ix-story__steps > li::after,
  [data-story] [data-story-art],
  .ix-story__dot::before,
  .ix-story__dot::after { transition: none; }
}
