.flex {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
}

.flex.card {
    gap: 0 1rem;
    padding: 0 1.5rem;
}

ul.flex li.block {
    border-radius: 0.65rem;
    transition: background 0.3s ease;
}

ul.flex li.subheader {
    grid-column: 1/-1;
}

ul.flex.card li.subheader {
    padding: 0;
}

.flex .block:not(.subheader) {
    overflow: hidden;
}

.flex.card .block:not(.subheader) {
    min-height: 5rem;
}

.flex.stacked .block:not(.subheader) {
    margin-bottom: 0;
}

.flex.third {
    grid-template-columns: repeat(3, 1fr);
}

.flex.fourth {
    grid-template-columns: repeat(4, 1fr);
}

.flex.fifth {
    grid-template-columns: repeat(5, 1fr);
}

.flex .block.large,
.flex.card .block.large {
    grid-column: 1/-1;
}

.column {
    column-count: 3;
    margin: 1rem 0;
    line-height: 0;
}

.column > * {
    display: inline-block;
    width: 100%;
}

@media screen and (min-width: 451px) and (max-width: 900px) {
    .flex.flex.third {
        grid-template-columns: repeat(2, 1fr);
    }

    .flex.fourth {
        grid-template-columns: repeat(3, 1fr);
    }

    .flex.flex.fifth {
        grid-template-columns: repeat(4, 1fr);
    }

    .column {
        column-count: 2;
    }
}

@media screen and (max-width: 450px) {
    .flex,
    .flex.flex.third {
        grid-template-columns: repeat(1, 1fr);
    }

    .flex.fourth {
        grid-template-columns: repeat(2, 1fr);
    }

    .flex.flex.fifth {
        grid-template-columns: repeat(3, 1fr);
    }

    .column {
        column-count: 1;
    }
}

/* Gallery */

ul.flex.gallery li.block:not(.subheader) {
    min-height: 25rem;
}

ul.flex.gallery li.block.story {
    width: 10rem;
    height: 16rem;
    min-height: 0;
    padding: 0 0.5rem 0.5rem;
}

ul.flex.gallery li.block {
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

ul.flex.gallery li.block p a.node,
ul.flex.gallery li.block > img + span,
ul.flex.gallery li.block > span.primary,
ul.flex.gallery li.block > span.control {
    display: none;
}

ul.flex.gallery li.block div {
    flex: initial;
    margin-top: auto;
    width: 100%;
    z-index: 0; /* It seems that the img mask is applied on the div */
}

ul.flex.gallery li.block img.main {
    position: relative;
    opacity: 1;
    height: initial;
    max-height: 35rem;
    left: 0;
    top: 0;
    max-width: calc(100% + 3rem);
    width: calc(100% + 3rem);
    filter: none;
    flex: 0 0 60%;
    mask-image: linear-gradient(to bottom, black calc(100% - 20rem), transparent);
    margin-bottom: -10rem;
}

ul.flex.gallery li.block.story img.main {
    max-height: 100%;
    max-width: calc(100% + 1rem);
}

ul.flex.gallery li.block img.main:after {
    content: attr(alt);
}

ul.flex.gallery li.block.embed:before {
    font-family: 'Material Symbols';
    content: "\e02c";
    display: flex;
    align-items: center;
    font-size: 3rem;
    line-height: 5rem;
    opacity: 0.75;
    position: absolute;
    left: 1.5rem;
    z-index: 1;
}
