/* Shared Page V2 composition rhythm.
   One boundary owns one gap. Ordinary sections use 80/64/48px; rails use
   the protected-home reference of 64/48px. The home layout does not load
   this file and remains unchanged. */
.ab-page-document {
  --ab-flow-gap-standard: var(--ab-flow-gap-major);
  --ab-flow-gap-divider: calc(var(--ab-flow-gap-standard) / 2);
}

.ab-page-document [data-ab-flow-root]
  > :where(section, [data-ab-flow="section"], [data-ab-flow="compact"]):has(+ :where(section, [data-ab-flow="section"], [data-ab-flow="compact"])) {
  margin-block-end: 0;
  padding-block-end: 0;
}

.ab-page-document [data-ab-flow-root]
  > :where(section, [data-ab-flow="section"], [data-ab-flow="compact"])
  + :where(section, [data-ab-flow="section"], [data-ab-flow="compact"]) {
  margin-block-start: 0;
  padding-block-start: var(--ab-flow-gap-standard);
}

/* Some CMS fragments need a non-semantic wrapper. Marking that wrapper keeps
   tag choice from changing the page rhythm, while the last inner section
   surrenders its own trailing whitespace to the following root item. */
.ab-page-document [data-ab-flow-root]
  > [data-ab-flow="section"]:has(+ :where(section, [data-ab-flow="section"], [data-ab-flow="compact"]))
  > section:last-of-type {
  margin-block-end: 0;
  padding-block-end: 0;
}

.ab-page-document [data-ab-flow-root]
  > :where(section, [data-ab-flow="section"], [data-ab-flow="compact"])
  + [data-ab-flow="compact"] {
  padding-block-start: var(--ab-flow-gap-compact);
}

/* Filtered catalog renderers are intentionally wrapped in divs. Their
   internal 96px terminal padding and the next chapter gap must not stack. */
.ab-page-document [data-ab-flow-root]
  > :is(.ab-concierge__catalog-slot, .ab-service-catalog__module--catalog):has(+ :where(section, .ab-service-catalog__module))
  > .ab-category-catalog {
  padding-block-end: 0;
}

.ab-page-document [data-ab-flow-root]
  > :is(.ab-concierge__catalog-slot, .ab-service-catalog__module--catalog)
  + section:not([data-ab-flow="rail"]) {
  margin-block-start: 0;
  padding-block-start: var(--ab-flow-gap-standard);
}

.ab-page-document [data-ab-flow-root]
  > .ab-service-catalog__module--catalog
  + .ab-service-catalog__module
  > :where(section, .video) {
  margin-block-start: 0;
  padding-block-start: var(--ab-flow-gap-standard);
}

.ab-page-document [data-ab-flow-root] > [data-ab-flow="rail"],
.ab-page-document [data-ab-flow="rail"] {
  margin-block: var(--ab-flow-gap-section) 0;
  padding-block: 0;
}

.ab-page-document :where(section, div):has(+ [data-ab-flow="rail"]) {
  margin-block-end: 0;
  padding-block-end: 0;
}

.ab-page-document [data-ab-flow-root] > [data-ab-flow="rail"] + :where(section, div):not([data-ab-flow="rail"]),
.ab-page-document [data-ab-flow="rail"] + :where(section, div):not([data-ab-flow="rail"]) {
  margin-block-start: 0;
  padding-block-start: var(--ab-flow-gap-section);
}

/* The concierge CTA has a fixed, edge-to-edge media composition. Keep the
   family boundary outside the panel so flow spacing cannot shift and clip its
   inner collage. */
.ab-page-document--concierge [data-ab-flow-root] > .ab-concierge__cta {
  margin-block-start: var(--ab-flow-gap-standard);
  padding-block-start: 0;
}

.ab-page-document--concierge [data-ab-flow-root] > [data-ab-flow="rail"] + .ab-concierge__cta {
  margin-block-start: var(--ab-flow-gap-section);
  padding-block-start: 0;
}

/* About uses the same full-image terminal composition: keep the rail gap
   outside the panel so it does not become empty space inside the artwork. */
.ab-page-document--about [data-ab-flow-root] > [data-ab-flow="rail"] + .ab-about__cta {
  margin-block-start: var(--ab-flow-gap-section);
  padding-block-start: 0;
}

/* Reference CTAs are full-bleed media panels. Preserve the accepted pre-flow
   geometry by keeping the preceding section gap outside the panel instead of
   inflating its image-backed box. */
.ab-page-document--static-content [data-ab-flow-root] > section + .ab-static__cta {
  margin-block-start: var(--ab-flow-gap-standard);
  padding-block-start: 0;
}

.ab-page-document--static-content [data-ab-flow-root] > [data-ab-flow="rail"] + .ab-static__cta {
  margin-block-start: var(--ab-flow-gap-section);
  padding-block-start: 0;
}

@media (max-width: 64rem) {
  .ab-page-document {
    --ab-flow-gap-standard: var(--ab-flow-gap-section);
  }
}

@media (max-width: 48rem) {
  .ab-page-document {
    --ab-flow-gap-standard: var(--ab-flow-gap-compact);
    --ab-flow-gap-terminal: var(--ab-flow-gap-compact);
  }

  .ab-page-document [data-ab-flow-root] > [data-ab-flow="rail"],
  .ab-page-document [data-ab-flow="rail"] {
    margin-block-start: var(--ab-flow-gap-compact);
  }

  .ab-page-document [data-ab-flow-root] > [data-ab-flow="rail"] + :where(section, div):not([data-ab-flow="rail"]),
  .ab-page-document [data-ab-flow="rail"] + :where(section, div):not([data-ab-flow="rail"]) {
    padding-block-start: var(--ab-flow-gap-compact);
  }

  .ab-page-document--concierge [data-ab-flow-root] > [data-ab-flow="rail"] + .ab-concierge__cta {
    margin-block-start: var(--ab-flow-gap-compact);
    padding-block-start: 0;
  }

  .ab-page-document--about [data-ab-flow-root] > [data-ab-flow="rail"] + .ab-about__cta {
    margin-block-start: var(--ab-flow-gap-compact);
    padding-block-start: 0;
  }

  .ab-page-document--static-content [data-ab-flow-root] > section + .ab-static__cta {
    margin-block-start: var(--ab-flow-gap-compact);
    padding-block-start: 0;
  }

  .ab-page-document--static-content [data-ab-flow-root] > [data-ab-flow="rail"] + .ab-static__cta {
    margin-block-start: var(--ab-flow-gap-compact);
    padding-block-start: 0;
  }
}
