/**
 * Shared hero header and media engine.
 *
 * One shell (copy left, media right) for articles and tours. The media block
 * has three modes:
 *
 * - justified: rows of equal height, widths follow the photo ratio, no crop.
 * - lanes: equal-width column stacks with natural heights. PHP assigns the
 *   photos to the columns (`rx_hero_gallery_column_plan()`), so every engine
 *   renders the same packing and the grid can align whole columns.
 * - single: one photo at its natural ratio.
 *
 * All three are plain CSS Grid/Flex behaviour: no `@supports`, no masonry and
 * no multi-column balancing, so they render identically in every browser.
 *
 * Loaded on article and tour singles by `remotex_hero_header_assets()`.
 */

/* ------------------------------------------------------------------ shell */

.rx-hero {
    margin-block: var(--space-m) var(--space-s);
}

.rx-hero__inner {
    display: grid;
    align-items: center;
    gap: var(--space-l);
    padding-block-start: var(--space-l);
}

.rx-hero__inner--with-media {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
}

.rx-hero__copy h1 {
    margin-block-end: var(--space-s);
}

.rx-hero__copy .pill-primary {
    display: inline-block;
    margin-block-end: var(--space-xs);
}

.rx-hero__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-3xs) var(--space-s);
    margin-block-start: var(--space-s);
}

.rx-hero__meta > .rx-article-byline {
    margin: 0;
}

/* --------------------------------------------------------------- gallery */

.rx-hero-gallery {
    min-width: 0;
    max-width: 100%;
}

.rx-hero-gallery__item {
    min-width: 0;
    margin: 0;
    overflow: hidden;
}

.rx-hero-gallery__image {
    display: block;
    width: 100%;
    height: auto;
}

/* Justified rows: one height per row, widths allocated from each ratio. */
.rx-hero-gallery--justified {
    display: grid;
    gap: var(--rx-hero-gap, 8px);
}

.rx-hero-gallery__row {
    display: grid;
    grid-template-columns: var(--rx-hero-tracks);
    align-items: start;
    gap: var(--rx-hero-gap, 8px);
}

/* Single photo. */
.rx-hero-gallery--single .rx-hero-gallery__image {
    max-height: 32rem;
    object-fit: contain;
    border-radius: inherit;
}

/* Lanes: the component renders one `.rx-hero-gallery__col` stack per lane, so
   the grid's items are the columns. `align-items: center` therefore aligns the
   shorter columns against the tallest instead of leaving their bottoms ragged,
   and the layout stays a single-pass grid. The packing itself is decided in PHP
   (`rx_hero_gallery_column_plan()`), never by the browser. */
.rx-hero-gallery--lanes {
    display: grid;
    grid-template-columns: repeat(var(--rx-hero-lanes, 3), minmax(0, 1fr));
    gap: var(--rx-hero-gap, 8px);
    align-items: center;
}

.rx-hero-gallery--lanes > .rx-hero-gallery__col {
    display: grid;
    align-content: start;
    gap: inherit;
    min-width: 0;
}

.rx-hero-gallery--lanes .rx-hero-gallery__item {
    margin: 0;
}

.rx-hero-gallery--lanes .rx-hero-gallery__image {
    border-radius: inherit;
}

/* ----------------------------------------------------------------- mobile */

@media (max-width: 760px) {
    .rx-hero__inner--with-media {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-m);
    }

    /* Lanes: the inline `--rx-hero-lanes` wins over a custom-property override,
       so the two-column phone strip sets the tracks directly and flattens the
       column stacks: with the wrappers out of the way the photos flow in the
       grid itself, where centring single photos would only add gaps. */
    .rx-hero-gallery--lanes {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }

    .rx-hero-gallery--lanes > .rx-hero-gallery__col {
        display: contents;
    }

    .rx-hero-gallery--single .rx-hero-gallery__image {
        max-height: 52vh;
    }
}
