/* ==========================================================================
   MWH FAQ. One column: the title, a few words and a button, then how many
   questions there are and a search box, then the questions (owner,
   2026-11-09). Colours and type come from the My Worthy Home theme where it
   is active, with plain fallbacks for any other theme.
   ========================================================================== */

.mwh-faq {
	--mwh-faq-ink: var(--mwh-ink, #171a17);
	--mwh-faq-muted: var(--mwh-graphite, #5a5d57);
	--mwh-faq-line: var(--mwh-line, #e2ddd3);
	--mwh-faq-control: var(--mwh-control-border, #b8b2a6);
	--mwh-faq-accent: var(--mwh-evergreen, #1f3a2e);
	--mwh-faq-paper: var(--mwh-paper, #fff);
	--mwh-faq-soft: var(--mwh-porcelain, #f7f5f0);

	container-type: inline-size;
	display: flex;
	flex-direction: column;
	gap: 24px;
	margin-block: clamp(48px, 7vw, 96px);
	color: var(--mwh-faq-ink);
}

.mwh-faq__intro,
.mwh-faq__list {
	min-width: 0;
}

.mwh-faq__intro {
	max-width: 760px;
}

.mwh-faq__intro > * {
	margin-block: 0;
}

.mwh-faq__intro > * + * {
	margin-top: 12px;
}

.mwh-faq__intro h2 {
	font-size: var(--wp--preset--font-size--section, clamp(1.875rem, 1.6rem + 1.1vw, 2.5rem));
	line-height: 1.1;
}

.mwh-faq__intro p {
	max-width: 60ch;
	font-size: var(--wp--preset--font-size--lg, 1.125rem);
	line-height: 1.55;
	color: var(--mwh-faq-muted);
}

.mwh-faq__intro .wp-block-buttons {
	margin-top: 20px;
}

/* In a narrow column, such as on a phone, the title steps down a size so the questions stay the focus. */
@container (max-width: 759px) {
	.mwh-faq__intro h2 {
		font-size: var(--wp--preset--font-size--xxl, 1.75rem);
	}

	.mwh-faq__intro p {
		font-size: var(--wp--preset--font-size--md, 1rem);
	}

	.mwh-faq__intro .wp-block-buttons {
		margin-top: 16px;
	}
}

/* How many questions, and the search box (view.js). The search sits first where there is room for both on one
   line, and the count beside it. */
.mwh-faq__tools {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px 20px;
}

.mwh-faq__count {
	margin: 0;
	font-size: var(--wp--preset--font-size--sm, 0.875rem);
	font-weight: 600;
	color: var(--mwh-faq-muted);
	font-variant-numeric: tabular-nums;
}

.mwh-faq__search {
	position: relative;
	flex: 0 1 420px;
	min-width: 0;
}

.mwh-faq__search::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 14px;
	width: 18px;
	height: 18px;
	background: var(--mwh-faq-muted);
	-webkit-mask: 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' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: 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' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") center / contain no-repeat;
	transform: translateY(-50%);
	pointer-events: none;
}

.mwh-faq .mwh-faq__search-input {
	width: 100%;
	min-height: 46px;
	margin: 0;
	padding: 10px 14px 10px 42px;
	font: inherit;
	font-size: var(--wp--preset--font-size--md, 1rem);
	color: var(--mwh-faq-ink);
	background: var(--mwh-faq-soft);
	border: 1px solid var(--mwh-faq-line);
	border-radius: 999px;
	box-shadow: none;
}

/* The browser's own clear button, in the section's colours rather than the browser's blue. */
.mwh-faq .mwh-faq__search-input::-webkit-search-cancel-button {
	width: 16px;
	height: 16px;
	cursor: pointer;
	background: var(--mwh-faq-muted);
	-webkit-mask: 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.2' stroke-linecap='round'%3E%3Cpath d='m6 6 12 12M18 6 6 18'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: 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.2' stroke-linecap='round'%3E%3Cpath d='m6 6 12 12M18 6 6 18'/%3E%3C/svg%3E") center / contain no-repeat;
	-webkit-appearance: none;
	appearance: none;
}

.mwh-faq .mwh-faq__search-input:focus {
	background: var(--mwh-faq-paper);
	border-color: var(--mwh-faq-accent);
	outline: 2px solid var(--mwh-faq-accent);
	outline-offset: 1px;
}

@container (max-width: 559px) {
	.mwh-faq__search {
		flex-basis: 100%;
	}
}

/* Nothing found: says so, with a way back to every question. */
.mwh-faq__empty {
	padding: 20px 22px;
	color: var(--mwh-faq-muted);
	background: var(--mwh-faq-soft);
	border: 1px solid var(--mwh-faq-line);
	border-radius: 14px;
}

.mwh-faq__empty[hidden],
.mwh-faq__list[hidden],
.mwh-faq__item[hidden] {
	display: none;
}

.mwh-faq__empty p {
	margin: 0 0 6px;
}

.mwh-faq__clear {
	padding: 0;
	font: inherit;
	font-weight: 600;
	color: var(--mwh-faq-accent);
	text-decoration: underline;
	text-underline-offset: 3px;
	cursor: pointer;
	background: none;
	border: 0;
}

/* Words for screen readers only, for any theme that does not provide this. */
.mwh-faq .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}
.mwh-faq__list {
	border-top: 1px solid var(--mwh-faq-line);
}

.mwh-faq__item {
	margin: 0;
	border-bottom: 1px solid var(--mwh-faq-line);
}

/* The question: the whole row opens the answer, with a round plus that becomes a minus. */
.mwh-faq__question {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
	min-height: 44px;
	margin: 0;
	padding: 20px 0;
	font-size: var(--wp--preset--font-size--lg, 1.125rem);
	font-weight: 600;
	line-height: 1.35;
	list-style: none;
	cursor: pointer;
	transition: color 160ms ease;
}

.mwh-faq__question::-webkit-details-marker {
	display: none;
}

.mwh-faq__question::after {
	content: "";
	flex: none;
	width: 34px;
	height: 34px;
	color: var(--mwh-faq-ink);
	background:
		linear-gradient(currentcolor, currentcolor) center / 12px 1.75px no-repeat,
		linear-gradient(currentcolor, currentcolor) center / 1.75px 12px no-repeat;
	border: 1px solid var(--mwh-faq-control);
	border-radius: 50%;
	transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, background-size 200ms ease;
}

summary.mwh-faq__question:hover {
	color: var(--mwh-faq-accent);
}

summary.mwh-faq__question:hover::after {
	border-color: var(--mwh-faq-accent);
}

summary.mwh-faq__question:focus-visible {
	outline: 2px solid var(--mwh-faq-accent);
	outline-offset: 4px;
	border-radius: 4px;
}

.mwh-faq__item[open] > .mwh-faq__question::after {
	color: var(--mwh-faq-paper);
	background-color: var(--mwh-faq-accent);
	background-size: 12px 1.75px, 1.75px 0;
	border-color: var(--mwh-faq-accent);
}

.mwh-faq__answer {
	padding: 0 54px 24px 0;
	font-size: var(--wp--preset--font-size--md, 1rem);
	line-height: 1.65;
	color: var(--mwh-faq-muted);
}

.mwh-faq__answer > * {
	margin-block: 0;
}

.mwh-faq__answer > * + * {
	margin-top: 0.8em;
}

/* Answers slide open where the browser can animate to their natural height. */
@supports (interpolate-size: allow-keywords) {
	.mwh-faq {
		interpolate-size: allow-keywords;
	}

	.mwh-faq__item::details-content {
		height: 0;
		overflow: hidden;
		transition: height 260ms ease, content-visibility 260ms allow-discrete;
	}

	.mwh-faq__item[open]::details-content {
		height: auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mwh-faq__question,
	.mwh-faq__question::after,
	.mwh-faq__item::details-content {
		transition: none;
	}
}

/* In the editor every answer stays open, so it can be written in place. */
.mwh-faq__item.is-editing .mwh-faq__question {
	cursor: text;
}

.mwh-faq__item.is-editing .mwh-faq__question::after {
	color: var(--mwh-faq-paper);
	background-color: var(--mwh-faq-accent);
	background-size: 12px 1.75px, 1.75px 0;
	border-color: var(--mwh-faq-accent);
}
