/*
 * Karusel fotek (Ark: Cube Portfolio slider).
 * Mezera 30 px; počet sloupců se řídí šířkou karuselu, ne okna: nad 480 px 2, nad 800 px 3.
 * Pod fotkami Ark vždy rezervuje 60 px (v nich jsou případné tečky stránkování).
 */
.basta-carousel {
	--basta-carousel-gap: 30px;
	position: relative;
	container-type: inline-size;
}

body .basta-carousel {
	padding-bottom: 60px;
}

.basta-carousel__viewport {
	--basta-carousel-cols: 1;
	position: relative;
	overflow-x: auto;
	/* Svisle neposouvat: jinak kolečko myši posune obsah karuselu místo stránky
	 * (když je některá položka vyšší než karusel, např. nenačtená fotka). */
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	overscroll-behavior-x: contain;
}

@container (min-width: 481px) {
	.basta-carousel__viewport {
		--basta-carousel-cols: 2;
	}
}

@container (min-width: 801px) {
	.basta-carousel__viewport {
		--basta-carousel-cols: 3;
	}
}

.basta-carousel__viewport::-webkit-scrollbar {
	display: none;
}

/* Výšku nastavuje JS podle právě viditelných fotek (jako Ark), proto align-items: flex-start. */
.basta-carousel__track {
	display: flex;
	align-items: flex-start;
	gap: var(--basta-carousel-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

.basta-carousel__item {
	flex: 0 0 calc((100% - (var(--basta-carousel-cols) - 1) * var(--basta-carousel-gap)) / var(--basta-carousel-cols));
	margin: 0;
	scroll-snap-align: start;
}

.basta-carousel__link {
	position: relative;
	display: block;
	overflow: hidden;
}

.basta-carousel__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
}

.basta-carousel--square .basta-carousel__image {
	aspect-ratio: 1;
}

/* Líné načítání Smush dává nenačteným fotkám šířku a poměr stran originálu (!important).
 * V karuselu musí mít i nenačtené fotky stejný rozměr jako načtené. */
.basta-carousel .basta-carousel__image:is(.lazyload, .lazyloading) {
	width: 100% !important;
	aspect-ratio: 4 / 3 !important;
}

.basta-carousel--square .basta-carousel__image:is(.lazyload, .lazyloading) {
	aspect-ratio: 1 !important;
}

/* Popisek pod fotkou (Ark: theme-portfolio-title, 18 px / 300). */
.basta-carousel__caption {
	margin: 0;
	padding: 20px;
	text-align: center;
}

.basta-carousel__caption h4 {
	margin: 0 0 3px;
	color: var(--wp--preset--color--heading);
	font-family: var(--wp--preset--font-family--roboto);
	font-size: 18px;
	font-weight: 300;
	line-height: 1.4;
}

.basta-carousel__caption a {
	color: inherit;
	font-weight: inherit;
}

/* Ikona lupy při najetí (Ark: zelený čtverec 45 px uprostřed). */
.basta-carousel__zoom {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 45px;
	height: 45px;
	border-radius: 3px;
	background: var(--wp--preset--color--primary);
	opacity: 0;
	transform: translate(-50%, -50%);
	transition: opacity 0.3s;
}

.basta-carousel__zoom::before,
.basta-carousel__zoom::after {
	content: "";
	position: absolute;
	background: var(--wp--preset--color--white);
}

.basta-carousel__zoom::before {
	top: 14px;
	left: 22px;
	width: 1px;
	height: 17px;
}

.basta-carousel__zoom::after {
	top: 22px;
	left: 14px;
	width: 17px;
	height: 1px;
}

.basta-carousel__link:hover .basta-carousel__zoom,
.basta-carousel__link:focus-visible .basta-carousel__zoom {
	opacity: 1;
}

/* Šipky: tmavé obdélníky 30 × 50 px u okrajů, na středu fotek. */
.basta-carousel__nav {
	position: absolute;
	top: calc(var(--basta-carousel-image-height, 50%) / 2);
	z-index: 2;
	width: 30px;
	height: 50px;
	margin-top: -25px;
	padding: 0;
	border: 0;
	border-radius: 2px;
	background: rgba(52, 52, 60, 0.8);
	cursor: pointer;
}

.basta-carousel__nav[aria-disabled="true"] {
	opacity: 0.5;
	cursor: default;
}

.basta-carousel__nav::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 7px;
	height: 7px;
	border-top: 1.5px solid #fff;
	border-right: 1.5px solid #fff;
}

.basta-carousel__nav--prev {
	left: 3px;
}

.basta-carousel__nav--prev::before {
	transform: translate(-30%, -50%) rotate(-135deg);
}

.basta-carousel__nav--next {
	right: 3px;
}

.basta-carousel__nav--next::before {
	transform: translate(-70%, -50%) rotate(45deg);
}

/* Tečky stránkování (Ark: 10 px, #797979, 20 px pod fotkami). */
.basta-carousel__dots {
	position: absolute;
	right: 0;
	bottom: 20px;
	left: 0;
	height: 20px;
	margin: 0;
	padding: 0;
	line-height: 20px;
	text-align: center;
}

.basta-carousel__dot {
	display: inline-block;
	width: 10px;
	height: 10px;
	margin: 0 4px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #797979;
	vertical-align: middle;
	cursor: pointer;
}

.basta-carousel__dot[aria-current="true"] {
	background: var(--wp--preset--color--primary);
}

/* Lightbox */
.basta-lightbox {
	width: 100vw;
	max-width: none;
	height: 100vh;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	overflow: hidden;
}

.basta-lightbox::backdrop {
	background: rgba(0, 0, 0, 0.7);
}

.basta-lightbox__figure {
	position: absolute;
	inset: 40px 60px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	margin: 0;
}

.basta-lightbox__image {
	display: block;
	max-width: 100%;
	max-height: calc(100% - 30px);
	object-fit: contain;
}

.basta-lightbox__meta {
	display: flex;
	justify-content: space-between;
	width: var(--basta-lightbox-width, 100%);
	max-width: 100%;
	padding-top: 6px;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
}

.basta-lightbox__btn {
	position: absolute;
	width: 38px;
	height: 38px;
	padding: 0;
	border: 0;
	border-radius: 2px;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	font-size: 24px;
	line-height: 38px;
	text-align: center;
	cursor: pointer;
}

.basta-lightbox__btn--close {
	top: 20px;
	right: 20px;
}

.basta-lightbox__btn--prev,
.basta-lightbox__btn--next {
	top: 50%;
	margin-top: -19px;
}

.basta-lightbox__btn--prev {
	left: 20px;
}

.basta-lightbox__btn--next {
	right: 20px;
}

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