/* ===========================================================================
   FAQ page, design canvas "QMS - FAQ" (2026-11-02)
   ===========================================================================
   Loaded only on pages whose content uses the `cq-faq-` sections (see
   inc/page-faq.php). Values follow the canvas and the Certain QMS Web Design
   System it was built with: white hero with breadcrumb, title and lead, then a
   category sidebar beside the question groups. Each question is a native
   <details> (one open at a time per group through its shared `name`), so the
   page works without script. Breakpoints as on the other canvas pages:
   tablet below 1024px, phone below 600px.

   assets/js/page-faq.js marks the category in view and, below 1024px, turns
   the category list into a dropdown under a button. It also adds the search
   field above the categories and the "expand all" button above the groups.
   Without script the list shows as a plain list above the questions.

   Spacing comes from flex/grid `gap`, so block margins inside these sections
   are reset, as on the configuration page. */

.cq-main {
	/* Same gutter as the header/footer (theme.json root padding). */
	--cq-faq-gutter: var(--wp--style--root--padding-left, clamp(24px, 5.56vw, 80px));
	--cq-faq-section: clamp(56px, 7vw, 96px);
	--cq-faq-text: #3f4947;
	--cq-faq-line: #e0e0e0;
	--cq-faq-ease: cubic-bezier(.2, 0, 0, 1);
}

.wp-block-post-content > .cq-faq-s {
	margin-block: 0 !important;
}

.cq-main .cq-faq-s :where(h1, h2, h3, p, ul, li, .wp-block-group) {
	margin: 0 !important;
}

.cq-main .cq-faq-s {
	font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.cq-main .cq-faq-wrap {
	box-sizing: border-box;
	margin-inline: auto !important;
	/* 1200px of content, like the header and footer (contentSize). */
	max-width: calc(1200px + 2 * var(--cq-faq-gutter));
	padding-inline: var(--cq-faq-gutter);
}

/* --- Hero ------------------------------------------------------------------- */

.cq-main .cq-faq-hero {
	background-color: #ffffff;
	border-bottom: 1px solid var(--cq-faq-line);
	padding-block: var(--cq-crumb-top) 72px;
}

.cq-main .cq-faq-hero .cq-breadcrumb ol {
	margin: 0;
}

.cq-main .cq-faq-hero__copy {
	/* Copy starts --cq-crumb-gap below the breadcrumb, as on every hero. */
	display: flex;
	flex-direction: column;
	gap: 16px;
	max-width: 760px;
	padding-top: var(--cq-crumb-gap);
}

.cq-main .cq-faq-h1 {
	color: var(--cq-ink);
	font-size: clamp(34px, 4.4vw, 56px);
	font-weight: 500;
	letter-spacing: -0.022em;
	line-height: 1.08;
	text-wrap: balance;
}

.cq-main .cq-faq-lead {
	color: var(--cq-faq-text);
	font-size: 20px;
	line-height: 1.6;
}

/* --- Layout: category sidebar beside the groups ------------------------------- */

.cq-main .cq-faq-body {
	background-color: #ffffff;
	padding-block: var(--cq-faq-section);
}

.cq-main .cq-faq-layout {
	align-items: flex-start;
	display: flex;
	gap: 64px;
}

.cq-main .cq-faq-aside {
	border-right: 1px solid var(--cq-faq-line);
	box-sizing: border-box;
	flex: 0 0 300px;
	padding-right: 32px;
	position: sticky;
	/* Clears the sticky site header (88px) with room to spare. */
	top: 120px;
}

.admin-bar .cq-main .cq-faq-aside {
	top: calc(120px + var(--wp-admin--admin-bar--height, 32px));
}

.cq-main .cq-faq-nav {
	display: flex;
	flex-direction: column;
	gap: 12px;
	position: relative;
}

.cq-main .cq-faq-eyebrow {
	color: var(--cq-navy);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.08em;
	line-height: 1.2;
	text-transform: uppercase;
}

.cq-main .cq-faq-nav__list {
	display: flex;
	flex-direction: column;
	gap: 2px;
	list-style: none;
	padding: 0;
}

.cq-main .cq-faq-nav__list a {
	align-items: center;
	border-left: 2px solid transparent;
	border-radius: 0 4px 4px 0;
	color: var(--cq-faq-text);
	display: flex;
	font-size: 16px;
	line-height: 1.35;
	min-height: 44px;
	padding: 6px 12px;
	box-sizing: border-box;
	text-decoration: none;
	transition: background-color 120ms var(--cq-faq-ease), color 120ms var(--cq-faq-ease);
}

.cq-main .cq-faq-nav__list a:hover {
	background-color: var(--cq-mist);
	color: var(--cq-ink);
}

.cq-main .cq-faq-nav__list a[aria-current="true"] {
	background-color: var(--cq-mist);
	border-left-color: var(--cq-blue);
	color: var(--cq-ink);
	font-weight: 500;
}

.cq-main .cq-faq-nav a:focus-visible,
.cq-main .cq-faq-select:focus-visible,
.cq-main .cq-faq-q:focus-visible {
	outline: 2px solid var(--cq-blue);
	outline-offset: 2px;
}

/* The dropdown button is made by the script and only used below 1024px. */
.cq-main .cq-faq-select {
	display: none;
}

/* --- Search and "expand all" (made by the script) ------------------------------- */

/* Filtered-out questions, groups and categories; beats the flex displays here. */
.cq-main .cq-faq-layout [hidden] {
	display: none !important;
}

.cq-main .cq-faq-aside {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.cq-main .cq-faq-panel {
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.cq-main .cq-faq-search .screen-reader-text {
	clip: rect(0 0 0 0);
	height: 1px;
	overflow: hidden;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

.cq-main .cq-faq-search__field {
	align-items: center;
	background-color: #ffffff;
	border: 1px solid #727272;
	border-radius: 8px;
	box-sizing: border-box;
	color: var(--cq-faq-text);
	display: flex;
	gap: 10px;
	min-height: 48px;
	padding: 0 14px;
	transition: border-color 120ms var(--cq-faq-ease), box-shadow 120ms var(--cq-faq-ease);
}

.cq-main .cq-faq-search__field:focus-within {
	border-color: var(--cq-blue);
	box-shadow: 0 0 0 1px var(--cq-blue);
}

.cq-main .cq-faq-search__field svg {
	flex: none;
	height: 20px;
	width: 20px;
}

/* By id: the theme's `.cq-main input:not(…)` rule sets an !important border
   with higher specificity than a class chain; the field draws the border here. */
.cq-main #cq-faq-search {
	appearance: none;
	background: transparent;
	border: 0 !important;
	border-radius: 0;
	box-shadow: none;
	color: var(--cq-ink);
	flex: 1;
	font: 400 16px/1.3 "Roboto", system-ui, sans-serif;
	min-height: 46px;
	min-width: 0;
	outline: none;
	padding: 0;
}

.cq-main #cq-faq-search::placeholder {
	color: var(--cq-faq-text);
	opacity: 1;
}

.cq-main .cq-faq-search__count {
	color: var(--cq-faq-text);
	font-size: 14px;
	line-height: 1.4;
	margin-top: 8px !important;
}

.cq-main .cq-faq-search__count:empty {
	display: none;
}

.cq-main .cq-faq-tools {
	display: flex;
	justify-content: flex-end;
	/* Sits 24px above the first group's heading instead of the 64px group gap. */
	margin-bottom: -40px !important;
}

.cq-main .cq-faq-expand {
	align-items: center;
	background: transparent;
	border: 0;
	border-radius: 4px;
	color: var(--cq-blue);
	cursor: pointer;
	display: inline-flex;
	font: 500 15px/1.3 "Roboto", system-ui, sans-serif;
	gap: 6px;
	min-height: 44px;
	padding: 0 4px;
}

.cq-main .cq-faq-expand svg {
	height: 18px;
	width: 18px;
}

.cq-main .cq-faq-expand:hover {
	color: var(--cq-navy);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.cq-main .cq-faq-empty {
	border: 1px solid var(--cq-faq-line);
	border-radius: 14px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding: 32px;
}

.cq-main .cq-faq-empty__title {
	color: var(--cq-ink);
	font-size: 20px;
	font-weight: 500;
	line-height: 1.35;
}

.cq-main .cq-faq-empty__text {
	color: var(--cq-faq-text);
	font-size: 17px;
	line-height: 1.6;
}

.cq-main .cq-faq-empty__text a {
	color: var(--cq-blue);
	font-weight: 500;
}

.cq-main .cq-faq-empty__reset {
	align-self: flex-start;
	background-color: #ffffff;
	border: 1px solid var(--cq-blue);
	border-radius: 8px;
	color: var(--cq-blue);
	cursor: pointer;
	font: 500 16px/1.2 "Roboto", system-ui, sans-serif;
	margin-top: 4px;
	min-height: 44px;
	padding: 0 20px;
}

.cq-main .cq-faq-empty__reset:hover {
	background-color: var(--cq-mist);
}

.cq-main .cq-faq-expand:focus-visible,
.cq-main .cq-faq-empty__reset:focus-visible {
	outline: 2px solid var(--cq-blue);
	outline-offset: 2px;
}

/* --- Question groups ------------------------------------------------------------ */

.cq-main .cq-faq-groups {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 64px;
	min-width: 0;
}

.cq-main .cq-faq-group {
	display: flex;
	flex-direction: column;
	gap: 24px;
	/* On top of the html scroll-padding (96px) that clears the sticky header. */
	scroll-margin-top: 24px;
}

.cq-main .cq-faq-h2 {
	color: var(--cq-ink);
	font-size: clamp(22px, 2.2vw, 28px);
	font-weight: 500;
	letter-spacing: -0.01em;
	line-height: 1.25;
}

.cq-main .cq-faq-list {
	border-top: 1px solid var(--cq-faq-line);
}

.cq-main .cq-faq-item {
	border-bottom: 1px solid var(--cq-faq-line);
	/* On top of the html scroll-padding (96px) that clears the sticky header. */
	scroll-margin-top: 24px;
}

.cq-main .cq-faq-q {
	align-items: center;
	color: var(--cq-ink);
	cursor: pointer;
	display: flex;
	gap: 16px;
	justify-content: space-between;
	list-style: none;
	min-height: 56px;
	padding: 20px 0;
	box-sizing: border-box;
}

.cq-main .cq-faq-q::-webkit-details-marker {
	display: none;
}

.cq-main .cq-faq-q__text {
	color: inherit;
	font-size: 20px;
	font-weight: 500;
	letter-spacing: -0.005em;
	line-height: 1.4;
}

.cq-main .cq-faq-q:hover {
	color: var(--cq-blue);
}

/* Plus that turns into a minus when the question is open. */
.cq-main .cq-faq-sign {
	color: var(--cq-blue);
	flex: none;
	height: 20px;
	position: relative;
	width: 20px;
}

.cq-main .cq-faq-sign::before,
.cq-main .cq-faq-sign::after {
	background-color: currentColor;
	content: "";
	left: 50%;
	position: absolute;
	top: 50%;
	transform: translate(-50%, -50%);
}

.cq-main .cq-faq-sign::before {
	height: 2px;
	width: 14px;
}

.cq-main .cq-faq-sign::after {
	height: 14px;
	transition: transform 200ms var(--cq-faq-ease);
	width: 2px;
}

.cq-main .cq-faq-item[open] .cq-faq-sign::after {
	transform: translate(-50%, -50%) scaleY(0);
}

.cq-main .cq-faq-a {
	color: var(--cq-faq-text);
	display: flex;
	flex-direction: column;
	font-size: 17px;
	gap: 12px;
	line-height: 1.65;
	max-width: 760px;
	padding-bottom: 28px;
}

.cq-main .cq-faq-a ul {
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding-left: 22px;
}

.cq-main .cq-faq-a strong {
	color: var(--cq-ink);
	font-weight: 500;
}

.cq-main .cq-faq-a a {
	color: var(--cq-blue);
	font-weight: 500;
	text-underline-offset: 3px;
}

.cq-main .cq-faq-a a:hover {
	color: var(--cq-navy);
}

/* --- Tablet and phone: one sticky "search questions" bar --------------------- */
/* Without script the sidebar stacks above the questions as a plain list. With
   it (`.is-ready`) the aside becomes a bar that sticks under the site header
   (--cq-faq-top, measured by the script) and opens one panel holding the
   search field and the categories, as on the ChemCenter FAQ. */

@media (max-width: 1023.98px) {
	.cq-main .cq-faq-hero {
		padding-bottom: 56px;
	}

	.cq-main .cq-faq-body {
		/* The bar starts at the top of the section and sticks from there. */
		padding-top: 0;
	}

	.cq-main .cq-faq-layout {
		flex-direction: column;
		gap: 32px;
	}

	.cq-main .cq-faq-aside {
		align-self: stretch;
		border-bottom: 1px solid var(--cq-faq-line);
		border-right: 0;
		flex: none;
		padding: 32px 0 24px;
		position: static;
	}

	.cq-main .cq-faq-aside.is-ready {
		background-color: #ffffff;
		/* Full width under the header, content on the page gutter. */
		margin-inline: calc(-1 * var(--cq-faq-gutter)) !important;
		padding: 12px var(--cq-faq-gutter);
		position: sticky;
		top: var(--cq-faq-top, 72px);
		z-index: 20;
	}

	.cq-main .cq-faq-group,
	.cq-main .cq-faq-item {
		/* Clears the sticky bar (about 77px) as well as the header. */
		scroll-margin-top: 100px;
	}

	.cq-main .cq-faq-q {
		padding: 24px 0;
	}

	.cq-main .is-ready .cq-faq-select {
		align-items: center;
		background-color: #ffffff;
		border: 1px solid #727272;
		border-radius: 8px;
		box-sizing: border-box;
		color: var(--cq-faq-text);
		cursor: pointer;
		display: flex;
		font: 400 16px/1.3 "Roboto", system-ui, sans-serif;
		gap: 10px;
		min-height: 52px;
		padding: 0 14px;
		text-align: left;
		transition: border-color 120ms var(--cq-faq-ease);
		width: 100%;
	}

	.cq-main .is-ready .cq-faq-select:hover,
	.cq-main .is-ready .cq-faq-select[aria-expanded="true"] {
		border-color: var(--cq-blue);
	}

	.cq-main .cq-faq-select.has-query {
		color: var(--cq-ink);
		font-weight: 500;
	}

	.cq-main .cq-faq-select__label {
		flex: 1;
		min-width: 0;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.cq-main .cq-faq-select__icon {
		flex: none;
		height: 20px;
		width: 20px;
	}

	.cq-main .cq-faq-select__caret {
		color: var(--cq-ink);
		flex: none;
		height: 20px;
		transition: transform 200ms var(--cq-faq-ease);
		width: 20px;
	}

	.cq-main .cq-faq-select[aria-expanded="true"] .cq-faq-select__caret {
		transform: rotate(180deg);
	}

	.cq-main .is-ready .cq-faq-panel {
		background-color: #ffffff;
		border: 1px solid var(--cq-faq-line);
		border-radius: 12px;
		box-shadow: 0 2px 4px rgba(6, 12, 49, .06), 0 8px 20px rgba(6, 12, 49, .07);
		box-sizing: border-box;
		display: none;
		gap: 16px;
		left: var(--cq-faq-gutter);
		/* Scrolls inside itself when the list is taller than the screen. */
		max-height: calc(100dvh - var(--cq-faq-top, 72px) - 96px);
		overflow-y: auto;
		overscroll-behavior: contain;
		padding: 12px;
		position: absolute;
		right: var(--cq-faq-gutter);
		top: calc(100% - 4px);
	}

	.cq-main .is-ready.is-open .cq-faq-panel {
		display: flex;
	}

	.cq-main .is-ready .cq-faq-search__field {
		min-height: 44px;
	}

	.cq-main .is-ready .cq-faq-nav {
		border-top: 1px solid var(--cq-faq-line);
		gap: 8px;
		padding-top: 16px;
	}

	.cq-main .is-ready .cq-faq-eyebrow {
		padding-inline: 4px;
	}

	.cq-main .is-ready .cq-faq-nav__list a {
		border-left: 0;
		border-radius: 8px;
		color: var(--cq-ink);
		gap: 12px;
		justify-content: space-between;
		min-height: 48px;
		padding: 6px 12px;
	}

	/* Check mark on the category in view. */
	.cq-main .is-ready .cq-faq-nav__list a[aria-current="true"]::after {
		background-color: var(--cq-blue);
		content: "";
		flex: none;
		height: 20px;
		-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5L20 7'/%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='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5L20 7'/%3E%3C/svg%3E") center / contain no-repeat;
		width: 20px;
	}
}

/* --- Phone ------------------------------------------------------------------------ */

@media (max-width: 599.98px) {
	.cq-main .cq-faq-hero {
		padding-bottom: 48px;
	}

	.cq-main .cq-faq-lead {
		font-size: 18px;
	}

	.cq-main .cq-faq-groups {
		gap: 48px;
	}

	.cq-main .cq-faq-q {
		gap: 20px;
		padding: 26px 0;
	}

	.cq-main .cq-faq-q__text {
		font-size: 18px;
	}

	.cq-main .cq-faq-a {
		padding-bottom: 32px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cq-main .cq-faq-nav__list a,
	.cq-main .cq-faq-sign::after,
	.cq-main .cq-faq-select,
	.cq-main .cq-faq-select__caret {
		transition: none;
	}
}
