/**
 * Pattern: Image gallery slider
 * Galeria na szerokość contentu (sectionWidth), proporcje ramki 10:9.
 * Zdjęcia 10:9 – idealnie w ramce; inne – object-fit: cover (fill).
 *
 * @package nbs-theme
 */

.nbs-image-gallery-slider {
	--nbs-gallery-aspect-ratio: 10 / 9;
}

section.nbs-image-gallery-slider {
	box-sizing: border-box;
	max-width: var(--wp--custom--section-width, 1140px);
	width: 100%;
	margin-top: var(--wp--custom--section-top-and-bottom-margin, 2rem);
	margin-bottom: var(--wp--custom--section-top-and-bottom-margin, 2rem);
	margin-left: auto;
	margin-right: auto;
	padding-left: var(--wp--custom--horizontal-section-margin, 24px);
	padding-right: var(--wp--custom--horizontal-section-margin, 24px);
	min-width: 0;
}

.nbs-image-gallery-slider__inner {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 1.25rem;
	min-width: 0;
	width: 100%;
}

/* Track – poziomy scroll, proporcje 10:9 */
.nbs-image-gallery-slider__gallery.wp-block-gallery,
.nbs-image-gallery-slider .wp-block-gallery.nbs-image-gallery-slider__gallery {
	box-sizing: border-box;
	display: flex !important;
	flex-wrap: nowrap !important;
	flex-direction: row !important;
	align-items: stretch;
	gap: 0;
	width: 100%;
	aspect-ratio: var(--nbs-gallery-aspect-ratio);
	height: auto;
	margin: 0;
	padding: 0;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
	list-style: none;
}

.nbs-image-gallery-slider__gallery::-webkit-scrollbar {
	display: none;
}

/* Slajd – pełna szerokość tracku, jedno zdjęcie na ekran */
.nbs-image-gallery-slider__gallery > .wp-block-image,
.nbs-image-gallery-slider__gallery > .blocks-gallery-item,
.nbs-image-gallery-slider__gallery .blocks-gallery-grid > .blocks-gallery-item,
.nbs-image-gallery-slider__gallery.has-nbf-columns-2 > .wp-block-image,
.nbs-image-gallery-slider__gallery.has-nbf-columns-3 > .wp-block-image,
.nbs-image-gallery-slider__gallery.columns-2 .wp-block-image,
.nbs-image-gallery-slider__gallery.columns-3 .wp-block-image,
.nbs-image-gallery-slider__gallery.columns-4 .wp-block-image,
.nbs-image-gallery-slider__gallery.columns-5 .wp-block-image,
.nbs-image-gallery-slider__gallery.columns-6 .wp-block-image,
.nbs-image-gallery-slider__gallery.columns-7 .wp-block-image,
.nbs-image-gallery-slider__gallery.columns-8 .wp-block-image {
	flex: 0 0 100% !important;
	width: 100% !important;
	min-width: 0;
	max-width: 100%;
	scroll-snap-align: start;
	scroll-snap-stop: always;
	margin: 0;
	height: 100%;
	min-height: 0;
	overflow: hidden;
	box-sizing: border-box;
}

.nbs-image-gallery-slider__gallery figure.wp-block-image,
.nbs-image-gallery-slider__gallery .blocks-gallery-item figure {
	margin: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	border-radius: 6px;
	line-height: 0;
}

/* Fill ramki 10:9 – cover dla innych proporcji */
.nbs-image-gallery-slider__gallery.is-cropped img,
.nbs-image-gallery-slider__gallery img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none;
	max-height: none;
	object-fit: cover;
	object-position: center;
	border-radius: 6px;
}

/* Legacy: grid wewnątrz galerii */
.nbs-image-gallery-slider__gallery .blocks-gallery-grid {
	display: flex !important;
	flex-wrap: nowrap !important;
	gap: 0;
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Nawigacja – strzałki pod galerią */
.nbs-image-gallery-slider__nav {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
	gap: 1rem;
}

.nbs-image-gallery-slider__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 2px solid var(--wp--preset--color--int-green);
	border-radius: 6px;
	background-color: var(--wp--preset--color--white);
	color: var(--wp--preset--color--text-primary);
	cursor: pointer;
	transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.nbs-image-gallery-slider__btn:hover {
	background-color: var(--wp--preset--color--int-green);
	color: var(--wp--preset--color--white);
}

.nbs-image-gallery-slider__btn:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent-blue);
	outline-offset: 2px;
	background-color: var(--wp--preset--color--accent-blue);
	border-color: var(--wp--preset--color--accent-blue);
	color: var(--wp--preset--color--white);
}

.nbs-image-gallery-slider__btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
	pointer-events: none;
}

.nbs-image-gallery-slider__btn svg {
	width: 20px;
	height: 20px;
	fill: currentColor;
}

@media (prefers-reduced-motion: reduce) {
	.nbs-image-gallery-slider__gallery.wp-block-gallery,
	.nbs-image-gallery-slider .wp-block-gallery.nbs-image-gallery-slider__gallery {
		scroll-behavior: auto;
	}
}
