/*
 * PARTNERS (plugin nrwkulturpartners_partners, member municipalities)
 *
 * Link list: small boxes in a grid, as many columns as fit with at least 10rem (four in the main column, two on
 * small viewports). The names may wrap, so the boxes grow with the text (no fixed height, WCAG 1.4.12). White boxes
 * with border like the buttons (also on light grey surfaces), on hover filled dark grey.
 *
 * Preview image: cards of the base list (.list__wrapper, .list--cards, see base.css), the image 4:3 reaches the
 * border of the card, the name links to the detail view and the link covers the whole card.
 *
 * Table: the names in four columns like a table (two on medium, one on small widths), each cell only with a bottom
 * border in the text color (also in the contrast mode), except the cells of the last row. The names may wrap, the cells of a row keep the same height,
 * the names stay at the top of the cell.
 *
 * Accordion: the accordion of the content element (see Accordion.css) in two independent columns (one on small widths),
 * first half of the items left, second half right. An open item only pushes down the items of its own column, so no
 * white space appears in the other column.
 */

.partners-list {
    --partners-list--background: var(--color--white);
    --partners-list--text      : var(--color--dark-grey);

    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(10rem, 100%), 1fr));
    gap: var(--layout--gap--small);
    list-style: none;
}

:root[data-contrast-mode="active"] .partners-list {
    --partners-list--background: #000000;
    --partners-list--text      : #FFFFFF;
}

.partners-list__item {
    display: flex;
}

.partners-list__link {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: var(--target);
    padding: var(--space--xs) var(--space--s);
    border: var(--border-width--default) solid var(--partners-list--text);
    border-radius: var(--border-radius--default);
    background-color: var(--partners-list--background);
    color: var(--partners-list--text);
    font-size: var(--font-size--text-small);
    line-height: var(--line-height--text-small);
    text-decoration: none;
    hyphens: auto;
    overflow-wrap: break-word;
}

a.partners-list__link:hover {
    background-color: var(--partners-list--text);
    color: var(--partners-list--background);
}

a.partners-list__link:focus-visible {
    outline: var(--outline-width--default) solid var(--partners-list--text);
    outline-offset: var(--outline-offset--default);
}


/* TABLE */

.partners-table {
    display: grid;
    grid-template-columns: 1fr;
    column-gap: var(--layout--gap--default);
    list-style: none;
}

@container content-element (min-width: 24rem) {
    .partners-table {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@container content-element (min-width: 40rem) {
    .partners-table {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.partners-table__item {
    display: flex;
    border-bottom: 1px solid currentColor;
}

/*
 * No bottom border in the last row: the first item of the last row (nth-child of the column count, within the last
 * items) and the items after it. The last row of fewer columns is always part of the last row of more columns, so the
 * rules of the smaller widths may stay active.
 */
.partners-table__item:last-child {
    border-bottom: 0;
}

@container content-element (min-width: 24rem) {
    .partners-table__item:nth-child(2n+1):nth-last-child(-n+2),
    .partners-table__item:nth-child(2n+1):nth-last-child(-n+2) ~ .partners-table__item {
        border-bottom: 0;
    }
}

@container content-element (min-width: 40rem) {
    .partners-table__item:nth-child(4n+1):nth-last-child(-n+4),
    .partners-table__item:nth-child(4n+1):nth-last-child(-n+4) ~ .partners-table__item {
        border-bottom: 0;
    }
}

.partners-table__link {
    display: flex;
    align-items: flex-start;
    width: 100%;
    min-height: var(--target);
    padding: var(--space--xs) 0;
    color: inherit;
    text-decoration: none;
    hyphens: auto;
    overflow-wrap: break-word;
}

/* Underline as thin as the bottom border of the cell, the regular thickness is too heavy for the small text */
a.partners-table__link:hover {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: .15em;
}

a.partners-table__link:focus-visible {
    outline: var(--outline-width--default) solid currentColor;
    outline-offset: var(--outline-offset--default);
}


/* PREVIEW IMAGE: same specificity as the card of the base list, to replace its padding */

.list__wrapper.list--cards .list__item--partner {
    position: relative;
    justify-content: flex-start;
    gap: 0;
    overflow: hidden;
    padding: 0;
}

/* Format classic (4:3, see ImageViewHelper), the box keeps it without image */
.list__item--partner .list__item__media {
    aspect-ratio: var(--ratio--classic);
    background-color: var(--color--light-grey);
}

.list__item--partner .list__item__image {
    height: 100%;
}

.list__item--partner .list__item__content {
    padding: var(--card--padding);
}

.list__item--partner .list__item__title {
    font-size: var(--font-size--h4);
    line-height: var(--line-height--sub-headline);
}

.list__item--partner a.list__item__link {
    text-decoration: none;
}

.list__item--partner a.list__item__link::after {
    content: "";
    position: absolute;
    inset: 0;
}

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

.list__item--partner:has(.list__item__link:focus-visible) {
    outline: var(--outline-width--default) solid var(--color--dark-grey);
    outline-offset: var(--outline-offset--default);
}


/* ACCORDION */

.partners-accordion {
    align-items: start;
}

/* Each column stacks its items on its own, an open item only moves the items below it in the same column */
.partners-accordion__column {
    display: grid;
    gap: var(--cb-accordion--gap);
    align-content: start;
}

.partners-accordion__column:not(:has(*)) {
    display: none;
}

@container content-element (min-width: 40rem) {
    .partners-accordion {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
