/* Column of header, hero, breadcrumbs, main and footer, only main grows (footer at the bottom of short pages) */
body {
    container: page / inline-size;

    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    margin: 0;
}

/*
 * Smooth scrolling of anchor links (e.g. back to top above the footer, skip link), only without reduced motion.
 * Scripts scrolling the page follow it too, unless they pass behavior "instant".
 */
@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/*
 * Anchor targets (e.g. #c123 of content elements) and focused elements stop below the sticky header instead of
 * behind it. Height of the scrolled header (--header-height--scrolled below, vw instead of cqi, the scrollbar only
 * adds a few pixels), the header is scrolled after the jump. Not on low viewports, the header is static there.
 */
html {
    scroll-padding-top: calc(clamp(2.75rem, 2.18rem + 2.431vw, 4.125rem) + 2 * clamp(.5rem, .396rem + .442vw, .75rem) + var(--layout--gap--default));
}

@media (max-height: 30em) {
    html { scroll-padding-top: 0; }
}

/*
 * PAGE HEADER (not the headers of content elements)
 * Mobile first, the items query the width of the header (container "header"):
 * - mobile  logo, accessibility button and hamburger button, search and language switch are part of the
 *           hamburger navigation
 * - 48rem   search and language switch in the service navigation
 * - 64rem   main navigation
 *
 * The logo fills the height of the header: mobile it is 66px high (as the scrolled desktop logo), from 48rem on
 * 247px × 124px (logo area of the design). The padding scales fluidly with the header width from 375px (12px)
 * to 1280px (24px, 172px header). The logo size is set in px, so it doesn't grow with the font size settings
 * (see AccessibilitySettings.js), but with the zoom.
 *
 * Scrolled (class header--scrolled, see Header.js) the header shrinks to 44px logo and 8px padding (60px header)
 * up to 66px logo and 12px padding (90px header), the logo keeps the height of the desktop hamburger button.
 *
 * Sticky with background so it stays visible on scroll, static on low viewports (zoom, landscape phones).
 * Colors follow --color--primary/--color--secondary, so the header is inverted in the contrast mode. The items
 * (main navigation, service navigation, language switch, hamburger button) are dark grey like the footer, the
 * logo stays in --color--secondary. In the contrast mode the items follow --color--secondary as well.
 */
#header {
    container: header / inline-size;
    --header--text: var(--color--dark-grey);

    /*
     * Sizes of the expanded and the scrolled header, used by .header__inner and for the margin below. The cqi
     * refer to the container "page" here, it has the width of the header.
     */
    --header-logo-max             : calc(100cqi - 2 * var(--page-pad) - 2 * var(--target) - 2 * var(--layout--gap--small));
    --header-pad--expanded        : clamp(.75rem, .439rem + 1.326cqi, 1.5rem);
    --header-logo-height--expanded: min(66px, var(--header-logo-max) / 2.23);
    --header-logo-width--expanded : calc(var(--header-logo-height--expanded) * 2.23);
    --header-pad--scrolled        : clamp(.5rem, .396rem + .442cqi, .75rem);
    --header-logo-height--scrolled: min(clamp(2.75rem, 2.18rem + 2.431cqi, 4.125rem), var(--header-logo-max) / 2.23);
    --header-logo-width--scrolled : calc(var(--header-logo-height--scrolled) * 2.23);
    /* At least as high as the buttons, they are higher than the limited logo at large font sizes */
    --header-height--expanded     : calc(max(var(--header-logo-height--expanded), var(--target)) + 2 * var(--header-pad--expanded));
    --header-height--scrolled     : calc(max(var(--header-logo-height--scrolled), var(--target)) + 2 * var(--header-pad--scrolled));

    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--color--primary);
    color: var(--header--text);
}

@container page (min-width: 48rem) {
    #header {
        --header-logo-width--expanded : min(247px, var(--header-logo-max));
        --header-logo-height--expanded: calc(var(--header-logo-width--expanded) * 124 / 247);
    }
}

/*
 * The scrolled header keeps the space of the expanded header as margin, so shrinking doesn't move the content and
 * the page height stays the same. Otherwise the content would move up after jumping to an anchor and the target
 * would end up behind the header.
 */
#header.header--scrolled {
    margin-bottom: calc(var(--header-height--expanded) - var(--header-height--scrolled));
}

:root[data-contrast-mode="active"] #header {
    --header--text: var(--color--secondary);
}

/*
 * Same outer spacing as main: page max width and page padding.
 *
 * The logo is at most as wide as the mobile header leaves space for it (next to the accessibility and hamburger
 * button), otherwise the header would overflow the viewport. Mobile and scrolled the logo area has the ratio of
 * the SVG (2.23:1), from 48rem on the ratio 247:124 of the design and the SVG is contained in it.
 */
.header__inner {
    --header-pad        : var(--header-pad--expanded);
    --header-logo-height: var(--header-logo-height--expanded);
    --header-logo-width : var(--header-logo-width--expanded);
    --header-height     : var(--header-height--expanded);

    display: flex;
    align-items: center;
    gap: var(--layout--gap--small);
    height: var(--header-height);
    max-width: var(--page-max);
    margin-inline: auto;
    padding: var(--header-pad) var(--page-pad);
}

.header--scrolled .header__inner {
    --header-pad        : var(--header-pad--scrolled);
    --header-logo-height: var(--header-logo-height--scrolled);
    --header-logo-width : var(--header-logo-width--scrolled);
    --header-height     : var(--header-height--scrolled);
}

@media (prefers-reduced-motion: no-preference) {
    #header {
        transition: margin-bottom .2s;
    }

    .header__inner,
    #header__logo {
        transition: width .2s, height .2s, padding .2s;
    }
}

/* Visible focus for all items of the header, in the text color of the header (hamburger navigation see below) */
#header :is(a, button, input):focus-visible {
    outline: 2px solid var(--header--text);
    outline-offset: 2px;
}


/* LOGO: inline SVG in the text color, the link is the target for the focus outline */

#header__logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    width: var(--header-logo-width);
    height: var(--header-logo-height);
    margin-right: auto;
    color: var(--color--secondary);
    text-decoration: none;
}

#header__logo:focus-visible {
    outline-offset: 4px;
}

/* Contained in the logo area (preserveAspectRatio of the SVG), vertically centered */
.header__logo__image {
    display: block;
    width: 100%;
    height: 100%;
}


/* MAIN NAVIGATION: from 64rem on, mobile it is part of the hamburger navigation */

#navigation__main {
    display: none;
}


/* SERVICE NAVIGATION: mobile only the accessibility button, search and language switch from 48rem on */

#navigation__service {
    display: flex;
    align-items: center;
    gap: var(--layout--gap--small);
    height: var(--target);
}

#navigation__service > div {
    height: 100%;
}

#navigation__service--search,
#navigation__service--language {
    display: none;
}

/* Only the buttons of the service navigation itself, not the ones in the accessibility settings */
#navigation__service > div > button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--target);
    min-height: var(--target);
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

/* Circle around the icon, the parent id is needed to override the border reset of the buttons above */
#navigation__service > #navigation__service--search > button,
#navigation__service > #navigation__service--accessibility > button {
    position: relative;
    border: var(--border-width--default) solid currentColor;
    border-radius: var(--border-radius--round);
}

/* Icon as mask over the whole button incl. border (view box of the icons, see variables.css), in the text color */
#navigation__service--search > button::before,
#navigation__service--accessibility > button::before {
    content: "";
    position: absolute;
    inset: -2px;
    background-color: currentColor;
    mask: var(--header--icon) center / contain no-repeat;
}

#navigation__service--search > button        { --header--icon: var(--icon--search); }
#navigation__service--accessibility > button { --header--icon: var(--icon--accessibility); }

/*
 * Hover: filled like the open state (see HeaderSearch.css and AccessibilitySettings.css), only on devices with hover,
 * otherwise the state would stick after a tap on touch devices
 */
@media (hover: hover) {
    #navigation__service--search > button:hover,
    #navigation__service--accessibility > button:hover {
        background-color: var(--header--text);
        color: var(--color--primary);
    }
}

/* Backgrounds are replaced in forced colors mode, keep the icons in the button text color */
@media (forced-colors: active) {
    #navigation__service--search > button::before,
    #navigation__service--accessibility > button::before {
        forced-color-adjust: none;
        background-color: ButtonText;
    }
}


/*
 * LANGUAGE SWITCH: pill with the languages separated by "/", in the service navigation (from 48rem on) and on
 * top of the hamburger navigation (mobile). In the header as high as the search and accessibility buttons.
 *
 * The languages are close together: the targets are only as wide as the text plus a small padding, but at
 * least 24px (WCAG 2.5.8), they fill the height of the pill. The height is set in rem, so it grows with the
 * font size (up to 200%).
 */
.navigation__language {
    --language--height: 2.25rem;

    align-items: center;
    width: fit-content;
    height: var(--language--height);
    padding: 0 .5rem;
    border: 2px solid currentColor;
    border-radius: var(--border-radius--round);
    list-style: none;
    text-transform: uppercase;
}

#navigation__service--language {
    --language--height: var(--target);
}

/* Flex, so the separator stays in one line with the language */
.navigation__language li {
    display: flex;
    align-items: center;
    height: 100%;
}

.navigation__language li:last-child::before {
    content: "/";
}

.navigation__language :is(a, span) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-width: 1.5rem;
    padding-inline: .25rem;
    color: inherit;
    text-decoration: none;
}

.navigation__language a:hover {
    text-decoration: underline;
}

/* Current language (or not available in the current language) */
.navigation__language span {
    font-weight: var(--font-weight--semibold);
}


/*
 * HAMBURGER BUTTON: round, the bars become a cross when the navigation is open. The button lies above the open
 * navigation and is inverted then (outline in the text color of the navigation), the label "Close" is placed
 * left of it. The label is part of the button, so it is clickable as well.
 */

#hamburger {
    --hamburger-size: var(--target);
    --bar           : .125rem;
    --bar-gap       : .3125rem;

    /* Keep the round shape, the header items must not shrink it on small widths */
    flex-shrink: 0;

    position: relative;
    z-index: 1;
    padding: 0;
    border: 0;
    border-radius: 100%;
    background: none;
    color: var(--color--primary);
    font: inherit;
    cursor: pointer;
}

/*
 * The header inner is limited to the page max width and centered, the panel lies at the right edge of the viewport.
 * On wide viewports the open button moves by the outer margin of the header inner, so it is at the right edge of the
 * panel (page padding from the viewport edge) as on mobile. 100cqi is the width of the header container.
 */
#hamburger[aria-expanded="true"] {
    color: #fff;
    translate: max(0px, (100cqi - var(--page-max)) / 2) 0;
}

@media (prefers-reduced-motion: no-preference) {
    #hamburger {
        transition: translate .3s ease-in-out;
    }
}

#hamburger[aria-expanded="true"]:focus-visible {
    outline-color: currentColor;
}

.hamburger__icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--bar-gap);
    width: var(--hamburger-size);
    height: var(--hamburger-size);
    padding: .75rem;
    border: 2px solid transparent;
    border-radius: 100%;
    background: var(--header--text);
}

#hamburger[aria-expanded="true"] .hamburger__icon {
    border-color: currentColor;
    background: none;
}

.hamburger__label {
    display: none;
    position: absolute;
    top: 50%;
    right: 100%;
    padding-right: var(--layout--gap--default);
    translate: 0 -50%;
    font-size: var(--font-size--text-large);
    white-space: nowrap;
}

#hamburger[aria-expanded="true"] .hamburger__label {
    display: block;
}

/*
 * The label is white and only readable on the dark panel: it fades in when the panel has unfolded (delay = duration
 * of the panel, --hamburger--duration of #navigation__hamburger), not right on click
 */
@media (prefers-reduced-motion: no-preference) {
    #hamburger[aria-expanded="true"] .hamburger__label {
        animation: hamburger__label--in .2s .3s both;
    }
}

@keyframes hamburger__label--in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.burger__bar {
    display: block;
    height: var(--bar);
    background: currentColor;
}

#hamburger[aria-expanded="true"] .burger__bar:nth-child(1) {
    transform: translateY(calc(var(--bar) + var(--bar-gap))) rotate(45deg);
}

#hamburger[aria-expanded="true"] .burger__bar:nth-child(2) {
    opacity: 0;
}

#hamburger[aria-expanded="true"] .burger__bar:nth-child(3) {
    transform: translateY(calc(-1 * (var(--bar) + var(--bar-gap)))) rotate(-45deg);
}

@media (prefers-reduced-motion: no-preference) {
    .burger__bar { transition: transform .2s, opacity .2s; }
}

/* Bars are drawn as background, keep them in the button text color in forced colors mode */
@media (forced-colors: active) {
    .burger__bar {
        forced-color-adjust: none;
        background: ButtonText;
    }
}


/*
 * HAMBURGER NAVIGATION: panel at the top right corner below the hamburger button, in the full height of the
 * viewport and scrollable if its content is higher. Mobile first 95% of the header width, 70% from 48rem on,
 * 40% from 64rem on (cqi of the header container, i.e. the viewport width without scrollbar).
 *
 * #header is a size container and therefore the containing block of fixed descendants too, so the panel is
 * positioned absolute in the header. The sticky header always starts at the top of the viewport.
 *
 * Opens like the program filter (see ProgramFilter.css): it unfolds from the top right corner to the left and
 * downwards, display is transitioned discretely so the panel stays visible until the closing animation ended.
 */

#navigation__hamburger {
    --hamburger--width   : 95cqi;
    --hamburger--duration: .3s;
    --hamburger--clip--closed: inset(0 0 100% 100%);
    --hamburger--clip--open  : inset(0);

    display: none;
    position: absolute;
    top: 0;
    right: 0;
    width: var(--hamburger--width);
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--color--dark-grey);

    clip-path: var(--hamburger--clip--closed);
    transition:
        clip-path var(--hamburger--duration) ease-in-out,
        display   var(--hamburger--duration) allow-discrete;
}

#navigation__hamburger[aria-hidden="false"] {
    display: block;
    clip-path: var(--hamburger--clip--open);
}

@starting-style {
    #navigation__hamburger[aria-hidden="false"] {
        clip-path: var(--hamburger--clip--closed);
    }
}

@media (prefers-reduced-motion: reduce) {
    #navigation__hamburger {
        transition: none;
    }
}

/*
 * The content starts below the hamburger button. Padding and font size scale with the width of the panel
 * (container navigation__hamburger), so the longest items ("Für Mitglieder") fit in one line.
 */
#navigation__hamburger__inner {
    container: navigation__hamburger / inline-size;
    --hamburger--pad      : clamp(var(--page-pad), 10cqi, 6.5rem);
    --hamburger--font-size: clamp(1.5rem, 8cqi, 3.25rem);

    padding: calc(var(--header-height) + var(--layout--gap--default)) 0 var(--layout--gap--large);
    color: #fff;
}

#navigation__hamburger__inner :is(a, button, input):focus-visible {
    outline-color: currentColor;
    outline-offset: -4px;
}

/* Menu items only, the language switch (mobile) on top of the navigation is a list with links as well */
.navigation__hamburger__menubar {
    list-style: none;
    font-family: var(--font-family--headline);
    font-size: var(--hamburger--font-size);
    line-height: var(--line-height--h1);
}

.navigation__hamburger__menubar a {
    display: block;
    padding: .25rem var(--hamburger--pad);
    color: inherit;
    text-decoration: none;
}

.navigation__hamburger__menubar li.spacer {
    padding-top: var(--hamburger--font-size);
}

/*
 * Last group (from the last spacer on, e.g. legal pages) in small font size. :last-of-type would select the
 * last li regardless of its class, the last spacer is the one without a following spacer.
 */
.navigation__hamburger__menubar li.spacer:not(:has(~ li.spacer)),
.navigation__hamburger__menubar li.spacer:not(:has(~ li.spacer)) ~ li {
    font-size: max(1rem, .6 * var(--hamburger--font-size));
}

.navigation__hamburger__menubar a:hover,
.navigation__hamburger__menubar a[aria-current] {
    text-decoration: underline;
}

/*
 * Language switch and search on top of the hamburger navigation, mobile only (see above). The language switch
 * as in the header (see above) but as high as the search, so both are large enough targets.
 */
#navigation__hamburger__inner #navigation__hamburger--language {
    --language--height: var(--target);

    display: flex;
    margin: 0 var(--hamburger--pad) var(--layout--gap--default);
}

/*
 * Search field and button in one pill (Layout/SearchForm), on top of the hamburger navigation and in the search
 * panel of the header (see HeaderSearch.css): the button is round with the search icon (text for screen readers),
 * so it keeps its size when the font size is increased. The pill shows the focus of the input.
 */
.navigation__search {
    display: flex;
    align-items: center;
    border: 2px solid currentColor;
    border-radius: var(--border-radius--round);
}

#navigation__hamburger--search {
    margin: 0 var(--hamburger--pad) var(--layout--gap--large);
}

.navigation__search:has(input:focus-visible) {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.navigation__search input {
    flex: 1;
    min-width: 0;
    min-height: var(--target);
    padding: 0 0 0 1rem;
    border: 0;
    appearance: none;
    background: transparent;
    color: inherit;
    font: inherit;
}

#header .navigation__search input:focus-visible {
    outline: none;
}

.navigation__search button {
    position: relative;
    flex-shrink: 0;
    width: var(--target);
    height: var(--target);
    padding: 0;
    border: 0;
    border-radius: 100%;
    background: none;
    color: inherit;
    cursor: pointer;
}

.navigation__search button::before {
    content: "";
    position: absolute;
    inset: 0;
    background-color: currentColor;
    mask: var(--icon--search) center / contain no-repeat;
}

@media (forced-colors: active) {
    .navigation__search button::before {
        forced-color-adjust: none;
        background-color: ButtonText;
    }
}


@container header (min-width: 48rem) {
    #navigation__service--search,
    #navigation__service--language {
        display: flex;
    }

    #navigation__hamburger__inner :is(#navigation__hamburger--language, #navigation__hamburger--search) {
        display: none;
    }

    #navigation__hamburger { --hamburger--width: 70cqi; }
}

@container header (min-width: 64rem) {
    .header__inner {
        gap: var(--space--m);
    }

    #header__logo { margin-right: 0; }

    #navigation__main { display: flex; flex: 1; justify-content: center; }
    #navigation__main ul { display: flex; flex-wrap: wrap; gap: var(--space--xs) var(--space--l); list-style: none; }
    #navigation__main ul a {
        display: block;
        padding: var(--space--xs) 0;
        color: inherit;
        font-size: var(--font-size--navigation);
        font-weight: var(--font-weight--medium);
        line-height: var(--line-height--text-large);
        text-decoration: none;
    }

    #navigation__main ul a:hover,
    #navigation__main ul a[aria-current] {
        text-decoration: underline;
    }

    /* 70px in the design (one grid column) */
    #hamburger {
        --hamburger-size: calc(1.5 * var(--target));
        --bar           : .1875rem;
        --bar-gap       : .5rem;
    }

    .hamburger__icon { padding: 1rem; }

    #navigation__hamburger { --hamburger--width: 40cqi; }
}

@media (max-height: 30em) {
    #header { position: static; }
}

/* Breadcrumbs from 48rem on, mobile the hamburger navigation is sufficient. Small text (16px), not the body text */
nav.breadcrumb {
    display: none;
    font-size: var(--font-size--text-small);
    line-height: var(--line-height--text-small);
}

@container page (min-width: 48rem) {
    nav.breadcrumb {
        display: block;
    }
}

/* Links without underline, identified by the separators, underlined on hover */
nav.breadcrumb a {
    text-decoration: none;
}

nav.breadcrumb a:hover {
    text-decoration: underline;
}

nav.breadcrumb ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: .5em;
}

/* Separator arrow between the items, decorative (not read by screen readers), drawn in the text color */
nav.breadcrumb li + li::before {
    content: "";
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-inline-end: .5em;
    vertical-align: -0.125em;
    background-color: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='butt' stroke-linejoin='miter'%3E%3Cpath d='M2 8h10M9 4l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Backgrounds are replaced in forced colors mode, keep the arrow in the text color */
@media (forced-colors: active) {
    nav.breadcrumb li + li::before {
        forced-color-adjust: none;
        background-color: CanvasText;
    }
}


/*
 * MAIN: hero and main content (see Page layout), so the h1 of the hero is part of the main landmark. A column like the
 * body before, so the hero is laid out as a body child; main grows, the footer stays at the bottom of short pages.
 */
main {
    flex-grow: 1;

    display: flex;
    flex-direction: column;
}

/* MAIN CONTENT: grid of the title, main content, aside and bottom content */
#main__content {
    flex-grow: 1;

    display: grid;
    grid-template-columns: repeat(var(--grid--columns), minmax(0, 1fr));
    align-content: start;
    /*
     * 12 columns with 32px gap from 48rem on: main content 790 and aside 378 of the 1200px content width
     * (design F1, G1). Below all areas span the full width, the 11 gaps (352px) would overflow 320px (WCAG 1.4.10).
     */
    gap: var(--section--gap) 0;

    width: 100%;
    max-width: var(--page-max);

    margin-inline: auto;
    padding-inline: var(--page-pad);
    padding-bottom: var(--section--gap);
}

#main__title,
#main__inner,
#main__inner--bottom,
#aside__flyout {
    grid-column: 1 / -1;
    min-width: 0
}

/*
 * More space between the elements of the main content (sections of the page, design) than between the content
 * elements within a section or the aside. Also the elements of record detail pages (e.g. funding programs).
 */
#main__inner > .content-element + .content-element,
#main__inner .record-detail__elements > .content-element + .content-element {
    margin-top: var(--section--gap);
}

/* Without hero the main content follows the breadcrumbs directly (see HeroSection.css), the hero brings no space */
.hero-section:not(.hero-section--on-hero) + main {
    padding-top: var(--layout--gap--large);
}

/* Page title above the main content, closer to it than the section gap */
#main__title {
    margin-bottom: calc(var(--layout--gap--default) - var(--section--gap));
}

@container page (min-width: 48rem) {
    #main__content {
        column-gap: var(--grid--gap);
    }

    /* The title reaches into the aside (10 of 12 columns), main content and aside follow in the next row */
    #main__title {
        grid-column: 1 / span 10;
    }

    #main__content:has(> #aside__flyout) > #main__inner:not(#main__inner--bottom) {
        grid-column: span 8;
    }
    #aside__flyout {
        grid-column: span 4;
    }
    #main__inner--bottom {
        grid-column: 1 / -1;
    }
}

@container page (min-width: 64rem) {
    #main__content { --grid--gap: 2rem; }
}

/*
 * PAGE FOOTER
 * Mobile first, the areas query the width of the footer (container "footer"):
 * - top     content segments (contact, questions, newsletter, links, social media) one below the other,
 *           from 48rem on side by side (wrapping), from 64rem on in one row, evenly distributed in between
 * - bottom  logos (funded by, media partners) one below the other, from 48rem on side by side, two columns each,
 *           from 64rem on media partners on the axis of the newsletter (common column grid, see #footer__content)
 *
 * The segments of the top area take the width of their content. Their content elements are no size containers
 * (see BaseContentElement.css), otherwise their content width would be 0 in the row. The components show their
 * mobile styles there, as their @container content-element (min-width: ...) queries don't match.
 *
 * White on dark grey (design H1), in the contrast mode white on black with a white line above, not inverted: the logos
 * are white for the dark background. Focus styles of the content elements in currentColor (see BaseContentElement.css).
 * Only the page footer (body > footer), not the <footer> of the record details (e.g. "back to the list" of news).
 */
body > footer {
    background-color: var(--color--dark-grey);
    color: var(--color--white);
}

:root[data-contrast-mode="active"] body > footer {
    background-color: #000000;
    color: #FFFFFF;
}

/* The line above the footer area is drawn below "back to top", which lies on the page surface and covers the footer top */
:root[data-contrast-mode="active"] #footer__to-top {
    border-bottom: var(--border-width--default) solid #FFFFFF;
}

/*
 * Texts of the footer in small text 16/24 (design H1), not in the normal text size of the text element (see Text.css).
 * The headlines of the logos have the same size (see #footer__bottom below).
 */
body > footer,
body > footer .cb-text :is(p, li) {
    font-size: var(--font-size--text-small);
    line-height: var(--line-height--footer);
}

/*
 * Links without underline, underlined on hover. The links of the footer stand alone (link list, contact), so they
 * are identified by their position, not by color only (WCAG 1.4.1).
 */
body > footer a:not(.btn),
body > footer .cb-text a:not(.btn) {
    text-decoration: none;
}

body > footer a:not(.btn):hover,
body > footer .cb-text a:not(.btn):hover {
    text-decoration: underline;
}

/*
 * Social media icon buttons of the footer: white with dark grey icon (design H1), inverted on hover. In the contrast
 * mode white with black icon on the black footer (contrast colors of all buttons, see base.css).
 */
body > footer .btn--social {
    --btn--background: var(--color--dark-grey);
    --btn--text      : var(--color--white);
    --btn--border    : var(--color--white);
}

/*
 * BACK TO TOP above the footer: arrow up in a circle like the arrows of the distributor and the CTA, right-aligned to
 * the content width, on the surface of the page (full width, so the dark grey of the footer only starts below it).
 * The link is a 44px target around the 30px arrow. On hover the circle is filled with the arrow cut out, like the
 * header buttons. The label is for screen readers only (see Partials/Layout/Footer).
 */
#footer__to-top {
    --footer--to-top--arrow: 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%3Cpath d='M15 21.5V10M10.5 13.5l4.5-4.5 4.5 4.5'/%3E%3C/svg%3E");
    --footer--to-top--circle: 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'%3E%3Ccircle cx='15' cy='15' r='14'/%3E%3C/svg%3E");
    --footer--to-top--disc: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Ccircle cx='15' cy='15' r='15'/%3E%3C/svg%3E");

    display: flex;
    justify-content: flex-end;
    /* Content width of the page like main and the footer content */
    /* The section gap at the end of main above, 2rem below to the footer */
    padding: 0 max(var(--page-pad), calc((100% - var(--page-max)) / 2 + var(--page-pad))) var(--layout--gap--large);
    background-color: var(--surface--background);
    color: var(--surface--text);
}

#footer__to-top__link {
    display: block;
    width: var(--target);
    height: var(--target);
    /* The arrow at the right edge of the content, the rest of the target around it */
    margin-right: calc((1.875rem - var(--target)) / 2);
    color: inherit;
}

#footer__to-top__link::before {
    content: "";
    display: block;
    width: 1.875rem;
    height: 1.875rem;
    margin: calc((var(--target) - 1.875rem) / 2);
    background-color: currentColor;
    mask: var(--footer--to-top--arrow) center / contain no-repeat, var(--footer--to-top--circle) center / contain no-repeat;
}

#footer__to-top__link:hover::before {
    mask: var(--footer--to-top--arrow) center / contain no-repeat, var(--footer--to-top--disc) center / contain no-repeat;
    mask-composite: exclude;
}

/* Abbreviation of phone numbers in the footer texts ("T", "M", see lib.footer.phoneLabels), no dotted underline */
#footer__top abbr[title] {
    text-decoration: none;
}

/* Around the circle like the other focus rings (default offset), not around the larger target */
#footer__to-top__link:focus-visible {
    outline: var(--outline-width--default) solid var(--surface--focus);
    outline-offset: calc((1.875rem - var(--target)) / 2 + var(--outline-offset--default));
    border-radius: var(--border-radius--round);
}

/* Backgrounds are replaced in forced colors mode, keep the arrow in the link color */
@media (forced-colors: active) {
    #footer__to-top__link::before {
        forced-color-adjust: none;
        background-color: LinkText;
    }
}

#footer__inner {
    container: footer / inline-size;

    max-width: var(--page-max);
    margin-inline: auto;
    padding: var(--layout--gap--large) var(--page-pad);
}

#footer__content {
    display: flex;
    flex-direction: column;
    gap: var(--space--l);
}

/*
 * Segments in grid areas, balanced by their heights (the links are the longest list, the social media icons the
 * shortest segment):
 * - mobile  one below the other
 * - 30rem   two columns: the links next to contact and questions, below newsletter and social media
 * - 48rem   three columns: contact and newsletter, questions and social media, links
 * - 64rem   one row, the columns as wide as their content, evenly distributed in between (design H1)
 */
#footer__top {
    display: grid;
    grid-template-areas:
        "contact"
        "questions"
        "newsletter"
        "links"
        "social";
    gap: var(--layout--gap--large) var(--grid--gap);
    align-items: start;
}

#footer__top--contact      { grid-area: contact; }
#footer__top--questions    { grid-area: questions; }
#footer__top--newsletter   { grid-area: newsletter; }
#footer__top--links        { grid-area: links; }
#footer__top--social-media { grid-area: social; }

#footer__top .content-element {
    container-type: normal;
}

@container footer (min-width: 30rem) {
    #footer__top {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-areas:
            "contact    links"
            "questions  links"
            "newsletter social";
    }
}

@container footer (min-width: 48rem) {
    #footer__top {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-template-areas:
            "contact    questions links"
            "newsletter social    links";
    }
}

/*
 * From 64rem on segments and logos share the columns of #footer__content (subgrid): five columns as wide as the
 * segments, evenly distributed in between (see #footer__bottom below for the logos).
 */
@container footer (min-width: 64rem) {
    #footer__content {
        display: grid;
        grid-template-columns: repeat(5, auto);
        justify-content: space-between;
        gap: var(--layout--gap--large) var(--grid--gap);
    }

    #footer__top {
        grid-column: 1 / -1;
        grid-template-columns: subgrid;
        grid-template-areas: "contact questions newsletter links social";
    }
}

/*
 * Social media icons (one paragraph per icon in the text element) side by side, from 64rem on one below the other at
 * the right end of the row (design H1)
 */
#footer__top--social-media .cb-text {
    display: flex;
    flex-wrap: wrap;
    gap: var(--layout--gap--default);
}

#footer__top--social-media .cb-text > p {
    margin: 0;
}

@container footer (min-width: 64rem) {
    #footer__top--social-media .cb-text {
        flex-direction: column;
    }
}

/*
 * Logos: funded by and media partners (one media element with headline each) one below the other, from 48rem on
 * side by side in two halves, from 64rem on in the columns of the segments (media partners below the newsletter). The logos of each half in two columns, so they keep the size of 3 of 12 grid columns
 * (see _redesign).
 */
#footer__bottom {
    display: grid;
    gap: var(--layout--gap--large) var(--grid--gap);
}

@container footer (min-width: 48rem) {
    #footer__bottom {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/*
 * From 64rem on in the columns of the segments (subgrid of #footer__content): funded by spans contact and questions,
 * media partners starts on the axis of the newsletter. The logos don't widen the columns (content elements are
 * inline-size containers).
 */
@container footer (min-width: 64rem) {
    #footer__bottom {
        grid-column: 1 / -1;
        grid-template-columns: subgrid;
    }

    #footer__bottom--partner       { grid-column: 1 / 3; }
    #footer__bottom--media-partner { grid-column: 3 / -1; }
}

/*
 * Same headline in both halves, whichever header layout the elements have (h2 is Courier on the start page), in the
 * size of the footer texts. The editors use the subheader as headline as well.
 */
#footer__bottom .content-element > .content-element__header :is(h1, h2, h3, h4, h5, h6, .content-element__subheader) {
    font-family: var(--font-family--text);
    font-size: var(--font-size--text-small);
    font-weight: var(--font-weight--bold);
    line-height: var(--line-height--footer);
    word-spacing: normal;
}

#footer__bottom .cb-media__list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--grid--gap);
}

/* The logo boxes (layout "logos", see Media.css) fill their grid column */
#footer__bottom .cb-media__item {
    width: auto;
}

/* Lower boxes (59px, design H3) with left-aligned logos than in the content (see Media.css) */
#footer__bottom :is(.content-element--cb_media--logos, .content-element--cb_media--logos-wide) {
    --cb-media--logo-height: 3.6875rem;
}

#footer__bottom :is(.content-element--cb_media--logos, .content-element--cb_media--logos-wide) .cb-media__image {
    object-position: left center;
}

/* 40px top and 80px bottom spacing of the design from 64rem on (the footer can't query itself, see body) */
@container page (min-width: 64rem) {
    #footer__inner {
        padding-block: var(--space--l) var(--section--gap);
    }
}
