/*
 * AfriBooking Manager: photo mosaic + full-screen viewer.
 *
 * Shared by the public property page and by the admin editor preview.
 * The mosaic adapts to the number of photos (classes abm-photos--n1 … n9):
 *
 *   1 photo   [ main                      ]
 *   2 photos  [ main              ][ tall ]
 *   3 photos  [ main              ][  b   ]
 *                                 [  c   ]
 *   4 photos  [ main              ][  b   ]
 *                                 [ c ][d ]
 *   5 photos  [ main              ][ b ][c]
 *                                 [ d ][e ]
 *   6+ photos [ main              ][  b   ]
 *                                 [  c   ]
 *             [ d ][ e ][ f ][ g ][ h ]      <- 3 to 5 photos; "+N autres photos" on the last one
 */

.abm-photos-wrap {
	min-width: 0;
	position: relative;
}

.abm-photos {
	--abm-gap: 8px;
	--abm-photos-h: 420px;
	--abm-main: 7;
	--abm-side: 3;
	display: flex;
	flex-direction: column;
	gap: var(--abm-gap);
	height: var(--abm-photos-h);
	min-width: 0;
	position: relative;
}

.abm-photos__top {
	display: flex;
	flex: 1 1 0%;
	gap: var(--abm-gap);
	min-height: 0;
}

.abm-photos__bottom {
	display: flex;
	flex: 0 0 27%;
	gap: var(--abm-gap);
	min-height: 0;
}

/* One tile = one photo. Images are absolutely positioned so a tile always
 * keeps the size given by the grid, whatever the photo ratio is. */
.abm-photos .abm-photo {
	-webkit-appearance: none;
	appearance: none;
	background: #e9efed;
	border: 0;
	border-radius: 10px;
	cursor: pointer;
	display: block;
	font: inherit;
	margin: 0;
	min-height: 0;
	min-width: 0;
	overflow: hidden;
	padding: 0;
	position: relative;
}

.abm-photos .abm-photo > img {
	display: block;
	filter: none;
	height: 100%;
	inset: 0;
	margin: 0;
	max-width: none;
	object-fit: cover;
	position: absolute;
	transition: filter .2s ease, transform .35s ease;
	width: 100%;
}

.abm-photos .abm-photo:hover > img {
	filter: brightness(.92);
	transform: scale(1.03);
}

.abm-photos .abm-photo:focus-visible,
.abm-photos__all:focus-visible {
	outline: 3px solid var(--abm-primary, #0071c2);
	outline-offset: 2px;
}

.abm-photos__top > .abm-photo.is-main {
	flex: var(--abm-main) 1 0%;
}

.abm-photos__side {
	display: grid;
	flex: var(--abm-side) 1 0%;
	gap: var(--abm-gap);
	min-height: 0;
	min-width: 0;
}

.abm-photos__bottom > .abm-photo {
	flex: 1 1 0%;
}

/* Layouts by number of photos. */
.abm-photos--n1 { --abm-main: 1; }
.abm-photos--n2 { --abm-main: 2; --abm-side: 1; }
.abm-photos--n4,
.abm-photos--n5 { --abm-main: 6; --abm-side: 4; }

.abm-photos__side--1 {
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: minmax(0, 1fr);
}

.abm-photos__side--2 {
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: repeat(2, minmax(0, 1fr));
}

.abm-photos__side--3,
.abm-photos__side--4 {
	grid-template-columns: repeat(2, minmax(0, 1fr));
	grid-template-rows: repeat(2, minmax(0, 1fr));
}

.abm-photos__side--3 > .abm-photo:first-child {
	grid-column: 1 / -1;
}

/* "N autres photos" on the last visible tile. */
.abm-photo__more {
	align-items: center;
	background: rgba(0, 0, 0, .5);
	color: #fff;
	display: flex;
	font-size: 16px;
	font-weight: 700;
	inset: 0;
	justify-content: center;
	line-height: 1.25;
	padding: 8px;
	position: absolute;
	text-align: center;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* "Voir les N photos": shown when the mosaic has no "+N" tile. */
.abm-photos__all {
	align-items: center;
	background: rgba(255, 255, 255, .96);
	border: 1px solid rgba(21, 33, 31, .18);
	border-radius: 999px;
	bottom: 12px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
	color: #15211f;
	cursor: pointer;
	display: inline-flex;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	padding: 9px 14px;
	position: absolute;
	right: 12px;
	z-index: 2;
}

.abm-photos--n6 .abm-photos__all,
.abm-photos--n7 .abm-photos__all,
.abm-photos--n8 .abm-photos__all,
.abm-photos.has-overlay .abm-photos__all {
	display: none;
}

@media (max-width: 1100px) {
	.abm-photos { --abm-photos-h: 380px; }
}

@media (max-width: 900px) {
	.abm-photos { --abm-photos-h: 340px; }
}

/* Phones: large main photo + one row of small photos. */
@media (max-width: 640px) {
	.abm-photos {
		display: grid;
		gap: 6px;
		grid-template-columns: repeat(var(--abm-m, 4), minmax(0, 1fr));
		height: auto;
	}

	.abm-photos__top,
	.abm-photos__side,
	.abm-photos__bottom {
		display: contents;
	}

	.abm-photos .abm-photo.abm-p0 {
		grid-column: 1 / -1;
		height: 250px;
	}

	.abm-photos .abm-photo:not(.abm-p0) {
		grid-column: auto;
		height: 70px;
	}

	.abm-photos .abm-photo.abm-p5,
	.abm-photos .abm-photo.abm-p6,
	.abm-photos .abm-photo.abm-p7 {
		display: none;
	}

	.abm-photos .abm-photos__all,
	.abm-photos.has-overlay .abm-photos__all {
		bottom: auto;
		display: inline-flex;
		right: 10px;
		top: 208px;
	}
}

/* ------------------------------------------------------------------ *
 * Full-screen viewer
 * ------------------------------------------------------------------ */
.abm-viewer {
	background: rgba(10, 14, 18, .98);
	color: #fff;
	display: flex;
	flex-direction: column;
	inset: 0;
	position: fixed;
	z-index: 999999;
}

.abm-viewer[hidden] {
	display: none;
}

.abm-viewer__bar {
	align-items: center;
	display: flex;
	flex: 0 0 auto;
	gap: 12px;
	padding: 12px 18px;
}

.abm-viewer__title {
	flex: 1;
	font-size: 15px;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.abm-viewer__count {
	font-size: 14px;
	opacity: .8;
	white-space: nowrap;
}

.abm-viewer__close,
.abm-viewer__nav {
	background: rgba(255, 255, 255, .14);
	border: 0;
	border-radius: 50%;
	color: #fff;
	cursor: pointer;
	line-height: 1;
	padding: 0;
	transition: background .15s ease;
}

.abm-viewer__close:hover,
.abm-viewer__nav:hover {
	background: rgba(255, 255, 255, .3);
}

.abm-viewer__close {
	font-size: 26px;
	height: 42px;
	width: 42px;
}

.abm-viewer__stage {
	align-items: center;
	display: flex;
	flex: 1 1 auto;
	justify-content: center;
	min-height: 0;
	padding: 0 70px;
	position: relative;
}

.abm-viewer__img {
	border-radius: 6px;
	display: block;
	height: auto;
	max-height: calc(100vh - 170px);
	max-height: calc(100dvh - 170px);
	max-width: 100%;
	object-fit: contain;
	user-select: none;
	width: auto;
}

.abm-viewer__nav {
	font-size: 30px;
	height: 46px;
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 46px;
	z-index: 2;
}

.abm-viewer__nav.is-prev { left: 12px; }
.abm-viewer__nav.is-next { right: 12px; }

.abm-viewer__thumbs {
	display: flex;
	flex: 0 0 auto;
	gap: 8px;
	overflow-x: auto;
	padding: 12px 18px 16px;
}

.abm-viewer__thumbs > :first-child { margin-left: auto; }
.abm-viewer__thumbs > :last-child { margin-right: auto; }

.abm-viewer__thumb {
	background: #222;
	border: 2px solid transparent;
	border-radius: 6px;
	cursor: pointer;
	flex: 0 0 auto;
	height: 60px;
	opacity: .55;
	overflow: hidden;
	padding: 0;
	position: relative;
	transition: opacity .15s ease;
	width: 84px;
}

.abm-viewer__thumb img {
	display: block;
	height: 100%;
	inset: 0;
	max-width: none;
	object-fit: cover;
	position: absolute;
	width: 100%;
}

.abm-viewer__thumb:hover { opacity: .85; }
.abm-viewer__thumb.is-active { border-color: #fff; opacity: 1; }

@media (max-width: 640px) {
	.abm-viewer__stage { padding: 0 6px; }
	.abm-viewer__nav { height: 40px; width: 40px; }
	.abm-viewer__nav.is-prev { left: 8px; }
	.abm-viewer__nav.is-next { right: 8px; }
	.abm-viewer__thumb { height: 48px; width: 68px; }
}
