/* The next opaque composition rises over the previous one in native scroll. */
.chapter-anchor { display: block; height: 0; min-height: 0; padding: 0; margin: 0; border: 0; scroll-margin-top: var(--chapter-anchor-margin, 0px); }
.chapter-card { display: flow-root; position: relative; width: 100%; background: var(--chapter-color, var(--cream)); }
.chapter-hold { display: none; pointer-events: none; }
.chapters-enabled > .chapter-hold:not(.chapter-terminal-hold) { display: block; height: var(--chapter-dwell, 0px); }
.chapters-enabled > .chapter-card {
  position: sticky;
  top: var(--chapter-top, var(--chapter-head, 0px));
  z-index: var(--chapter-layer, 1);
  min-height: calc(var(--chapter-view, 100svh) - var(--chapter-head, 0px));
  border-radius: clamp(18px, 2vw, 32px) clamp(18px, 2vw, 32px) 0 0;
  box-shadow: 0 -12px 35px #432b4615, 0 -1px 0 #432b4610;
}
/* Do not add overflow, transform, filter, or containment here: the services
   chapter owns a second, independent native sticky stage inside this card. */
.chapters-enabled > .chapter-card:not(.chapter-group):not(.chapter-nested):not(.chapter-opening) { display: flex; flex-direction: column; justify-content: center; }
.chapters-enabled > .chapter-card > :first-child { border-top-left-radius: inherit; border-top-right-radius: inherit; }
.chapters-enabled > .chapter-opening { border-radius: 0; box-shadow: none; }
.chapters-enabled > .chapter-final { position: relative; top: auto; }
.chapters-enabled > .chapter-card:not(.chapter-opening)::before {
  content: '';
  position: absolute;
  z-index: 0;
  inset: auto 0 calc(100% - 2px);
  height: clamp(55px, 11vw, 175px);
  pointer-events: none;
  opacity: var(--chapter-lead, 0);
  background: linear-gradient(117deg, var(--chapter-accent, var(--lilac)) 0% 28%, var(--chapter-color, var(--cream)) 28% 76%, var(--chapter-accent, var(--lilac)) 76%);
  clip-path: polygon(0 75%, 100% 0, 100% 100%, 0 100%);
}
.chapters-enabled > .chapter-card::after { content: ''; position: absolute; z-index: 30; inset: 0; border-radius: inherit; pointer-events: none; background: rgb(39 23 43 / .14); opacity: 0; }
/* Depth lives on leaf compositions. The chapter and the nested services'
   ancestors remain untransformed so scrolling, focus, and sticky still agree. */
.chapters-enabled > .chapter-card:not(.chapter-nested):not(.chapter-form) :is(.section-heading, .welcome-copy, .neighborhood-grid > div:first-child, .faq-section > div:first-child) {
  translate: 0 calc(var(--chapter-arrival, 0) * 26px - var(--chapter-cover, 0) * 26px);
}
.chapters-enabled > .chapter-card:not(.chapter-nested):not(.chapter-form) :is(.hero-art, .welcome-visual, .detail-photo) {
  translate: 0 calc(var(--chapter-arrival, 0) * 38px - var(--chapter-cover, 0) * 40px);
}
.chapters-enabled > .chapter-card:not(.chapter-nested):not(.chapter-form) :is(.hero-photo img, .welcome-visual > img, .detail-photo img) {
  scale: calc(1 + var(--chapter-cover, 0) * .065 + var(--chapter-arrival, 0) * .035);
}
/* Height eligibility is handled in JS using the stable mobile scene height. */
@media(max-width:359px), (prefers-reduced-motion:reduce), print {
  .chapters-enabled > .chapter-hold { display: none; }
  .chapters-enabled > .chapter-card { position: relative; top: auto; min-height: 0; border-radius: 0; box-shadow: none; }
  .chapters-enabled > .chapter-card::before, .chapters-enabled > .chapter-card::after { display: none; }
  .chapters-enabled > .chapter-card :is(.section-heading, .welcome-copy, .neighborhood-grid > div:first-child, .faq-section > div:first-child, .hero-art, .welcome-visual, .detail-photo) { translate: none !important; }
  .chapters-enabled > .chapter-card :is(.hero-photo img, .welcome-visual > img, .detail-photo img) { scale: none !important; }
}
