/**
 * CH Product Archive Engine — grid styles.
 * El color principal es configurable (--ch-pae-primary, inyectado por PHP /
 * por el widget de Elementor). No hay colores de marca fijos aquí.
 */

/* Defaults live on :root so the PHP-injected :root override (added after this
 * file) and the Elementor per-widget selector both win the cascade. */
:root {
	--ch-pae-primary: #8a6d3b;
	--ch-pae-columns: 4;
	--ch-pae-instock: #7a8a1e;
	--ch-pae-gap: 24px;
	--ch-pae-radius: 14px;
	/* Proporción del área de imagen (ancho / alto). Ajustable por instancia. */
	--ch-pae-media-ratio: 1 / 1;
}

.ch-pae-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(var(--ch-pae-cols, var(--ch-pae-columns, 4)), minmax(0, 1fr));
	gap: var(--ch-pae-gap);
}

.ch-pae-card {
	margin: 0;
	list-style: none;
}

.ch-pae-card__inner {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	background: #fff;
	border-radius: var(--ch-pae-radius);
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
	overflow: hidden;
	transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.ch-pae-card__inner:hover {
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
	transform: translateY(-2px);
}

.ch-pae-card__media {
	position: relative;
	display: block;
}

.ch-pae-card__image {
	display: block;
	text-decoration: none;
}

.ch-pae-card__figure {
	margin: 0;
	padding: 14px 16px;
	aspect-ratio: var(--ch-pae-media-ratio);
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	overflow: hidden;
}

.ch-pae-card__figure img {
	width: 100%;
	height: 100%;
	/* contain = nunca recorta la imagen; se ve el puro completo. */
	object-fit: contain;
	object-position: center;
}

.ch-pae-card__brand {
	position: absolute;
	left: 0;
	bottom: 10px;
	max-width: 80%;
	padding: 10px 18px;
	background: var(--ch-pae-primary);
	color: #fff;
	font-weight: 700;
	font-size: 0.95rem;
	line-height: 1.2;
	border-top-right-radius: 10px;
	border-bottom-right-radius: 10px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	text-decoration: none;
}

/* Botón "+" para añadir al carrito sin abrir el producto (AJAX WooCommerce). */
.ch-pae-card__cart-wrap {
	position: absolute;
	right: 16px;
	bottom: 16px;
	z-index: 3;
	line-height: 0;
}

/* Especificidad reforzada con la clase propia .ch-pae-card__cart + resets, para
 * ganarle a los estilos de .button / .add_to_cart_button del tema/WooCommerce
 * que solo cargan en tienda/archivo. */
.ch-pae-card__cart-wrap a.button.ch-pae-card__cart {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	min-width: 0;
	min-height: 0;
	max-width: none;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: var(--ch-pae-primary);
	color: #fff;
	font-size: 0;
	line-height: 0;
	letter-spacing: 0;
	text-align: center;
	text-decoration: none;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
	transition: transform 0.15s ease, filter 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.ch-pae-card__cart-icon {
	width: 22px;
	height: 22px;
	display: block;
}

.ch-pae-card__cart-wrap a.button.ch-pae-card__cart:hover {
	filter: brightness(0.92);
	transform: translateY(-1px);
}

/* Estado "cargando" de WooCommerce: spinner en lugar del icono. */
.ch-pae-card__cart-wrap a.button.ch-pae-card__cart.loading .ch-pae-card__cart-icon {
	visibility: hidden;
}

.ch-pae-card__cart-wrap a.button.ch-pae-card__cart.loading::after {
	content: "";
	position: absolute;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.5);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ch-pae-spin 0.8s linear infinite;
}

/* Estado "añadido": marca de verificación. */
.ch-pae-card__cart-wrap a.button.ch-pae-card__cart.added .ch-pae-card__cart-icon {
	visibility: hidden;
}

.ch-pae-card__cart-wrap a.button.ch-pae-card__cart.added::after {
	content: "\2713";
	position: absolute;
	font-size: 22px;
	line-height: 1;
}

/* Oculta el enlace "Ver carrito" que WooCommerce añade tras el botón AJAX. */
.ch-pae-card__cart-wrap .added_to_cart {
	display: none;
}

/* Sin botón "+" en productos agotados. */
.ch-pae-card.is-outofstock .ch-pae-card__cart-wrap {
	display: none;
}

@keyframes ch-pae-spin {
	to {
		transform: rotate(360deg);
	}
}

/* El chip de marca ahora es un enlace propio (va a la marca, no al producto). */
a.ch-pae-card__brand {
	cursor: pointer;
	transition: filter 0.2s ease;
}

a.ch-pae-card__brand:hover {
	filter: brightness(0.92);
	color: #fff;
}

.ch-pae-card__body {
	padding: 12px 18px 18px;
	display: flex;
	flex-direction: column;
	gap: 5px;
}

.ch-pae-card__title {
	margin: 0;
	font-size: 1.15rem;
	line-height: 1.3;
	font-weight: 700;
}

.ch-pae-card__title a {
	color: var(--ch-pae-primary);
	text-decoration: none;
}

.ch-pae-card__title a:hover {
	text-decoration: underline;
}

.ch-pae-card__price {
	font-size: 1.15rem;
	font-weight: 700;
	color: #333;
}

.ch-pae-card__price del {
	color: #999;
	font-weight: 400;
	margin-right: 6px;
}

.ch-pae-card__price ins {
	text-decoration: none;
}

.ch-pae-card__stock {
	margin: 2px 0 0;
	font-size: 1.05rem;
	font-weight: 600;
}

.ch-pae-card__stock.is-instock {
	color: var(--ch-pae-instock);
}

.ch-pae-card__stock.is-outofstock {
	color: #b23b3b;
}

/* Pagination — inherits WooCommerce markup, tinted with the primary color. */
.ch-pae-pagination {
	margin-top: 32px;
}

.ch-pae-pagination .page-numbers {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
	list-style: none;
	margin: 0;
	padding: 0;
}

.ch-pae-pagination .page-numbers li {
	list-style: none;
}

.ch-pae-pagination .page-numbers a,
.ch-pae-pagination .page-numbers span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 42px;
	height: 42px;
	padding: 0 12px;
	border: 1px solid rgba(0, 0, 0, 0.12);
	border-radius: 8px;
	text-decoration: none;
	color: var(--ch-pae-primary);
}

.ch-pae-pagination .page-numbers .current,
.ch-pae-pagination .page-numbers a:hover {
	background: var(--ch-pae-primary);
	color: #fff;
	border-color: var(--ch-pae-primary);
}

.ch-pae-empty {
	padding: 40px 0;
	text-align: center;
	color: #666;
	font-size: 1.05rem;
}

/* ------------------------------------------------------------------ */
/* Filtros facetados (sidebar / barra superior) + chips activos.       */
/* ------------------------------------------------------------------ */
.ch-pae-filter {
	--ch-pae-primary: var(--ch-pae-primary, #8a6d3b);
}

.ch-pae-filter__heading {
	margin: 0 0 12px;
	font-size: 1.1rem;
	font-weight: 700;
	color: var(--ch-pae-primary);
}

.ch-pae-filter__groups {
	display: flex;
	flex-direction: column;
	gap: 18px;
}

.ch-pae-filter--bar .ch-pae-filter__groups {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 24px;
}

.ch-pae-filter__group {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
}

.ch-pae-filter__title {
	display: block;
	padding: 0;
	margin: 0 0 8px;
	font-size: 1rem;
	font-weight: 700;
	color: var(--ch-pae-primary);
}

.ch-pae-filter__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.ch-pae-filter--bar .ch-pae-filter__list {
	flex-direction: row;
	flex-wrap: wrap;
	gap: 6px 16px;
}

.ch-pae-filter__label {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	font-size: 0.95rem;
	line-height: 1.3;
}

.ch-pae-filter__label input {
	accent-color: var(--ch-pae-primary);
	width: 16px;
	height: 16px;
	margin: 0;
	flex: 0 0 auto;
}

.ch-pae-filter__actions {
	margin-top: 16px;
	display: flex;
	align-items: center;
	gap: 14px;
	flex-wrap: wrap;
}

.ch-pae-filter__apply {
	border: 0;
	cursor: pointer;
	background: var(--ch-pae-primary);
	color: #fff;
	font-weight: 600;
	padding: 10px 18px;
	border-radius: 8px;
}

.ch-pae-filter__reset {
	color: var(--ch-pae-primary);
	text-decoration: underline;
	font-size: 0.9rem;
}

/* Grupos plegables (acordeón). */
.ch-pae-filter__legend {
	padding: 0;
	width: 100%;
	display: block;
}

button.ch-pae-filter__title {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
	text-align: left;
}

button.ch-pae-filter__title::after {
	content: "";
	width: 8px;
	height: 8px;
	margin-left: 10px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg);
	transition: transform 0.2s ease;
}

.ch-pae-filter__group.is-collapsed button.ch-pae-filter__title::after {
	transform: rotate(-45deg);
}

.ch-pae-filter__group.is-collapsed .ch-pae-filter__list {
	display: none;
}

/* Botón "Filtros" para móvil: mismo aspecto que el desplegable de precios
 * (caja blanca redondeada con flecha). Abre/cierra con un onclick inline que
 * cambia el display (no depende de JS externo ni de CSS de estado, así funciona
 * aunque WP Rocket retrase el JS o elimine el CSS no usado). Oculto en escritorio. */
.ch-pae-filter-wrap .ch-pae-filter__mobile-toggle {
	display: none;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	cursor: pointer;
	background-color: #fff;
	color: #333;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 10px;
	padding: 10px 16px;
	font-size: 0.95rem;
	font-weight: 600;
	line-height: 1.2;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.ch-pae-filter-wrap .ch-pae-filter__mobile-toggle::after {
	content: "";
	width: 9px;
	height: 9px;
	flex: 0 0 auto;
	border-right: 2px solid var(--ch-pae-primary);
	border-bottom: 2px solid var(--ch-pae-primary);
	transform: translateY(-2px) rotate(45deg);
	transition: transform 0.2s ease;
}

.ch-pae-filter-wrap.is-open .ch-pae-filter__mobile-toggle::after {
	transform: translateY(2px) rotate(-135deg);
}

/* En móvil: muestra el botón y colapsa el panel. El onclick inline pone
 * display:block en el panel para abrirlo (sobrescribe este display:none). */
@media (max-width: 768px) {
	.ch-pae-filter-wrap .ch-pae-filter__mobile-toggle {
		display: flex;
	}

	.ch-pae-filter-wrap .ch-pae-filter.has-mobile-toggle .ch-pae-filter__body {
		display: none;
		margin-top: 12px;
	}
}

/* Desplegable de ordenamiento (mismo estilo redondeado de la tarjeta). */
.ch-pae-orderby {
	display: inline-flex;
	align-items: center;
	gap: 10px;
}

.ch-pae-orderby__label {
	font-weight: 600;
	color: var(--ch-pae-primary);
}

.ch-pae-orderby__select {
	appearance: none;
	-webkit-appearance: none;
	cursor: pointer;
	background-color: #fff;
	color: #333;
	border: 1px solid rgba(0, 0, 0, 0.15);
	border-radius: 10px;
	padding: 10px 40px 10px 16px;
	font-size: 0.95rem;
	line-height: 1.2;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238a6d3b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 14px center;
}

.ch-pae-orderby__select:focus {
	outline: none;
	border-color: var(--ch-pae-primary);
}

/* Chips de filtros activos (barra superior). */
.ch-pae-active {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
	margin: 0 0 18px;
}

.ch-pae-active__chip,
.ch-pae-active__reset {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	border-radius: 999px;
	border: 1px solid var(--ch-pae-primary);
	color: var(--ch-pae-primary);
	background: #fff;
	text-decoration: none;
	font-size: 0.9rem;
	line-height: 1;
}

.ch-pae-active__reset {
	font-weight: 700;
}

.ch-pae-active__chip:hover {
	background: var(--ch-pae-primary);
	color: #fff;
}

.ch-pae-active__x {
	font-size: 1.1em;
	line-height: 1;
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Carrusel (scroll-snap CSS + JS mínimo para las flechas).            */
/* ------------------------------------------------------------------ */
.ch-pae-carousel {
	position: relative;
}

.ch-pae-carousel__track {
	list-style: none;
	margin: 0;
	padding: 4px 4px 12px;
	display: flex;
	gap: var(--ch-pae-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	/* Sin barra de scroll visible (se navega con flechas / arrastre). */
	scrollbar-width: none;
	-ms-overflow-style: none;
}

.ch-pae-carousel__track::-webkit-scrollbar {
	display: none;
	width: 0;
	height: 0;
}

.ch-pae-carousel__track > .ch-pae-card,
.ch-pae-carousel__track > .ch-pae-cat {
	flex: 0 0 calc((100% - (var(--ch-pae-slides, 4) - 1) * var(--ch-pae-gap)) / var(--ch-pae-slides, 4));
	scroll-snap-align: start;
}

.ch-pae-carousel__nav {
	position: absolute;
	top: 40%;
	transform: translateY(-50%);
	z-index: 2;
	width: 44px;
	height: 44px;
	border: 0;
	border-radius: 50%;
	background: var(--ch-pae-primary);
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.2s ease;
}

.ch-pae-carousel__nav--prev {
	left: -10px;
}

.ch-pae-carousel__nav--next {
	right: -10px;
}

.ch-pae-carousel__nav[disabled] {
	opacity: 0.35;
	cursor: default;
}

.ch-pae-carousel__dots {
	display: flex;
	justify-content: center;
	gap: 8px;
	margin-top: 14px;
}

.ch-pae-carousel__dot {
	width: 10px;
	height: 10px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.18);
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
}

.ch-pae-carousel__dot.is-active {
	background: var(--ch-pae-primary);
	transform: scale(1.25);
}

@media (max-width: 1024px) {
	.ch-pae-carousel__track > .ch-pae-card,
.ch-pae-carousel__track > .ch-pae-cat {
		flex-basis: calc((100% - (var(--ch-pae-slides-tablet, 3) - 1) * var(--ch-pae-gap)) / var(--ch-pae-slides-tablet, 3));
	}
}

@media (max-width: 600px) {
	.ch-pae-carousel__track > .ch-pae-card,
.ch-pae-carousel__track > .ch-pae-cat {
		flex-basis: calc((100% - (var(--ch-pae-slides-mobile, 1.2) - 1) * var(--ch-pae-gap)) / var(--ch-pae-slides-mobile, 1.2));
	}

	.ch-pae-carousel__nav {
		display: none;
	}
}

/* Columnas responsive controladas por instancia (escritorio/tablet/móvil). */
@media (max-width: 1024px) {
	.ch-pae-grid {
		grid-template-columns: repeat(var(--ch-pae-cols-tablet, 2), minmax(0, 1fr));
	}
}

@media (max-width: 600px) {
	.ch-pae-grid {
		grid-template-columns: repeat(var(--ch-pae-cols-mobile, 1), minmax(0, 1fr));
	}
}

/* ------------------------------------------------------------------ */
/* Carrusel de categorías (imagen + nombre, enlace a la categoría).    */
/* ------------------------------------------------------------------ */
.ch-pae-cat {
	margin: 0;
	list-style: none;
}

.ch-pae-cat__link {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
	text-decoration: none;
	color: inherit;
}

.ch-pae-cat__media {
	width: 100%;
	aspect-ratio: var(--ch-pae-cat-ratio, 1 / 1);
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	transition: transform 0.2s ease;
}

.ch-pae-cat__link:hover .ch-pae-cat__media {
	transform: translateY(-3px);
}

.ch-pae-cat__media img {
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

.ch-pae-cat__name {
	font-weight: 700;
	font-size: 1rem;
	line-height: 1.2;
	text-align: center;
	color: var(--ch-pae-primary);
}

.ch-pae-cat__link:hover .ch-pae-cat__name {
	text-decoration: underline;
}

/* Flechas minimalistas (chevron fino, sin círculo) solo en el carrusel de
 * categorías; el carrusel de productos conserva sus flechas redondas. */
/* Gutter lateral para que las flechas NO se monten sobre los logos. */
.ch-pae--categories .ch-pae-carousel {
	padding: 0 48px;
}

.ch-pae--categories .ch-pae-carousel__nav,
.ch-pae--categories .ch-pae-carousel__nav:focus,
.ch-pae--categories .ch-pae-carousel__nav:hover,
.ch-pae--categories .ch-pae-carousel__nav:active {
	width: 40px;
	height: 40px;
	padding: 0;
	background: transparent;
	background-color: transparent;
	color: var(--ch-pae-primary);
	border: 0;
	border-radius: 0;
	box-shadow: none;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
	top: 50%;
}

.ch-pae--categories .ch-pae-carousel__nav:focus-visible {
	outline: 2px solid var(--ch-pae-primary);
	outline-offset: 2px;
}

.ch-pae--categories .ch-pae-carousel__nav svg {
	width: 28px;
	height: 28px;
	display: block;
}

.ch-pae--categories .ch-pae-carousel__nav:hover {
	opacity: 0.6;
}

.ch-pae--categories .ch-pae-carousel__nav--prev {
	left: 0;
}

.ch-pae--categories .ch-pae-carousel__nav--next {
	right: 0;
}

@media (max-width: 600px) {
	.ch-pae--categories .ch-pae-carousel {
		padding: 0 34px;
	}

	.ch-pae--categories .ch-pae-carousel__nav {
		width: 30px;
		height: 30px;
	}

	.ch-pae--categories .ch-pae-carousel__nav svg {
		width: 22px;
		height: 22px;
	}
}
