/**
 * Thumbnail Carousel with Lightbox
 *
 * Scrolling is native (overflow-x + scroll-snap) rather than JS-driven, so it
 * stays smooth on touch devices and works with the scrollbar, trackpad, arrow
 * keys and assistive tech without extra code.
 */

.tmbc {
	--tmbc-thumb-height: 150px;
	--tmbc-gap: 8px;
	--tmbc-radius: 2px;
	--tmbc-nav-size: 36px;
	--tmbc-focus: #fff;

	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
}

/* Track ---------------------------------------------------------------- */

.tmbc__track {
	display: flex;
	gap: var(--tmbc-gap);
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
	list-style: none;
	margin: 0;
	padding: 0;
	width: 100%;
	/* Prevent vertical page scroll being captured while swiping sideways. */
	touch-action: pan-x;
	-webkit-overflow-scrolling: touch;
}

.tmbc__track::-webkit-scrollbar {
	display: none;
}

.tmbc__track:focus-visible {
	outline: 2px solid var(--tmbc-focus);
	outline-offset: 3px;
}

.tmbc__item {
	flex: 0 0 auto;
	margin: 0;
	padding: 0;
	scroll-snap-align: start;
}

/* Thumbnails ----------------------------------------------------------- */

.tmbc__trigger {
	display: block;
	padding: 0;
	margin: 0;
	border: 0;
	background: none;
	cursor: pointer;
	border-radius: var(--tmbc-radius);
	overflow: hidden;
	line-height: 0;
	transition: transform 0.25s ease, opacity 0.25s ease;
}

.tmbc__trigger--static {
	cursor: default;
}

/*
 * Two classes deliberately. Themes and page builders ship a broad
 * `img { height: auto; max-width: 100% }` reset, and Elementor's is loaded
 * after plugin styles, so a single-class rule loses on source order and the
 * thumbnail renders at the natural size of whatever srcset candidate the
 * browser picked. 0,2,0 beats their 0,1,1.
 */
.tmbc .tmbc__img {
	display: block;
	height: var(--tmbc-thumb-height);
	width: auto;
	max-width: none;
	object-fit: cover;
	border-radius: var(--tmbc-radius);
}

.tmbc__trigger:hover,
.tmbc__trigger:focus-visible {
	transform: translateY(-2px);
}

.tmbc__trigger:focus-visible {
	outline: 2px solid var(--tmbc-focus);
	outline-offset: 2px;
}

/* Arrows --------------------------------------------------------------- */

.tmbc__nav {
	position: absolute;
	top: 50%;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: var(--tmbc-nav-size);
	height: var(--tmbc-nav-size);
	transform: translateY(-50%);
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s ease;
}

.tmbc__nav:hover,
.tmbc__nav:focus-visible {
	background: rgba(0, 0, 0, 0.8);
}

.tmbc__nav[hidden] {
	display: none;
}

.tmbc__nav--prev {
	left: 4px;
}

.tmbc__nav--next {
	right: 4px;
}

/* Lightbox ------------------------------------------------------------- */

.tmbc-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	background: rgba(0, 0, 0, 0.9);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.tmbc-lightbox.is-open {
	opacity: 1;
}

.tmbc-lightbox__figure {
	margin: 0;
	max-width: 100%;
	max-height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
}

.tmbc-lightbox__img {
	max-width: 100%;
	max-height: calc(100vh - 120px);
	width: auto;
	height: auto;
	display: block;
	border-radius: 2px;
}

.tmbc-lightbox__caption {
	color: #fff;
	font-size: 14px;
	text-align: center;
	margin: 0;
	max-width: 70ch;
}

.tmbc-lightbox__counter {
	position: absolute;
	top: 20px;
	left: 24px;
	color: rgba(255, 255, 255, 0.75);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

.tmbc-lightbox__btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	border-radius: 50%;
	transition: background 0.2s ease;
}

.tmbc-lightbox__btn:hover,
.tmbc-lightbox__btn:focus-visible {
	background: rgba(255, 255, 255, 0.28);
}

.tmbc-lightbox__btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.tmbc-lightbox__close {
	top: 16px;
	right: 16px;
	width: 44px;
	height: 44px;
	font-size: 26px;
	line-height: 1;
}

.tmbc-lightbox__prev,
.tmbc-lightbox__next {
	top: 50%;
	transform: translateY(-50%);
	width: 48px;
	height: 48px;
	font-size: 30px;
	line-height: 1;
}

.tmbc-lightbox__prev {
	left: 16px;
}

.tmbc-lightbox__next {
	right: 16px;
}

/* Editor-only configuration notice ------------------------------------- */

.tmbc-notice {
	padding: 10px 14px;
	border-left: 3px solid #d63638;
	background: rgba(214, 54, 56, 0.08);
	font-size: 14px;
}

/* Motion and small screens --------------------------------------------- */

@media (max-width: 600px) {
	.tmbc {
		--tmbc-nav-size: 30px;
	}

	/*
	 * Clamp on the image rather than redefining --tmbc-thumb-height on .tmbc.
	 * The shortcode writes that custom property as an inline style, and inline
	 * styles beat stylesheet rules even inside a media query, so overriding it
	 * here would silently do nothing.
	 */
	.tmbc .tmbc__img {
		height: min(var(--tmbc-thumb-height), 110px);
	}

	.tmbc-lightbox__prev,
	.tmbc-lightbox__next {
		width: 40px;
		height: 40px;
		font-size: 24px;
	}
}

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

	.tmbc__trigger,
	.tmbc-lightbox {
		transition: none;
	}

	.tmbc__trigger:hover,
	.tmbc__trigger:focus-visible {
		transform: none;
	}
}
