/*
 * Visible section rhythm.
 * --m365-section is the clearance from content to a background boundary.
 * Consecutive blocks on one uninterrupted background share ONE clearance.
 * Component padding (cards, tabs, forms and sticky navigation) stays local.
 */

/* A single owner for the gap at uninterrupted section joins. */
.m365-network + .m365-collections,
.m365-catalogue-browse + .m365-catalogue-cta {
    padding-block-start: 0;
}
.m365-workflow + .m365-footer {
    padding-block-start: 0;
}

/*
 * Align section titles to their capital-letter edge, not the font's line box.
 * No font sizes, letter spacing or inter-line spacing are changed.
 */
main :is(h1, h2) {
    text-box-trim: trim-start;
    text-box-edge: cap alphabetic;
}
.m365-section-heading,
.m365-tour-section-heading { align-items: start; }
.m365-collection-copy > .m365-text-link { margin-block-start: auto; }
.m365-tour-section-heading > p,
.m365-about-industries .m365-about-split > div > p:first-child,
.m365-about-promise .m365-about-split > div > p:first-child {
    text-box-trim: trim-start;
    text-box-edge: cap alphabetic;
}

/* Body copy at an exposed section edge must not add its own trailing leading. */
.m365-journey-stage > p,
.m365-finish-panel > p:last-child,
.m365-about-intro-grid > div > p:last-child,
.m365-about-benefits > div:last-child dd,
.m365-about-industries li,
.m365-about-promise .m365-about-promise-close,
.m365-workflow-overview-copy,
.m365-workflow-stage-copy > p:last-child,
.m365-proof-handover > p,
.m365-service-body > p:last-child,
.m365-product-gallery > .m365-image-note,
.m365-product-copy > .m365-product-note,
.m365-tour-process li > p,
.m365-tour .m365-tour-date-note {
    text-box-trim: trim-end;
    text-box-edge: cap alphabetic;
    margin-block-end: 0;
}
.m365-proof-handover > p { min-height: 0; }

/* A last inline action must end at the button, not at an extra baseline row. */
.m365-tour-city-copy > .m365-button,
.m365-tour-kit-copy > .m365-button,
.m365-service-brief > .m365-text-link,
.m365-policy-top {
    display: flex;
    width: fit-content;
    max-width: 100%;
}

/* Keep the last catalogue action on the card's actual bottom edge. */
.m365-product-card { display: flex; flex-direction: column; align-items: stretch; }
.m365-product-card .m365-add-product { align-self: flex-start; margin-block-start: auto; }
@media (max-width: 767px) {
    .m365-product-card .m365-add-product { align-self: stretch; }
}

/* Text-only and illustrated hero columns keep the same vertical centre. */
.m365-hero-grid,
.m365-service-hero-grid,
.m365-about-intro-grid,
.m365-tour-hero-grid,
.m365-product-layout { align-items: center; }

/*
 * Raleway fallback for older engines without text-box trimming.
 * Keep this limited to headings at section starts; do not move card titles.
 */
@supports not (text-box-trim: trim-start) {
    :is(.m365-hero-copy, .m365-about-intro-grid > div, .m365-service-hero-grid > div:first-child,
        .m365-tour-hero-copy, .m365-workflow-hero > .m365-container, .m365-policy-hero > .m365-container,
        .m365-catalogue-intro > div, .m365-product-copy, .m365-enquiry-copy) > h1:first-child,
    .m365-section-heading h2:first-child,
    .m365-featured-heading h2:first-child,
    .m365-tour-section-heading h2:first-child,
    .m365-section > .m365-container > h2:first-child {
        margin-block-start: -.16em;
    }
}
