/*
 * CONTENT BLOCK MEDIA (cb_media)
 * Mobile first: one column, from 30rem element width on 2 columns for the layouts with 2 and 3 columns, from 45rem on
 * (main column at its max width, also next to the aside and in a frame, see BaseContentElement.css) the grid of 1-3
 * columns selected by the layout
 * (layout wrapper classes content-element--cb_media--grid-1 to grid-3, see Default layout). In the aside always one
 * column.
 * Images keep the format of the grid (21:9, 16:9, 4:3, see ImageViewHelper), videos use the same aspect ratio.
 */

.content-element--cb_media {
    --cb-media--aspect-ratio: 21 / 9;
}

.content-element--cb_media--grid-2 {
    --cb-media--aspect-ratio: 16 / 9;
}

.content-element--cb_media--grid-3 {
    --cb-media--aspect-ratio: 4 / 3;
}

.cb-media__list {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--layout--grid--gap--default);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* 2 and 3 columns: 2 columns from 30rem on (e.g. main column with collapsed aside), like the lists */
@container content-element (min-width: 30rem) {
    .content-element--cb_media:is(.content-element--cb_media--grid-2, .content-element--cb_media--grid-3) .cb-media__list {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Same specificity as the rule of 30rem */
@container content-element (min-width: 45rem) {
    .content-element--cb_media.content-element--cb_media--grid-3 .cb-media__list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/*
 * Aside: always one column like on mobile, the media take the full width of the aside whatever its width (e.g. the
 * flyout on tablets is wider than 30rem). Also the logos, the wide logos then without spanning 2 columns (would
 * create an implicit second column). The id outranks the rules of the layouts and the container queries.
 */
#aside__flyout .content-element--cb_media .cb-media__list {
    grid-template-columns: minmax(0, 1fr);
}

#aside__flyout .content-element--cb_media .cb-media__item {
    grid-column: auto;
}

.cb-media__figure {
    margin: 0;
}

.cb-media__image {
    display: block;
    width: 100%;
    height: auto;
}

.cb-media__video {
    aspect-ratio: var(--cb-media--aspect-ratio);
}

.cb-media__video > *,
.cb-media__video video,
.cb-media__video iframe {
    width: 100%;
    height: 100%;
}

/*
 * YouTube/Vimeo placeholder of the cookie consent (iframemanager.css): its rule div[data-service] makes it an
 * inline-block of min. 300px and is more specific than the rule above, so the video would not fill the box
 */
.cb-media__video > div[data-service] {
    display: block;
    width: 100%;
    height: 100%;
}

/* Rounded corners like the CTA with image (design D1), not for logos (see below) */
.content-element--cb_media:not(.content-element--cb_media--logos, .content-element--cb_media--logos-wide) :is(.cb-media__image, .cb-media__video) {
    overflow: hidden;
    border-radius: var(--border-radius--default);
}

.cb-media__audio {
    width: 100%;
}

.cb-media__caption {
    margin-top: var(--layout--gap--small);
    font-size: var(--font-size--text-small);
}

/* "Show more" as E2 with arrow down (see .btn--wide in base.css), 32 below the media like the event list (F6) */
.cb-media__more {
    margin-top: var(--layout--gap--large);
}

.cb-media__more[hidden] {
    display: none;
}


/*
 * LOGOS (layout "logos", design H3): boxes of the same height (5rem) in a grid of 3 equal columns (2 columns on
 * containers narrower than 30rem), so the logos are aligned in rows and columns whatever their number and format.
 * The logos keep their aspect ratio (object-fit: contain), centered in the box filling the column: wide logos are
 * limited by the column width, high logos get more height, which balances their visual weight. The boxes bring
 * their own space around the logos, so rows and columns have the same gap (default gap of .cb-media__list).
 * The footer keeps lower, left-aligned boxes (see #footer__bottom in layout.css).
 * Layout "logos-wide": the same boxes, but each spanning 2 of the 3 columns (the full width below 30rem), for wide
 * logos like logo combinations ("Doppel-Logos") which would be too small in one column.
 */

:is(.content-element--cb_media--logos, .content-element--cb_media--logos-wide) {
    --cb-media--logo-height: 5rem;
}

:is(.content-element--cb_media--logos, .content-element--cb_media--logos-wide) .cb-media__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@container content-element (min-width: 30rem) {
    :is(.content-element--cb_media--logos, .content-element--cb_media--logos-wide) .cb-media__list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.content-element--cb_media--logos-wide .cb-media__item {
    grid-column: span 2;
}

:is(.content-element--cb_media--logos, .content-element--cb_media--logos-wide) :is(.cb-media__frame, .cb-media__frame > a, .cb-media__image) {
    display: block;
    width: 100%;
    height: var(--cb-media--logo-height);
}

main :is(.content-element--cb_media--logos, .content-element--cb_media--logos-wide) .cb-media__item {
	border: 2px solid var(--color--light-grey);
	border-radius: var(--border-radius--default);
	padding: 1rem;
}

:is(.content-element--cb_media--logos, .content-element--cb_media--logos-wide) .cb-media__image {
    object-fit: contain;
    object-position: center;
}

:is(.content-element--cb_media--logos, .content-element--cb_media--logos-wide) .cb-media__caption {
    display: none;
}
