/*
 * MrHost Forge Commerce: styles for the Product Carousel widget.
 * Loaded together with products.css. Uses logical properties, so it works right-to-left.
 */

/*
 * min-inline-size: 0 and a full width stop the row of cards from stretching the widget, and with it the page,
 * when the widget sits inside a flex container such as an Elementor container.
 */
.mhf-carousel {
	position: relative;
	inline-size: 100%;
	min-inline-size: 0;
	max-inline-size: 100%;
}

/* The grid becomes one scrolling, snapping row. The number of cards in view comes from --mhf-prods-cols. */
.mhf-prods .mhf-carousel__track {
	/* Positioned, so absolutely placed parts of a card (such as hidden screen-reader text) stay inside the row. */
	position: relative;
	display: flex;
	gap: var(--mhf-prods-gap);
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	min-inline-size: 0;
	-webkit-overflow-scrolling: touch;
	/* Room for the hover lift and shadow, which the scrolling row would otherwise cut off. */
	padding-block: 0.75rem;
	margin-block: -0.75rem;
}

.mhf-carousel__track::-webkit-scrollbar { display: none; }

.mhf-carousel__track > .mhf-prod {
	flex: 0 0 calc((100% - (var(--mhf-prods-cols) - 1) * var(--mhf-prods-gap)) / var(--mhf-prods-cols));
	scroll-snap-align: start;
}

.mhf-carousel__track:focus-visible { outline: 2px solid var(--mhf-color-primary); outline-offset: 2px; }

/* Arrows: hidden until the script is ready, so a page without JavaScript shows no dead buttons. */
.mhf-carousel__arrow {
	position: absolute;
	inset-block-start: 40%;
	z-index: 2;
	display: none;
	place-items: center;
	inline-size: 2.5rem;
	block-size: 2.5rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgb(0 0 0 / 0.55);
	color: #fff;
	cursor: pointer;
	transform: translateY(-50%);
}

.mhf-carousel.is-ready:not(.is-static) .mhf-carousel__arrow { display: grid; }
.mhf-carousel__arrow:hover { background: rgb(0 0 0 / 0.8); }
.mhf-carousel__arrow:focus-visible { outline: 3px solid var(--mhf-color-primary); outline-offset: 2px; }
.mhf-carousel__arrow:disabled { opacity: 0.35; cursor: default; }
.mhf-carousel__arrow--prev { inset-inline-start: var(--mhf-space-sm); }
.mhf-carousel__arrow--next { inset-inline-end: var(--mhf-space-sm); }

/* Arrow glyphs are drawn with borders so no icon font is needed. They turn around in right-to-left pages. */
.mhf-carousel__arrow span {
	inline-size: 0.6rem;
	block-size: 0.6rem;
	border-block-start: 2px solid currentcolor;
	border-inline-start: 2px solid currentcolor;
}

.mhf-carousel__arrow--prev span { transform: translateX(0.12rem) rotate(-45deg); }
.mhf-carousel__arrow--next span { transform: translateX(-0.12rem) rotate(135deg); }
[dir="rtl"] .mhf-carousel__arrow--prev span { transform: translateX(-0.12rem) rotate(135deg); }
[dir="rtl"] .mhf-carousel__arrow--next span { transform: translateX(0.12rem) rotate(-45deg); }

.mhf-carousel__dots {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
	margin-block-start: var(--mhf-space-md);
}

.mhf-carousel.is-static .mhf-carousel__dots { display: none; }

.mhf-carousel__dot {
	inline-size: 0.7rem;
	block-size: 0.7rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--mhf-color-border);
	cursor: pointer;
}

.mhf-carousel__dot.is-active { background: var(--mhf-color-primary); }
.mhf-carousel__dot:focus-visible { outline: 2px solid var(--mhf-color-primary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
	.mhf-prods .mhf-carousel__track { scroll-behavior: auto; }
}

/* Category filter tabs: hidden until the script is ready, because they do nothing without it. */
.mhf-carousel__filters {
	display: none;
	flex-wrap: wrap;
	gap: var(--mhf-space-sm);
	margin-block-end: var(--mhf-space-lg);
}

.mhf-carousel.is-ready .mhf-carousel__filters { display: flex; }

.mhf-carousel__filter {
	padding: 0.5rem 1.1rem;
	border: 2px solid var(--mhf-color-border);
	border-radius: 999px;
	background: transparent;
	color: var(--mhf-color-text);
	font-size: 0.875rem;
	font-weight: var(--mhf-font-weight-bold);
	line-height: 1.2;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.mhf-carousel__filter:hover { border-color: var(--mhf-color-primary); }
.mhf-carousel__filter:focus-visible { outline: 3px solid var(--mhf-color-primary); outline-offset: 2px; }

.mhf-carousel__filter.is-active {
	border-color: var(--mhf-color-accent);
	background: var(--mhf-color-accent);
	color: #fff;
}

.mhf-carousel__track > .mhf-prod[hidden] { display: none; }

@media (max-width: 767px) {
	.mhf-carousel__filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-block-end: 0.25rem; }
	.mhf-carousel__filter { flex: none; padding: 0.4rem 0.9rem; font-size: 0.8125rem; }
}
