/*
 * Row slider (4c-T5): one sliding row with arrows. The row scrolls with CSS only; arrows show only when the script
 * marks the row as overflowing (is-ready) and hide at the start / end. Colours come from the tokens only (R5).
 */
.tq-rowslider {
	position: relative;
}

.tq-rowslider > .tq-cards {
	display: grid;
	grid-auto-flow: column;
	grid-auto-columns: minmax(132px, 1fr);
	grid-template-columns: none;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scrollbar-width: none;
	padding-block-end: var(--tq-gap-s);
}

/* No visible scrollbar (Sherif 15/11: he complained about the bar under the row); arrows, drag and swipe move it. */
.tq-rowslider > .tq-cards::-webkit-scrollbar {
	display: none;
}

.tq-rowslider > .tq-cards > .tq-card {
	scroll-snap-align: start;
}

@media (min-width: 1025px) {
	.tq-rowslider > .tq-cards {
		grid-auto-columns: calc((100% - 5 * var(--tq-gap-m)) / 6);
	}
}

@media (max-width: 767px) {
	.tq-rowslider > .tq-cards {
		grid-auto-columns: 40%;
	}
}

.tq-rowslider__arrow {
	position: absolute;
	inset-block-start: 38%;
	z-index: 2;
	display: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--tq-line);
	border-radius: 50%;
	background: var(--tq-surface);
	color: var(--tq-text);
	font-size: 20px;
	line-height: 1;
	box-shadow: var(--tq-shade);
	cursor: pointer;
	transform: translateY(-50%);
}

.tq-rowslider__arrow--prev {
	inset-inline-start: var(--tq-gap-s);
}

.tq-rowslider__arrow--next {
	inset-inline-end: var(--tq-gap-s);
}

/* The previous arrow points to the start: the chevron is mirrored by .tq-icon--dir in right-to-left, so flip it back. */
.tq-rowslider__arrow--prev .tq-icon {
	transform: scaleX(-1);
}

.tq-rowslider__arrow--prev .tq-icon--dir:dir(rtl) {
	transform: none;
}

.tq-rowslider__arrow:focus-visible {
	outline: 2px solid var(--tq-accent);
	outline-offset: 2px;
}

/* Only the script knows the row overflows: no script = no arrows, the swipe and the scrollbar still work. */
.tq-rowslider.is-ready .tq-rowslider__arrow:not([hidden]) {
	display: inline-flex;
}

/* A pointer device without touch (the arrows are for it); the phone swipes. */
@media (hover: none) {
	.tq-rowslider.is-ready .tq-rowslider__arrow:not([hidden]) {
		display: none;
	}
}

.tq-rowslider.is-dragging > .tq-cards {
	cursor: grabbing;
	scroll-snap-type: none;
	user-select: none;
}

.tq-rowslider.is-dragging > .tq-cards a {
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	.tq-rowslider > .tq-cards {
		scroll-behavior: auto;
	}
}
