/*
 * CONTENT BLOCK DISTRIBUTOR (cb_distributor)
 * Grid and card (border, radius) of the base list (.list__wrapper, .list--cards, see base.css), the grid of the
 * field "grid" is the list--grid--1, --2 or --default. Tiles of a row have the same height.
 *
 * Default (layout wrapper class content-element--cb_distributor--default, design C1): title in the headline font,
 * teaser and an arrow in a circle at the bottom right. The link of the title covers the tile, on hover the title
 * is underlined.
 *
 * Colored label (content-element--cb_distributor--label, design C2): label bar in the surface of the item
 * (.surface--*, see variables.css), title, teaser and a button E1 in full width. On hover the button is filled in
 * the color of the label with the text color of its surface.
 *
 * Button next to the header (optional link of the element, e.g. "All projects"): button E1 with the width of its text.
 * From 45rem element width the header takes the first two thirds and the button is right-aligned in the last third,
 * vertically centered to the intro (subheader) of the header, without intro to the whole header. For that the header
 * shares the rows of the element grid (subgrid): the headline in the first, the intro next to the button in the second
 * row. The thirds match the three columns of the tiles (same gap). Below that width the button follows the header.
 */

/* Intro of the header in the size of the teaser of the tiles instead of the lead size */
.content-element--cb_distributor > .content-element__header .content-element__subheader {
    font-size: var(--font-size--text-small);
    line-height: var(--line-height--text-small);
}

/* Grid of the element, the header and the tiles span all columns unless placed otherwise */
.content-element--cb_distributor:has(> .cb-distributor__more) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--grid--gap);
}

.content-element--cb_distributor:has(> .cb-distributor__more) > * {
    grid-column: 1 / -1;
}

/* Same distance to the tiles as the header */
.content-element--cb_distributor > .cb-distributor__more {
    justify-self: start;
    margin-bottom: var(--content-element--header-gap);
}

@container content-element (min-width: 45rem) {
    .content-element--cb_distributor:has(> .cb-distributor__more) > .content-element__header {
        grid-column: 1 / span 2;
    }

    .content-element--cb_distributor > .cb-distributor__more {
        grid-column: 3;
        justify-self: end;
        align-self: center;
    }

    /*
     * With intro: header over two rows of the element grid, the button in the row of the intro. The distance to the
     * tiles moves from the header (its margin would enlarge the row of the intro) to the tiles, the button gets the
     * distance of the intro to the headline, so both are centered with the same margins.
     */
    .content-element--cb_distributor:has(> .cb-distributor__more):has(> .content-element__header .content-element__subheader) > .content-element__header {
        grid-row: span 2;
        display: grid;
        grid-template-rows: subgrid;
        margin-bottom: 0;
    }

    .content-element--cb_distributor:has(> .cb-distributor__more):has(> .content-element__header .content-element__subheader) > .cb-distributor__more {
        grid-row: 2;
        margin-top: var(--space--s);
        margin-bottom: 0;
    }

    .content-element--cb_distributor:has(> .cb-distributor__more):has(> .content-element__header .content-element__subheader) > .list__wrapper {
        margin-top: var(--content-element--header-gap);
    }
}

/* Same specificity as the card of the base list, to replace its layout */
.list__wrapper.list--cards .list__item--distributor {
    --distributor--arrow: 1.875rem;

    position: relative;
    justify-content: flex-start;
    gap: 0;
    overflow: hidden;
}

.list__item--distributor .list__item__title {
    margin: 0;
    hyphens: auto;
}

.list__item--distributor .list__item__text {
    margin: 0;
    font-size: var(--font-size--text-small);
    line-height: var(--line-height--text-small);
}


/* DEFAULT (C1) */

.content-element--cb_distributor--default .list__wrapper.list--cards .list__item--distributor {
    min-height: 13.125rem;
    padding-bottom: calc(var(--card--padding) * 2 + var(--distributor--arrow));
}

.content-element--cb_distributor--default .list__item__title {
    font-family: var(--font-family--headline);
    word-spacing: var(--word-spacing--headline);
    font-size: var(--font-size--cta);
    font-weight: var(--font-weight--regular);
    line-height: var(--line-height--cta);
}

.content-element--cb_distributor--default .list__item__text {
    margin-top: var(--space--xs);
}

.list__item--distributor .list__item__link {
    color: inherit;
    text-decoration: none;
}

.list__item--distributor .list__item__link:hover {
    text-decoration: underline;
    text-decoration-thickness: var(--text-decoration-thickness--regular);
    text-underline-offset: .15em;
}

/* The link covers the tile */
.list__item--distributor .list__item__link::before {
    content: "";
    position: absolute;
    inset: 0;
}

/* Arrow in a circle at the bottom right, drawn in the text color */
.list__item--distributor .list__item__link::after {
    content: "";
    position: absolute;
    right: var(--card--padding);
    bottom: var(--card--padding);
    width: var(--distributor--arrow);
    height: var(--distributor--arrow);
    background-color: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='butt' stroke-linejoin='miter'%3E%3Ccircle cx='15' cy='15' r='14'/%3E%3Cpath d='M8.5 15h11.5M16.5 10.5l4.5 4.5-4.5 4.5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Focus around the tile instead of the title */
.list__item--distributor .list__item__link:focus-visible {
    outline: none;
}

.list__item--distributor:has(.list__item__link:focus-visible) {
    outline: var(--outline-width--default) solid var(--surface--focus);
    outline-offset: var(--outline-offset--default);
}

/* Backgrounds are replaced in forced colors mode, keep the arrow in the link color */
@media (forced-colors: active) {
    .list__item--distributor .list__item__link::after {
        forced-color-adjust: none;
        background-color: LinkText;
    }
}


/* COLORED LABEL (C2): the label bar reaches the border of the card, the content below has the padding of the card */

.content-element--cb_distributor--label .list__wrapper.list--cards .list__item--distributor {
    padding: 0;
}

.list__item--distributor .list__item__label {
    margin: 0;
    padding: var(--space--s) var(--card--padding);
    font-size: var(--font-size--label);
    font-weight: var(--font-weight--regular);
    line-height: var(--line-height--single);
}

.list__item--distributor .list__item__content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: var(--card--padding);
}

.content-element--cb_distributor--label .list__item__title {
    font-size: var(--font-size--h3);
    font-weight: var(--font-weight--bold);
    line-height: var(--line-height--sub-headline);
}

.content-element--cb_distributor--label .list__item__text {
    margin-top: var(--space--xs);
}

/* Button at the bottom, so the buttons of a row are aligned, with a minimum distance to the text above */
.list__item--distributor .list__item__content > :has(+ .list__item__button) {
    margin-bottom: var(--space--s);
}

.list__item--distributor .list__item__button {
    box-sizing: border-box;
    margin-top: auto;
}

.list__item--distributor .list__item__button:hover {
    background-color: var(--surface--background);
    color: var(--surface--text);
}
