/* Шорткод [gallery]: слайдер на ширину текста (inc/gallery.php, assets/js/gallery.js) */

.id-gallery {
	--id-gallery-ratio: 4 / 3;
	--id-gallery-bg: var(--wp--preset--color--surface, #f5f5f7);
	--id-gallery-radius: 8px;
	--id-gallery-accent: var(--wp--preset--color--primary, #2563eb);

	box-sizing: border-box;
	width: 100%;
	max-width: 100%;
	margin-block: 1.5rem;
	outline-offset: 4px;
}

.id-gallery__stage {
	position: relative;
	overflow: hidden;
	border-radius: var(--id-gallery-radius);
	background: var(--id-gallery-bg);
}

.id-gallery__track {
	display: flex;
	margin: 0;
	padding: 0;
	overflow-x: auto;
	list-style: none;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
}

.id-gallery__track::-webkit-scrollbar {
	display: none;
}

.id-gallery__slide {
	display: flex;
	flex: 0 0 100%;
	align-items: center;
	justify-content: center;
	aspect-ratio: var(--id-gallery-ratio);
	margin: 0;
	scroll-snap-align: start;
}

.id-gallery__slide img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.id-gallery__arrow {
	position: absolute;
	top: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	color: var(--wp--preset--color--contrast, #111);
	background: rgb(255 255 255 / 92%);
	box-shadow: 0 2px 8px rgb(0 0 0 / 15%);
	cursor: pointer;
	transform: translateY(-50%);
}

.id-gallery__arrow--prev {
	left: 12px;
}

.id-gallery__arrow--next {
	right: 12px;
}

.id-gallery__arrow--next svg {
	transform: scaleX(-1);
}

.id-gallery__arrow:hover,
.id-gallery__arrow:focus-visible {
	color: var(--id-gallery-accent);
}

.id-gallery__count {
	position: absolute;
	top: 12px;
	right: 12px;
	margin: 0;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: 13px;
	line-height: 1.6;
	color: var(--wp--preset--color--contrast, #111);
	background: rgb(255 255 255 / 92%);
}

.id-gallery__thumbs {
	display: flex;
	gap: 8px;
	margin: 10px 0 0;
	padding: 0 0 2px;
	overflow-x: auto;
	list-style: none;
	scrollbar-width: thin;
}

.id-gallery__thumbs li {
	flex: 0 0 auto;
	margin: 0;
}

.id-gallery__thumb {
	display: block;
	box-sizing: border-box;
	width: 64px;
	height: 64px;
	padding: 2px;
	border: 2px solid transparent;
	border-radius: 6px;
	background: var(--id-gallery-bg);
	cursor: pointer;
	opacity: 0.7;
}

.id-gallery__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.id-gallery__thumb.is-active,
.id-gallery__thumb:hover,
.id-gallery__thumb:focus-visible {
	opacity: 1;
}

.id-gallery__thumb.is-active {
	border-color: var(--id-gallery-accent);
}

@media (max-width: 781px) {
	.id-gallery__arrow {
		width: 34px;
		height: 34px;
	}

	.id-gallery__thumb {
		width: 52px;
		height: 52px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.id-gallery__track {
		scroll-behavior: auto;
	}
}
