/* Adev Media Gallery – Frontend Styles
   ========================================= */

:root {
	--adev-primary:    #1a2b5e;
	--adev-accent:     #1a2b5e;
	--adev-white:      #ffffff;
	--adev-gray-light: #f5f5f5;
	--adev-gray:       #888888;
	--adev-border:     #e0e0e0;
	--adev-text:       #333333;
	--adev-radius:     0px;
	--adev-transition: 0.3s ease;
	--adev-gap:        12px;
}

/* ── Hero ────────────────────────────────── */
.adev-mg-hero {
	position: relative;
	display: flex;
	align-items: flex-end;
	min-height: 260px;
	background: var(--adev-primary) no-repeat center center / cover;
	overflow: hidden;
	margin-bottom: 0;
}

.adev-mg-hero__overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient(to right, rgba(255,255,255,0.95) 40%, rgba(255,255,255,0) 100%);
	z-index: 1;
}

.adev-mg-hero__content {
	position: relative;
	z-index: 2;
	padding: 48px 40px 48px 40px;
	max-width: 520px;
}

.adev-mg-hero__title {
	font-size: clamp(2rem, 5vw, 3rem);
	font-weight: 800;
	color: var(--adev-primary);
	letter-spacing: 0.05em;
	text-transform: uppercase;
	margin: 0 0 16px;
	line-height: 1.1;
}

.adev-mg-hero__description {
	font-size: 0.95rem;
	color: var(--adev-text);
	line-height: 1.7;
	margin: 0;
}

.adev-mg-hero__image {
	position: absolute;
	inset: 0;
	z-index: 0;
}

.adev-mg-hero__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ── Wrapper ─────────────────────────────── */
.adev-mg-wrapper {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 20px;
}

/* ── Filters ─────────────────────────────── */
.adev-mg-filters {
	padding: 32px 0 24px;
}

.adev-mg-filters__inner {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
}

.adev-mg-filter-btn {
	display: inline-block;
	padding: 10px 24px;
	font-size: 0.8rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	border: 2px solid var(--adev-primary);
	background: transparent;
	color: var(--adev-primary);
	cursor: pointer;
	transition: background var(--adev-transition), color var(--adev-transition);
	outline: none;
	font-family: inherit;
}

.adev-mg-filter-btn:hover,
.adev-mg-filter-btn:focus-visible {
	background: var(--adev-primary);
	color: var(--adev-white);
}

.adev-mg-filter-btn.is-active {
	background: var(--adev-primary);
	color: var(--adev-white);
}

/* ── Gallery Grid ────────────────────────── */
.adev-mg-gallery {
	padding-bottom: 40px;
}

.adev-mg-gallery__grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: var(--adev-gap);
}

.adev-mg-gallery__empty {
	grid-column: 1 / -1;
	text-align: center;
	color: var(--adev-gray);
	padding: 40px 0;
}

/* Grid transition when filtering */
.adev-mg-gallery__grid.is-loading {
	opacity: 0.5;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

/* ── Card ────────────────────────────────── */
.adev-mg-card {
	position: relative;
	overflow: hidden;
	background: var(--adev-gray-light);
	display: block;
}

.adev-mg-card__link {
	display: block;
	width: 100%;
	height: 100%;
	text-decoration: none;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	font: inherit;
}

.adev-mg-card__image-wrap {
	position: relative;
	overflow: hidden;
	aspect-ratio: 1 / 1;
}

.adev-mg-card__img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.4s ease;
}

.adev-mg-card:hover .adev-mg-card__img,
.adev-mg-card:focus-within .adev-mg-card__img {
	transform: scale(1.06);
}

.adev-mg-card__overlay {
	position: absolute;
	inset: 0;
	background: rgba(26, 43, 94, 0);
	transition: background var(--adev-transition);
	pointer-events: none;
}

.adev-mg-card:hover .adev-mg-card__overlay,
.adev-mg-card:focus-within .adev-mg-card__overlay {
	background: rgba(26, 43, 94, 0.15);
}

.adev-mg-card__placeholder {
	width: 100%;
	height: 100%;
	background: var(--adev-gray-light);
}

.adev-mg-card__category {
	display: block;
	padding: 8px 12px;
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--adev-text);
	background: var(--adev-white);
}

/* Focus ring for accessibility */
.adev-mg-card__link:focus-visible {
	outline: 3px solid var(--adev-primary);
	outline-offset: 2px;
}

/* ── Load More ───────────────────────────── */
.adev-mg-load-more-wrap {
	text-align: center;
	padding: 32px 0;
}

.adev-mg-load-more {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 14px 40px;
	font-size: 0.8rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	border: 2px solid var(--adev-primary);
	background: transparent;
	color: var(--adev-primary);
	cursor: pointer;
	transition: background var(--adev-transition), color var(--adev-transition);
	font-family: inherit;
}

.adev-mg-load-more:hover,
.adev-mg-load-more:focus-visible {
	background: var(--adev-primary);
	color: var(--adev-white);
}

.adev-mg-load-more.is-loading .adev-mg-load-more__text {
	opacity: 0.5;
}

.adev-mg-load-more__spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: adev-spin 0.7s linear infinite;
}

.adev-mg-load-more.is-loading .adev-mg-load-more__spinner {
	display: block;
}

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

/* ── Lightbox ────────────────────────────── */
/*
 * z-index must beat sticky theme headers (Divi etc. often use 99999).
 * The node is also moved to document.body in JS to escape stacking contexts
 * created by theme sections (transform / z-index on parents).
 */
.adev-mg-lightbox {
	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	isolation: isolate;
}

.adev-mg-lightbox[hidden] {
	display: none !important;
}

.adev-mg-lightbox__backdrop {
	position: absolute;
	inset: 0;
	z-index: 0;
	background: rgba(0, 0, 0, 0.92);
	cursor: pointer;
}

/*
 * Stable stage: chrome (close / nav) stays fixed to the viewport.
 * Image area is a fixed max box; any aspect ratio fits with contain
 * (letterbox / pillarbox) — no cropping, no layout jump between slides.
 */
.adev-mg-lightbox__container {
	position: relative;
	z-index: 1;
	display: grid;
	grid-template-columns: auto minmax(0, 1fr) auto;
	grid-template-rows: auto minmax(0, 1fr) auto;
	align-items: center;
	justify-items: center;
	width: min(96vw, 1400px);
	height: min(96vh, 100dvh);
	max-width: 96vw;
	max-height: 96vh;
	padding: 12px;
	padding-top: 56px; /* room under fixed close control */
	box-sizing: border-box;
	pointer-events: none;
}

.adev-mg-lightbox__container > * {
	pointer-events: auto;
}

.adev-mg-lightbox__content {
	grid-column: 2;
	grid-row: 2;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
}

.adev-mg-lightbox__stage {
	position: relative;
	flex: 1 1 auto;
	width: 100%;
	min-height: 0;
	/* Soft frame so very small images still feel intentional */
	background: rgba(255, 255, 255, 0.03);
}

.adev-mg-lightbox__img {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: block;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
	object-position: center;
	border: 0;
	opacity: 1;
	transition: opacity 0.2s ease;
}

.adev-mg-lightbox__img.is-loading {
	opacity: 0;
}

.adev-mg-lightbox__caption {
	flex: 0 0 auto;
	color: var(--adev-white);
	font-size: 0.9rem;
	text-align: center;
	margin: 0;
	max-width: min(600px, 100%);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 0 8px;
}

.adev-mg-lightbox__caption-category {
	display: inline-block;
	background: rgba(255,255,255,0.15);
	border: 1px solid rgba(255,255,255,0.3);
	color: var(--adev-white);
	font-size: 0.75rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	padding: 2px 10px;
	border-radius: 20px;
}

.adev-mg-lightbox__caption-alt {
	color: rgba(255,255,255,0.85);
	font-size: 0.88rem;
}

.adev-mg-lightbox__close,
.adev-mg-lightbox__nav {
	background: none;
	border: none;
	color: var(--adev-white);
	cursor: pointer;
	font-family: inherit;
	padding: 8px;
	opacity: 0.95;
	transition: opacity var(--adev-transition), background 0.2s ease, transform 0.15s ease;
	line-height: 1;
}

.adev-mg-lightbox__close:hover,
.adev-mg-lightbox__close:focus-visible,
.adev-mg-lightbox__nav:hover,
.adev-mg-lightbox__nav:focus-visible {
	opacity: 1;
}

/*
 * Close is fixed to the viewport (not the image box) so theme headers
 * cannot cover it, and it stays reachable on every aspect ratio.
 */
.adev-mg-lightbox__close {
	position: fixed;
	top: max(12px, env(safe-area-inset-top, 0px));
	right: max(12px, env(safe-area-inset-right, 0px));
	z-index: 2147483001;
	font-size: 2rem;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	border: 1px solid rgba(255, 255, 255, 0.35);
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
	pointer-events: auto;
}

.adev-mg-lightbox__close:hover,
.adev-mg-lightbox__close:focus-visible {
	background: rgba(0, 0, 0, 0.75);
	transform: scale(1.05);
}

.adev-mg-lightbox__prev {
	grid-column: 1;
	grid-row: 2;
	font-size: 2.75rem;
	padding: 12px 8px;
	z-index: 2;
}

.adev-mg-lightbox__next {
	grid-column: 3;
	grid-row: 2;
	font-size: 2.75rem;
	padding: 12px 8px;
	z-index: 2;
}

/* While open: keep page from scrolling; help sticky headers stay under overlay */
body.adev-mg-lightbox-open {
	overflow: hidden !important;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 1024px) {
	.adev-mg-gallery__grid {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 768px) {
	.adev-mg-hero {
		min-height: 200px;
	}

	.adev-mg-hero__content {
		padding: 28px 16px;
		max-width: 100%;
	}

	.adev-mg-hero__overlay {
		background: linear-gradient(to bottom, rgba(255,255,255,0.92) 60%, rgba(255,255,255,0.5) 100%);
	}

	.adev-mg-gallery__grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 8px;
	}

	.adev-mg-wrapper {
		padding: 0 10px;
	}

	.adev-mg-filters {
		padding: 20px 0 16px;
	}

	/* Lightbox: hide side nav buttons on touch, use swipe */
	.adev-mg-lightbox__nav {
		display: none;
	}

	.adev-mg-lightbox__container {
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: auto minmax(0, 1fr);
		width: 100vw;
		height: 100dvh;
		max-width: 100vw;
		max-height: 100dvh;
		padding: 8px;
		padding-top: 60px;
	}

	.adev-mg-lightbox__content {
		grid-column: 1;
		grid-row: 2;
		gap: 8px;
		padding: 0 4px 12px;
	}

	.adev-mg-lightbox__close {
		top: max(10px, env(safe-area-inset-top, 0px));
		right: max(10px, env(safe-area-inset-right, 0px));
		width: 44px;
		height: 44px;
		font-size: 1.75rem;
		background: rgba(0, 0, 0, 0.6);
	}

	.adev-mg-lightbox__stage {
		background: transparent;
	}
}

@media (max-width: 480px) {
	/* Keep 2 columns on phones — compact gallery style */
	.adev-mg-gallery__grid {
		grid-template-columns: repeat(2, 1fr);
		gap: 4px;
	}

	.adev-mg-filters__inner {
		gap: 6px;
		justify-content: flex-start;
		padding: 0 2px;
		overflow-x: auto;
		flex-wrap: nowrap;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	.adev-mg-filters__inner::-webkit-scrollbar {
		display: none;
	}

	.adev-mg-filter-btn {
		padding: 8px 16px;
		font-size: 0.72rem;
		white-space: nowrap;
		flex-shrink: 0;
	}

	.adev-mg-hero__title {
		font-size: 1.5rem;
	}

	/* Category label under card — smaller on mobile */
	.adev-mg-card__category {
		font-size: 0.65rem;
		padding: 5px 8px;
		letter-spacing: 0.04em;
	}

	.adev-mg-load-more {
		padding: 12px 28px;
		font-size: 0.75rem;
	}
}
