/* Keep the architectural study interactive at every screen height. Small
   viewport units hold its layout steady while phone browser bars move. */
.build-story { --study-viewport: 100vh; }
@supports (height: 100svh) {
  .build-story { --study-viewport: 100svh; }
}
.build-story.is-animated .blueprint-panel {
  position: sticky;
  top: calc(var(--study-header-height, var(--header)) + 10px);
}
.build-story.is-animated .build-story-steps {
  padding-block: 18vh 14vh;
  padding-block: 18svh 14svh;
}
.build-story.is-animated .build-story-step {
  min-height: 56vh;
  min-height: 56svh;
  scroll-margin-top: var(--study-anchor-offset, 30px);
}
.build-story.is-animated .blueprint-scroll-cue { display: flex; }
.build-story.is-animated .blueprint-model {
  max-height: max(100px, calc(var(--study-viewport) - var(--study-header-height, var(--header)) - 165px));
}

@media (max-width: 800px) {
  /* A single-column grid confines a sticky child to its own short grid row.
     Normal block flow lets the illustration stay pinned across all chapters. */
  .build-story.is-animated .build-story-layout { display: block; }
  .build-story.is-animated .blueprint-panel {
    top: var(--study-header-height, var(--header));
    padding-block: 10px 8px;
    background: linear-gradient(#192019 96%, #19201900);
    z-index: 2;
  }
  .build-story.is-animated .blueprint-model {
    /* Leave space for the chapter beneath the pinned illustration. */
    height: clamp(112px, calc((var(--study-viewport) - var(--study-header-height, var(--header))) * .35), 300px);
    max-height: none;
    width: 100%;
  }
  .build-story.is-animated .blueprint-caption { padding-block: 5px 8px; }
  .build-story.is-animated .blueprint-nav { padding-top: 3px; }
  .build-story.is-animated .blueprint-nav > a { min-height: 44px; }
  .build-story.is-animated .build-story-steps { padding-block: 16px calc(var(--study-viewport) * .1); }
  .build-story.is-animated .build-story-step {
    min-height: max(340px, calc(var(--study-viewport) * .62));
    padding-block: 28px 44px;
    scroll-margin-top: var(--study-anchor-offset, 290px);
  }
}

/* Landscape phones use the desktop side-by-side composition so the barn and
   text stay visible together even with very little vertical room. */
@media (max-width: 800px) and (orientation: landscape) and (max-height: 500px) {
  .build-story.is-animated .build-story-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px;
  }
  .build-story.is-animated .blueprint-model {
    height: max(100px, calc(var(--study-viewport) - var(--study-header-height, var(--header)) - 115px));
  }
  .build-story.is-animated .blueprint-topline > span:first-child { display: none; }
  .build-story.is-animated .blueprint-caption > span:first-child { display: none; }
  .build-story.is-animated .blueprint-caption { min-height: 15px; }
  .build-story.is-animated .blueprint-progress { max-width: none; }
  .build-story.is-animated .blueprint-nav { gap: 8px; flex-wrap: wrap; }
  .build-story.is-animated .blueprint-nav > a { font-size: 8px; gap: 4px; }
  .build-story.is-animated .blueprint-nav > a > span { font-size: 16px; }
  .build-story.is-animated .build-story-step { min-height: calc(var(--study-viewport) * .75); }
}

@media print {
  .build-story.is-animated .build-story-steps { padding: 0; }
  .build-story.is-animated .build-story-step { min-height: 0; padding: 15px 0; }
}
