/**
 * Zenth Toolkit — FAQ Accordion
 *
 * Acordeón accesible de preguntas frecuentes. El contenido se gestiona desde
 * el CPT cr_faq; el header de la sección se arma en Elementor.
 *
 * Standalone: usa var(--cr-*, fallback) para funcionar sin el theme.
 *
 * Prefijo `zenth-faq__*` (NO `cr-faq*`) para no colisionar con el FAQ del home
 * que vive en el theme (home.css + faq-accordion.js global).
 *
 * ─────────────────────────────────────────────────────────────────────────
 * ÍNDICE
 *   §1  Base          → anti-colapso del widget + container .zenth-faq + tokens
 *   §2  Item          → card con borde redondeado (+ hover / is-open / heading)
 *   §3  Pregunta      → botón .zenth-faq__question (+ focus, text)
 *   §4  Icono +/−     → .zenth-faq__icon (barras ::before / ::after)
 *   §5  Respuesta     → animación grid-rows + .zenth-faq__answer-inner
 *   §6  Responsive    → solo accesibilidad (prefers-reduced-motion)
 * ─────────────────────────────────────────────────────────────────────────
 * BREAKPOINTS: ninguno de tamaño (el layout es fluido — clamp + max-width).
 *   Único @media es de accesibilidad (prefers-reduced-motion), aislado en §6.
 * ─────────────────────────────────────────────────────────────────────────
 */


/* ═══════════════════════════════════════════════════════════════════════
   §1 · BASE — anti-colapso del widget + container + tokens locales
   ═══════════════════════════════════════════════════════════════════════ */

/* Anti-colapso: el widget puede vivir dentro de un contenedor flex con
   align-items:center (p. ej. .cr-section--center), que encogería su wrapper.
   Forzamos ancho completo (misma lección que el grid de Proyectos). */
.elementor-widget-zenth_faq_accordion {
	width: 100% !important;
}

.zenth-faq {
	--cr-faq-gap: 16px;
	--cr-faq-radius: 12px;
	--cr-faq-border: rgba(255, 255, 255, 0.12);

	box-sizing: border-box;
	width: 100%;
	max-width: min(1040px, 100%);
	margin-inline: auto;
	padding-inline: var(--cr-container-pad, 32px);
}

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


/* ═══════════════════════════════════════════════════════════════════════
   §2 · ITEM — card con borde redondeado
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-faq__item {
	border: 1px solid var(--cr-faq-border);
	border-radius: var(--cr-faq-radius);
	margin-bottom: var(--cr-faq-gap);
	background: transparent;
	transition: border-color var(--cr-transition-base, 250ms ease),
				box-shadow var(--cr-transition-base, 250ms ease);
}

.zenth-faq__item:last-child {
	margin-bottom: 0;
}

.zenth-faq__item:hover,
.zenth-faq__item.is-open {
	border-color: var(--cr-color-primary, #c00000);
}

.zenth-faq__item.is-open {
	box-shadow: 0 0 0 1px var(--cr-color-primary, #c00000),
				0 8px 30px rgba(192, 0, 0, 0.12);
}

/* El <h3> envuelve al botón solo por semántica/outline; sin estilos propios. */
.zenth-faq__heading {
	margin: 0;
	font: inherit;
}


/* ═══════════════════════════════════════════════════════════════════════
   §3 · PREGUNTA — botón
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-faq__question {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
	width: 100% !important;
	margin: 0 !important;
	padding: 22px 28px !important;
	border: 0 !important;
	background: transparent !important;
	color: var(--cr-color-white, #fff) !important;
	font-family: var(--cr-font-body, system-ui, sans-serif) !important;
	font-size: clamp(1rem, 0.95rem + 0.3vw, 1.125rem) !important;
	font-weight: 600 !important;
	line-height: 1.4 !important;
	text-align: left !important;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	border-radius: var(--cr-faq-radius);
}

.zenth-faq__question:focus-visible {
	outline: 2px solid var(--cr-color-primary, #c00000);
	outline-offset: -2px;
}

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


/* ═══════════════════════════════════════════════════════════════════════
   §4 · ICONO +/−
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-faq__icon {
	position: relative;
	flex: 0 0 auto;
	width: 22px;
	height: 22px;
	color: var(--cr-color-white, #fff);
	transition: color var(--cr-transition-base, 250ms ease);
}

.zenth-faq__icon::before,
.zenth-faq__icon::after {
	content: '';
	position: absolute;
	background: currentColor;
	border-radius: 2px;
}

/* Barra horizontal */
.zenth-faq__icon::before {
	top: 50%;
	left: 0;
	width: 100%;
	height: 2px;
	transform: translateY(-50%);
}

/* Barra vertical (la que colapsa al abrir → "−") */
.zenth-faq__icon::after {
	left: 50%;
	top: 0;
	width: 2px;
	height: 100%;
	transform: translateX(-50%);
	transition: transform var(--cr-transition-base, 250ms ease);
}

.zenth-faq__item.is-open .zenth-faq__icon {
	color: var(--cr-color-primary, #c00000);
}

.zenth-faq__item.is-open .zenth-faq__icon::after {
	transform: translateX(-50%) scaleY(0);
}


/* ═══════════════════════════════════════════════════════════════════════
   §5 · RESPUESTA — animación con grid-rows
   ═══════════════════════════════════════════════════════════════════════ */

/* Colapso con grid-rows. Usamos `minmax(0, 0fr)` (no `0fr` pelado) para FORZAR
   el mínimo del track a 0: el `0fr` pelado equivale a `minmax(auto, 0fr)` y, si
   el navegador no respeta el `min-height:0` del item, deja un "sliver" visible
   (se ve la 1ª línea de la respuesta colapsada). `overflow:hidden` en el propio
   contenedor es un refuerzo por si quedara altura residual. */
.zenth-faq__answer {
	display: grid;
	grid-template-rows: minmax(0, 0fr);
	overflow: hidden;
	transition: grid-template-rows var(--cr-transition-slow, 400ms cubic-bezier(0.4, 0, 0.2, 1));
}

.zenth-faq__item.is-open .zenth-faq__answer {
	grid-template-rows: minmax(0, 1fr);
}

.zenth-faq__answer-inner {
	overflow: hidden;
	min-height: 0;
	padding: 0 28px 24px;
	color: var(--cr-color-text-dim, rgba(255, 255, 255, 0.78));
	font-family: var(--cr-font-body, system-ui, sans-serif);
	font-size: 0.9375rem;
	line-height: 1.65;
}

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

.zenth-faq__answer-inner > :last-child {
	margin-bottom: 0;
}

.zenth-faq__answer-inner p {
	margin: 0 0 0.85em;
}

.zenth-faq__answer-inner a {
	color: var(--cr-color-primary-hover, #e60000);
	text-decoration: underline;
}


/* ═══════════════════════════════════════════════════════════════════════
   §6 · RESPONSIVE
   ───────────────────────────────────────────────────────────────────────
   Un breakpoint de tamaño (Mobile ≤767: pregunta a UNA línea con ellipsis) +
   accesibilidad (prefers-reduced-motion), aislada al final.
   ═══════════════════════════════════════════════════════════════════════ */

/* ───────────────────────── MOBILE · max-width: 767px ──────────────────── */
@media (max-width: 767px) {
	/* Pregunta colapsada en UNA línea con puntos suspensivos: el texto largo
	   rompía el layout en móvil. Al abrir el acordeón (.is-open) se muestra la
	   pregunta COMPLETA (multilínea) junto con la respuesta. min-width:0 es
	   imprescindible para que el ellipsis funcione dentro del flex. */
	.zenth-faq__question-text {
		min-width: 0;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	.zenth-faq__item.is-open .zenth-faq__question-text {
		white-space: normal;
		overflow: visible;
	}
}


/* ─────────────────── ACCESIBILIDAD · prefers-reduced-motion ───────────── */
@media (prefers-reduced-motion: reduce) {
	.zenth-faq__item,
	.zenth-faq__icon,
	.zenth-faq__icon::after,
	.zenth-faq__answer {
		transition: none;
	}
}
