/*
 * core/accordion (old .c-accordion), the site's one toggle component, also
 * offered as the ragazzo/accordion pattern: primary header bar, bold title
 * at its heading level's size, plus-circle icon when closed / minus-circle when open (medium-gray), 2px
 * between items. Core markup (WP 7.1): .wp-block-accordion-item[.is-open] >
 * .wp-block-accordion-heading > button.wp-block-accordion-heading__toggle >
 * __toggle-title + __toggle-icon ("+" text). The "+" glyph is hidden and
 * replaced by an SVG CSS mask.
 */
.wp-block-accordion {
	--ragazzo-acc-plus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 0a12 12 0 1 0 0 24 12 12 0 0 0 0-24Zm1.5 6v4.5H18v3h-4.5V18h-3v-4.5H6v-3h4.5V6Z'/%3E%3C/svg%3E");
	--ragazzo-acc-minus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 0a12 12 0 1 0 0 24 12 12 0 0 0 0-24ZM6 10.5h12v3H6Z'/%3E%3C/svg%3E");
}

.wp-block-accordion > .wp-block-accordion-item + .wp-block-accordion-item {
	margin-block-start: 2px;
}

/*
 * Each item is a card like the old Bootstrap .card: a faint outline around
 * the header and, when open, its white panel, which follows the header
 * directly (live: .card border 1px rgb(0 0 0 / 12.5%), .card-header 12px
 * 20px, .card-body 20px).
 */
.wp-block-accordion > .wp-block-accordion-item {
	border: 1px solid rgb(0 0 0 / 12.5%);
}

/*
 * The title keeps the size of its heading level, as the old
 * .section-content__title hN did (live: h3 = 36.6px at 1440px). The bar
 * itself is h6 size, which sets the icon size.
 */
.wp-block-accordion-heading {
	--ragazzo-acc-icon: var(--wp--preset--font-size--h-6);
	margin: 0;
	padding: 12px 20px;
	font-size: var(--wp--preset--font-size--h-6);
	font-weight: 700;
	line-height: 1.2;
}

h1.wp-block-accordion-heading { font-size: var(--wp--preset--font-size--h-1); }
h2.wp-block-accordion-heading { font-size: var(--wp--preset--font-size--h-2); }
h3.wp-block-accordion-heading { font-size: var(--wp--preset--font-size--h-3); }
h4.wp-block-accordion-heading { font-size: var(--wp--preset--font-size--h-4); }
h5.wp-block-accordion-heading { font-size: var(--wp--preset--font-size--h-5); }

/*
 * Every accordion title looks the same: gray-900 on the taupe, 7.45:1 (white
 * was 2.07:1). The editor offers no colours for the heading (theme.json), and
 * colours left in older or pasted content are overridden (core prints the
 * colour classes with !important).
 */
.wp-block-accordion-heading,
.wp-block-accordion-heading:is(.has-background, .has-text-color) {
	background-color: var(--wp--preset--color--primary) !important;
	color: var(--wp--preset--color--gray-900) !important;
}

.wp-block-accordion-heading__toggle {
	gap: 1rem;
	justify-content: space-between;
	padding: 0;
}

.wp-block-accordion-heading__toggle:hover .wp-block-accordion-heading__toggle-title {
	text-decoration: none;
}

.wp-block-accordion-heading__toggle-icon {
	flex: none;
	width: var(--ragazzo-acc-icon);
	height: var(--ragazzo-acc-icon);
	overflow: hidden;
	color: transparent;
	background-color: var(--wp--preset--color--white);
	mask: var(--ragazzo-acc-plus) center / contain no-repeat;
}

.wp-block-accordion-item.is-open > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
	transform: none;
	background-color: var(--wp--preset--color--medium-gray);
	mask-image: var(--ragazzo-acc-minus);
}

/*
 * Two classes to beat the flow layout's 1.5rem gap (:root :where(...) > *),
 * printed after this file. Vertical padding is 0 in theme.json.
 */
.wp-block-accordion-item > .wp-block-accordion-panel {
	margin-block-start: 0;
	padding: 0 20px;
	font-size: 18px;
}

/*
 * Core zeroes a closed panel's padding (padding: 0 !important on [hidden]),
 * which made the content jump 20px left as soon as closing started. Keep the
 * side padding while closed: the panel is 0 high and clipped, so it is never
 * seen, and the content stays in place throughout.
 */
.wp-block-accordion-panel[hidden] {
	padding-inline: 20px !important;
}

/*
 * Vertical room as margins of the content, not panel padding: the panel
 * (overflow hidden) then only changes height while it opens and closes, so
 * the content stays put. 20px above and below (the old card-body's 20px;
 * the live site added the list's 1rem below, made even on request).
 */
.wp-block-accordion-item > .wp-block-accordion-panel > :first-child {
	margin-block-start: 20px;
}

.wp-block-accordion-item > .wp-block-accordion-panel > :last-child {
	margin-block-end: 20px;
}

/*
 * Product variant (old .product .c-accordion): white header, 1px black
 * border, body-colour uppercase text; hover and open invert to body-colour
 * background / white text. Icon colour set per state. No top margin.
 */
.wp-block-accordion.is-style-product {
	margin-block-start: 0;
}

/*
 * Like the live site: 59px rows (12px 20px), 4px apart, h5-size bold
 * titles, 20px panel padding with 18px text.
 */
.is-style-product > .wp-block-accordion-item + .wp-block-accordion-item,
.wp-block-accordion.is-style-product + .wp-block-accordion.is-style-product > .wp-block-accordion-item:first-child,
.wp-block-post-content:has(> .wp-block-accordion.is-style-product:last-child) + .wp-block-accordion.is-style-product > .wp-block-accordion-item:first-child {
	margin-block-start: 4px;
}

/*
 * Card layout, panel padding and 18px text come from the base rules above.
 * The padding sits on the toggle so the bordered header is all clickable;
 * every level is h5 size, and so is the icon.
 */
.is-style-product .wp-block-accordion-heading {
	--ragazzo-acc-icon: 1em;
	padding: 0;
	font-size: var(--wp--preset--font-size--h-5);
}

.is-style-product .wp-block-accordion-heading__toggle {
	padding: 12px 20px;
}

/*
 * Consecutive product accordions read as one list: the product's own accordion
 * (last block of post-content) and the synced "Materiali" item of the
 * materials slot right after post-content in single-prodotto.
 */
.wp-block-accordion.is-style-product + .wp-block-accordion.is-style-product,
.wp-block-post-content:has(> .wp-block-accordion.is-style-product:last-child) + .wp-block-accordion.is-style-product {
	margin-block-start: 0;
}

.is-style-product .wp-block-accordion-heading:not(.has-background) {
	background-color: var(--wp--preset--color--white);
}

.is-style-product .wp-block-accordion-heading:not(.has-text-color) {
	color: var(--wp--preset--color--body-color);
}

/*
 * No borders on a closed item: just the bars, 4px apart. An open item keeps
 * the card outline around its title and panel.
 */
.wp-block-accordion.is-style-product > .wp-block-accordion-item:not(.is-open) {
	border-color: transparent;
}

.is-style-product .wp-block-accordion-heading {
	text-transform: uppercase;
	transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.is-style-product .wp-block-accordion-heading:hover,
.is-style-product .wp-block-accordion-heading:has(:focus-visible),
.is-style-product .wp-block-accordion-item.is-open > .wp-block-accordion-heading {
	background-color: var(--wp--preset--color--body-color);
	color: var(--wp--preset--color--white);
}

/*
 * The icon glyph is hidden with color: transparent, so currentColor cannot be
 * used for the mask fill: set it explicitly per state.
 */
.is-style-product .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon,
.is-style-product .wp-block-accordion-item.is-open > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
	background-color: var(--wp--preset--color--body-color);
}

.is-style-product .wp-block-accordion-heading:hover .wp-block-accordion-heading__toggle-icon,
.is-style-product .wp-block-accordion-heading:has(:focus-visible) .wp-block-accordion-heading__toggle-icon,
.is-style-product .wp-block-accordion-item.is-open > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
	background-color: var(--wp--preset--color--white);
}

/*
 * Smooth opening and closing. Core hides a closed panel with
 * hidden="until-found" (content-visibility: hidden, still findable with the
 * browser's find in page). Animate its height between 0 and auto
 * (interpolate-size), keeping content-visibility until the closing finishes
 * (allow-discrete). Browsers without interpolate-size simply open instantly.
 */
.wp-block-accordion-panel {
	interpolate-size: allow-keywords;
	height: auto;
	overflow: hidden;
	transition:
		height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
		opacity 0.3s ease,
		content-visibility 0.35s allow-discrete;
}

.wp-block-accordion-panel[hidden] {
	height: 0;
	opacity: 0;
}

.wp-block-accordion-heading__toggle-icon {
	transition: background-color 0.15s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {

	.wp-block-accordion-panel {
		transition: none;
	}
}
