/*
 * CONTENT BLOCK ACCORDION (cb_accordion)
 * Accordion of the shared extension cb_accordion with the theme's template (design F5). The rows are buttons in full
 * width with icon (.btn.btn--wide, design E2, see base.css) one below the other, the icon is an arrow down in a circle,
 * turned up when the row is open. The labels wrap instead of being cut, the questions can be long.
 * The contents are in small text like the facts of the record detail views (see RecordDetail.css), not in the normal
 * text size of the text element (see Text.css).
 */

.cb-accordion {
    --cb-accordion--gap: var(--padding--default);

    display: grid;
    gap: var(--cb-accordion--gap);
}

.cb-accordion__item {
	--btn--border: var(--color--dark-grey);
	border: var(--border-width--default) solid var(--btn--border);
	border-radius: var(--border-radius--default);
}

.cb-accordion__heading {
    margin: 0;
    font: inherit;
}

.cb-accordion__button {
    --btn--icon: var(--icon--arrow-down--stroke-2);

    text-align: left;
	border: unset;
    /* Rounded like the inside of the item, not as pill: the hover background stays in the item's shape when open */
    border-radius: calc(var(--border-radius--default) - var(--border-width--default));
}

/*
 * Focus ring around the whole item instead of the button: the button sits inside the item's border, so its ring
 * (outside the button, see .btn:focus-visible in base.css) would be wider than the border of the open panel below.
 * Same selectors as in base.css to override its specificity.
 */
.cb-accordion__item:has(.cb-accordion__button:focus-visible) {
    outline: var(--outline-width--default) solid var(--btn--border);
    outline-offset: var(--outline-offset--default);
}

.cb-accordion__button.btn:focus-visible,
.content-element .cb-accordion__button:is(a, button).btn:focus-visible {
    outline: none;
    box-shadow: none;
}

.cb-accordion__button[aria-expanded="true"] {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
}

.cb-accordion__button[aria-expanded="true"]::after {
    transform: rotate(180deg);
}

@media (prefers-reduced-motion: no-preference) {
    .cb-accordion__button::after {
        transition: transform .2s ease-in-out;
    }
}

.cb-accordion__panel {
    padding: var(--layout--gap--default) var(--padding--default);
    font-size: var(--font-size--text-small);
    line-height: var(--line-height--text-small);
}

/* Paragraphs and list items as well, the rich text sets them to the normal text size (see Text.css) */
.cb-accordion__panel .cb-text :is(p, li) {
    font-size: inherit;
    line-height: inherit;
}

.cb-accordion__panel[hidden] {
    display: none;
}
