/* =============================================================
 * Minimog Child — Category Carousel widget
 *
 * A row of linked category tiles. The artwork carries the design,
 * so this file only handles placement, rounding, hover and the
 * arrows/dots.
 *
 * Everything sizeable is a custom property set by the widget's
 * Elementor controls, so the defaults here are only the fallback
 * when a control has not been touched.
 * ============================================================= */

.bsp-cats {
	--bsp-cats-gap: 20px;
	--bsp-cats-radius: 8px;
	--bsp-cats-zoom: 1.05;
	--bsp-cats-lift: -4px;
	--bsp-cats-per-view: 5;
	--bsp-cats-ease: cubic-bezier(.2, .75, .5, 1);

	position: relative;
}

/* Swiper needs the viewport to clip; the tiles themselves are
 * rounded, so nothing is cut off by this. */
.bsp-cats__viewport {
	overflow: hidden;
}

/* Sizing the slides in CSS rather than letting Swiper calculate
 * widths keeps the tiles correct before the script runs, so there
 * is no reflow on load. JS sets --bsp-cats-per-view per breakpoint. */
.bsp-cats .swiper-slide.bsp-cats__slide {
	width: calc(
		(100% - (var(--bsp-cats-per-view) - 1) * var(--bsp-cats-gap))
		/ var(--bsp-cats-per-view)
	);
	height: auto;
	flex-shrink: 0;
}

.bsp-cats__item {
	display: block;
	text-decoration: none;
	color: inherit;
	transition: transform .35s var(--bsp-cats-ease);
}

.bsp-cats__item:hover,
.bsp-cats__item:focus-visible {
	text-decoration: none;
	color: inherit;
	transform: translateY(var(--bsp-cats-lift));
}

/* A visible focus ring for keyboard users — the tile is a link, and
 * the default outline would be lost against the artwork. */
.bsp-cats__item:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
	border-radius: var(--bsp-cats-radius);
}

.bsp-cats__media {
	display: block;
	position: relative;
	overflow: hidden;
	border-radius: var(--bsp-cats-radius);
	/* aspect-ratio comes from the Tile Shape control; this is the
	 * fallback when that control is set to "use the image". */
	aspect-ratio: 1 / 1;
	background-color: rgba(26, 26, 46, .04);
}

.bsp-cats__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	border-radius: inherit;
	transition: transform .55s var(--bsp-cats-ease);
}

.bsp-cats__item:hover .bsp-cats__img,
.bsp-cats__item:focus-visible .bsp-cats__img {
	transform: scale(var(--bsp-cats-zoom));
}

/* -------------------------------------------------------------
 * Overlay caption (Name Placement: "On the image")
 *
 * The name is ALWAYS legible — it is how someone identifies the
 * tile, so it is never hidden behind a hover. What hover reveals is
 * the product count, which is extra reason to click rather than
 * basic identification.
 *
 * That split is also what makes this work on touch, where hover
 * never fires: see the coarse-pointer block near the end, which
 * shows the count outright.
 * ----------------------------------------------------------- */
.bsp-cats__overlay {
	position: absolute;
	z-index: 1;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	padding: 0 14px 12px;
	border-radius: inherit;
	/* A scrim, not a bar. Three things keep it from reading as a grey
	 * band stuck to the bottom of the picture: it starts fully opaque
	 * only at the very bottom edge, it gives up most of its opacity
	 * within the first third, and it runs tall (the padding-top below)
	 * so the fade has distance to disappear over. Ease-out stops the
	 * midpoint of a linear ramp from showing as a visible edge. */
	padding-top: 42%;
	background-image: linear-gradient(
		to top,
		var(--bsp-cats-scrim, rgba(16, 10, 28, .82)) 0%,
		color-mix(in srgb, var(--bsp-cats-scrim, rgba(16, 10, 28, .82)) 62%, transparent) 22%,
		color-mix(in srgb, var(--bsp-cats-scrim, rgba(16, 10, 28, .82)) 24%, transparent) 52%,
		transparent 100%
	);
	/* The gradient must not paint over the tile's rounded corners. */
	border-top-left-radius: 0;
	border-top-right-radius: 0;
	pointer-events: none;
}

/* color-mix is recent; without it the middle stop is dropped and the
 * gradient still runs dark-to-transparent, just with a harder edge. */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
	.bsp-cats__overlay {
		background-image: linear-gradient(
			to top,
			var(--bsp-cats-scrim, rgba(16, 10, 28, .82)) 0%,
			transparent 100%
		);
	}
}

.bsp-cats--caption-overlay .bsp-cats__title {
	display: block;
	color: #FFF;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -.01em;
	/* Keeps the name readable even where the scrim is thinnest. */
	text-shadow: 0 1px 2px rgba(16, 10, 28, .45);
}

.bsp-cats--caption-overlay .bsp-cats__count {
	display: block;
	margin-top: 3px;
	color: rgba(255, 255, 255, .82);
	font-size: 12px;
	font-weight: 600;
	line-height: 1.3;
}

/* ---- The hover reveal ----
 *
 * The count is a single short line, so its height is predictable and
 * a transition on height works cleanly here without the usual
 * auto-height problem. The line-height below is what that height is
 * derived from, so the two are deliberately kept in step.
 *
 * It animates together with a small rise and a fade, which is what
 * makes it read as the count arriving rather than the tile resizing.
 */
.bsp-cats--count-hover .bsp-cats__count {
	height: 0;
	margin-top: 0;
	overflow: hidden;
	opacity: 0;
	transform: translateY(4px);
	transition:
		height .4s var(--bsp-cats-ease),
		margin-top .4s var(--bsp-cats-ease),
		opacity .3s var(--bsp-cats-ease),
		transform .4s var(--bsp-cats-ease);
}

/* 1.3 line-height on a 12px font = 15.6px; 16px covers it without
 * clipping a descender. */
.bsp-cats--count-hover .bsp-cats__item:hover .bsp-cats__count,
.bsp-cats--count-hover .bsp-cats__item:focus-visible .bsp-cats__count {
	height: 16px;
	margin-top: 3px;
	opacity: 1;
	transform: translateY(0);
}

/* The scrim grows a little as the count appears, so the text always
 * has shade under it rather than the count sliding past the fade. */
.bsp-cats--count-hover .bsp-cats__overlay {
	transition: padding-bottom .4s var(--bsp-cats-ease);
}

.bsp-cats--count-hover .bsp-cats__item:hover .bsp-cats__overlay,
.bsp-cats--count-hover .bsp-cats__item:focus-visible .bsp-cats__overlay {
	padding-bottom: 14px;
}

/* -------------------------------------------------------------
 * Caption below the image (Name Placement: "Below the image")
 * ----------------------------------------------------------- */
.bsp-cats__caption {
	display: block;
	margin-top: 12px;
	text-align: center;
}

.bsp-cats--caption-below .bsp-cats__title {
	display: block;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	transition: color .3s var(--bsp-cats-ease);
}

.bsp-cats--caption-below .bsp-cats__count {
	display: block;
	margin-top: 3px;
	color: #6B7280;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.4;
}

/* -------------------------------------------------------------
 * Arrows
 * ----------------------------------------------------------- */
.bsp-cats__arrow {
	position: absolute;
	top: 50%;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	transform: translateY(-50%);
	border: 0;
	border-radius: 50%;
	background-color: #FFF;
	color: #1A1A2E;
	box-shadow: 0 6px 18px -6px rgba(26, 26, 46, .35);
	cursor: pointer;
	transition:
		opacity .3s var(--bsp-cats-ease),
		background-color .3s var(--bsp-cats-ease),
		color .3s var(--bsp-cats-ease);
}

.bsp-cats__arrow svg {
	width: 18px;
	height: 18px;
}

.bsp-cats__arrow--prev {
	left: 0;
	transform: translate(-50%, -50%);
}

.bsp-cats__arrow--next {
	right: 0;
	transform: translate(50%, -50%);
}

.bsp-cats__arrow:hover {
	background-color: #8022DB;
	color: #FFF;
}

/* Swiper adds this class at the ends of a non-looping carousel. */
.bsp-cats__arrow.swiper-button-disabled {
	opacity: 0;
	pointer-events: none;
}

/* Nothing to scroll: Swiper flags this and both arrows go. */
.bsp-cats__viewport.swiper-container-locked ~ .bsp-cats__arrow {
	display: none;
}

/* -------------------------------------------------------------
 * Dots
 * ----------------------------------------------------------- */
.bsp-cats__dots {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 18px;
}

.bsp-cats__dots .swiper-pagination-bullet {
	width: 8px;
	height: 8px;
	margin: 0;
	border-radius: 50%;
	background-color: rgba(26, 26, 46, .25);
	opacity: 1;
	cursor: pointer;
	transition: background-color .3s var(--bsp-cats-ease), width .3s var(--bsp-cats-ease);
}

.bsp-cats__dots .swiper-pagination-bullet-active {
	width: 22px;
	border-radius: 999px;
	background-color: #8022DB;
}

/* -------------------------------------------------------------
 * Responsive
 * ----------------------------------------------------------- */
@media (max-width: 1024px) {
	.bsp-cats__arrow {
		width: 36px;
		height: 36px;
	}

	/* Keep the arrows inside the section on narrower screens, where
	 * there is no page gutter for them to hang in. */
	.bsp-cats__arrow--prev {
		left: 4px;
		transform: translateY(-50%);
	}

	.bsp-cats__arrow--next {
		right: 4px;
		transform: translateY(-50%);
	}
}

/* -------------------------------------------------------------
 * Touch screens
 *
 * There is no hover on a touch screen, so a hover-revealed count
 * would simply never be seen. Anything the hover state was holding
 * back is shown outright here instead — the whole caption is
 * visible the moment the tile is.
 *
 * Keyed to the pointer, not the viewport: a small laptop window
 * still has a mouse and should still get the reveal, while a large
 * tablet has no hover however wide its screen is.
 * ----------------------------------------------------------- */
@media (hover: none), (pointer: coarse) {
	.bsp-cats--count-hover .bsp-cats__count {
		height: auto;
		margin-top: 3px;
		overflow: visible;
		opacity: 1;
		transform: none;
		transition: none;
	}
}

@media (max-width: 767px) {
	/* Touch devices swipe; the arrows only take up room. */
	.bsp-cats__arrow {
		display: none;
	}

	/* The tiles are roughly half the width here, so the overlay
	 * tightens up to keep the name off the tile's edges. */
	.bsp-cats__overlay {
		padding-left: 11px;
		padding-right: 11px;
		padding-bottom: 10px;
	}

	.bsp-cats--caption-overlay .bsp-cats__title {
		font-size: 13px;
	}

	.bsp-cats--caption-overlay .bsp-cats__count {
		font-size: 11px;
	}

	.bsp-cats--caption-below .bsp-cats__title {
		font-size: 13px;
	}

	/* Phones show the name only. Placed after the touch-screen block,
	   which would otherwise force the count visible. */
	.bsp-cats--no-count-mobile .bsp-cats__count {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bsp-cats__item,
	.bsp-cats__img,
	.bsp-cats__title,
	.bsp-cats__count,
	.bsp-cats__overlay,
	.bsp-cats__arrow,
	.bsp-cats__dots .swiper-pagination-bullet {
		transition: none !important;
	}

	.bsp-cats__item:hover,
	.bsp-cats__item:focus-visible,
	.bsp-cats__item:hover .bsp-cats__img,
	.bsp-cats__item:focus-visible .bsp-cats__img {
		transform: none !important;
	}

	/* The count still appears on hover — it just appears, rather
	 * than sliding. Removing the motion must not remove the
	 * information. */
	.bsp-cats--count-hover .bsp-cats__count {
		transform: none !important;
	}
}
