/* The controls carry the hidden attribute; slider.js removes it. */
.c-slider {
	position: relative;
}

.c-slider__track {
	display: flex;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
}

.c-slider__track {
	/* Hide the scrollbar only while the buttons and dots are available */
	.c-slider:has(.c-slider__dots:not([hidden])) & {
		scrollbar-width: none;

		&::-webkit-scrollbar {
			display: none;
		}
	}
}

.c-slider__track:focus-visible {
	outline: 3px solid var(--color-accent);
	outline-offset: 2px;
}

.c-slider {
	--slider-ratio: 3 / 2;
}

.c-slider__slide {
	flex: 0 0 100%;
	aspect-ratio: var(--slider-ratio);
	scroll-snap-align: start;
}

.c-slider__slide img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.c-slider__button {
	position: absolute;
	top: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 3rem;
	height: 3rem;
	transform: translateY(-50%);
	border: 0;
	border-radius: 50%;
	background: var(--color-bg);
	color: var(--color-text);
	font-size: 1.5rem;
	cursor: pointer;
	box-shadow: 0 0 0 1px var(--color-border);

	&[hidden] {
		display: none;
	}

	&:disabled {
		opacity: 0.4;
		cursor: default;
	}

	&:focus-visible {
		outline: 3px solid var(--color-accent);
		outline-offset: 2px;
	}

	@media (max-width: 48em) {
		display: none;
	}
}

.c-slider__button--prev {
	left: var(--space-3);

	&::before {
		content: '\2039';
	}
}

.c-slider__button--next {
	right: var(--space-3);

	&::before {
		content: '\203A';
	}
}

.c-slider__dots {
	display: flex;
	justify-content: center;
	gap: var(--space-2);
	padding-top: var(--space-3);

	&[hidden] {
		display: none;
	}
}

/* 2.75rem is the touch target; the visible dot is drawn smaller inside it. */
.c-slider__dot {
	position: relative;
	width: 2.75rem;
	height: 1.5rem;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;

	&::before {
		content: '';
		position: absolute;
		inset: 50% auto auto 50%;
		width: 0.75rem;
		height: 0.75rem;
		transform: translate(-50%, -50%);
		border-radius: 50%;
		background: var(--color-border);
		box-shadow: inset 0 0 0 1px var(--color-muted);
	}

	&[aria-current='true']::before {
		background: var(--color-accent);
		box-shadow: none;
	}

	&:focus-visible {
		outline: 3px solid var(--color-accent);
		outline-offset: -2px;
	}
}
