/*
 * Accordion.
 * Loaded only on pages containing the mainoslahde/accordion block
 * (see inc/accordion.php).
 *
 * The open/close animation is pure CSS (grid-template-rows 0fr -> 1fr on
 * the panel wrapper) -- JS only toggles a class + aria-expanded, no
 * scrollHeight measuring needed and no layout jump before JS runs, since
 * the closed (0fr) state is the correct first-paint default.
 *
 * Every selector here is prefixed with .accordion (not just
 * .accordion-item / .accordion-item__*) so it's always at least two
 * classes deep. That's deliberate: when the accordion is nested inside
 * Rich Content, .rich-content-body's own h1-h4/p rules (one class + one
 * tag) are otherwise EQUALLY OR MORE specific than a bare
 * ".accordion-item__heading" (one class only) and win regardless of
 * stylesheet load order, leaking rich-content-body's heading/paragraph
 * styling onto the accordion's own h3/p. Two classes beats one-class+tag
 * unconditionally, so this can't happen no matter where the accordion is used.
 */

.accordion {
	margin-bottom: 32px;
}

.accordion .accordion-item {
	border: 1px solid #e4e4e7;
}

.accordion .accordion-item + .accordion-item {
	margin-top: 12px;
}

/* "Headings only" display mode: static bordered box, centered title, no
   toggle button/icon. */
.accordion .accordion-item__title--static {
	display: block;
	padding: 16px 20px;
	text-align: center;
}

@media (min-width: 768px) {
	.accordion {
		margin-bottom: 48px;
	}
}

.accordion .accordion-item__heading {
	margin: 0;
}

.accordion .accordion-item__trigger {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	width: 100%;
	padding: 16px 20px;
	background: transparent;
	border: none;
	text-align: left;
	cursor: pointer;
}

.accordion .accordion-item__trigger:focus-visible {
	outline: 2px solid #18181b;
	outline-offset: -2px;
}

.accordion .accordion-item__title {
	font-family: 'Outfit', sans-serif;
	font-weight: 700;
	font-size: 20px;
	line-height: normal;
	letter-spacing: normal;
	color: #000;
}

.accordion .accordion-item__icon {
	position: relative;
	flex-shrink: 0;
	width: 24px;
	height: 24px;
	border-radius: 2px;
	transition: background-color 200ms ease;
}

.accordion .accordion-item__icon span {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 12px;
	height: 2px;
	background-color: #000;
	transform: translate(-50%, -50%);
	transition: transform 250ms ease, background-color 200ms ease;
}

.accordion .accordion-item__icon span:last-child {
	transform: translate(-50%, -50%) rotate(90deg);
}

.accordion .accordion-item.is-open .accordion-item__icon {
	background-color: #000;
}

.accordion .accordion-item.is-open .accordion-item__icon span {
	background-color: #fff;
}

.accordion .accordion-item.is-open .accordion-item__icon span:last-child {
	transform: translate(-50%, -50%) rotate(0deg);
}

.accordion .accordion-item__panel {
	display: grid;
	grid-template-rows: 0fr;
	transition: grid-template-rows 300ms ease;
}

.accordion .accordion-item.is-open .accordion-item__panel {
	grid-template-rows: 1fr;
}

.accordion .accordion-item__panel-inner {
	/* Grid items get min-height:auto by default, which stops the row from
	   actually shrinking to 0fr no matter what -- min-height:0 fixes that.
	   Padding must NOT live here: padding is part of a grid item's box
	   size regardless of min-height, so it would floor the row at that
	   padding height even when "collapsed". It lives on the inner content
	   wrapper below instead, which isn't itself a grid item. */
	min-height: 0;
	overflow: hidden;
}

.accordion .accordion-item__panel-content {
	padding: 0 20px 20px;
}

.accordion .accordion-item__panel-content p {
	margin: 0 0 16px;
	font-family: 'Rubik', sans-serif;
	font-weight: 300;
	font-size: 16px;
	line-height: 30px;
	letter-spacing: normal;
	color: #666666;
}

.accordion .accordion-item__panel-content p:last-child {
	margin-bottom: 0;
}

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

	.accordion .accordion-item__icon span {
		transition: none;
	}
}
