/**
 * CatFolders front-end gallery module.
 * Grid + Slider layouts, fully responsive.
 */

.catf-gallery {
	--catf-gap: 12px;
	--catf-cols: 3;
	--catf-ratio: 4 / 3;
	box-sizing: border-box;
	margin: 0 0 1.5em;
}

.catf-gallery *,
.catf-gallery *::before,
.catf-gallery *::after {
	box-sizing: border-box;
}

.catf-gallery img {
	display: block;
	max-width: 100%;
	height: auto;
}

.catf-gallery__caption {
	font-size: 0.8em;
	text-align: center;
	margin: 0.4em 0 0;
	color: inherit;
}

/* -------------------------------------------------------------------------
 * GRID
 * ---------------------------------------------------------------------- */
.catf-gallery--grid {
	display: grid;
	grid-template-columns: repeat(var(--catf-cols), 1fr);
	gap: var(--catf-gap);
}

.catf-gallery--grid .catf-gallery__item {
	margin: 0;
	overflow: hidden;
}

.catf-gallery--grid .catf-gallery__item figure {
	margin: 0;
	height: 100%;
}

.catf-gallery--grid .catf-gallery__item a {
	display: block;
	height: 100%;
}

.catf-gallery--grid .catf-gallery__item img {
	width: 100%;
}

/* Crop to a fixed aspect ratio. */
.catf-gallery--grid.is-cropped .catf-gallery__item img {
	width: 100%;
	height: 100%;
	aspect-ratio: var(--catf-ratio);
	object-fit: cover;
}

/* Responsive columns (tablet + mobile) are emitted per gallery as a scoped
   <style> block by the renderer, since the chosen breakpoints are configurable
   and media-query conditions cannot read CSS variables. */

/* -------------------------------------------------------------------------
 * SLIDER
 * ---------------------------------------------------------------------- */
.catf-gallery--slider {
	position: relative;
	width: 100%;
	outline: none;
}

.catf-slider__stage {
	position: relative;
	overflow: hidden;
	border-radius: 4px;
	background: #000;
}

.catf-slider__track {
	display: flex;
	width: 100%;
	transition: transform 0.4s ease;
	will-change: transform;
}

.catf-slider__slide {
	position: relative;
	flex: 0 0 100%;
	width: 100%;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.catf-slider__slide a {
	display: block;
	width: 100%;
}

.catf-slider__slide img {
	width: 100%;
	margin: 0 auto;
	max-height: 70vh;
	object-fit: contain;
}

/* Cropped slider: uniform stage height. */
.catf-gallery--slider.is-cropped .catf-slider__slide img {
	height: 100%;
	max-height: none;
	aspect-ratio: var(--catf-ratio);
	object-fit: cover;
}

.catf-slider__slide .catf-gallery__caption {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0;
	padding: 28px 12px 10px;
	color: #fff;
	background: linear-gradient(0deg, rgba(0, 0, 0, 0.65), transparent);
	font-size: 0.85em;
}

/* Arrows */
.catf-slider__arrow {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 5;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	background: rgba(0, 0, 0, 0.45);
	transition: background 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.catf-slider__arrow:hover,
.catf-slider__arrow:focus-visible {
	background: rgba(0, 0, 0, 0.75);
	outline: none;
}

.catf-slider__arrow span {
	display: block;
	width: 12px;
	height: 12px;
	border-top: 2px solid #fff;
	border-right: 2px solid #fff;
}

.catf-slider__arrow--prev {
	left: 12px;
}

.catf-slider__arrow--prev span {
	transform: rotate(-135deg);
	margin-left: 4px;
}

.catf-slider__arrow--next {
	right: 12px;
}

.catf-slider__arrow--next span {
	transform: rotate(45deg);
	margin-right: 4px;
}

.catf-slider__arrow[disabled] {
	opacity: 0.35;
	cursor: default;
}

/* Dots */
.catf-slider__dots {
	display: flex;
	justify-content: center;
	gap: 8px;
	margin-top: 10px;
}

.catf-slider__dot {
	width: 10px;
	height: 10px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.25);
	cursor: pointer;
	transition: background 0.2s ease;
}

.catf-slider__dot.is-active {
	background: rgba(0, 0, 0, 0.75);
}

/* Thumbnail strip */
.catf-slider__thumbs {
	display: flex;
	gap: 8px;
	margin-top: 10px;
	overflow-x: auto;
	scroll-behavior: smooth;
	-webkit-overflow-scrolling: touch;
	padding-bottom: 4px;
}

.catf-slider__thumbs::-webkit-scrollbar {
	height: 6px;
}

.catf-slider__thumbs::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.25);
	border-radius: 3px;
}

.catf-slider__thumb {
	flex: 0 0 90px;
	width: 90px;
	height: 64px;
	padding: 0;
	border: 2px solid transparent;
	border-radius: 3px;
	overflow: hidden;
	cursor: pointer;
	background: none;
	opacity: 0.6;
	transition: opacity 0.2s ease, border-color 0.2s ease;
}

.catf-slider__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.catf-slider__thumb.is-active,
.catf-slider__thumb:hover {
	opacity: 1;
	border-color: #2563eb;
}

@media (max-width: 600px) {
	.catf-slider__arrow {
		width: 36px;
		height: 36px;
	}
	.catf-slider__thumb {
		flex-basis: 64px;
		width: 64px;
		height: 48px;
	}
	.catf-slider__slide img {
		max-height: 55vh;
	}
}
