/*
 * CONTENT BLOCK CALL TO ACTION (cb_cta)
 *
 * Without image (.cb-cta--portal, design D2): white box with orange border, text and button accent (.btn--accent, E3, see base.css)
 * centered side by side, wrapping on small widths.
 *
 * With image (.cb-cta--image, design D1): image and color area of the surface (.surface--*, see variables.css).
 * Mobile first: image above the color area, from 36rem element width on (e.g. main column with collapsed aside, main
 * column at its max width next to the aside) side by side with the image taking 1/3 (16:9) or 2/3 (21:9) of the width (layout wrapper classes content-element--cb_cta--image-one-third /
 * --image-two-thirds, see Default layout). The link covers the color area, the arrow in a circle is its visible
 * part, on hover the text is underlined.
 *
 * The image keeps its format at all widths (see .image--format in base.css): side by side the row is as high as the
 * image, the color area follows. Its vertical padding is reduced then, the arrow has its space in the padding at the
 * sides. Short text (up to 3 words) is set in 40px, longer text in 32px. In narrow text columns the text is set in
 * h3 size. Only text higher than the image (long texts, 200% font size) makes the row higher, the image is cut then
 * (object-fit).
 *
 * Font size setting of the accessibility settings (150%/200%, rem): the text grows, the arrow and the side padding keep
 * their size (px), so the text gets the width of the color area. The narrow text columns are queried in px, a larger
 * font size alone doesn't switch to the smaller h3 size. The text is limited to the width of the color area (about 9
 * characters per line), so long words are not cut.
 */

.cb-cta {
    --cb-cta--radius: var(--border-radius--default);
    --cb-cta--pad   : var(--padding--default);
    /*
     * Arrow and its distance to the edges in px, they don't grow with the font size setting (see above). The distance
     * is the 1rem step of the spacing scale at 16px.
     */
    --cb-cta--arrow       : 30px;
    --cb-cta--arrow-offset: 16px;
}


/* WITHOUT IMAGE: funding portal (D2) */

.cb-cta--portal {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space--s) var(--space--m);
    min-height: 5rem;
    padding: var(--cb-cta--pad);
    border: var(--border-width--default) solid var(--color--orange);
    border-radius: var(--cb-cta--radius);
    text-align: center;
}

.cb-cta--portal .cb-cta__text {
    font-size: var(--font-size--h3);
    font-weight: var(--font-weight--bold);
    line-height: var(--line-height--sub-headline);
}


/* WITH IMAGE (D1) */

.cb-cta--image {
    display: grid;
    grid-template-columns: 1fr;
    overflow: hidden;
    border-radius: var(--cb-cta--radius);
}

@container content-element (min-width: 36rem) {
    .content-element--cb_cta--image-one-third .cb-cta--image {
        grid-template-columns: 1fr 2fr;
    }

    .content-element--cb_cta--image-two-thirds .cb-cta--image {
        grid-template-columns: 2fr 1fr;
    }

    /*
     * Side by side the image sets the height: no min height, the arrow lies in the padding at the sides. Higher
     * specificity than the color area below.
     */
    .cb-cta.cb-cta--image .cb-cta__content {
        min-height: 0;
        padding-block: var(--cb-cta--pad);
    }
}

/*
 * Narrow text columns side by side, the text in h3 size keeps the row as high as the image: image 1/3 below 720px
 * (e.g. collapsed aside), image 2/3 below 1024px (also next to the aside, text column 263px). Max width in px, so the
 * font size setting doesn't make the text smaller (see above).
 */
@container content-element (min-width: 36rem) and (max-width: 719.98px) {
    .content-element--cb_cta--image-one-third .cb-cta.cb-cta--image .cb-cta__content {
        font-size: var(--font-size--h3);
        line-height: var(--line-height--sub-headline);
    }
}

@container content-element (min-width: 36rem) and (max-width: 1023.98px) {
    .content-element--cb_cta--image-two-thirds .cb-cta.cb-cta--image .cb-cta__content {
        font-size: var(--font-size--h3);
        line-height: var(--line-height--sub-headline);
    }
}

/* Side by side the image fills the row, which is at least as high as the image in its format */
.cb-cta__image {
    height: 100%;
}

.cb-cta--image .cb-cta__content {
    /* The text is limited to its width (see .cb-cta__text below) */
    container: cb-cta-content / inline-size;

    position: relative;
    display: grid;
    place-items: center;
    min-height: 10rem;
    /* Space for the arrow at the bottom, at the sides the text keeps clear of the arrow (side by side) */
    padding: calc(var(--cb-cta--pad) * 2 + var(--cb-cta--arrow)) calc(var(--cb-cta--arrow-offset) + var(--cb-cta--arrow));
    text-align: center;
    font-family: var(--font-family--headline);
    /* Text 32/32, bold */
    font-size: 2rem;
    font-weight: var(--font-weight--bold);
    line-height: 1;
    /* Only long words are hyphenated, short ones like "Aufruf" wrap as a whole (design D1) */
    hyphens: auto;
    hyphenate-limit-chars: 10 4 4;
}

/*
 * Short text (up to 3 words, modifier set in the template) 40/40, so it fills the color area. Longer text stays at
 * 32px. In narrow text columns side by side the h3 size above still applies (higher specificity).
 */
.cb-cta--image .cb-cta__content--short {
    font-size: 2.5rem;
}

/*
 * At most about 9 characters per line of the headline font (short words are not hyphenated, see above), so large font
 * sizes in narrow color areas don't cut words. Wraps long words as a last resort (e.g. wider fonts of program designs).
 */
.cb-cta--image .cb-cta__text {
    font-size: min(1em, 100cqi / 5.5);
    overflow-wrap: break-word;
}

/* Text and link in the same grid cell, so the text is centered vertically in the color area (design D1) */
.cb-cta--image .cb-cta__content > * {
    grid-area: 1 / 1;
}

/* The link covers the color area, its text is for screen readers only */
.cb-cta__link {
    text-decoration: none;
}

.cb-cta__link::before {
    content: "";
    position: absolute;
    inset: 0;
}

/* Arrow in a circle at the bottom right, drawn in the text color of the surface */
.cb-cta__link::after {
    content: "";
    position: absolute;
    right: var(--cb-cta--arrow-offset);
    bottom: var(--cb-cta--arrow-offset);
    width: var(--cb-cta--arrow);
    height: var(--cb-cta--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;
}

/* Links in the text stay clickable above the link of the color area */
.cb-cta--image .cb-cta__text a {
    position: relative;
    z-index: 1;
    text-decoration: underline;
}

.cb-cta--image .cb-cta__content:has(.cb-cta__link:hover) .cb-cta__text {
    text-decoration: underline;
    text-decoration-thickness: var(--text-decoration-thickness--bold);
    text-underline-offset: .15em;
}

/* Focus around the color area instead of the empty link */
.cb-cta .cb-cta__link:focus-visible {
    outline: none;
}

.cb-cta .cb-cta__link:focus-visible::before {
    outline: var(--outline-width--default) solid var(--surface--focus);
    outline-offset: calc(-1 * var(--outline-offset--default) - var(--outline-width--default));
}

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