/* ==========================================================================
   Kojak Product Cards — Frontend
   Tarjetas de altura uniforme · carrusel / grid / fila
   Las variables --kpc-* se inyectan desde los ajustes del admin.
   ========================================================================== */

.kpc-wrap {
	position: relative;
	margin: 24px 0;
}

/* ----- Layouts ---------------------------------------------------------- */

.kpc-track {
	display: grid;
	gap: 22px;
}

/* Grilla fija */
.kpc-layout-grid {
	grid-template-columns: repeat(var(--kpc-cols, 4), minmax(0, 1fr));
}

/* Fila: una sola línea, se ajusta al ancho */
.kpc-layout-fila {
	grid-auto-flow: column;
	grid-auto-columns: minmax(0, 1fr);
}

/* Carrusel: scroll horizontal con snap */
.kpc-layout-carrusel {
	grid-auto-flow: column;
	grid-auto-columns: calc((100% - (var(--kpc-cols, 4) - 1) * 22px) / var(--kpc-cols, 4));
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	padding-bottom: 6px;
	scrollbar-width: none;
}
.kpc-layout-carrusel::-webkit-scrollbar { display: none; }
.kpc-layout-carrusel .kpc-card { scroll-snap-align: start; }

/* Flechas del carrusel */
.kpc-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 5;
	width: 42px;
	height: 42px;
	border: none;
	border-radius: 50%;
	background: var(--kpc-accent, #c8102e);
	color: #fff;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
	transition: transform .15s ease, opacity .15s ease;
	opacity: .92;
}
.kpc-nav:hover { transform: translateY(-50%) scale(1.08); opacity: 1; }
.kpc-nav:focus-visible { outline: 3px solid rgba(0, 0, 0, .35); outline-offset: 2px; }
.kpc-prev { left: -14px; }
.kpc-next { right: -14px; }
.kpc-nav[disabled] { opacity: .25; cursor: default; pointer-events: none; }

/* ----- Tarjeta ----------------------------------------------------------- */

.kpc-card {
	display: flex;
	flex-direction: column;
	height: 100%;
	background: var(--kpc-card-bg, #fff);
	border: 1px solid var(--kpc-card-border, #ececec);
	border-radius: var(--kpc-card-radius, 14px);
	box-shadow: var(--kpc-card-shadow, none);
	overflow: hidden;
	transition: transform .22s ease, box-shadow .22s ease;
}
.kpc-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 6px 14px rgba(20, 20, 30, .08), 0 18px 38px rgba(20, 20, 30, .12);
}

/* Imagen: proporción fija para uniformidad total */
.kpc-media {
	position: relative;
	display: block;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	background: #f6f6f7;
}
.kpc-media img,
.kpc-img {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover;
	display: block;
	transition: transform .35s ease;
}
.kpc-card:hover .kpc-media img { transform: scale(1.05); }

.kpc-badge {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 2;
	background: var(--kpc-accent, #c8102e);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .06em;
	text-transform: uppercase;
	padding: 5px 10px;
	border-radius: 999px;
}

/* Cuerpo flexible: el footer siempre queda abajo */
.kpc-body {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	padding: 16px 18px 18px;
	gap: 8px;
}

/* .kpc-title funciona igual con h1-h6, p, div o span (etiqueta configurable) */
.kpc-card .kpc-title,
h1.kpc-title, h2.kpc-title, h3.kpc-title, h4.kpc-title, h5.kpc-title, h6.kpc-title {
	margin: 0;
	padding: 0;
	font-family: var(--kpc-font-title, inherit);
	font-size: 1.02rem;
	font-weight: 700;
	line-height: 1.35;
	/* Recorte a 2 líneas: todas las tarjetas iguales */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: calc(1.35em * 2);
}
.kpc-title a {
	color: var(--kpc-title, #1c1c1e);
	text-decoration: none;
	transition: color .15s ease;
}
.kpc-title a:hover { color: var(--kpc-accent, #c8102e); }

.kpc-card .kpc-excerpt {
	margin: 0;
	padding: 0;
	display: -webkit-box;
	font-family: var(--kpc-font-text, inherit);
	font-size: .875rem;
	line-height: 1.5;
	color: var(--kpc-text, #5c5c61);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: calc(1.5em * 2);
}

.kpc-footer {
	margin-top: auto;
	padding-top: 12px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	flex-wrap: wrap;
}

.kpc-price {
	font-family: var(--kpc-font-text, inherit);
	font-size: 1.05rem;
	font-weight: 800;
	color: var(--kpc-price, #c8102e);
	white-space: nowrap;
}
.kpc-price del { opacity: .45; font-weight: 500; font-size: .85em; margin-right: 4px; }
.kpc-price ins { text-decoration: none; }

.kpc-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 9px 18px;
	font-family: var(--kpc-font-btn, inherit);
	font-size: .85rem;
	font-weight: 700;
	letter-spacing: .02em;
	text-decoration: none !important;
	background: var(--kpc-btn-bg, #c8102e);
	color: var(--kpc-btn-color, #fff) !important;
	border-radius: var(--kpc-btn-radius, 8px);
	transition: background .18s ease, color .18s ease, transform .12s ease;
	white-space: nowrap;
}
.kpc-btn:hover {
	background: var(--kpc-btn-bg-hover, #9e0c24);
	color: var(--kpc-btn-color-hover, #fff) !important;
	transform: translateY(-1px);
}
.kpc-btn:focus-visible { outline: 3px solid rgba(0, 0, 0, .3); outline-offset: 2px; }
.kpc-btn.kpc-loading { opacity: .6; pointer-events: none; }

/* ----- Responsive -------------------------------------------------------- */

@media (max-width: 1024px) {
	.kpc-layout-grid { grid-template-columns: repeat(var(--kpc-cols-t, 3), minmax(0, 1fr)); }
	.kpc-layout-carrusel { grid-auto-columns: calc((100% - (var(--kpc-cols-t, 3) - 1) * 22px) / var(--kpc-cols-t, 3)); }
}

@media (max-width: 768px) {
	.kpc-layout-grid { grid-template-columns: repeat(var(--kpc-cols-m, 2), minmax(0, 1fr)); }
	.kpc-layout-carrusel { grid-auto-columns: calc((100% - (var(--kpc-cols-m, 2) - 1) * 22px) / var(--kpc-cols-m, 2)); }
	.kpc-prev { left: 4px; }
	.kpc-next { right: 4px; }
}

@media (max-width: 480px) {
	.kpc-track { gap: 14px; }
}

/* Accesibilidad: respetar reduced motion */
@media (prefers-reduced-motion: reduce) {
	.kpc-card, .kpc-media img, .kpc-btn, .kpc-nav { transition: none; }
	.kpc-layout-carrusel { scroll-behavior: auto; }
}
