/*
 * Boxed accordion (core/accordion): a +/− square at the start of each heading row (at the end when the accordion's
 * icon position is right), the open item framed. The heading bar colour, text colours, type and paddings of headings and panels, and the gap between items
 * are block settings. The style adds what no setting covers: the square and its sign, the open item's frame, the
 * heading line height and the focus ring.
 * Loaded only on pages where an accordion uses the style (inc/rt-block-styles.php).
 */

/* Defaults for items added with "+" (core adds them without settings). One class: the blocks' settings (preset
   classes, inline styles) and Styles > Blocks win; theme.json's h3 type (0,0,1) does not. */
:where(.is-style-accordion-boxed) .wp-block-accordion-heading {
	background-color: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--contrast);
	font-family: var(--wp--preset--font-family--body);
	font-size: var(--wp--preset--font-size--base);
	font-weight: var(--wp--custom--font--weight--medium);
}

:where(.is-style-accordion-boxed) .wp-block-accordion-heading__toggle {
	padding-block: 1.25rem;
	padding-inline: 0 2.25rem;
}

:where(.is-style-accordion-boxed) .has-icon-right > .wp-block-accordion-heading__toggle {
	padding-inline: 2.25rem 0;
}

:where(.is-style-accordion-boxed) .wp-block-accordion-panel {
	padding: 1.8125rem 1.75rem 2.6875rem;
	line-height: var(--wp--custom--font--line-height--body);
}

@media (max-width: 37.5rem) {
	:where(.is-style-accordion-boxed) .wp-block-accordion-panel {
		padding-inline: 1.25rem;
	}
}

.is-style-accordion-boxed > .wp-block-accordion-item.is-open {
	border: 1px solid var(--wp--preset--color--line);
}

.is-style-accordion-boxed .wp-block-accordion-heading {
	margin: 0;
	line-height: var(--wp--custom--font--line-height--heading);
}

.is-style-accordion-boxed .wp-block-accordion-heading__toggle:focus-visible {
	outline: 2px solid currentcolor;
	outline-offset: -0.375rem;
}

/* The square fills the row's height whatever the heading padding: its ::before reaches far up and down and the
   toggle (overflow: hidden in core) clips it. The sign sits on ::after, centred on the title's line. */
.is-style-accordion-boxed .wp-block-accordion-heading__toggle-icon {
	position: relative;
	flex: none;
	width: 3.75rem;
	height: auto;
	align-self: stretch;
	margin-inline: 0 2.25rem;
	-webkit-text-fill-color: transparent; /* hides core's + sign; the heading's font size still reaches it */
}

.is-style-accordion-boxed .has-icon-right .wp-block-accordion-heading__toggle-icon {
	margin-inline: 2.25rem 0;
}

/* Phones: less room between the square and the title (no block setting holds it) */
@media (max-width: 37.5rem) {
	.is-style-accordion-boxed .wp-block-accordion-heading__toggle-icon {
		margin-inline: 0 1.25rem;
	}

	.is-style-accordion-boxed .has-icon-right .wp-block-accordion-heading__toggle-icon {
		margin-inline: 1.25rem 0;
	}
}

.is-style-accordion-boxed .wp-block-accordion-heading__toggle-icon::before,
.is-style-accordion-boxed .wp-block-accordion-heading__toggle-icon::after {
	content: "";
	position: absolute;
	inset-inline: 0;
}

.is-style-accordion-boxed .wp-block-accordion-heading__toggle-icon::before {
	inset-block: -50rem;
	background-color: var(--wp--preset--color--line);
}

.is-style-accordion-boxed .wp-block-accordion-heading__toggle-icon::after {
	inset-block: 0;
	background:
		linear-gradient(currentcolor, currentcolor) center / 0.625rem 2px no-repeat,
		linear-gradient(currentcolor, currentcolor) center / 2px 0.625rem no-repeat;
}

/* Open: − instead of +. Core turns the open icon 45° (0,4,0); the square must not turn. */
.is-style-accordion-boxed .wp-block-accordion-item.is-open > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
	transform: none;
}

.is-style-accordion-boxed .wp-block-accordion-item.is-open > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon::after {
	background-size: 0.625rem 2px, 2px 0;
}
