/*
 * ASIDE FLYOUT
 * Mobile first: the aside is a modal flyout, opened by a sticky toggle at the right edge.
 * From 48rem on (see AsideFlyout.js) it is rendered inline next to the main content.
 * Without JavaScript the aside is always rendered inline.
 */

.aside__panel > aside {
    padding: 1rem;
}

.aside__panel .content-element > .content-element__header {
	margin-bottom: var(--space--xs);
}

/* Module titles in Inter Bold 24 (design G1-G5), whatever headline level the editors choose */
.aside__panel .content-element > .content-element__header :is(h2, h3, h4, h5, h6) {
    font-family: var(--font-family--text);
    font-size: var(--font-size--h3);
    font-weight: var(--font-weight--bold);
    line-height: var(--line-height--sub-headline);
    word-spacing: normal;
}

/*
 * Texts of the modules in small text 16/24 like the contact person cards and the facts box (design G1-G5), not in the
 * normal text size of the text element (see Text.css). Also the intro (subheader) of the header instead of the lead
 * size, e.g. the teaser of the news box "Aktuelles" (cb_links).
 */
.aside__panel .cb-text :is(p, li),
.aside__panel .content-element > .content-element__header .content-element__subheader {
    font-size: var(--font-size--text-small);
    line-height: var(--line-height--text-small);
}

/*
 * Spacing between the modules of the contact column and the other modules (design G1: 32), also between columns that
 * don't stick (e.g. contact of artist groups)
 */
:is(.aside--sticky, .aside--content) + .aside--content {
    margin-top: var(--layout--gap--large);
}

/* TOGGLE: sticky tab at the right edge, vertically centered */
.aside__toggle {
    position: fixed;
    top: 50%;
    right: 0;
    z-index: 90;
    translate: 0 -50%;
    rotate: 180deg;
    writing-mode: vertical-rl;

    min-width: var(--target);
    min-height: var(--target);
    padding: 1rem .75rem;
    border: 1px solid transparent; /* visible in forced colors mode */
    border-radius: 0 .5rem .5rem 0; /* rotated: rounded on the left side */
    background: #000;
    color: #FFF;
    font: inherit;
    cursor: pointer;
}

.aside__toggle:focus-visible,
.aside__close:focus-visible {
    outline: .1875rem solid #000;
    outline-offset: .1875rem;
}

/* Without JavaScript the aside is rendered inline, flyout elements are hidden */
@media (scripting: none) {
    .aside__toggle,
    .aside__header,
    .aside__backdrop {
        display: none;
    }
}

@media (scripting: enabled) {
    /* Prevent scrolling of the page behind the open flyout */
    html:has(.aside__flyout[data-open]) {
        overflow: hidden;
    }

    .aside__flyout {
        position: fixed;
        inset: 0;
        z-index: 1000;
        visibility: hidden;
        transition: visibility 0s linear .3s;
    }

    .aside__flyout[data-open] {
        visibility: visible;
        transition-delay: 0s;
    }

    .aside__backdrop {
        position: absolute;
        inset: 0;
        background: rgb(0 0 0 / .5);
        opacity: 0;
        transition: opacity .3s;
    }

    .aside__flyout[data-open] .aside__backdrop {
        opacity: 1;
    }

    .aside__panel {
        position: absolute;
        inset-block: 0;
        right: 0;
        display: flex;
        flex-direction: column;
        width: 95vw;
        border-left: 1px solid transparent; /* visible in forced colors mode */
        background: #FFF;
        box-shadow: 0 0 1.5rem rgb(0 0 0 / .25);
        translate: 100% 0;
        transition: translate .3s ease;
    }

    .aside__flyout[data-open] .aside__panel {
        translate: 0 0;
    }

    /* Yellow header (surface--yellow, see Mobile_Aside_Open.png), the border is visible in forced colors mode */
    .aside__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: .5rem .5rem .5rem 1rem;
        border-bottom: 1px solid transparent;
    }

    .aside__title {
        margin: 0;
        font-family: var(--font-family--headline);
        font-size: var(--font-size--h4);
        font-weight: var(--font-weight--regular);
        line-height: var(--line-height--sub-headline);
    }

    .aside__close {
        display: inline-flex;
        flex-shrink: 0;
        align-items: center;
        justify-content: center;
        width: var(--target);
        height: var(--target);
        padding: 0;
        border: 2px solid currentColor;
        border-radius: 100%;
        background: none;
        color: inherit;
        cursor: pointer;
    }

    /* Decorative icon, overrides the global [aria-hidden="true"] rule in base.css */
    .aside__close svg {
        display: block;
    }

    .aside__panel > aside {
        flex: 1;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

/* The hidden header still labels the aside landmark via aria-labelledby */
@container page (min-width: 48rem) {
    .aside__toggle,
    .aside__header,
    .aside__backdrop {
        display: none;
    }

    .aside__flyout {
        position: static;
        z-index: auto;
        visibility: visible;
        transition: none;
    }

    .aside__panel {
        position: static;
        display: block;
        width: auto;
        border: 0;
        background: none;
        box-shadow: none;
        translate: none;
        transition: none;
    }

    /*
     * Inline the modules take the full column width (design G1: 378 of 1200). Panel and aside fill the stretched
     * grid cell of the aside, so the contact column can stick within the full height of the main content.
     * No scroll container, that would stop the sticky positioning.
     */
    .aside__panel,
    .aside__panel > aside {
        height: 100%;
    }

    .aside__panel > aside {
        padding: 0;
        overflow: visible;
    }

    /*
     * Contact column sticky below the scrolled header (height see .header--scrolled in layout.css, vw instead of
     * the cqi of the header, the scrollbar only adds a few pixels). The following modules scroll below it, the
     * background covers them. Only on high viewports, a sticky column higher than the viewport couldn't be read.
     */
    @media (min-height: 40em) {
        .aside--sticky {
            --aside--header-height: calc(clamp(2.75rem, 2.18rem + 2.431vw, 4.125rem) + 2 * clamp(.5rem, .396rem + .442vw, .75rem));

            position: sticky;
            top: calc(var(--aside--header-height) + var(--layout--gap--default));
            z-index: 1;
            background-color: var(--surface--background);
            /* Covers the gap to the header as well */
            box-shadow: 0 calc(-1 * var(--layout--gap--default)) 0 var(--surface--background);
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    .aside__flyout,
    .aside__backdrop,
    .aside__panel {
        transition: none;
    }
}
