/* TC Gold native-media Gallery replacement. */

.tcg-gallery {
	width: 100%;
}

/*
 * Elementor's mobile flex containers can shrink a shortcode widget to its
 * one-line fallback height even though the shortcode output has real height.
 * Expand only the Elementor host that contains this gallery so the following
 * page section cannot overlap the images. The :has() scope keeps this rule
 * away from unrelated Elementor widgets and Astra content.
 */
.elementor-widget-shortcode:has(.tcg-gallery) {
	display: contents !important;
	flex: 0 0 auto !important;
	height: max-content !important;
	min-height: max-content !important;
}

.elementor-widget-shortcode:has(.tcg-gallery) > .elementor-widget-container {
	width: 100%;
}

.e-con:has(.tcg-gallery) {
	height: max-content !important;
	min-height: max-content !important;
}

.e-con:has(.tcg-gallery) > .e-con-inner {
	height: max-content !important;
	min-height: max-content !important;
}

.tcg-gallery,
.tcg-gallery * {
	box-sizing: border-box;
}

.tcg-gallery__grid {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	align-items: flex-start;
	gap: var(--tcg-gallery-gap, 10px);
	width: 100%;
}

.tcg-gallery__grid:not(.is-ready) > .tcg-gallery__item {
	width: 100%;
}

.tcg-gallery__grid.is-ready {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
}

.tcg-gallery__grid.is-ready > .tcg-gallery__column {
	flex: 1 1 0%;
	width: auto;
}

.tcg-gallery__column {
	display: flex;
	min-width: 0;
	flex: 1 1 0;
	flex-direction: column;
	gap: var(--tcg-gallery-gap, 10px);
}

.tcg-gallery__item {
	display: block;
	position: relative;
	width: 100%;
	overflow: hidden;
	color: inherit;
	line-height: 0;
	text-decoration: none;
	transition: 0.35s linear;
}

.tcg-gallery__item:focus-visible {
	z-index: 1;
	outline: 2px solid #9b0002;
	outline-offset: 3px;
}

.tcg-gallery__image {
	display: block;
	width: 100%;
	aspect-ratio: var(--tcg-gallery-ratio, 1 / 1);
	background-position: center center;
	background-repeat: no-repeat;
	background-size: cover;
	transform-origin: center top;
	transition: filter 0.8s, transform 0.8s;
}

.tcg-gallery__overlay {
	position: absolute;
	inset: 0;
	background-color: transparent;
	mix-blend-mode: normal;
	transition: mix-blend-mode 0.8s, transform 0.8s, opacity 0.8s, background-color 0.8s;
}

.tcg-gallery__item:hover .tcg-gallery__overlay,
.tcg-gallery__item:focus-visible .tcg-gallery__overlay {
	background-color: rgba(0, 0, 0, 0.5);
}

.tcg-gallery__lightbox[hidden] {
	display: none;
}

.tcg-gallery__lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: grid;
	place-items: center;
	padding: 32px;
	background: rgba(0, 0, 0, 0.94);
}

.tcg-gallery__lightbox-backdrop {
	position: absolute;
	inset: 0;
}

.tcg-gallery__lightbox-dialog {
	display: grid;
	position: relative;
	grid-template-columns: 48px minmax(0, 1fr) 48px;
	grid-template-rows: minmax(0, 1fr) auto;
	align-items: center;
	width: min(1100px, 100%);
	height: min(90vh, 900px);
	min-height: 0;
}

.tcg-gallery__lightbox-figure {
	display: grid;
	grid-column: 2;
	grid-row: 1;
	place-items: center;
	width: 100%;
	height: 100%;
	margin: 0;
}

.tcg-gallery__lightbox-image {
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

.tcg-gallery__lightbox-caption {
	position: absolute;
	bottom: 10px;
	left: 50%;
	max-width: 80%;
	color: #fff;
	font-size: 14px;
	line-height: 1.4;
	text-align: center;
	transform: translateX(-50%);
}

.tcg-gallery__lightbox-close,
.tcg-gallery__lightbox-prev,
.tcg-gallery__lightbox-next {
	position: relative;
	z-index: 1;
	display: grid;
	place-items: center;
	width: 42px;
	height: 42px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.7);
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.35);
	color: #fff;
	cursor: pointer;
	font-size: 24px;
	line-height: 1;
}

.tcg-gallery__lightbox-close:focus-visible,
.tcg-gallery__lightbox-prev:focus-visible,
.tcg-gallery__lightbox-next:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

.tcg-gallery__lightbox-close {
	position: absolute;
	top: -8px;
	right: -8px;
}

.tcg-gallery__lightbox-prev {
	grid-column: 1;
	grid-row: 1;
}

.tcg-gallery__lightbox-next {
	grid-column: 3;
	grid-row: 1;
}

.tcg-gallery__lightbox-count {
	grid-column: 2;
	grid-row: 2;
	padding-top: 10px;
	color: rgba(255, 255, 255, 0.85);
	font-size: 13px;
	line-height: 1.4;
	text-align: center;
}

body.tcg-gallery-lightbox-open {
	overflow: hidden;
}

@media (max-width: 767px) {
	.tcg-gallery__grid:not(.is-ready) {
		grid-template-columns: minmax(0, 1fr);
	}

	.tcg-gallery__lightbox {
		padding: 18px;
	}

	.tcg-gallery__lightbox-dialog {
		grid-template-columns: 36px minmax(0, 1fr) 36px;
		height: min(88vh, 700px);
	}

	.tcg-gallery__lightbox-close {
		top: -12px;
		right: -12px;
	}
}

@media (min-width: 768px) and (max-width: 1024px) {
	.tcg-gallery__grid:not(.is-ready) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (prefers-reduced-motion: reduce) {
	.tcg-gallery__item,
	.tcg-gallery__image,
	.tcg-gallery__overlay {
		transition-duration: 0.01ms;
	}
}
