/**
 * Zenth Toolkit — Search Modal v2.0 (Culture Racing rebrand)
 *
 * Modal centrado, dark, agresivo. Paleta CR: negro profundo + rojo #E8001D
 * + tipografía display. Sin border-radius (estética racing). Mantiene la
 * estructura HTML/JS intacta del v1; solo cambian tokens visuales y el
 * carácter del componente.
 *
 * ─────────────────────────────────────────────────────────────────────────
 * ÍNDICE
 *   §1  Tokens            → .zenth-search-root (custom props del componente)
 *   §2  Shell             → root fixed + .is-open + body scroll lock
 *   §3  Overlay           → backdrop con blur
 *   §4  Modal             → panel + animación de entrada
 *   §5  Input             → wrap + línea de acento + icono + campo + close/esc
 *   §6  Body              → área scrolleable + scrollbar
 *   §7  Empty + chips     → estado vacío + sugerencias (chips racing)
 *   §8  Results           → grupos + items (thumb, título, precio, excerpt)
 *   §9  See-all           → link "ver todos"
 *   §10 Estados           → [hidden] + loading/spinner + no-results
 *   §11 Responsive        → @media de tamaño + a11y
 * ─────────────────────────────────────────────────────────────────────────
 * BREAKPOINTS usados acá:  640 (max · mobile)
 *   Único breakpoint de tamaño (compacta paddings/tipografía del modal).
 *   + 1 media de A11Y (prefers-reduced-motion), subsección aparte en §11.
 *   El @keyframes zenth-search-spin vive junto a su consumidor (spinner, §10),
 *   no es media query.
 * ─────────────────────────────────────────────────────────────────────────
 */


/* ═══════════════════════════════════════════════════════════════════════
   §1 · TOKENS — custom props del componente
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-search-root {
	--zenth-search-bg: #0a0a0a;
	--zenth-search-text: #ffffff;
	--zenth-search-text-muted: rgba(255, 255, 255, 0.55);
	--zenth-search-text-dim: rgba(255, 255, 255, 0.35);
	--zenth-search-accent: #E8001D;
	--zenth-search-accent-soft: rgba(232, 0, 29, 0.12);
	--zenth-search-accent-glow: rgba(232, 0, 29, 0.4);
	/* Unificado al overlay global del proyecto (declarado en theme global.css). */
	--zenth-search-overlay: var(--zenth-mm-overlay, rgba(0, 0, 0, 0.7));
	--zenth-search-border: rgba(255, 255, 255, 0.08);
	--zenth-search-border-strong: rgba(255, 255, 255, 0.16);
	--zenth-search-hover: rgba(255, 255, 255, 0.04);
	--zenth-search-selected-bg: rgba(232, 0, 29, 0.10);
	--zenth-search-selected-border: var(--zenth-search-accent);
	--zenth-search-shadow:
		0 1px 0 rgba(255, 255, 255, 0.04) inset,
		0 24px 80px rgba(0, 0, 0, 0.7),
		0 8px 24px rgba(0, 0, 0, 0.5);
	--zenth-search-speed-open: 280ms;
	--zenth-search-speed-close: 220ms;
	--zenth-search-ease-open: cubic-bezier(0.32, 0.72, 0, 1);
	--zenth-search-ease-close: cubic-bezier(0.4, 0, 0.2, 1);

	/* Alias. */
	--zenth-search-speed: var(--zenth-search-speed-open);
	--zenth-search-ease: var(--zenth-search-ease-open);
	--zenth-search-z: 999997;

	/* Tipografía CR — fallbacks porque las fuentes display
	   no siempre están disponibles en todos los contextos. */
	--zenth-search-font-display: "Bebas Neue", "Barlow Condensed", "Super Brigade", system-ui, sans-serif;
	--zenth-search-font-label: "Barlow Condensed", "Barlow", system-ui, sans-serif;
}


/* ═══════════════════════════════════════════════════════════════════════
   §2 · SHELL — root fixed + estados de apertura + lock del body
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-search-root {
	position: fixed;
	inset: 0;
	z-index: var(--zenth-search-z);
	pointer-events: none;
	display: grid;
	place-items: start center;
	padding: 12vh 24px 24px;
	font-family: inherit;
	visibility: hidden;
	transition: visibility 0s linear var(--zenth-search-speed-close);
}

.zenth-search-root.is-open {
	pointer-events: auto;
	visibility: visible;
	transition: visibility 0s linear 0s;
}

/* Bloquear scroll del body cuando el modal está abierto */
body.zenth-search-body-lock {
	overflow: hidden;
}


/* ═══════════════════════════════════════════════════════════════════════
   §3 · OVERLAY — backdrop con blur
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-search-root .zenth-search-overlay {
	position: absolute;
	inset: 0;
	background: var(--zenth-search-overlay);
	backdrop-filter: blur(8px) saturate(120%);
	-webkit-backdrop-filter: blur(8px) saturate(120%);
	opacity: 0;
	transition: opacity var(--zenth-search-speed-close) var(--zenth-search-ease-close);
	cursor: pointer;
}

.zenth-search-root.is-open .zenth-search-overlay {
	opacity: 1;
	transition: opacity var(--zenth-search-speed-open) var(--zenth-search-ease-open);
}


/* ═══════════════════════════════════════════════════════════════════════
   §4 · MODAL — panel + animación de entrada
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-search-root .zenth-search-modal {
	position: relative;
	width: 100%;
	max-width: 680px;
	background: var(--zenth-search-bg);
	color: var(--zenth-search-text);
	border: 1px solid var(--zenth-search-border);
	box-shadow: var(--zenth-search-shadow);
	overflow: hidden;
	max-height: calc(100vh - 20vh);
	display: flex;
	flex-direction: column;

	/* Animación de entrada: escalar desde 0.96 y subir 12px. */
	opacity: 0;
	transform: scale(0.96) translateY(12px);
	transition: opacity var(--zenth-search-speed-close) var(--zenth-search-ease-close),
				transform var(--zenth-search-speed-close) var(--zenth-search-ease-close);
}

.zenth-search-root.is-open .zenth-search-modal {
	opacity: 1;
	transform: scale(1) translateY(0);
	transition: opacity var(--zenth-search-speed-open) var(--zenth-search-ease-open),
				transform var(--zenth-search-speed-open) var(--zenth-search-ease-open);
}


/* ═══════════════════════════════════════════════════════════════════════
   §5 · INPUT — wrap + línea de acento + icono + campo + close/esc
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-search-root .zenth-search-input-wrap {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 22px 24px;
	border-bottom: 2px solid var(--zenth-search-border);
	flex-shrink: 0;
	position: relative;
}

/* Línea de acento rojo bajo el input cuando hay foco dentro del modal.
   Visualiza el "estado activo" del modal de forma sutil. */
.zenth-search-root .zenth-search-input-wrap::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	bottom: -2px;
	height: 2px;
	background: var(--zenth-search-accent);
	transform: scaleX(0);
	transform-origin: center;
	transition: transform 320ms var(--zenth-search-ease-open);
}

.zenth-search-root.is-open .zenth-search-input-wrap:focus-within::after {
	transform: scaleX(1);
}

.zenth-search-root .zenth-search-input-icon {
	flex-shrink: 0;
	color: var(--zenth-search-accent);
	display: flex;
	align-items: center;
	justify-content: center;
}

.zenth-search-root .zenth-search-input-icon svg {
	width: 24px;
	height: 24px;
	display: block;
	stroke-width: 2.25;
}

.zenth-search-root .zenth-search-input {
	flex: 1;
	min-width: 0;
	border: none !important;
	outline: none !important;
	background: transparent !important;
	box-shadow: none !important;
	padding: 4px 0 !important;
	margin: 0 !important;
	font-family: var(--zenth-search-font-display) !important;
	font-size: clamp(1.5rem, 3vw, 2rem) !important;
	font-weight: 400 !important;
	line-height: 1.1 !important;
	letter-spacing: 0.02em;
	color: var(--zenth-search-text) !important;
	-webkit-appearance: none;
	appearance: none;
	caret-color: var(--zenth-search-accent);
	text-transform: uppercase;
}

.zenth-search-root .zenth-search-input::placeholder {
	color: var(--zenth-search-text-dim);
	font-weight: 400;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

/* Quitar el botón X nativo del input[type=search] en WebKit */
.zenth-search-root .zenth-search-input::-webkit-search-cancel-button,
.zenth-search-root .zenth-search-input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
}

.zenth-search-root .zenth-search-close {
	flex-shrink: 0;
	background: transparent;
	border: none;
	padding: 4px;
	cursor: pointer;
	color: var(--zenth-search-text-muted);
	transition: color 150ms ease;
	display: flex;
	align-items: center;
}

.zenth-search-root .zenth-search-close:hover {
	color: var(--zenth-search-text);
}

.zenth-search-root .zenth-search-esc {
	display: inline-block;
	padding: 5px 10px;
	background: transparent;
	border: 1px solid var(--zenth-search-border-strong);
	font-family: var(--zenth-search-font-label);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	color: inherit;
	transition: border-color 150ms ease, color 150ms ease;
}

.zenth-search-root .zenth-search-close:hover .zenth-search-esc {
	border-color: var(--zenth-search-accent);
	color: var(--zenth-search-accent);
}


/* ═══════════════════════════════════════════════════════════════════════
   §6 · BODY — área scrolleable + scrollbar
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-search-root .zenth-search-body {
	flex: 1 1 auto;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	min-height: 180px;
	scrollbar-width: thin;
	scrollbar-color: var(--zenth-search-border-strong) transparent;
}

.zenth-search-root .zenth-search-body::-webkit-scrollbar {
	width: 6px;
}

.zenth-search-root .zenth-search-body::-webkit-scrollbar-track {
	background: transparent;
}

.zenth-search-root .zenth-search-body::-webkit-scrollbar-thumb {
	background: var(--zenth-search-border-strong);
}

.zenth-search-root .zenth-search-body::-webkit-scrollbar-thumb:hover {
	background: var(--zenth-search-accent);
}


/* ═══════════════════════════════════════════════════════════════════════
   §7 · EMPTY + CHIPS — estado vacío + sugerencias
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-search-root .zenth-search-empty {
	padding: 36px 28px 40px;
	text-align: center;
}

.zenth-search-root .zenth-search-empty__hint {
	margin: 0 0 24px;
	font-family: var(--zenth-search-font-label);
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 2px;
	color: var(--zenth-search-text-muted);
	line-height: 1.5;
}

.zenth-search-root .zenth-search-suggestions__label {
	display: block;
	font-family: var(--zenth-search-font-label);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 2px;
	color: var(--zenth-search-text-dim);
	margin-bottom: 14px;
}

.zenth-search-root .zenth-search-suggestions__list {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
}

/* Chips uppercase, sin radius, estilo racing — no pills genéricas.
   Border rojo translúcido por defecto, sólido al hover. */
.zenth-search-root .zenth-search-suggestion {
	padding: 9px 18px;
	background: transparent;
	border: 1px solid rgba(232, 0, 29, 0.3);
	font-family: var(--zenth-search-font-label);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	color: var(--zenth-search-text);
	cursor: pointer;
	transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.zenth-search-root .zenth-search-suggestion:hover {
	background: var(--zenth-search-accent);
	border-color: var(--zenth-search-accent);
	color: #ffffff;
	transform: translateY(-1px);
}

.zenth-search-root .zenth-search-suggestion:active {
	transform: translateY(0);
}


/* ═══════════════════════════════════════════════════════════════════════
   §8 · RESULTS — grupos + items
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-search-root .zenth-search-results {
	padding: 8px 0;
}

.zenth-search-root .zenth-search-group {
	padding: 0;
}

.zenth-search-root .zenth-search-group__label {
	margin: 0 !important;
	padding: 16px 24px 8px;
	font-family: var(--zenth-search-font-label);
	font-size: 11px !important;
	font-weight: 700 !important;
	text-transform: uppercase;
	letter-spacing: 2px;
	color: var(--zenth-search-text-dim);
	line-height: 1;
}

.zenth-search-root .zenth-search-group__list {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
}

.zenth-search-root .zenth-search-item {
	margin: 0;
	padding: 0;
	list-style: none !important;
	border-left: 3px solid transparent;
	transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.zenth-search-root .zenth-search-item:hover,
.zenth-search-root .zenth-search-item.is-selected {
	background: var(--zenth-search-selected-bg);
	border-left-color: var(--zenth-search-selected-border);
	box-shadow: inset 0 0 24px -8px var(--zenth-search-accent-glow);
}

.zenth-search-root .zenth-search-item__link {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 12px 24px 12px 21px; /* 21 = 24 - 3 del border-left */
	text-decoration: none !important;
	color: inherit !important;
}

.zenth-search-root .zenth-search-item__thumb {
	flex: 0 0 auto;
	width: 52px;
	height: 52px;
	background: rgba(255, 255, 255, 0.04);
	border: 1px solid var(--zenth-search-border);
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: border-color 140ms ease;
}

.zenth-search-root .zenth-search-item:hover .zenth-search-item__thumb,
.zenth-search-root .zenth-search-item.is-selected .zenth-search-item__thumb {
	border-color: var(--zenth-search-accent);
}

.zenth-search-root .zenth-search-item__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.zenth-search-root .zenth-search-item__thumb--placeholder {
	background: rgba(255, 255, 255, 0.04);
}

.zenth-search-root .zenth-search-item__body {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.zenth-search-root .zenth-search-item__title {
	font-family: inherit;
	font-size: 15px;
	font-weight: 600;
	color: var(--zenth-search-text);
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.zenth-search-root .zenth-search-item__price {
	font-family: var(--zenth-search-font-label);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 1px;
	text-transform: uppercase;
	color: var(--zenth-search-accent);
	line-height: 1.3;
}

.zenth-search-root .zenth-search-item__excerpt {
	font-size: 13px;
	font-weight: 400;
	color: var(--zenth-search-text-muted);
	line-height: 1.4;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}


/* ═══════════════════════════════════════════════════════════════════════
   §9 · SEE-ALL — link "ver todos"
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-search-root .zenth-search-see-all {
	display: block;
	padding: 18px 24px;
	margin-top: 8px;
	border-top: 1px solid var(--zenth-search-border);
	font-family: var(--zenth-search-font-label);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 2px;
	text-transform: uppercase;
	color: var(--zenth-search-accent) !important;
	text-decoration: none !important;
	text-align: center;
	transition: background 140ms ease, letter-spacing 220ms ease;
}

.zenth-search-root .zenth-search-see-all:hover {
	background: var(--zenth-search-accent-soft);
	letter-spacing: 2.5px;
}


/* ═══════════════════════════════════════════════════════════════════════
   §10 · ESTADOS — [hidden] + loading/spinner + no-results
   ═══════════════════════════════════════════════════════════════════════ */

.zenth-search-root [hidden] {
	display: none !important;
}

.zenth-search-root .zenth-search-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	padding: 48px 20px;
	color: var(--zenth-search-text-muted);
}

.zenth-search-root .zenth-search-spinner {
	width: 26px;
	height: 26px;
	border: 2px solid rgba(255, 255, 255, 0.08);
	border-top-color: var(--zenth-search-accent);
	border-right-color: var(--zenth-search-accent);
	border-radius: 50%;
	animation: zenth-search-spin 700ms linear infinite;
}

@keyframes zenth-search-spin {
	to { transform: rotate(360deg); }
}

.zenth-search-root .zenth-search-loading__text {
	font-family: var(--zenth-search-font-label);
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 2px;
	text-transform: uppercase;
}

.zenth-search-root .zenth-search-no-results {
	padding: 44px 28px;
	text-align: center;
}

.zenth-search-root .zenth-search-no-results__text {
	margin: 0 0 10px !important;
	font-family: var(--zenth-search-font-display);
	font-size: 22px;
	font-weight: 400;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--zenth-search-text);
}

.zenth-search-root .zenth-search-no-results__text strong {
	color: var(--zenth-search-accent);
	font-weight: 400;
}

.zenth-search-root .zenth-search-no-results__hint {
	margin: 0 !important;
	font-family: var(--zenth-search-font-label);
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 1.5px;
	text-transform: uppercase;
	color: var(--zenth-search-text-muted);
}


/* ═══════════════════════════════════════════════════════════════════════
   §11 · RESPONSIVE
   ───────────────────────────────────────────────────────────────────────
   Único tier de TAMAÑO: max-width 640 (mobile) — compacta paddings,
   tipografía e íconos del modal. Las reglas base (§1–§10) están todas ANTES,
   así el cascade es correcto.

   Al final, subsección de A11Y (prefers-reduced-motion): NO es un breakpoint
   de tamaño y NO se consolida con el de arriba.
   ═══════════════════════════════════════════════════════════════════════ */

/* ───────────────────────── MOBILE · max-width: 640px ──────────────────── */
@media (max-width: 640px) {
	/* §2 · Shell: menos padding superior */
	.zenth-search-root {
		padding: 6vh 12px 12px;
	}

	/* §4 · Modal: más alto en pantalla chica */
	.zenth-search-root .zenth-search-modal {
		max-height: calc(100vh - 10vh);
	}

	/* §5 · Input: padding/gap e ícono más compactos; font >=16px evita zoom iOS */
	.zenth-search-root .zenth-search-input-wrap {
		padding: 18px 18px;
		gap: 12px;
	}

	.zenth-search-root .zenth-search-input {
		font-size: 1.25rem !important; /* >=16px equivalente para evitar zoom iOS */
	}

	.zenth-search-root .zenth-search-input-icon svg {
		width: 20px;
		height: 20px;
	}

	/* §8 · Items: padding/gap y thumb más chicos */
	.zenth-search-root .zenth-search-item__link {
		padding: 10px 16px 10px 13px;
		gap: 12px;
	}

	.zenth-search-root .zenth-search-item__thumb {
		width: 44px;
		height: 44px;
	}

	/* §8 · Label de grupo más compacto */
	.zenth-search-root .zenth-search-group__label {
		padding: 14px 18px 6px;
	}

	/* §7 · Empty + chips más compactos */
	.zenth-search-root .zenth-search-empty {
		padding: 28px 20px 32px;
	}

	.zenth-search-root .zenth-search-suggestion {
		padding: 8px 14px;
		font-size: 11px;
	}

	/* §10 · No-results: título más chico */
	.zenth-search-root .zenth-search-no-results__text {
		font-size: 18px;
	}
}


/* ── §11.1 · A11Y (sin breakpoint de tamaño) ──────────────────────────── */

/* §3/§4/§5/§7/§8/§9 · prefers-reduced-motion: anular transiciones y el spin */
@media (prefers-reduced-motion: reduce) {
	.zenth-search-root .zenth-search-overlay,
	.zenth-search-root .zenth-search-modal,
	.zenth-search-root .zenth-search-input-wrap::after,
	.zenth-search-root .zenth-search-suggestion,
	.zenth-search-root .zenth-search-see-all,
	.zenth-search-root .zenth-search-item {
		transition: none !important;
	}
	.zenth-search-root .zenth-search-spinner {
		animation-duration: 0ms !important;
	}
}
