/* FAQ accordion. Loaded only on pages with a .tofts-faq group (see functions.php). */

.tofts-faq-all {
	display: block;
	margin: 0 0 var(--wp--preset--spacing--30, 1rem) auto;
	padding: 0.5rem 1rem;
	font: inherit;
	font-size: var(--wp--preset--font-size--small, 0.9rem);
	color: var(--wp--preset--color--ink);
	background: transparent;
	border: 2px solid var(--wp--preset--color--ink);
	border-radius: 4px;
	cursor: pointer;
	/* Double chevron: down to show all, up to hide all */
	--tofts-faq-all-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 6 6 6 6-6M6 12l6 6 6-6'/%3E%3C/svg%3E");
}

.tofts-faq-all.is-all-open {
	--tofts-faq-all-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 18 6-6 6 6M6 12l6-6 6 6'/%3E%3C/svg%3E");
}

/* Decorative: the button's name stays its text. */
.tofts-faq-all::before {
	content: "";
	display: inline-block;
	width: 1em;
	height: 1em;
	margin-inline-end: 0.45em;
	vertical-align: -0.15em;
	background-color: currentColor;
	-webkit-mask: var(--tofts-faq-all-icon) center / contain no-repeat;
	mask: var(--tofts-faq-all-icon) center / contain no-repeat;
}

.tofts-faq-item {
	border-top: 1px solid var(--wp--preset--color--rule);
}

.tofts-faq-item:last-child {
	border-bottom: 1px solid var(--wp--preset--color--rule);
}

.tofts-faq-item > h3 {
	margin: 0;
}

.tofts-faq-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	width: 100%;
	/* 44px+ target (WCAG 2.5.8 needs 24px; this is comfortable on touch). */
	min-height: 2.75rem;
	padding: 0.75rem 0;
	font: inherit;
	color: inherit;
	text-align: left;
	background: none;
	border: 0;
	cursor: pointer;
}

/* Plus/minus drawn in CSS, so screen readers hear only the question and its expanded state. */
.tofts-faq-toggle::after {
	content: "";
	flex: none;
	width: 0.9em;
	height: 0.9em;
	background:
		linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat,
		linear-gradient(currentColor, currentColor) center / 2px 100% no-repeat;
	transition: transform 0.15s ease;
}

.tofts-faq-toggle[aria-expanded="true"]::after {
	background: linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat;
}

.tofts-faq-panel {
	padding-bottom: var(--wp--preset--spacing--30, 1rem);
}

.tofts-faq-panel > :first-child {
	margin-top: 0;
}

@media (prefers-reduced-motion: reduce) {
	.tofts-faq-toggle::after {
		transition: none;
	}
}

/* Windows High Contrast: keep the icon visible. */
@media (forced-colors: active) {
	.tofts-faq-toggle::after {
		forced-color-adjust: none;
		background-color: transparent;
		color: ButtonText;
	}

	.tofts-faq-all::before {
		forced-color-adjust: none;
		background-color: ButtonText;
	}
}

@media print {
	.tofts-faq-all {
		display: none;
	}

	.tofts-faq-panel[hidden] {
		display: block;
		content-visibility: visible;
	}

	.tofts-faq-toggle::after {
		display: none;
	}
}
