/* =========================================================================
 * CERVO — FICHA · PRODUCTOS RELACIONADOS (slider)
 *
 * Rediseño del snippet 15157 con los tokens de la ficha (cervo-base). Responsive
 * de verdad: 2 tarjetas por vista en móvil, 4 en escritorio. Slider por scroll
 * con snap; flechas, dots, arrastre y táctil los añade cervo-relacionados.js.
 *
 * Solo se encola en la vista previa (?cervo=1).
 * ========================================================================= */

.crel {
	/* El espaciado con las demás secciones lo da la rejilla de la ficha
	   (row-gap) + el separador de cervo-ficha.css. Sin margen propio para no
	   duplicar el hueco. */
	margin: 0;
	font-family: var(--cv-sans);
	color: var(--cv-ink);
}

/* ---- Encabezado (título + flechas a la derecha) -------------------------- */
.crel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--cv-s4);
	margin-bottom: 5px;
}

.crel-heading {
	font-family: var(--cv-serif);
	font-size: clamp(1.5rem, 1.2rem + 1vw, 2.25rem); /* 24 → 36 */
	font-weight: 500;
	line-height: 1.1;
	color: var(--cv-ink);
	margin: 0;
	padding-left: 5px;
}

.crel-nav {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

/* ---- Slider -------------------------------------------------------------- */
.crel-slider {
	position: relative;
	margin-left: 4px;
}

.crel-track {
	display: flex;
	flex-wrap: nowrap;
	gap: var(--cv-s4);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	padding: 4px 2px var(--cv-s3);
	margin: 0;
	list-style: none;
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
	cursor: grab;
}

.crel-track::-webkit-scrollbar {
	display: none;
}

.crel-track.is-dragging {
	cursor: grabbing;
	scroll-behavior: auto;
	user-select: none;
}

/* Tarjetas: 2 por vista (móvil) → 4 por vista (escritorio). El gap se descuenta
   para que entren exactas. */
.crel-card {
	--per: 2;
	flex: 0 0 calc((100% - (var(--per) - 1) * var(--cv-s4)) / var(--per));
	scroll-snap-align: start;
	background: var(--cv-bg);
	border: 1px solid var(--cv-line-soft);
	border-radius: var(--cv-radius);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transition: border-color var(--cv-fast) var(--cv-ease-io),
		box-shadow var(--cv-slow) var(--cv-ease),
		transform var(--cv-slow) var(--cv-ease);
}

@media (min-width: 769px) {
	.crel-card {
		--per: 4;
	}
}

.crel-card:hover {
	border-color: var(--cv-line);
	box-shadow: var(--cv-shadow-up);
	transform: translateY(-3px);
}

/* Imagen */
.crel-media {
	position: relative;
	display: block;
	overflow: hidden;
	background: var(--cv-bg-soft);
}

.crel-media img {
	width: 100%;
	aspect-ratio: 3 / 4;
	object-fit: cover;
	display: block;
	transition: transform var(--cv-slow) var(--cv-ease), opacity var(--cv-fast) linear;
}

.crel-card:hover .crel-media img {
	transform: scale(1.04);
}

.crel-flash {
	position: absolute;
	top: 10px;
	left: 10px;
	background: var(--cv-ink);
	color: #fff;
	font-size: 9px;
	font-weight: 600;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	padding: 4px 8px;
	border-radius: 999px;
}

/* Cuerpo */
.crel-body {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 12px 12px 14px;
}

.crel-name {
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	color: var(--cv-ink);
	line-height: 1.35;
	text-decoration: none;
	/* dos líneas máximo */
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.crel-name:hover {
	color: var(--cv-gold-deep);
}

.crel-price {
	font-size: 13px;
	font-weight: 600;
	color: var(--cv-ink-soft);
}

.crel-price del {
	color: var(--cv-mut);
	font-weight: 400;
	font-size: 11px;
	margin-right: 5px;
}

.crel-price ins {
	text-decoration: none;
	color: var(--cv-warn);
}

/* ---- Swatches de color --------------------------------------------------- */
.crel-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	margin-top: 2px;
	min-height: 16px;
}

.crel-sw {
	--sw: #ccc;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	border: 0;
	padding: 0;
	position: relative;
	cursor: pointer;
	background: var(--sw);
	background-clip: padding-box;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
	transition: transform var(--cv-fast) var(--cv-ease), box-shadow var(--cv-fast) var(--cv-ease);
	flex-shrink: 0;
}

/* EL COLOR SIEMPRE VISIBLE: el tema pinta el fondo de TODOS los <button> al
   pasar el ratón (naranja) y al enfocar. Con selector más específico
   (`.crel-swatches button.crel-sw`) reafirmamos el color del swatch en todos
   los estados y le ganamos sin `!important`. */
.crel-swatches button.crel-sw,
.crel-swatches button.crel-sw:hover,
.crel-swatches button.crel-sw:focus,
.crel-swatches button.crel-sw:active,
.crel-swatches button.crel-sw.is-active {
	background: var(--sw);
	background-clip: padding-box;
	color: inherit;
}

.crel-swatches button.crel-sw:not(.is-out):hover,
.crel-swatches button.crel-sw.is-active {
	transform: scale(1.18);
	box-shadow: 0 0 0 1px var(--cv-bg), 0 0 0 2px var(--cv-ink);
}

/* Color agotado: aro rojo + tachado (coherente con la ficha) */
.crel-sw.is-out {
	--crel-out: #d92d20;
	cursor: not-allowed;
	opacity: 0.55;
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18), 0 0 0 1.5px var(--crel-out);
}

.crel-sw.is-out::after {
	content: '';
	position: absolute;
	inset: 0;
	border-radius: 50%;
	background: linear-gradient(135deg, transparent 42%, var(--crel-out) 42%, var(--crel-out) 58%, transparent 58%);
}

/* Nombre del color: etiqueta de texto bajo los swatches (NO un tooltip
   flotante, que se cortaba contra el borde de la tarjeta/slider). Aparece al
   pasar/seleccionar un color; envuelve si el nombre es largo → nunca se corta. */
.crel-color {
	display: block;
	min-height: 14px;
	margin-top: 2px;
	font-size: 10.5px;
	line-height: 1.3;
	color: var(--cv-mut);
	transition: color var(--cv-fast) linear;
}

/* ---- Flechas (en el encabezado; nunca se cortan) ------------------------- */
.crel-arrow {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: 1px solid var(--cv-line);
	background: var(--cv-bg);
	color: var(--cv-ink);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	box-shadow: var(--cv-shadow);
	transition: background var(--cv-fast) var(--cv-ease-io),
		border-color var(--cv-fast) var(--cv-ease-io),
		color var(--cv-fast) var(--cv-ease-io),
		transform var(--cv-fast) var(--cv-ease-out),
		box-shadow var(--cv-fast) var(--cv-ease-io);
}

.crel-arrow svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.crel-arrow:hover:not(:disabled) {
	background: var(--cv-ink);
	border-color: var(--cv-ink);
	color: #fff;
	transform: translateY(-2px);
	box-shadow: var(--cv-shadow-up);
}

.crel-arrow:active:not(:disabled) {
	transform: translateY(0);
}

.crel-arrow:disabled {
	opacity: 0.3;
	cursor: default;
	box-shadow: none;
}

/* ---- Dots ---------------------------------------------------------------- */
.crel-dots {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 7px;
	margin-top: var(--cv-s4);
}

.crel-dots:empty {
	display: none;
}

.crel-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--cv-line);
	border: none;
	padding: 0;
	cursor: pointer;
	transition: background var(--cv-fast) var(--cv-ease), transform var(--cv-fast) var(--cv-ease);
}

.crel-dot.is-active {
	background: var(--cv-ink);
	transform: scale(1.3);
}

/* ---- Accesibilidad ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.crel-track {
		scroll-behavior: auto;
	}
}
