/*
 * NEWS (list plugin news_pi1, see List.fluid.html of the theme's news templates)
 *
 * Post-its (template layout "postit", design B6): white cards 276 wide with orange border, close button "×" in an
 * orange circle at the top right, label (category or "Current news"), title, teaser and "Learn more" (E3 full width).
 * Narrow screens: below each other at the position of the plugin. From 64rem in a grid: the first at the top right,
 * the second below and the third left of the second (data-postit-position, see Postits.js). In the hero of the start
 * page (after cb_hero in the column "Hero") absolute at the top right of the hero, so they scroll away with it; if they
 * would cover a link or button of the hero, in the flow below the hero (.postits--inline, see Postits.js).
 *
 * Tiles (template layout "tiles", design C4): cards of the base list (.list__wrapper, .list--cards, see base.css)
 * with an orange label bar "Notice", title and teaser, no button: the link of the title covers the tile.
 * "Show more" is an E2 with arrow down at a spacing of 32.
 */


/* POST-ITS (B6) */

.postits {
    --postit--width: 17.25rem;
    --postit--gap  : var(--layout--gap--large);

    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--postit--gap);
}

.postits[hidden],
.postit[hidden] {
    display: none;
}

.postit {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: var(--postit--width);
    padding: var(--padding--default);
    border: var(--border-width--default) solid var(--color--orange);
    border-radius: var(--border-radius--default);
    background-color: var(--color--white);
    color: var(--color--dark-grey);
}

.postit:focus {
    outline: none;
}

.postit:focus-visible {
    outline: var(--outline-width--default) solid var(--color--dark-grey);
    outline-offset: var(--outline-offset--default);
}

/* Space for the close button */
.postit__label {
    margin: 0 var(--space--m) 0 0;
    font-size: var(--font-size--text-large);
    font-weight: var(--font-weight--bold);
    line-height: var(--line-height--single);
}

.postit__title {
    margin: var(--space--xs) 0 0;
	font-family: var(--font-family--text);
    font-size: var(--font-size--text-small);
    font-weight: var(--font-weight--bold);
    line-height: var(--line-height--text-small);
    hyphens: auto;
	word-spacing: unset;
}

.postit__text {
    margin: var(--space--xs) 0 0;
    font-size: var(--font-size--text-small);
    line-height: var(--line-height--text-small);
}

.postit__more {
    box-sizing: border-box;
    margin-top: var(--layout--gap--default);
}

:root:not([data-contrast-mode="active"]) .btn--accent.postit__more:hover {
	color: var(--color--white);
}

.postit__close {
    position: absolute;
    top: var(--space--s);
    right: var(--space--s);
	display: flex;
	justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    padding: 0;
    border: var(--border-width--default) solid var(--color--orange);
    border-radius: var(--border-radius--round);
    background-color: var(--color--white);
    color: var(--color--dark-grey);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.postit__close:hover {
    background-color: var(--color--orange);
    color: var(--color--white);
}

.postit__close:focus-visible {
    outline: var(--outline-width--default) solid var(--color--dark-grey);
    outline-offset: var(--outline-offset--default);
}

@media (min-width: 64rem) {
    /* Outside the hero (e.g. in the main content) in the flow, aligned right */
    .postits {
        display: grid;
        grid-template-columns: repeat(2, var(--postit--width));
        justify-content: end;
        align-items: start;
        /* The empty cell at the top left lets clicks through to the page */
        pointer-events: none;
    }

    .postit {
        pointer-events: auto;
        box-shadow: 0 .25rem 1rem rgb(0 0 0 / .12);
    }

    .postit[data-postit-position="1"] {
        grid-column: 2;
        grid-row: 1;
    }

    .postit[data-postit-position="2"] {
        grid-column: 2;
        grid-row: 2;
    }

    .postit[data-postit-position="3"] {
        grid-column: 1;
        grid-row: 2;
    }
}

/*
 * In the hero of the start page (column "Hero", colPos 1000, sorted after cb_hero): the post-its follow the hero in
 * the DOM and so in the tab order (header, hero, news, main content). Narrow screens: below the hero within the page
 * padding, with the distance of the hero to the main content.
 */
.hero > .content-element:has(.postits) {
    margin-top: 0;
}

.hero .postits {
    box-sizing: border-box;
    max-width: var(--page-max);
    margin: 0 auto var(--layout--gap--large);
    padding-inline: var(--page-pad);
}

@media (min-width: 64rem) {
    /*
     * Wide screens: absolute at the top right of the hero (reference box), aligned with the content of the page, so
     * they scroll away with the hero and don't cover the following content while tabbing through it. Below the sticky
     * header (z-index 100). The container of the content element would be the containing block (layout
     * containment), so it is removed.
     */
    .hero:has(.postits) {
        position: relative;
    }

    .hero > .content-element:has(.postits) {
        container-type: normal;
    }

    .hero .postits {
        position: absolute;
        z-index: 10;
        top: var(--layout--gap--large);
        right: calc((100% - min(100%, var(--page-max))) / 2 + var(--page-pad));
        max-width: none;
        margin: 0;
        padding: 0;
    }

    /*
     * Post-its covering a link or button of the hero (e.g. the linked stamp or the copyright of the image, checked
     * by Postits.js): in the flow below the hero side by side, aligned right like on narrow screens.
     */
    .hero .postits.postits--inline:not([hidden]) {
        position: static;
        display: flex;
        flex-flow: row wrap;
        justify-content: flex-end;
        align-items: flex-start;
        max-width: var(--page-max);
        margin: 0 auto var(--layout--gap--large);
        padding-inline: var(--page-pad);
        pointer-events: auto;
    }

    .postits--inline .postit {
        box-shadow: none;
    }
}

@media (forced-colors: active) {
    .postit,
    .postit__close {
        border-color: CanvasText;
    }
}


/* TILES (C4) */

/* Same specificity as the card of the base list, to replace its layout: the label bar reaches the border */
.list__wrapper.list--cards .list__item--news {
    position: relative;
    justify-content: flex-start;
    gap: 0;
    padding: 0;
    overflow: hidden;
}

/* After the content in the markup (title first for screen readers), shown above it */
.list__item--news .list__item__label {
    order: -1;
    margin: 0;
    padding: var(--space--s) var(--card--padding);
    font-size: var(--font-size--label);
    font-weight: var(--font-weight--bold);
    line-height: var(--line-height--single);
}

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

.list__item--news .list__item__title {
    margin: 0;
    font-size: var(--font-size--h3);
    font-weight: var(--font-weight--bold);
    line-height: var(--line-height--sub-headline);
    hyphens: auto;
}

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

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

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

/* The link covers the tile, the focus is drawn around the tile */
.list__item--news .list__item__link::before {
    content: "";
    position: absolute;
    inset: 0;
}

.list__item--news .list__item__link:focus-visible {
    outline: none;
}

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

.news-tiles__more {
    margin-top: var(--layout--gap--large);
}
