/**
 * Strongway — mini-carrito lateral.
 *
 * Panel deslizante con entrada en 3D, barra de progreso hacia el envío
 * gratis, artículos con relevo escalonado y vuelo del producto al icono.
 */

/* ==================================================================
   Subtotal en la cabecera, junto al icono del carrito
   ================================================================== */

.sw-cartbtn {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	width: auto;
	padding-inline: 12px;
}

.sw-cart-total {
	font-family: var(--sw-cond);
	font-weight: 700;
	font-size: 14px;
	letter-spacing: 0.04em;
	color: var(--sw-ink);
	transition: color var(--sw-fast) ease;
}

.sw-cart-total.is-empty {
	display: none;
}

.sw-cartbtn:hover .sw-cart-total {
	color: var(--sw-red);
}

@media (max-width: 640px) {
	.sw-cart-total {
		display: none;
	}
}

/* Pulso del contador cuando entra un producto. */
@keyframes sw-badge-bump {
	0% { transform: scale(1); }
	40% { transform: scale(1.45); }
	100% { transform: scale(1); }
}

.sw-cart-count.is-bumping {
	animation: sw-badge-bump 0.45s var(--sw-ease);
}

/* ==================================================================
   Botón flotante del carrito
   ================================================================== */

.sw-fab {
	position: fixed;
	right: clamp(16px, 3vw, 30px);
	bottom: calc(clamp(16px, 3vw, 30px) + env(safe-area-inset-bottom, 0px));
	z-index: 230;

	/* Elevación extra cuando algo ocupa el borde inferior. Va por variable
	   para que los tres estados (listo, panel abierto, barra de compra) no
	   se pisen el transform entre ellos. */
	--sw-fab-lift: 0px;

	display: flex;
	align-items: center;
	gap: 0;
	height: 62px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: linear-gradient(140deg, color-mix(in srgb, var(--sw-red) 76%, #fff) 0%, var(--sw-red) 52%, color-mix(in srgb, var(--sw-red-dark) 96%, #000) 100%);
	color: var(--sw-on-brand);
	cursor: pointer;

	/* Sin recorte: el contador asoma fuera del círculo y la onda del rebote
	   se expande más allá del borde. Quien recorta es la etiqueta. */
	overflow: visible;

	/* Oculto hasta que el carrito tenga algo: sin artículos no aporta. */
	transform: translateY(calc(26px + var(--sw-fab-lift))) scale(0.6);
	opacity: 0;
	pointer-events: none;
	visibility: hidden;

	box-shadow:
		0 14px 32px color-mix(in srgb, var(--sw-red) 42%, transparent),
		0 4px 10px color-mix(in srgb, var(--sw-shade) 18%, transparent),
		inset 0 1px 0 rgb(255 255 255 / 28%);
	transition:
		transform 0.5s cubic-bezier(0.34, 1.4, 0.5, 1),
		opacity 0.35s ease,
		visibility 0s linear 0.4s,
		box-shadow 0.35s var(--sw-ease),
		width 0.45s var(--sw-ease);
}

.sw-fab.is-ready {
	transform: translateY(var(--sw-fab-lift)) scale(1);
	opacity: 1;
	pointer-events: auto;
	visibility: visible;
	transition-delay: 0s;
}

.sw-fab:hover {
	box-shadow:
		0 20px 44px color-mix(in srgb, var(--sw-red) 52%, transparent),
		0 6px 14px color-mix(in srgb, var(--sw-shade) 22%, transparent),
		inset 0 1px 0 rgb(255 255 255 / 34%);
}

.sw-fab:focus-visible {
	outline: 3px solid var(--sw-ink);
	outline-offset: 3px;
}

/* El icono ocupa el círculo completo; el texto crece a su lado al pasar
   el cursor, así el botón vive plegado y no tapa contenido. */
.sw-fab-ic {
	display: grid;
	place-items: center;
	width: 62px;
	height: 62px;
	flex: 0 0 auto;
	transition: transform 0.45s var(--sw-ease);
}

.sw-fab:hover .sw-fab-ic {
	transform: translateY(-2px) rotate(-8deg);
}

.sw-fab-label {
	display: grid;
	align-content: center;
	gap: 1px;
	max-width: 0;
	padding-right: 0;
	text-align: left;
	white-space: nowrap;
	/* El recorte vive aquí: sin él, el texto plegado se saldría del botón. */
	overflow: hidden;
	opacity: 0;
	transition:
		max-width 0.45s var(--sw-ease),
		padding-right 0.45s var(--sw-ease),
		opacity 0.3s ease;
}

.sw-fab:hover .sw-fab-label,
.sw-fab:focus-visible .sw-fab-label {
	max-width: 200px;
	/* Deja libre la esquina donde vive el contador. Ahora que asoma hacia
	   fuera, invade menos la píldora y el texto puede acercarse. */
	padding-right: 28px;
	opacity: 1;
}

.sw-fab-label b {
	font-family: var(--sw-head);
	font-weight: 700;
	font-size: 17px;
	line-height: 1.05;
	letter-spacing: 0.01em;
}

.sw-fab-label small {
	font-family: var(--sw-cond);
	font-weight: 600;
	font-size: 11px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	opacity: 0.82;
}

/* Contador en tinta: contrasta sobre el rojo sin competir con él.
   Se ancla sobre el filo del círculo, medio dentro y medio fuera, que es
   como lo resuelven las tiendas grandes: se lee antes y da profundidad. */
.sw-fab-badge {
	position: absolute;
	top: -6px;
	right: -6px;
	display: grid;
	place-items: center;
	min-width: 26px;
	height: 26px;
	padding-inline: 7px;
	border-radius: 999px;
	/* El aro claro despega el contador tanto del rojo del botón como del
	   contenido de la página por la mitad que sobresale. */
	border: 2.5px solid var(--sw-paper);
	background: var(--sw-ink);
	font-family: var(--sw-cond);
	font-weight: 700;
	font-size: 12.5px;
	line-height: 1;
	color: #fff;
	box-shadow: 0 3px 8px color-mix(in srgb, var(--sw-shade) 28%, transparent);
	transition: transform 0.35s var(--sw-ease);
}

.sw-fab:hover .sw-fab-badge {
	transform: scale(1.08);
}

/* Onda que se expande al agregar un producto. */
.sw-fab-ring {
	position: absolute;
	inset: 0;
	border-radius: inherit;
	border: 2px solid var(--sw-red);
	opacity: 0;
	pointer-events: none;
}

@keyframes sw-fab-ping {
	0% { transform: scale(1); opacity: 0.75; }
	100% { transform: scale(1.85); opacity: 0; }
}

@keyframes sw-fab-pop {
	0% { transform: translateY(0) scale(1); }
	35% { transform: translateY(-7px) scale(1.13); }
	100% { transform: translateY(0) scale(1); }
}

.sw-fab.is-bumping {
	animation: sw-fab-pop 0.6s var(--sw-ease);
}

.sw-fab.is-bumping .sw-fab-ring {
	animation: sw-fab-ping 0.7s ease-out;
}

/* En la ficha, la barra de compra fija ocupa el borde inferior: el botón
   sube por encima de ella mientras esté visible. Solo mueve la variable,
   así no compite con los estados de visibilidad. */
body:has(.sw-buybar.is-visible) .sw-fab {
	--sw-fab-lift: calc(-1 * var(--sw-buybar-h, 74px) - 12px);
}

/* Con el panel abierto el botón estorba: se retira. */
html.sw-mc-lock .sw-fab {
	transform: translateY(calc(20px + var(--sw-fab-lift))) scale(0.7);
	opacity: 0;
	pointer-events: none;
}

@media (max-width: 480px) {
	.sw-fab,
	.sw-fab-ic {
		height: 56px;
	}

	.sw-fab-ic {
		width: 56px;
	}

	/* En móvil el texto no cabe: solo el círculo con su contador. */
	.sw-fab-label {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sw-fab,
	.sw-fab-ic,
	.sw-fab-label,
	.sw-fab-badge {
		transition: opacity 0.2s ease;
	}

	.sw-fab.is-bumping,
	.sw-fab.is-bumping .sw-fab-ring {
		animation: none;
	}
}

/* ==================================================================
   Velo y panel
   ================================================================== */

.sw-mc {
	position: fixed;
	inset: 0;
	z-index: 240;
	perspective: 1600px;
}

.sw-mc-veil {
	position: absolute;
	inset: 0;
	background: color-mix(in srgb, var(--sw-shade) 45%, transparent);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	opacity: 0;
	transition: opacity 0.35s ease;
}

.sw-mc.is-open .sw-mc-veil {
	opacity: 1;
}

.sw-mc-panel {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(430px, 94vw);
	display: flex;
	flex-direction: column;
	background: var(--sw-paper);
	border-radius: 22px 0 0 22px;
	box-shadow: -32px 0 80px color-mix(in srgb, var(--sw-shade) 35%, transparent);
	transform: translateX(60px) rotateY(-7deg);
	transform-origin: right center;
	opacity: 0;
	transition: transform 0.45s var(--sw-ease), opacity 0.3s ease;
	overflow: hidden;
}

.sw-mc.is-open .sw-mc-panel {
	transform: translateX(0) rotateY(0);
	opacity: 1;
}

/* ==================================================================
   Cabecera del panel
   ================================================================== */

.sw-mc-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 18px 20px;
	background:
		radial-gradient(120% 180% at 100% 0%, color-mix(in srgb, var(--sw-red) 22%, transparent), transparent 55%),
		var(--sw-ink);
	color: var(--sw-on-brand);
}

.sw-mc-title {
	display: flex;
	align-items: center;
	gap: 11px;
}

.sw-mc-title-ic {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	border-radius: 12px;
	background: var(--sw-red);
	color: var(--sw-on-brand);
	box-shadow: 0 6px 16px color-mix(in srgb, var(--sw-red) 45%, transparent);
}

.sw-mc-title h2 {
	font-family: var(--sw-head);
	font-weight: 700;
	font-size: 19px;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	margin: 0;
	color: #fff;
}

.sw-mc-count {
	display: grid;
	place-items: center;
	min-width: 24px;
	height: 24px;
	padding-inline: 7px;
	border-radius: 999px;
	background: rgb(255 255 255 / 14%);
	font-family: var(--sw-cond);
	font-weight: 700;
	font-size: 13px;
	color: #fff;
}

.sw-mc-close {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	border: 0;
	border-radius: 12px;
	background: rgb(255 255 255 / 10%);
	color: #fff;
	cursor: pointer;
	transition: background var(--sw-fast) ease, transform var(--sw-fast) ease;
}

.sw-mc-close:hover {
	background: var(--sw-red);
	transform: rotate(90deg);
}

/* ==================================================================
   Progreso hacia el envío gratis
   ================================================================== */

.sw-mc-ship {
	padding: 14px 20px 12px;
	background: #fff;
	border-bottom: 1px solid var(--sw-grey-200);
}

.sw-mc-ship-label {
	margin: 0 0 8px;
	font-family: var(--sw-cond);
	font-weight: 600;
	font-size: 13.5px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--sw-grey-500);
}

.sw-mc-ship-label b {
	color: var(--sw-red);
}

.sw-mc-ship.is-done .sw-mc-ship-label {
	color: var(--sw-green);
}

.sw-mc-ship-track {
	height: 7px;
	border-radius: 999px;
	background: var(--sw-grey-100);
	overflow: hidden;
}

.sw-mc-ship-bar {
	display: block;
	height: 100%;
	width: 0;
	border-radius: inherit;
	background: linear-gradient(90deg, var(--sw-red), var(--sw-red-light));
	transition: width 0.6s var(--sw-ease);
}

.sw-mc-ship.is-done .sw-mc-ship-bar {
	background: linear-gradient(90deg, var(--sw-green), color-mix(in srgb, var(--sw-green) 45%, var(--sw-green-light)));
}

/* ==================================================================
   Artículos
   ================================================================== */

.sw-mc-body {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 14px 20px;
}

.sw-mc-item {
	display: grid;
	grid-template-columns: 74px 1fr auto;
	gap: 14px;
	align-items: center;
	padding: 12px;
	margin-bottom: 12px;
	border: 1.5px solid var(--sw-grey-200);
	border-radius: var(--sw-radius);
	background: #fff;
	box-shadow: var(--sw-shadow);
	opacity: 0;
	transform: translateY(14px) rotateX(-8deg);
	animation: sw-mc-item-in 0.45s var(--sw-ease) forwards;
	animation-delay: var(--d, 0ms);
	transition: box-shadow 0.3s var(--sw-ease), transform 0.3s var(--sw-ease), opacity 0.3s ease;
}

@keyframes sw-mc-item-in {
	to {
		opacity: 1;
		transform: translateY(0) rotateX(0);
	}
}

.sw-mc-item:hover {
	box-shadow: var(--sw-shadow-lg);
}

.sw-mc-item.is-leaving {
	opacity: 0;
	transform: translateX(40px) scale(0.96);
	pointer-events: none;
}

.sw-mc-item-img {
	display: block;
	width: 74px;
	height: 74px;
	border-radius: 12px;
	overflow: hidden;
	background: var(--sw-grey-100);
}

.sw-mc-item-img img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.4s var(--sw-ease);
}

.sw-mc-item:hover .sw-mc-item-img img {
	transform: scale(1.08);
}

.sw-mc-item-info {
	min-width: 0;
}

.sw-mc-item-name {
	display: block;
	font-family: var(--sw-cond);
	font-weight: 600;
	font-size: 15px;
	line-height: 1.25;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	color: var(--sw-ink);
	text-decoration: none;
	margin-bottom: 4px;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.sw-mc-item-name:hover {
	color: var(--sw-red);
}

.sw-mc-item-total {
	font-family: var(--sw-cond);
	font-weight: 700;
	font-size: 15.5px;
	color: var(--sw-red);
}

.sw-mc-qty {
	display: inline-flex;
	align-items: center;
	gap: 2px;
	margin-top: 7px;
	border: 1.5px solid var(--sw-grey-200);
	border-radius: 999px;
	background: var(--sw-grey-100);
}

.sw-mc-qty button {
	display: grid;
	place-items: center;
	width: 27px;
	height: 27px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	font-size: 15px;
	font-weight: 700;
	color: var(--sw-ink);
	cursor: pointer;
	transition: background var(--sw-fast) ease, color var(--sw-fast) ease;
}

.sw-mc-qty button:hover {
	background: var(--sw-ink);
	color: #fff;
}

.sw-mc-qty button:disabled {
	opacity: 0.35;
	pointer-events: none;
}

.sw-mc-qty span {
	min-width: 22px;
	text-align: center;
	font-family: var(--sw-cond);
	font-weight: 700;
	font-size: 14px;
}

.sw-mc-item-side {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 8px;
	align-self: stretch;
	justify-content: space-between;
}

.sw-mc-item-remove {
	display: grid;
	place-items: center;
	width: 28px;
	height: 28px;
	border: 0;
	border-radius: 9px;
	background: transparent;
	color: var(--sw-grey-500);
	cursor: pointer;
	transition: background var(--sw-fast) ease, color var(--sw-fast) ease, transform var(--sw-fast) ease;
}

.sw-mc-item-remove:hover {
	background: color-mix(in srgb, var(--sw-red) 10%, transparent);
	color: var(--sw-red);
	transform: rotate(90deg);
}

/* Mientras la API responde, el panel baja la intensidad. */
.sw-mc-items.is-busy {
	opacity: 0.55;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

/* ==================================================================
   Estado vacío
   ================================================================== */

.sw-mc-empty {
	text-align: center;
	padding: 46px 24px;
}

.sw-mc-empty-ic {
	display: grid;
	place-items: center;
	width: 68px;
	height: 68px;
	margin: 0 auto 16px;
	border-radius: 20px;
	background: var(--sw-grey-100);
	color: var(--sw-red);
}

.sw-mc-empty h3 {
	font-family: var(--sw-head);
	font-weight: 700;
	font-size: 19px;
	text-transform: uppercase;
	margin: 0 0 8px;
	color: var(--sw-ink);
}

.sw-mc-empty p {
	margin: 0 0 18px;
	font-size: 14.5px;
	line-height: 1.6;
	color: var(--sw-grey-500);
}

.sw-mc-empty-cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 46px;
	padding: 0 26px;
	border-radius: 999px;
	background: var(--sw-ink);
	color: #fff;
	font-family: var(--sw-cond);
	font-weight: 600;
	font-size: 14.5px;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	text-decoration: none;
	transition: background var(--sw-fast) ease, transform var(--sw-fast) ease;
}

.sw-mc-empty-cta:hover {
	background: var(--sw-red);
	transform: translateY(-2px);
}

/* ==================================================================
   Pie: subtotal y acciones
   ================================================================== */

.sw-mc-foot {
	padding: 16px 20px calc(18px + env(safe-area-inset-bottom, 0px));
	background: #fff;
	border-top: 1px solid var(--sw-grey-200);
	box-shadow: 0 -12px 28px color-mix(in srgb, var(--sw-shade) 6%, transparent);
}

.sw-mc-subtotal {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	margin-bottom: 4px;
}

.sw-mc-subtotal span {
	font-family: var(--sw-cond);
	font-weight: 600;
	font-size: 14px;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: var(--sw-grey-500);
}

.sw-mc-subtotal b {
	font-family: var(--sw-head);
	font-weight: 700;
	font-size: 24px;
	color: var(--sw-ink);
}

.sw-mc-note {
	margin: 0 0 14px;
	font-size: 12.5px;
	color: var(--sw-grey-500);
}

.sw-mc-checkout {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 9px;
	min-height: 52px;
	border-radius: 14px;
	background: var(--sw-red);
	color: var(--sw-on-brand);
	font-family: var(--sw-cond);
	font-weight: 700;
	font-size: 15.5px;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	text-decoration: none;
	overflow: hidden;
	box-shadow: 0 10px 24px color-mix(in srgb, var(--sw-red) 35%, transparent);
	transition: transform var(--sw-fast) ease, box-shadow var(--sw-fast) ease, background var(--sw-fast) ease;
}

.sw-mc-checkout:hover {
	background: var(--sw-red-dark, color-mix(in srgb, var(--sw-red) 23%, var(--sw-red-dark)));
	transform: translateY(-2px);
	box-shadow: 0 14px 30px color-mix(in srgb, var(--sw-red) 45%, transparent);
}

/* Barrido de luz, como el botón de compra de la ficha. */
.sw-mc-checkout::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(115deg, transparent 30%, rgb(255 255 255 / 30%) 50%, transparent 70%);
	transform: translateX(-120%);
	transition: transform 0.7s ease;
}

.sw-mc-checkout:hover::after {
	transform: translateX(120%);
}

.sw-mc-viewcart {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin-top: 9px;
	border: 1.5px solid var(--sw-grey-200);
	border-radius: 14px;
	background: transparent;
	color: var(--sw-ink);
	font-family: var(--sw-cond);
	font-weight: 600;
	font-size: 13.5px;
	letter-spacing: 0.09em;
	text-transform: uppercase;
	text-decoration: none;
	transition: border-color var(--sw-fast) ease, background var(--sw-fast) ease;
}

.sw-mc-viewcart:hover {
	border-color: var(--sw-ink);
	background: var(--sw-grey-100);
}

/* ==================================================================
   Vuelo del producto al icono del carrito
   ================================================================== */

.sw-fly {
	position: fixed;
	z-index: 260;
	border-radius: 14px;
	object-fit: cover;
	pointer-events: none;
	box-shadow: 0 18px 44px color-mix(in srgb, var(--sw-shade) 35%, transparent);
	transition:
		transform 0.75s cubic-bezier(0.3, 0.7, 0.25, 1),
		opacity 0.75s ease,
		border-radius 0.75s ease;
	will-change: transform;
}

.sw-fly.is-flying {
	border-radius: 50%;
	opacity: 0.25;
}

/* Bloqueo de scroll con el panel abierto (en html, nunca en body: el
   overflow en body rompe el sticky de la cabecera). */
html.sw-mc-lock {
	overflow: hidden;
}

/* ==================================================================
   Accesibilidad y movimiento reducido
   ================================================================== */

@media (prefers-reduced-motion: reduce) {
	.sw-mc-veil,
	.sw-mc-panel,
	.sw-mc-item,
	.sw-mc-ship-bar {
		transition: none;
		animation: none;
	}

	.sw-mc-panel {
		transform: none;
		opacity: 1;
	}

	.sw-mc:not(.is-open) .sw-mc-panel {
		display: none;
	}

	.sw-mc-item {
		opacity: 1;
		transform: none;
	}

	.sw-fly {
		display: none;
	}
}
