/*
 * Textbox: Text und Buttons in einer Box. Farben aus der Theme-Palette:
 * km-bg-{id} (Hintergrund), km-border-{id} (Rahmen), km-ink-{id} setzt --km-ink
 * (Textfarbe). Das Design-Element kommt aus km-section.css (km-overlay-host).
 */
.ce_rsce_textbox {
    --km-textbox-padding: 2rem;
    --km-textbox-gap: 1.5rem;   
    padding: var(--km-textbox-padding);
    color: var(--km-ink, inherit);
    border-radius: var(--km-box-radius, 0);

    > .rte > :last-child {
        margin-bottom: 0;
    }

    /* Am Text statt an den Buttons, die in einer Zeile margin-top: auto haben. ~ statt +, dazwischen kann der Toggle stehen. */
    > .rte:has(~ .km-buttons) {
        margin-bottom: var(--km-textbox-gap);
    }

    /* Sichtbarkeit pro Breakpoint in _custom-textbox.scss (styles.css) */
    > .km-textbox__toggle {
        width: fit-content;
        align-items: center;
        gap: .25em;
        /* Zieht ihn in den Abstand zwischen Text und Buttons */
        margin-top: calc(var(--km-textbox-gap) * -.5);
        margin-bottom: var(--km-textbox-gap);
        padding: 0;
        border: 0;
        background: none;
        color: inherit;
        font: inherit;
        cursor: pointer;

        /* Am span statt am Button, sonst wäre auch der Pfeil unterstrichen */
        > span {
            text-decoration: underline;
            text-decoration-thickness: 1px;
            text-underline-offset: .3em;
        }

        &::after {
            /* Material Icon "expand_more" als Maske in Textfarbe */
            content: "";
            width: 1.25em;
            height: 1.25em;
            background: currentColor;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z'/%3E%3C/svg%3E") center / contain no-repeat;
            transition: rotate .2s;

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

    > .km-textbox__toggle:not(:has(~ .km-buttons)) {
        margin-top: calc(var(--km-textbox-gap) * .5);
        margin-bottom: 0;
    }

    &.is-expanded > .km-textbox__toggle::after {
        rotate: 180deg;
    }

    /* Die Textfarbe der Box gilt nicht für die Buttons, sie haben eigene Farben */
    > .km-buttons {
        --km-ink: initial;
        --km-fill: initial;
    }
}

/*
 * In einer Zeile füllt die Box ihre Spalte, so sind alle Boxen der Zeile so
 * hoch wie die höchste. Die Buttons stehen unten bündig.
 */
.row > :has(> .ce_rsce_textbox) {
    display: flex;
    flex-direction: column;
}

.row > * > .ce_rsce_textbox {
    flex-grow: 1;
    display: flex;
    flex-direction: column;

    > .km-buttons {
        margin-top: auto;
    }
}
