/*!
 * SG FAQ front-end styles.
 * Every rule is scoped to .sgfaq-wrap so nothing leaks into the theme.
 * Headings and text inherit the site's fonts, sizes and colours; the plugin
 * only sets spacing, lines, and the accent colour.
 * Override any --sgfaq-* variable from SG FAQ > Shortcodes & Settings > Custom CSS.
 */

.sgfaq-wrap {
	--sgfaq-accent: #1d6b8f;
	--sgfaq-on-accent: #ffffff;
	--sgfaq-accent-soft: rgba(29, 107, 143, 0.14);
	--sgfaq-line: rgba(128, 128, 128, 0.3);
	--sgfaq-tint: rgba(128, 128, 128, 0.07);
	--sgfaq-radius: 14px;
	--sgfaq-gap: 2.5rem;
	container: sgfaq / inline-size;
	position: relative;
	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin: 0 0 2em;
}

/* Lines and tints are mixed from the text colour, so they suit light and dark themes. */
@supports (color: color-mix(in srgb, red 50%, blue)) {
	.sgfaq-wrap {
		--sgfaq-accent-soft: color-mix(in srgb, var(--sgfaq-accent) 14%, transparent);
		--sgfaq-line: color-mix(in srgb, currentColor 16%, transparent);
		--sgfaq-tint: color-mix(in srgb, currentColor 5%, transparent);
	}
}

.sgfaq-wrap .sgfaq-list,
.sgfaq-wrap .sgfaq-item,
.sgfaq-wrap .sgfaq-q,
.sgfaq-wrap .sgfaq-a,
.sgfaq-wrap .sgfaq-split,
.sgfaq-wrap .sgfaq-nav,
.sgfaq-wrap .sgfaq-panels,
.sgfaq-wrap .sgfaq-search {
	box-sizing: border-box;
}

.sgfaq-wrap [hidden],
.sgfaq-wrap .sgfaq-is-filtered {
	display: none !important;
}

/* ---- Shared ---------------------------------------------------------- */

.sgfaq-wrap .sgfaq-title {
	margin: 0 0 1em;
}

/* Theme sets font, weight, size and colour. We only reset spacing. */
.sgfaq-wrap .sgfaq-q {
	margin: 0;
	padding: 0;
}

.sgfaq-wrap .sgfaq-a > :first-child {
	margin-top: 0;
}

.sgfaq-wrap .sgfaq-a > :last-child {
	margin-bottom: 0;
}

.sgfaq-wrap .sgfaq-a img,
.sgfaq-wrap .sgfaq-a video {
	max-width: 100%;
	height: auto;
}

.sgfaq-wrap .sgfaq-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---- Search ---------------------------------------------------------- */

.sgfaq-wrap .sgfaq-search {
	position: relative;
	max-width: 26rem;
	margin: 0 0 1.75em;
}

.sgfaq-wrap .sgfaq-search .sgfaq-search-icon {
	position: absolute;
	top: 50%;
	left: 1rem;
	width: 18px;
	height: 18px;
	margin-top: -9px;
	opacity: 0.55;
	pointer-events: none;
}

.sgfaq-wrap .sgfaq-search .sgfaq-search-input {
	-webkit-appearance: none;
	appearance: none;
	display: block;
	width: 100%;
	height: auto;
	min-height: 0;
	margin: 0;
	padding: 0.7em 1em 0.7em 2.75rem;
	font: inherit;
	line-height: 1.4;
	color: inherit !important;
	background: transparent !important;
	border: 1px solid var(--sgfaq-line) !important;
	border-radius: 999px !important;
	box-shadow: none !important;
	outline: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.sgfaq-wrap .sgfaq-search .sgfaq-search-input:focus {
	border-color: var(--sgfaq-accent) !important;
	box-shadow: 0 0 0 3px var(--sgfaq-accent-soft) !important;
}

.sgfaq-wrap .sgfaq-empty {
	margin: 1em 0;
	opacity: 0.75;
}

/* ---- 1. Accordion ---------------------------------------------------- */

.sgfaq-style-accordion .sgfaq-list {
	border-top: 1px solid var(--sgfaq-line);
}

.sgfaq-style-accordion .sgfaq-item {
	border-bottom: 1px solid var(--sgfaq-line);
}

/* Reset whatever the theme or page builder applies to buttons. */
.sgfaq-wrap .sgfaq-q .sgfaq-toggle {
	all: unset;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1.25rem;
	width: 100%;
	padding: 1.1em 0.25em;
	text-align: start;
	cursor: pointer;
	color: inherit !important;
	background: none !important;
	border: 0 !important;
	border-radius: 0;
	box-shadow: none !important;
	-webkit-tap-highlight-color: transparent;
}

.sgfaq-wrap .sgfaq-q .sgfaq-toggle:hover,
.sgfaq-wrap .sgfaq-q .sgfaq-toggle:focus,
.sgfaq-wrap .sgfaq-q .sgfaq-toggle:active {
	color: inherit !important;
	background: none !important;
	box-shadow: none !important;
}

.sgfaq-wrap .sgfaq-q .sgfaq-toggle:focus-visible {
	outline: 2px solid var(--sgfaq-accent) !important;
	outline-offset: 2px;
	border-radius: 6px;
}

.sgfaq-wrap .sgfaq-q-text {
	flex: 1 1 auto;
	min-width: 0;
}

.sgfaq-wrap .sgfaq-icon {
	position: relative;
	flex: none;
	width: 2rem;
	height: 2rem;
	border: 1px solid var(--sgfaq-line);
	border-radius: 50%;
	transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.3s ease;
}

.sgfaq-wrap .sgfaq-icon::before,
.sgfaq-wrap .sgfaq-icon::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 0.75rem;
	height: 2px;
	margin: -1px 0 0 -0.375rem;
	background: currentColor;
	border-radius: 2px;
	transition: transform 0.3s ease;
}

.sgfaq-wrap .sgfaq-icon::after {
	transform: rotate(90deg);
}

.sgfaq-wrap .sgfaq-q .sgfaq-toggle:hover .sgfaq-icon {
	border-color: var(--sgfaq-accent);
	background: var(--sgfaq-accent-soft);
}

.sgfaq-wrap .sgfaq-q .sgfaq-toggle[aria-expanded="true"] .sgfaq-icon {
	color: var(--sgfaq-on-accent);
	background: var(--sgfaq-accent);
	border-color: var(--sgfaq-accent);
	transform: rotate(180deg);
}

.sgfaq-wrap .sgfaq-q .sgfaq-toggle[aria-expanded="true"] .sgfaq-icon::after {
	transform: rotate(0deg);
}

.sgfaq-style-accordion .sgfaq-a {
	padding: 0 3.5rem 1.5em 0.25em;
}

.sgfaq-style-accordion .sgfaq-a:not([hidden]),
.sgfaq-style-split .sgfaq-panel:not([hidden]) {
	animation: sgfaq-reveal 0.25s ease;
}

@keyframes sgfaq-reveal {
	from {
		opacity: 0;
		transform: translateY(-4px);
	}
	to {
		opacity: 1;
		transform: none;
	}
}

/* ---- 2. Grid --------------------------------------------------------- */

.sgfaq-style-grid .sgfaq-list {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 2.25rem var(--sgfaq-gap);
}

.sgfaq-style-grid.sgfaq-cols-1 .sgfaq-list {
	grid-template-columns: minmax(0, 1fr);
}

.sgfaq-style-grid.sgfaq-cols-3 .sgfaq-list {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sgfaq-style-grid .sgfaq-item {
	position: relative;
	padding-top: 1.25rem;
	border-top: 1px solid var(--sgfaq-line);
}

.sgfaq-style-grid .sgfaq-item::before {
	content: "";
	position: absolute;
	top: -2px;
	left: 0;
	width: 2.5rem;
	height: 3px;
	border-radius: 3px;
	background: var(--sgfaq-accent);
}

.sgfaq-style-grid .sgfaq-item .sgfaq-q {
	margin-bottom: 0.6em;
}

/* ---- 3. Split -------------------------------------------------------- */

.sgfaq-style-split .sgfaq-split {
	display: grid;
	grid-template-columns: minmax(12rem, 2fr) minmax(0, 3fr);
	gap: var(--sgfaq-gap);
	align-items: start;
}

.sgfaq-style-split .sgfaq-nav {
	display: flex;
	flex-direction: column;
	border-left: 1px solid var(--sgfaq-line);
}

.sgfaq-wrap .sgfaq-nav .sgfaq-tab {
	all: unset;
	box-sizing: border-box;
	display: block;
	width: calc(100% + 1px);
	margin: 0 0 0 -1px;
	padding: 0.75em 1em 0.75em 1.25em;
	line-height: 1.4;
	text-align: start;
	cursor: pointer;
	opacity: 0.72;
	color: inherit !important;
	background: none !important;
	border: 0 !important;
	border-left: 2px solid transparent !important;
	border-radius: 0;
	box-shadow: none !important;
	transition: opacity 0.15s ease, border-color 0.15s ease;
	-webkit-tap-highlight-color: transparent;
}

.sgfaq-wrap .sgfaq-nav .sgfaq-tab:hover,
.sgfaq-wrap .sgfaq-nav .sgfaq-tab:focus,
.sgfaq-wrap .sgfaq-nav .sgfaq-tab:active {
	opacity: 1;
	color: inherit !important;
	background: none !important;
	box-shadow: none !important;
}

.sgfaq-wrap .sgfaq-nav .sgfaq-tab[aria-selected="true"] {
	opacity: 1;
	font-weight: 600;
	border-left-color: var(--sgfaq-accent) !important;
}

.sgfaq-wrap .sgfaq-nav .sgfaq-tab:focus-visible {
	outline: 2px solid var(--sgfaq-accent) !important;
	outline-offset: -2px;
	border-radius: 4px;
}

.sgfaq-style-split .sgfaq-panel {
	padding: clamp(1.25rem, 3vw, 2.25rem);
	border-radius: var(--sgfaq-radius);
	background: var(--sgfaq-tint);
}

.sgfaq-style-split .sgfaq-panel .sgfaq-q {
	margin-bottom: 0.75em;
}

.sgfaq-style-split .sgfaq-panel:focus {
	outline: none;
}

.sgfaq-style-split .sgfaq-panel:focus-visible {
	outline: 2px solid var(--sgfaq-accent);
	outline-offset: 2px;
}

/* ---- Narrow spaces (based on the FAQ's own width, not the screen) ---- */

@container sgfaq (max-width: 60rem) {
	.sgfaq-style-grid.sgfaq-cols-3 .sgfaq-list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@container sgfaq (max-width: 40rem) {
	.sgfaq-style-grid .sgfaq-list,
	.sgfaq-style-grid.sgfaq-cols-3 .sgfaq-list {
		grid-template-columns: minmax(0, 1fr);
		gap: 1.75rem;
	}

	.sgfaq-style-accordion .sgfaq-a {
		padding-right: 0.25em;
	}

	.sgfaq-style-split .sgfaq-split {
		display: block;
	}

	.sgfaq-style-split .sgfaq-nav {
		display: none;
	}

	.sgfaq-wrap.sgfaq-style-split .sgfaq-panel[hidden]:not(.sgfaq-is-filtered) {
		display: block !important;
	}

	.sgfaq-style-split .sgfaq-panel + .sgfaq-panel {
		margin-top: 1rem;
	}

	.sgfaq-style-split .sgfaq-panel:not([hidden]) {
		animation: none;
	}
}

/* ---- Motion & print -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.sgfaq-wrap *,
	.sgfaq-wrap *::before,
	.sgfaq-wrap *::after {
		animation: none !important;
		transition: none !important;
	}
}

@media print {
	.sgfaq-wrap .sgfaq-a[hidden],
	.sgfaq-wrap .sgfaq-panel[hidden] {
		display: block !important;
	}

	.sgfaq-wrap .sgfaq-search,
	.sgfaq-wrap .sgfaq-nav,
	.sgfaq-wrap .sgfaq-icon {
		display: none !important;
	}

	.sgfaq-wrap.sgfaq-style-split .sgfaq-split {
		display: block;
	}
}
