/**
 * PXC Freqs – Frontend (plugin-eigen, .pxcfaq-*).
 *
 * Akzent ist autoritativ aus den Plugin-Settings: --pxcfaq-accent wird am
 * Wrapper gesetzt (oder fällt auf einen festen Default zurück) – bewusst KEIN
 * Erben von ambienten --pxc-primary aus Theme/Elementor, damit Theme-Akzente
 * nicht durchschlagen.
 *
 * Progressive Enhancement: ohne .pxcfaq--js sind alle Antworten sichtbar.
 */

.pxcfaq {
	/* Akzent NUR aus Plugin-Settings (--pxcfaq-accent) + fester Fallback. */
	--pxcfaq-primary: var(--pxcfaq-accent, #2563eb);
	--pxcfaq-text: #1f2933;
	--pxcfaq-muted: #6b7280;
	--pxcfaq-border: rgba(0, 0, 0, 0.12);
	--pxcfaq-surface: #fff;
	--pxcfaq-surface-hover: rgba(0, 0, 0, 0.02);
	--pxcfaq-radius: 12px;
	--pxcfaq-primary-subtle: color-mix(in srgb, var(--pxcfaq-primary) 8%, transparent);

	/* Volle Containerbreite erzwingen – auch als Flex-Item in Elementor-
	   Containern mit align-items:center (sonst schrumpft/zentriert die Box). */
	display: block;
	box-sizing: border-box;
	width: 100% !important;
	max-width: 100% !important;
	flex: 1 0 100%;
	align-self: stretch;
	margin: 1.5rem 0;
	color: var(--pxcfaq-text);
	font-size: 1rem;
	line-height: 1.6;
	text-align: left; /* Fragen UND Antworten linksbündig, egal was das Theme zentriert. */
}

.pxcfaq *,
.pxcfaq *::before,
.pxcfaq *::after {
	box-sizing: border-box;
}

/*
 * Volle Breite in Elementor: das umgebende Shortcode-/Block-Widget ist oft ein
 * Flex-Item in einem Container mit align-items:center und schrumpft dann auf
 * seinen Inhalt (→ wird beim Filtern schmaler). align-self:stretch zwingt es,
 * die volle (definierte) Containerbreite einzunehmen. Scope strikt auf Wrapper
 * mit unserem .pxcfaq (kein Effekt auf andere Shortcodes/Widgets).
 */
.elementor-widget-shortcode:has(.pxcfaq),
.elementor-widget:has(> .elementor-widget-container > .pxcfaq),
.wp-block-shortcode:has(.pxcfaq) {
	align-self: stretch;
	width: 100%;
	max-width: 100%;
}

/* ── Suche ─────────────────────────────────────────────────────────── */
.pxcfaq .pxcfaq__search {
	position: relative;
	width: 100%;
	margin-bottom: 1rem;
}

.pxcfaq .pxcfaq__search-input {
	display: block;
	width: 100%;
	margin: 0;
	padding: 0.7em 0.95em 0.7em 2.55em;
	font: inherit;
	line-height: 1.4;
	color: var(--pxcfaq-text);
	background-color: var(--pxcfaq-surface);
	background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%236b7280" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><path d="m21 21-4.3-4.3"/></svg>');
	background-repeat: no-repeat;
	background-position: 0.85em center;
	background-size: 1.05em 1.05em;
	border: 1px solid var(--pxcfaq-border);
	border-radius: var(--pxcfaq-radius);
	box-shadow: none;
	transition: border-color 0.18s ease, box-shadow 0.18s ease;
	-webkit-appearance: none;
	appearance: none;
}

.pxcfaq .pxcfaq__search-input:focus {
	outline: none;
	border-color: var(--pxcfaq-primary);
	box-shadow: 0 0 0 3px var(--pxcfaq-primary-subtle);
}

/* ── Liste ─────────────────────────────────────────────────────────── */
.pxcfaq .pxcfaq__list {
	list-style: none;
	width: 100%;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
}

.pxcfaq .pxcfaq__item {
	width: 100%;
	background-color: var(--pxcfaq-surface) !important;
	border: 1px solid var(--pxcfaq-border);
	border-radius: var(--pxcfaq-radius);
	overflow: hidden;
}

.pxcfaq .pxcfaq__item[hidden] {
	display: none;
}

/* Geschlossene Akkordeon-Items leicht transparent, offene voll deckend. */
.pxcfaq--js.pxcfaq--accordion .pxcfaq__item {
	background-color: color-mix(in srgb, var(--pxcfaq-surface) 50%, transparent) !important;
	transition: background-color 0.25s ease, border-color 0.25s ease;
}

.pxcfaq--js.pxcfaq--accordion .pxcfaq__item.is-open {
	background-color: var(--pxcfaq-surface) !important;
}

/* ── Frage / Trigger ───────────────────────────────────────────────── */
.pxcfaq .pxcfaq__q {
	margin: 0;
	padding: 0;
	font-size: 1.05rem;
	font-weight: 600;
	line-height: 1.4;
	color: var(--pxcfaq-text);
	background: none;
	border: 0;
}

.pxcfaq .pxcfaq__q--static {
	padding: 0.9em 1.1em 0.2em;
}

/* Theme-/Elementor-Bleed auf den Button hart neutralisieren. */
.pxcfaq .pxcfaq__trigger,
.pxcfaq .pxcfaq__trigger:hover,
.pxcfaq .pxcfaq__trigger:focus,
.pxcfaq .pxcfaq__trigger:focus-visible,
.pxcfaq .pxcfaq__trigger:active {
	background-color: transparent !important;
	background-image: none !important;
	box-shadow: none !important;
	text-shadow: none !important;
	border: 0 !important;
}

.pxcfaq .pxcfaq__trigger {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1em;
	width: 100%;
	margin: 0;
	padding: 0.95em 1.1em;
	font: inherit;
	font-weight: 600;
	text-align: left;
	color: var(--pxcfaq-text) !important;
	cursor: pointer;
	border-radius: inherit;
	transition: background-color 0.18s ease, color 0.18s ease;
	-webkit-appearance: none;
	appearance: none;
}

.pxcfaq .pxcfaq__trigger:hover {
	background-color: var(--pxcfaq-surface-hover) !important;
	color: var(--pxcfaq-primary) !important;
}

.pxcfaq .pxcfaq__trigger:focus-visible {
	outline: 2px solid var(--pxcfaq-primary);
	outline-offset: -2px;
}

.pxcfaq .pxcfaq__q-text {
	flex: 1 1 auto;
}

/* ── Icon ──────────────────────────────────────────────────────────── */
.pxcfaq .pxcfaq__icon {
	flex: 0 0 auto;
	position: relative;
	width: 1.05em;
	height: 1.05em;
	color: var(--pxcfaq-primary);
	transition: transform 0.3s ease;
}

.pxcfaq .pxcfaq__icon::before,
.pxcfaq .pxcfaq__icon::after {
	content: "";
	position: absolute;
	background: currentColor;
	border-radius: 2px;
}

/* Plus / Minus */
.pxcfaq--icon-plus .pxcfaq__icon::before {
	top: 50%;
	left: 0;
	width: 100%;
	height: 2px;
	transform: translateY(-50%);
}

.pxcfaq--icon-plus .pxcfaq__icon::after {
	top: 0;
	left: 50%;
	width: 2px;
	height: 100%;
	transform: translateX(-50%);
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.pxcfaq--icon-plus .pxcfaq__item.is-open .pxcfaq__icon::after {
	opacity: 0;
	transform: translateX(-50%) rotate(90deg);
}

/* Chevron */
.pxcfaq--icon-chevron .pxcfaq__icon::before,
.pxcfaq--icon-chevron .pxcfaq__icon::after {
	top: 42%;
	width: 0.62em;
	height: 2px;
}

.pxcfaq--icon-chevron .pxcfaq__icon::before {
	left: 6%;
	transform: rotate(45deg);
}

.pxcfaq--icon-chevron .pxcfaq__icon::after {
	right: 6%;
	transform: rotate(-45deg);
}

.pxcfaq--icon-chevron .pxcfaq__item.is-open .pxcfaq__icon {
	transform: rotate(180deg);
}

/* ── Antwort ───────────────────────────────────────────────────────── */
.pxcfaq .pxcfaq__a-inner {
	padding: 0 1.1em 1.05em;
	color: var(--pxcfaq-text);
}

.pxcfaq .pxcfaq__a-inner > :first-child {
	margin-top: 0;
}

.pxcfaq .pxcfaq__a-inner > :last-child {
	margin-bottom: 0;
}

.pxcfaq .pxcfaq__a-inner a {
	color: var(--pxcfaq-primary);
}

/*
 * Akkordeon-Mechanik nur bei aktivem JS. Die Höhe wird vom JS deterministisch
 * gesetzt (0 ↔ scrollHeight ↔ auto): geschlossen = Höhe 0 + overflow hidden →
 * garantiert KEIN Anschneiden, unabhängig von Theme-/Browser-Eigenheiten.
 * Schließen startet sofort und animiert synchron mit dem Icon (beide 0,3 s).
 */
.pxcfaq--js.pxcfaq--accordion .pxcfaq__a {
	height: 0;
	overflow: hidden;
	transition: height 0.3s ease;
	will-change: height;
}

@media (prefers-reduced-motion: reduce) {
	.pxcfaq .pxcfaq__icon,
	.pxcfaq--js.pxcfaq--accordion .pxcfaq__a,
	.pxcfaq .pxcfaq__trigger,
	.pxcfaq .pxcfaq__search-input {
		transition: none;
	}
}
