/* ============================================================
   FAQ accordion section ("Questions from families")
   Design ref: Family Service page accordion (fs-05 / fs-06).
   Light-grey band, centred intro, centred ~1050px column of
   cream accordion cards. Bold teal question left, +/- icon
   right (minus open / plus closed), collapsible answer panel.
   Grid-rows animation; the intended-open row renders open with
   no JS (server is-open class + hidden attr on closed panels).
   ============================================================ */

.faq {
	background: var(--color-light-grey);
	padding-block: var(--section-padding);
}

/* ---- Intro ---- */

.faq__intro {
	text-align: center;
	max-width: 48rem;
	margin-inline: auto;
	margin-bottom: var(--space-lg);
}

.faq__heading {
	margin-bottom: 0;
}

/* ---- List ---- */

.faq__list {
	max-width: 1050px;
	margin-inline: auto;
	display: flex;
	flex-direction: column;
	gap: var(--space-md);
}

/* ---- Item / card ---- */

.faq__item {
	background: var(--color-cream-light);
	border-radius: var(--radius-sm);
	box-shadow: 0 4px 18px rgb(0 31 38 / 0.08);
	overflow: hidden;
}

/* ---- Toggle button ---- */

.faq__question {
	margin: 0;
	font-size: inherit;
	line-height: inherit;
}

.faq__toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-md);
	width: 100%;
	margin: 0;
	padding: 1.375rem 1.625rem;
	background: transparent;
	border: 0;
	border-radius: var(--radius-sm);
	font-family: var(--font-body);
	font-weight: 700;
	font-size: 1rem;
	line-height: 1.4;
	color: var(--color-teal-dark);
	text-align: left;
	cursor: pointer;
}

.faq__toggle:focus-visible {
	outline: 2px solid var(--color-caramel);
	outline-offset: -2px;
}

.faq__question-text {
	flex: 1 1 auto;
}

/* ---- +/- icon (single SVG, minus line always shown, vertical
   line hidden when the row is open) ---- */

.faq__icon {
	flex: 0 0 auto;
	display: inline-flex;
	color: var(--color-teal-dark);
}

.faq__icon svg {
	display: block;
	width: 24px;
	height: 24px;
}

.faq__icon-v {
	transition: opacity var(--transition), transform var(--transition);
	transform-origin: center;
}

/* Open (aria-expanded=true) -> hide the vertical stroke = minus */
.faq__toggle[aria-expanded="true"] .faq__icon-v {
	opacity: 0;
	transform: rotate(90deg);
}

/* ---- Answer panel: grid-rows collapse animation ----
   Collapsing is scoped to .has-js (set inline in header.php before first
   paint). Without JS there is nothing to reopen a collapsed panel, so the
   answers must simply render open - otherwise a no-JS visitor loses the
   entire content payload of the FAQs page, which is 21 answers. Do NOT
   unscope this, and do NOT reintroduce a server-rendered `hidden`
   attribute on closed panels for the same reason. */

.faq__panel {
	display: grid;
	grid-template-rows: 1fr;
}

/* ONLY grid-template-rows animates. An earlier version also transitioned
   the answer's padding-bottom, and because the 1fr track resolves to a
   height that INCLUDES that padding, the two curves multiplied - peak
   velocity came out ~2x what a single ease predicts and the middle of the
   move visibly surged. Keeping every other contributor constant leaves one
   clean easing curve. easeInOutCubic (not easeOut) so neither end starts
   at full speed: an easeOut curve is fastest on its very first frame,
   which threw the collapse forward ~14px in one frame. */
.has-js .faq__panel {
	grid-template-rows: 0fr;
	transition: grid-template-rows 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}

.has-js .faq__item.is-open .faq__panel {
	grid-template-rows: 1fr;
}

.faq__answer {
	min-height: 0;
	overflow: hidden;
	padding: 0 1.625rem;
	color: var(--color-text);
	font-size: 1rem;
	line-height: 1.6;
}

/* The copy fades rather than arriving at full strength while the box is
   still moving. Opening is delayed slightly so the box leads and the words
   follow; closing fades out fast so the text is gone before the collapse
   finishes. Opacity does not affect layout, so it cannot disturb the
   height curve above. */
.has-js .faq__answer {
	opacity: 0;
	transition: opacity 0.2s ease;
}

.has-js .faq__item.is-open .faq__answer {
	opacity: 1;
	transition: opacity 0.28s ease 0.1s;
}

.faq__answer > :first-child {
	margin-top: 0;
}

/* Bottom breathing space as a child MARGIN, not container padding.
   overflow:hidden clips a child's margin when the track collapses to 0,
   but it does NOT clip the container's own padding - that would leave a
   24px sliver under every closed row, which is why the padding used to be
   toggled. As a margin it can stay constant, so nothing but the row
   animates, and the no-JS (always open) rendering is spaced correctly too. */
.faq__answer > :last-child {
	margin-bottom: 1.5rem;
}

/* ---- Reduced motion: no height / icon animation ---- */

/* Selectors must carry at least the specificity of the .has-js rules above,
   or the transitions they set simply win and reduced-motion does nothing. */
@media (prefers-reduced-motion: reduce) {
	.faq__icon-v,
	.has-js .faq__panel,
	.has-js .faq__answer,
	.has-js .faq__item.is-open .faq__answer {
		transition: none;
	}
}

/* ---- Tablet: roomier padding, deliberate middle treatment ---- */

@media (min-width: 768px) {
	.faq__toggle {
		padding: 1.5rem 2rem;
		font-size: 1.0625rem;
	}

	.faq__answer {
		padding-inline: 2rem;
		font-size: 1.0625rem;
	}
}

/* ---- Desktop ---- */

@media (min-width: 1024px) {
	.faq__toggle {
		padding: 1.75rem 2.25rem;
		font-size: 1.125rem;
	}

	.faq__answer {
		padding-inline: 2.25rem;
		font-size: 1.125rem;
	}

	.faq__answer > :last-child {
		margin-bottom: 1.75rem;
	}
}
