/* TGJ Gallery – front end */

.tgj-gallery {
	--tgj-cols: 3;
	--tgj-cols-md: 3;
	--tgj-cols-sm: 2;
	--tgj-gap: 16px;
	--tgj-radius: 16px;
	--tgj-overlay: #071464;
	--tgj-text: #ffffff;
	--tgj-ratio: 1/1;
	--tgj-current: var(--tgj-cols);

	margin: 0 0 1.5em;
}

/* Responsive column count. Set on a separate custom property so the inline
   style on the element (which holds the author's desktop value) is not fought. */
@media (max-width: 1024px) {
	.tgj-gallery { --tgj-current: var(--tgj-cols-md); }
}

@media (max-width: 690px) {
	.tgj-gallery { --tgj-current: var(--tgj-cols-sm); }
}

@media (max-width: 440px) {
	.tgj-gallery { --tgj-current: 1; }
}

.tgj-gallery--grid {
	display: grid;
	grid-template-columns: repeat(var(--tgj-current), minmax(0, 1fr));
	gap: var(--tgj-gap);
}

.tgj-gallery--masonry {
	column-count: var(--tgj-current);
	column-gap: var(--tgj-gap);
}

.tgj-gallery__item {
	margin: 0;
	padding: 0;
	min-width: 0;
}

.tgj-gallery--masonry .tgj-gallery__item {
	break-inside: avoid;
	margin: 0 0 var(--tgj-gap);
	display: inline-block;
	width: 100%;
}

.tgj-gallery__media {
	position: relative;
	display: block;
	overflow: hidden;
	line-height: 0;
	border-radius: var(--tgj-radius);
	background: rgba(0, 0, 0, 0.06);
	text-decoration: none;
	box-shadow: none;
}

.tgj-gallery--grid .tgj-gallery__media {
	aspect-ratio: var(--tgj-ratio);
	height: 100%;
}

.tgj-gallery__img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	border-radius: inherit;
	box-shadow: none;
	transition: transform 0.45s ease;
}

.tgj-gallery--grid .tgj-gallery__img {
	height: 100%;
	object-fit: cover;
}

.tgj-gallery--lightbox .tgj-gallery__media { cursor: zoom-in; }

.tgj-gallery--lightbox .tgj-gallery__media:hover .tgj-gallery__img,
.tgj-gallery--lightbox .tgj-gallery__media:focus-visible .tgj-gallery__img {
	transform: scale(1.045);
}

.tgj-gallery__media:focus-visible {
	outline: 3px solid var(--tgj-overlay);
	outline-offset: 3px;
}

/* Text over the image */
.tgj-gallery__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-end;
	padding: 1em;
	line-height: 1.35;
	background: linear-gradient(to top, var(--tgj-overlay) 0%, rgba(0, 0, 0, 0) 78%);
	border-radius: inherit;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.tgj-gallery__overlay-text {
	color: var(--tgj-text);
	font-size: 0.95em;
	font-weight: 600;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.tgj-gallery--cap-hover .tgj-gallery__overlay { opacity: 0; }

.tgj-gallery--cap-hover .tgj-gallery__media:hover .tgj-gallery__overlay,
.tgj-gallery--cap-hover .tgj-gallery__media:focus-visible .tgj-gallery__overlay,
.tgj-gallery--cap-hover .tgj-gallery__item:focus-within .tgj-gallery__overlay {
	opacity: 1;
}

.tgj-gallery--cap-always .tgj-gallery__overlay { opacity: 1; }

/* Text under the image */
.tgj-gallery__caption {
	margin: 0.6em 0 0;
	font-size: 0.9em;
	line-height: 1.4;
	opacity: 0.85;
}

.tgj-gallery-notice {
	padding: 0.8em 1em;
	border-left: 4px solid #fe6b0b;
	background: rgba(254, 107, 11, 0.08);
	font-size: 0.95em;
}

/* Lightbox */
.tgj-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: max(16px, 3vmin);
	background: rgba(3, 8, 41, 0.94);
	opacity: 0;
	transition: opacity 0.25s ease;
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
}

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

.tgj-lightbox__figure {
	margin: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75em;
	max-width: 100%;
	max-height: 100%;
}

.tgj-lightbox__img {
	display: block;
	max-width: min(1600px, 92vw);
	max-height: 84vh;
	width: auto;
	height: auto;
	border-radius: var(--tgj-radius, 16px);
	background: rgba(255, 255, 255, 0.04);
}

.tgj-lightbox__caption {
	max-width: min(900px, 90vw);
	color: #fff;
	font-size: 0.95rem;
	line-height: 1.45;
	text-align: center;
	opacity: 0.9;
}

.tgj-lightbox__btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
}

.tgj-lightbox__btn:hover,
.tgj-lightbox__btn:focus-visible {
	background: #fe6b0b;
	transform: scale(1.06);
	outline: none;
}

.tgj-lightbox__close { top: max(12px, 2vmin); right: max(12px, 2vmin); }
.tgj-lightbox__prev { left: max(12px, 2vmin); top: 50%; transform: translateY(-50%); }
.tgj-lightbox__next { right: max(12px, 2vmin); top: 50%; transform: translateY(-50%); }

.tgj-lightbox__prev:hover,
.tgj-lightbox__prev:focus-visible { transform: translateY(-50%) scale(1.06); }

.tgj-lightbox__next:hover,
.tgj-lightbox__next:focus-visible { transform: translateY(-50%) scale(1.06); }

.tgj-lightbox__counter {
	position: absolute;
	bottom: max(12px, 2vmin);
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.75);
	font-size: 0.85rem;
	letter-spacing: 0.04em;
}

.tgj-lightbox.is-single .tgj-lightbox__prev,
.tgj-lightbox.is-single .tgj-lightbox__next,
.tgj-lightbox.is-single .tgj-lightbox__counter { display: none; }

body.tgj-lightbox-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
	.tgj-gallery__img,
	.tgj-gallery__overlay,
	.tgj-lightbox,
	.tgj-lightbox__btn { transition: none; }

	.tgj-gallery--lightbox .tgj-gallery__media:hover .tgj-gallery__img { transform: none; }
}
