.shap-story {
  padding: clamp(56px, 8vw, 125px) var(--pad) 0;
}

.shap-heading {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: end;
  gap: var(--gap);
  margin-bottom: clamp(24px, 3.6vw, 54px);
}

.shap-heading > .mono {
  grid-column: span 2;
  align-self: start;
  color: var(--sky-ink);
}

.shap-intro-copy {grid-column:span 7}
.shap-intro-copy p {max-width:53ch;margin-top:18px;font-size:var(--body-sm);line-height:1.5;color:var(--muted)}

.shap-heading h2 {
  font-size: clamp(43px, 6.4vw, 112px);
  font-weight: 750;
  line-height: .94;
  letter-spacing: -.055em;
}

.shap-heading em {
  font-family: var(--serif);
  font-weight: 400;
  color: var(--sky-ink);
}

.shap-source {
  grid-column: span 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: .75em;
  min-height: 44px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: .25em;
  text-decoration-color: var(--sky);
}

.shap-source:hover, .shap-source:focus-visible {
  color: var(--sky-ink);
}

.shap-source:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

.shap-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  list-style: none;
  border-block: 1px solid var(--ink);
  background: var(--paper);
}

.shap-steps li {
  padding: clamp(18px, 2.4vw, 39px);
}

.shap-steps li + li {
  border-left: 1px solid var(--line);
}

.shap-steps svg {
  display: block;
  width: min(100%, 305px);
  margin: 0 auto clamp(15px, 2vw, 30px);
  overflow: visible;
}

.shap-steps h3 {
  font-size: clamp(22px, 2.3vw, 39px);
  line-height: 1.05;
  letter-spacing: -.04em;
}

.shap-steps p {
  max-width: 39ch;
  margin-top: .55em;
  font-size: var(--body-sm);
  line-height: 1.5;
  color: var(--muted);
}

.shap-guides, .shap-track, .shap-ink-trace, .shap-cut {
  fill: none;
}

.shap-guides { stroke: #c2d4db; }
.shap-track, .shap-bars { stroke: #b3dae6; }
.shap-track, .shap-ink-trace, .shap-cut { stroke-width: 2; }
.shap-ink-trace { stroke: var(--sky); }
.shap-bars .shap-ink-trace { stroke-width: 8; }
.shap-cut { stroke: var(--accent-ink); }
.shap-wash { fill: #f9e8f2; }
.shap-glyph { fill: var(--accent-ink); font: italic 22px var(--serif); }
.shap-gate { fill: #ecf6f9; stroke: var(--sky-ink); }
.shap-label { fill: var(--ink); font: 500 12px var(--mono); letter-spacing: .035em; }
.shap-output { fill: var(--accent-ink); }

/* The complete diagram is the default for print, reduced motion, and no JS. */
@media screen and (prefers-reduced-motion: no-preference) {
  .shap-story.is-tracing .shap-ink-trace {
    stroke-dasharray: 1;
    stroke-dashoffset: var(--trace-remaining, 0);
  }
}

@media (max-width: 760px) {
  .shap-heading {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
    margin-bottom: 18px;
  }

  .shap-heading > .mono, .shap-intro-copy, .shap-source {
    grid-column: 1;
  }

  .shap-source { justify-self: start; }

  .shap-steps { grid-template-columns: 1fr; }

  .shap-steps li {
    display: grid;
    grid-template-columns: minmax(105px, .65fr) minmax(0, 1.35fr);
    column-gap: clamp(12px, 3vw, 24px);
    align-items: center;
    padding: 20px 0;
  }

  .shap-steps li + li {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .shap-steps svg {
    grid-row: span 2;
    margin: 0;
  }

  .shap-steps p { margin-top: .35em; }
}

@media print {
  .shap-story { break-inside: avoid; }
}
