/**
 * Galerie mosaïque + lightbox AFMED
 */

.entry-content .afmed-gallery,
.afmed-gallery {
	margin: 36px 0 8px;
	padding: 0;
	max-width: 100%;
}

.entry-content p:has(+ .afmed-gallery):empty,
.entry-content .afmed-gallery + p:empty {
	display: none;
}

.entry-content .afmed-gallery a,
.entry-content .afmed-gallery a:hover,
.entry-content .afmed-gallery a:focus {
	color: inherit;
	text-decoration: none;
	box-shadow: none;
	border: 0;
}

.afmed-gallery__head {
	display: flex;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	margin: 0 0 14px;
	padding-bottom: 12px;
	border-bottom: 1px solid var(--afmed-line, #e3e8ee);
}

.afmed-gallery__kicker {
	margin: 0 0 4px;
	font-family: var(--afmed-sans-cond, sans-serif);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--afmed-cyan, #0099d6);
}

.afmed-gallery__title {
	margin: 0;
	font-family: var(--afmed-serif, Georgia, serif);
	font-size: 22px;
	font-weight: 600;
	line-height: 1.25;
	color: var(--afmed-ink, #141414);
}

.afmed-gallery__count {
	margin: 0;
	flex-shrink: 0;
	font-family: var(--afmed-sans-cond, sans-serif);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.04em;
	color: var(--afmed-ink-soft, #3a4250);
}

.afmed-gallery__mosaic,
.afmed-gallery__rest {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	grid-auto-rows: 92px;
	gap: 4px;
}

.afmed-gallery__rest {
	margin-top: 4px;
}

.afmed-gallery__cell {
	position: relative;
	display: block;
	overflow: hidden;
	background: #0b1220;
	grid-column: span 1;
	grid-row: span 1;
	min-height: 0;
	height: 100%;
	text-decoration: none;
}

.afmed-gallery__cell.is-hero {
	grid-column: span 2;
	grid-row: span 3;
}

.afmed-gallery__cell.is-wide {
	grid-column: span 2;
	grid-row: span 2;
}

.afmed-gallery__rest .afmed-gallery__cell {
	grid-row: span 2;
}

.entry-content .afmed-gallery img.afmed-gallery__img,
.afmed-gallery__img {
	display: block;
	width: 100% !important;
	height: 100% !important;
	max-width: none !important;
	max-height: none !important;
	margin: 0;
	padding: 0;
	border: 0;
	object-fit: cover;
	transform: scale(1.01);
	transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.afmed-gallery__cell::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(180deg, transparent 55%, rgba(11, 18, 32, 0.45) 100%);
	opacity: 0.35;
	transition: opacity 0.35s ease;
	pointer-events: none;
}

.afmed-gallery__zoom {
	position: absolute;
	right: 10px;
	bottom: 10px;
	z-index: 1;
	width: 28px;
	height: 28px;
	border: 1px solid rgba(255, 255, 255, 0.7);
	border-radius: 50%;
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.3s ease, transform 0.3s ease;
	pointer-events: none;
}

.afmed-gallery__zoom::before,
.afmed-gallery__zoom::after {
	content: "";
	position: absolute;
	background: #fff;
}

.afmed-gallery__zoom::before {
	top: 13px;
	left: 8px;
	width: 12px;
	height: 1.5px;
}

.afmed-gallery__zoom::after {
	top: 8px;
	left: 13px;
	width: 1.5px;
	height: 12px;
}

.afmed-gallery__cell:hover img,
.afmed-gallery__cell:focus-visible img {
	transform: scale(1.07);
}

.afmed-gallery__cell:hover::after,
.afmed-gallery__cell:focus-visible::after {
	opacity: 0.7;
}

.afmed-gallery__cell:hover .afmed-gallery__zoom,
.afmed-gallery__cell:focus-visible .afmed-gallery__zoom {
	opacity: 1;
	transform: translateY(0);
}

.afmed-gallery__cell:focus-visible {
	outline: 2px solid var(--afmed-cyan, #0099d6);
	outline-offset: 2px;
}

.afmed-gallery__more {
	display: block;
	width: 100%;
	margin: 10px 0 0;
	padding: 13px 18px;
	border: 1px solid var(--afmed-navy, #0e2c7f);
	background: transparent;
	color: var(--afmed-navy, #0e2c7f);
	font-family: var(--afmed-sans-cond, sans-serif);
	font-size: 14px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
}

.afmed-gallery__more:hover,
.afmed-gallery__more:focus-visible {
	background: var(--afmed-navy, #0e2c7f);
	color: #fff;
}

.afmed-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 48px 72px 56px;
	background: rgba(8, 12, 22, 0.94);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.22s ease, visibility 0.22s ease;
}

.afmed-lightbox.is-open {
	opacity: 1;
	visibility: visible;
}

.afmed-lightbox__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	max-width: min(1200px, 100%);
	max-height: 100%;
}

.afmed-lightbox__img {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 120px);
	width: auto;
	height: auto;
	box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.25s ease, transform 0.25s ease;
}

.afmed-lightbox.is-ready .afmed-lightbox__img {
	opacity: 1;
	transform: none;
}

.afmed-lightbox__meta {
	position: absolute;
	left: 24px;
	bottom: 18px;
	margin: 0;
	font-family: var(--afmed-sans-cond, sans-serif);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.08em;
	color: rgba(255, 255, 255, 0.78);
}

.afmed-lightbox__btn {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, 0.28);
	background: rgba(11, 18, 32, 0.35);
	color: #fff;
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.afmed-lightbox__btn:hover,
.afmed-lightbox__btn:focus-visible {
	background: var(--afmed-navy, #0e2c7f);
	border-color: var(--afmed-cyan, #0099d6);
}

.afmed-lightbox__close {
	top: 16px;
	right: 16px;
}

.afmed-lightbox__prev {
	left: 16px;
	top: 50%;
	transform: translateY(-50%);
}

.afmed-lightbox__next {
	right: 16px;
	top: 50%;
	transform: translateY(-50%);
}

.afmed-lightbox__btn svg {
	display: block;
	width: 18px;
	height: 18px;
}

@media (max-width: 760px) {
	.afmed-gallery__mosaic,
	.afmed-gallery__rest {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		grid-auto-rows: 78px;
	}

	.afmed-gallery__cell.is-hero {
		grid-column: span 2;
		grid-row: span 3;
	}

	.afmed-gallery__cell.is-wide {
		grid-column: span 2;
		grid-row: span 2;
	}

	.afmed-gallery__title {
		font-size: 18px;
	}

	.afmed-lightbox {
		padding: 56px 12px 48px;
	}

	.afmed-lightbox__prev,
	.afmed-lightbox__next {
		top: auto;
		bottom: 12px;
		transform: none;
	}

	.afmed-lightbox__prev {
		left: 12px;
	}

	.afmed-lightbox__next {
		right: 12px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.afmed-gallery__img,
	.afmed-gallery__zoom,
	.afmed-lightbox,
	.afmed-lightbox__img {
		transition: none;
	}

	.afmed-gallery__cell:hover img,
	.afmed-gallery__cell:focus-visible img {
		transform: none;
	}
}
