/*
 * HERO SECTION (Partials/Layout/HeroSection)
 * Breadcrumbs of record detail pages and pages above the hero, in the page max width. The hero image is part of the
 * hero (cb_hero or record hero, see Hero.css).
 *
 * Without hero (.hero-section): only the breadcrumbs, no extra space.
 * Mobile first: no breadcrumbs on small widths (see layout.css), so the hero section is hidden.
 *
 * On the hero (.hero-section--on-hero, cb_hero or record hero follows, see Hero.css): from 48rem page width on the
 * breadcrumbs are placed in the top clamp of the hero. The hero section is pulled over it by its negative bottom
 * margin. The float .hero-section__clamp follows the top edge of the hero by shape-outside, so the breadcrumbs wrap
 * along the diagonal instead of reaching into the hero. The hero has the page max width like the hero section, so
 * the float follows the same diagonal. Breadcrumbs higher than the clamp would reach into the hero, HeroSection.js
 * marks them by .hero-section--breadcrumbs-overflow and the hero starts below the breadcrumbs.
 */

.hero-section {
    /* Same clamp as cb_hero (see Hero.css), cqi of the page (body) */
    --hero-section--clamp        : clamp(2.5rem, 1.464rem + 4.42cqi, 5rem);
    --hero-section--gap          : var(--layout--gap--small);
    --hero-section--clamp-gap    : 0.25rem; /* vertical distance between breadcrumbs and hero edge */

    display: none;
    width: 100%;
    max-width: var(--page-max);
    margin-inline: auto;
}

.hero-section__breadcrumbs {
    padding: var(--hero-section--gap) var(--page-pad);
}

/* Inline breadcrumbs: line boxes wrap along the float shape (see below), flex and grid containers don't */
.hero-section__breadcrumbs nav.breadcrumb :is(ol, li) {
    display: inline;
}

.hero-section__breadcrumbs nav.breadcrumb li:not(:last-child) {
    margin-inline-end: .5em;
}

.hero-section__clamp {
    display: none;
}


@container page (min-width: 48rem) {
    .hero-section {
        display: grid;
    }

    /* ON THE HERO: breadcrumbs in its top clamp (see Hero.css) */
    .hero-section--on-hero {
        position: relative;
        z-index: 1;
        margin-bottom: calc(-1 * var(--hero-section--clamp));
    }

    .hero-section--on-hero .hero-section__breadcrumbs {
        min-height: var(--hero-section--clamp);
        padding: 0;
    }

    /*
     * Top padding only for the focus outline of the links (otherwise covered by the sticky header) and a compact
     * line height, as the clamp is flat and gets narrow quickly. The float stays at the top of the clamp.
     */
    .hero-section--on-hero .hero-section__breadcrumbs nav.breadcrumb {
        padding: calc(var(--outline-width--default) + var(--outline-offset--default)) var(--page-pad) 0;
        line-height: 1.25;
    }

    /* Breadcrumbs higher than the clamp (see HeroSection.js): the hero starts below them */
    .hero-section--breadcrumbs-overflow .hero-section__breadcrumbs {
        padding-bottom: var(--hero-section--gap);
    }

    .hero-section--on-hero.hero-section--breadcrumbs-overflow {
        margin-bottom: 0;
    }

    /*
     * Float in the full width, its shape is the hero area below the diagonal of the top clamp, moved up by
     * the clamp gap. No shape-margin: it is applied perpendicular to the flat diagonal and would cost a
     * multiple of its value in width.
     */
    .hero-section__clamp {
        display: block;
        float: right;
        width: 100%;
        height: var(--hero-section--clamp);
        shape-outside: polygon(
            0 calc(100% - var(--hero-section--clamp-gap)),
            100% calc(0% - var(--hero-section--clamp-gap)),
            100% 100%,
            0 100%
        );
    }
}
