/*
 * FS Media Gallery - justified layout and photo polish.
 *
 * The lightbox is powered by GLightbox (MIT), which ships its own stylesheet.
 * Only the grid and its captions are styled here.
 */

.fs-media-gallery {
	display: block;
	line-height: 0;
	margin: 0;
	padding: 0;
}

.fs-media-gallery > a {
	position: relative;
	display: inline-block;
	box-sizing: border-box;
	overflow: hidden;
	line-height: normal;
	border-radius: 6px;
	/* Not a link, but a preview trigger, so a pointer is correct. */
	cursor: pointer;
	background: #eef0f3 linear-gradient( 110deg, #eceff3 8%, #f5f7fa 18%, #eceff3 33% );
	background-size: 200% 100%;
	animation: fsmg-skeleton 1.4s linear infinite;
	text-decoration: none;
	transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.fs-media-gallery > a:hover,
.fs-media-gallery > a:focus-visible {
	transform: translateY( -2px );
	box-shadow: 0 8px 20px rgba( 15, 23, 42, 0.18 );
}

.fs-media-gallery > a:focus-visible {
	outline: 2px solid #2563eb;
	outline-offset: 2px;
}

.fs-media-gallery > a > img {
	display: block;
	width: 100%;
	height: 100%;
	border: 0;
	object-fit: cover;
}

.fs-media-gallery-caption {
	position: absolute;
	inset: auto 0 0 0;
	box-sizing: border-box;
	max-height: 100%;
	overflow: hidden;
	padding: 28px 10px 8px;
	color: #fff;
	background: linear-gradient( to top, rgba( 0, 0, 0, 0.82 ), rgba( 0, 0, 0, 0 ) );
	font-size: 12px;
	line-height: 1.35;
	text-align: left;
}

.fs-media-gallery-title {
	display: block;
	font-weight: 600;
}

.fs-media-gallery-description {
	display: block;
	margin-top: 2px;
}

.fs-media-gallery-description a {
	color: inherit;
}

.fs-media-gallery-no-photos,
.fs-media-gallery-error {
	margin: 12px 0;
	padding: 14px 16px;
	border-radius: 6px;
	border-left: 4px solid currentColor;
	background: rgba( 15, 23, 42, 0.05 );
	font-size: 14px;
	line-height: 1.5;
}

.fs-media-gallery-error {
	border-left-color: #dc2626;
	color: #b91c1c;
}

.fs-media-gallery-no-photos {
	border-left-color: #6b7280;
	color: #4b5563;
}

.fs-media-gallery-pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	justify-content: center;
	align-items: center;
	margin: 16px 0;
	font-size: 14px;
	line-height: 1.5;
}

.fs-media-gallery-pagination a,
.fs-media-gallery-pagination span {
	min-width: 28px;
	padding: 5px 10px;
	border-radius: 4px;
	text-align: center;
	text-decoration: none;
}

.fs-media-gallery-pagination a {
	border: 1px solid #d1d5db;
	background: #fff;
	color: #374151;
	transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.fs-media-gallery-pagination a:hover,
.fs-media-gallery-pagination a:focus {
	border-color: #2563eb;
	background: #eff6ff;
	color: #1d4ed8;
}

.fs-media-gallery-pagination .prev,
.fs-media-gallery-pagination .next {
	padding: 5px 14px;
	font-weight: 500;
}

.fs-media-gallery-pagination [ aria-current='page' ] {
	border: 1px solid #2563eb;
	background: #2563eb;
	color: #fff;
	font-weight: 700;
}

@keyframes fsmg-skeleton {
	to {
		background-position: -200% 0;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.fs-media-gallery > a {
		animation: none;
		transition: none;
	}

	.fs-media-gallery > a:hover,
	.fs-media-gallery > a:focus-visible {
		transform: none;
	}
}

/* ==================================================================
   In-page photo preview (vanilla JS, no third-party script)
   ================================================================== */

.fsmg-preview {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	align-items: center;
	justify-content: center;
}

.fsmg-preview.is-open {
	display: flex;
}

.fsmg-preview-backdrop {
	position: absolute;
	inset: 0;
	background: rgba( 9, 12, 18, 0.72 );
	backdrop-filter: blur( 14px ) saturate( 120% );
	-webkit-backdrop-filter: blur( 14px ) saturate( 120% );
	animation: fsmg-fade 0.2s ease;
}

.fsmg-preview-panel {
	position: relative;
	display: flex;
	flex-direction: column;
	/* Fill the viewport so the photo is viewed full window. */
	width: 100vw;
	height: 100vh;
	height: 100dvh;
	max-width: 100vw;
	max-height: 100dvh;
	border: 0;
	border-radius: 0;
	background: #0f1218;
	overflow: hidden;
	animation: fsmg-fade 0.2s ease;
}

/* Top bar */
.fsmg-preview-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 14px;
	border-bottom: 1px solid rgba( 255, 255, 255, 0.08 );
	color: #e8ecf3;
}

.fsmg-preview-counter {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.06em;
	color: #a9b4c4;
}

/* Buttons */
.fsmg-preview-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 1px solid rgba( 255, 255, 255, 0.14 );
	border-radius: 10px;
	background: rgba( 255, 255, 255, 0.06 );
	color: #eef2f8;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	/* Must sit above the stage, which is a later DOM sibling. */
	z-index: 3;
	transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.fsmg-preview-btn:hover {
	background: rgba( 255, 255, 255, 0.14 );
	border-color: rgba( 255, 255, 255, 0.3 );
	transform: translateY( -1px );
}

.fsmg-preview-btn:focus-visible {
	outline: 2px solid #7aa2ff;
	outline-offset: 2px;
}

.fsmg-preview-btn:disabled {
	opacity: 0.4;
	cursor: default;
	transform: none;
}

.fsmg-preview-close {
	width: 34px;
	height: 34px;
	font-size: 22px;
}

/* Stage: fills the window beside the top bar and caption. */
.fsmg-preview-stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 1 1 auto;
	min-height: 0;
	height: auto;
	background: radial-gradient( circle at 50% 40%, rgba( 255, 255, 255, 0.05 ), rgba( 0, 0, 0, 0 ) );
	touch-action: pan-y;
}

.fsmg-preview-figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	min-height: 0;
}

.fsmg-preview-image {
	/* Use every pixel of the window beside the bar and the caption. */
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	opacity: 0;
	transition: opacity 0.22s ease;
}

.fsmg-preview-image.is-loaded {
	opacity: 1;
}

.fsmg-preview-loader {
	position: absolute;
	display: none;
	width: 26px;
	height: 26px;
	border: 3px solid rgba( 255, 255, 255, 0.25 );
	border-top-color: #fff;
	border-radius: 50%;
	animation: fsmg-spin 0.8s linear infinite;
}

.fsmg-preview-caption {
	box-sizing: border-box;
	width: 100%;
	min-height: 30px;
	padding: 10px 14px;
	border-top: 1px solid rgba( 255, 255, 255, 0.08 );
	color: #dfe5ee;
	font-size: 13px;
	line-height: 1.5;
	text-align: center;
}

/* Prev / next sit inside the panel flanks on desktop */
.fsmg-preview-panel .fsmg-preview-prev,
.fsmg-preview-panel .fsmg-preview-next {
	position: absolute;
	top: 50%;
	transform: translateY( -50% );
}

.fsmg-preview-panel .fsmg-preview-prev {
	left: 12px;
}

.fsmg-preview-panel .fsmg-preview-next {
	right: 12px;
}

.fsmg-preview-panel .fsmg-preview-btn:hover {
	transform: translateY( calc( -50% - 1px ) );
}

html.fsmg-preview-open,
html.fsmg-preview-open body {
	overflow: hidden;
}

@keyframes fsmg-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes fsmg-spin {
	to { transform: rotate( 360deg ); }
}

/* Mobile stack the controls under the image */
@media screen and ( max-width: 640px ) {
	.fsmg-preview-panel {
		max-height: 100dvh;
	}

	.fsmg-preview-caption {
		font-size: 12px;
	}

	.fsmg-preview-panel .fsmg-preview-prev {
		left: 8px;
	}

	.fsmg-preview-panel .fsmg-preview-next {
		right: 8px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.fsmg-preview,
	.fsmg-preview-backdrop,
	.fsmg-preview-panel,
	.fsmg-preview-image,
	.fsmg-preview-loader,
	.fsmg-preview-btn {
		animation: none;
		transition: none;
	}
}