/**
 * Gallery Listing — Common base CSS (loads for every style).
 *
 * Shared mechanics only: wrapper, filter bar, item/media reset, hover effects,
 * overlay, caption base, filtering transition and the full lightbox UI. Each style
 * file paints the layout skin (grid vs masonry vs metro) and visual treatment.
 *
 * @package captain-widgets-kit
 * @since   1.5.0
 */

.captwiki-gallery {
	--captwiki-gallery-accent: #6366f1;
	--captwiki-gallery-cols: 3;
	--captwiki-gallery-gap: 16px;
	--captwiki-gallery-ratio: 75%;
	display: block;
	box-sizing: border-box;
	width: 100%;
}

.captwiki-gallery *,
.captwiki-gallery *::before,
.captwiki-gallery *::after {
	box-sizing: border-box;
}

/* ── Filter bar ────────────────────────────────────────── */
.captwiki-gallery__filters {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin-bottom: 24px;
}

.captwiki-gallery__filter {
	margin: 0;
	padding: 8px 18px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.3;
	color: #4b5563;
	background: #f1f2f6;
	border: none;
	border-radius: 999px;
	cursor: pointer;
	transition: color 0.22s ease, background-color 0.22s ease, box-shadow 0.22s ease;
	-webkit-appearance: none;
	appearance: none;
}

.captwiki-gallery__filter:hover {
	color: #111827;
}

.captwiki-gallery__filter.is-active {
	color: #ffffff;
	background: var( --captwiki-gallery-accent );
}

.captwiki-gallery__filter:focus-visible {
	outline: 2px solid var( --captwiki-gallery-accent );
	outline-offset: 2px;
}

/* ── Item & media base ─────────────────────────────────── */
.captwiki-gallery__item {
	margin: 0;
	padding: 0;
}

.captwiki-gallery__link {
	display: block;
	text-decoration: none;
	color: inherit;
}

.captwiki-gallery__media {
	position: relative;
	display: block;
	overflow: hidden;
	background: #eef0f5;
}

.captwiki-gallery__img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.5s ease, filter 0.4s ease;
}

/* ── Overlay ───────────────────────────────────────────── */
.captwiki-gallery__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba( 17, 24, 39, 0.55 );
	opacity: 0;
	transition: opacity 0.32s ease;
}

.captwiki-gallery__item:hover .captwiki-gallery__overlay,
.captwiki-gallery__link:focus-visible .captwiki-gallery__overlay {
	opacity: 1;
}

.captwiki-gallery__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 52px;
	height: 52px;
	font-size: 24px;
	color: #ffffff;
	background: rgba( 255, 255, 255, 0.16 );
	border-radius: 50%;
	transform: scale( 0.7 );
	transition: transform 0.32s ease;
}

.captwiki-gallery__icon svg {
	width: 1em;
	height: 1em;
}

.captwiki-gallery__item:hover .captwiki-gallery__icon {
	transform: scale( 1 );
}

/* ── Caption base ──────────────────────────────────────── */
.captwiki-gallery__caption {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 14px 4px 0;
}

.captwiki-gallery__title {
	font-size: 16px;
	font-weight: 700;
	line-height: 1.3;
	color: #111827;
}

.captwiki-gallery__desc {
	font-size: 13px;
	line-height: 1.5;
	color: #6b7280;
}

/* ── Hover effects ─────────────────────────────────────── */
.captwiki-gallery--hover-zoom-in .captwiki-gallery__item:hover .captwiki-gallery__img {
	transform: scale( 1.08 );
}

.captwiki-gallery--hover-zoom-out .captwiki-gallery__img {
	transform: scale( 1.08 );
}

.captwiki-gallery--hover-zoom-out .captwiki-gallery__item:hover .captwiki-gallery__img {
	transform: scale( 1 );
}

.captwiki-gallery--hover-grayscale .captwiki-gallery__img {
	filter: grayscale( 100% );
}

.captwiki-gallery--hover-grayscale .captwiki-gallery__item:hover .captwiki-gallery__img {
	filter: grayscale( 0 );
}

.captwiki-gallery--hover-tilt .captwiki-gallery__media {
	transition: transform 0.4s ease;
}

.captwiki-gallery--hover-tilt .captwiki-gallery__item:hover .captwiki-gallery__media {
	transform: rotate( -1.5deg ) scale( 1.03 );
}

/* ── Filtering transition ──────────────────────────────── */
.captwiki-gallery__item {
	transition: opacity 0.3s ease, transform 0.3s ease;
}

.captwiki-gallery__item.is-hidden {
	opacity: 0;
	transform: scale( 0.96 );
}

/* ── Lightbox ──────────────────────────────────────────── */
.captwiki-gallery-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.captwiki-gallery-lightbox[hidden] {
	display: none;
}

.captwiki-gallery-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 9, 11, 20, 0.9 );
	animation: captwiki-gallery-fade 0.25s ease;
}

.captwiki-gallery-lightbox__stage {
	position: relative;
	z-index: 1;
	display: flex;
	align-items: center;
	gap: 14px;
	max-width: 92vw;
	max-height: 90vh;
}

.captwiki-gallery-lightbox__figure {
	margin: 0;
	max-width: 80vw;
	max-height: 86vh;
	text-align: center;
}

.captwiki-gallery-lightbox__img {
	display: block;
	max-width: 80vw;
	max-height: 78vh;
	width: auto;
	height: auto;
	border-radius: 8px;
	box-shadow: 0 30px 80px -20px rgba( 0, 0, 0, 0.7 );
	animation: captwiki-gallery-zoom 0.28s ease;
}

.captwiki-gallery-lightbox__caption {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin-top: 14px;
	color: #f3f4f6;
}

.captwiki-gallery-lightbox__caption strong {
	font-size: 16px;
	font-weight: 700;
}

.captwiki-gallery-lightbox__caption span {
	font-size: 13px;
	color: #b6bbc6;
}

.captwiki-gallery-lightbox__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	height: 46px;
	padding: 0;
	color: #ffffff;
	background: rgba( 255, 255, 255, 0.12 );
	border: none;
	border-radius: 50%;
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.captwiki-gallery-lightbox__btn:hover {
	background: var( --captwiki-gallery-accent, #6366f1 );
}

.captwiki-gallery-lightbox__btn:focus-visible {
	outline: 2px solid #ffffff;
	outline-offset: 2px;
}

.captwiki-gallery-lightbox__btn[hidden] {
	display: none;
}

.captwiki-gallery-lightbox__close {
	position: absolute;
	top: -54px;
	right: 0;
}

.captwiki-gallery-lightbox__counter {
	position: absolute;
	top: -46px;
	left: 0;
	font-size: 13px;
	color: #cbd0db;
}

body.captwiki-gallery-lightbox-open {
	overflow: hidden;
}

@keyframes captwiki-gallery-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes captwiki-gallery-zoom {
	from { opacity: 0; transform: scale( 0.94 ); }
	to { opacity: 1; transform: none; }
}

@media ( max-width: 600px ) {

	.captwiki-gallery-lightbox__stage {
		gap: 6px;
	}

	.captwiki-gallery-lightbox__btn {
		width: 38px;
		height: 38px;
	}

	.captwiki-gallery-lightbox__img {
		max-width: 86vw;
	}
}

/* ── Reduced motion ────────────────────────────────────── */
@media ( prefers-reduced-motion: reduce ) {

	.captwiki-gallery__img,
	.captwiki-gallery__icon,
	.captwiki-gallery__overlay,
	.captwiki-gallery__item,
	.captwiki-gallery-lightbox__img,
	.captwiki-gallery-lightbox__backdrop {
		transition: none;
		animation: none;
	}
}
