:root {
	--bg-dark: #0a0a0a;
	--bg-overlay: rgba(10, 10, 10, 0.75);
	--text-primary: #e8e8e8;
	--text-secondary: #a0a0a0;
	--accent-color: #4a9eff;
	--control-bg: rgba(20, 20, 20, 0.85);
	--control-hover: rgba(40, 40, 40, 0.95);
	--transition-speed: 0.3s;
}

body, html {
	color: var(--text-primary);
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
	background: var(--bg-dark);
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	line-height: 1.5;
}

a:link, a:visited, a:hover {
	text-decoration: none;
	color: var(--accent-color);
	transition: all var(--transition-speed) ease;
}

a.menu {
	display: flex;
	align-items: center;
	justify-content: center;
	position: fixed;
	opacity: 0;
	visibility: hidden;
	transition: opacity var(--transition-speed) ease,
	visibility var(--transition-speed) ease,
	transform var(--transition-speed) ease;
	z-index: 100;
	background: var(--control-bg);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border-radius: 12px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

body:hover a.menu,
body:active a.menu {
	opacity: 1;
	visibility: visible;
}

a.menu:hover {
	background: var(--control-hover);
	transform: scale(1.05);
}

a.menu img {
	background: none !important;
	width: 24px;
	height: 24px;
	filter: brightness(0) invert(1);
	opacity: 0.9;
	transition: opacity var(--transition-speed) ease;
}

a.menu:hover img {
	opacity: 1;
}

a.menu.previous,
a.menu.next {
	top: 50%;
	transform: translateY(-50%);
	width: 56px;
	height: 56px;
	padding: 0;
}

a.menu.previous:hover,
a.menu.next:hover {
	transform: translateY(-50%) scale(1.05);
}

a.menu.previous {
	left: 20px;
}

a.menu.next {
	right: 20px;
}

a.menu.previous img,
a.menu.next img {
	width: 28px;
	height: 28px;
}

a.menu.home,
a.menu.search {
	top: 20px;
	width: 48px;
	height: 48px;
	padding: 0;
}

a.menu.home {
	left: 20px;
}

a.menu.search {
	right: 20px;
}

a.menu.home img,
a.menu.search img {
	width: 24px;
	height: 24px;
}

div[align="center"] {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100vw;
	height: 100vh;
	padding: 0;
	margin: 0;
}

#img {
	max-width: 95vw;
	max-height: 95vh;
	width: auto;
	height: auto;
	border: 1px solid black;
	box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
	border-radius: 4px;
	object-fit: contain;
	cursor: zoom-in;
	transition: transform var(--transition-speed) ease;
	animation: fadeIn 0.4s ease;
}

#img.zoomed {
	cursor: zoom-out;
	max-width: none;
	max-height: none;
}

.fleches {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--control-bg);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	padding: 12px 24px;
	border-radius: 24px;
	font-size: 11px;
	color: var(--text-secondary);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.5s ease, visibility 0.5s ease;
	z-index: 50;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.fleches.visible {
	opacity: 0.8;
	visibility: visible;
}

.fleches p {
	margin: 0;
	display: flex;
	align-items: center;
	gap: 8px;
}

.fleches p img {
	vertical-align: middle;
	width: 16px;
	height: 16px;
}

/* ============================================================================
   STYLES POUR LES LÉGENDES D'IMAGES
   ============================================================================ */

.image-caption {
	position: fixed;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--control-bg);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	padding: 12px 24px;
	border-radius: 24px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--text-primary);
	max-width: 80%;
	text-align: center;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
	z-index: 60;
	opacity: 1;
	visibility: visible;
	transition: opacity var(--transition-speed) ease,
	visibility var(--transition-speed) ease,
	transform var(--transition-speed) ease;
	animation: fadeInUp 0.4s ease-out;
}

.image-caption.hidden {
	opacity: 0;
	visibility: hidden;
	transform: translateX(-50%) translateY(10px);
}

/* Ajustement quand les flèches sont visibles */
.fleches.visible ~ .image-caption {
	bottom: 70px;
}

/* Animation d'apparition */
@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateX(-50%) translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateX(-50%) translateY(0);
	}
}

/* ============================================================================
   MEDIA QUERIES POUR MOBILE - VERSION OPTIMISÉE
   ============================================================================ */

@media (max-width: 768px) {
	/* Reset du body et html pour mobile */
	body, html {
		overflow: hidden;
		width: 100vw;
		height: 100vh;
		margin: 0;
		padding: 0;
	}

	/* Contrôles de navigation - TOUJOURS VISIBLES */
	a.menu {
		opacity: 0.8 !important;
		visibility: visible !important;
		z-index: 100;
	}

	a.menu:active,
	a.menu:hover {
		opacity: 1 !important;
		background: var(--control-hover) !important;
	}

	/* Boutons précédent/suivant - plus gros pour être facilement cliquables */
	a.menu.previous,
	a.menu.next {
		width: 64px !important;
		height: 64px !important;
		background: rgba(20, 20, 20, 0.7) !important;
	}

	a.menu.previous {
		left: 8px !important;
	}

	a.menu.next {
		right: 8px !important;
	}

	a.menu.previous img,
	a.menu.next img {
		width: 32px !important;
		height: 32px !important;
	}

	/* Boutons home et search */
	a.menu.home,
	a.menu.search {
		width: 50px !important;
		height: 50px !important;
		top: 12px !important;
		background: rgba(20, 20, 20, 0.7) !important;
	}

	a.menu.home {
		left: 12px !important;
	}

	a.menu.search {
		right: 12px !important;
	}

	a.menu.home img,
	a.menu.search img {
		width: 26px !important;
		height: 26px !important;
	}

	/* Conteneur de l'image - FORCE la taille à 100% */
	div[align="center"] {
		display: flex !important;
		align-items: center !important;
		justify-content: center !important;
		width: 100vw !important;
		height: 100vh !important;
		padding: 0 !important;
		margin: 0 !important;
		position: fixed !important;
		top: 0 !important;
		left: 0 !important;
		background: var(--bg-dark);
	}

	/* L'image - FORCE à être grande */
	#img {
		max-width: 100vw !important;
		max-height: 100vh !important;
		width: auto !important;
		height: auto !important;
		border: none !important;
		box-shadow: none !important;
		border-radius: 0 !important;
		object-fit: contain !important;
		margin: 0 !important;
		padding: 0 !important;
	}

	/* Légende - BULLE arrondie sur mobile */
	.image-caption {
		position: fixed !important;
		bottom: 90px !important;
		left: 50% !important;
		right: auto !important;
		transform: translateX(-50%) !important;
		width: auto !important;
		max-width: 80% !important;
		min-width: 180px !important;
		background: rgba(30, 30, 30, 0.95) !important;
		backdrop-filter: blur(20px) !important;
		-webkit-backdrop-filter: blur(20px) !important;
		padding: 16px 24px !important;
		font-size: 15px !important;
		line-height: 1.5 !important;
		color: #ffffff !important;
		border-radius: 20px !important;
		text-align: center !important;
		box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7),
		0 0 0 1px rgba(255, 255, 255, 0.15) inset !important;
		z-index: 90 !important;
		font-weight: 400 !important;
		animation: bubbleIn 0.4s ease-out !important;
	}

	@keyframes bubbleIn {
		from {
			opacity: 0;
			transform: translateX(-50%) translateY(20px) scale(0.9);
		}
		to {
			opacity: 1;
			transform: translateX(-50%) translateY(0) scale(1);
		}
	}

	/* Message des flèches - en dessous de la bulle */
	.fleches {
		position: fixed !important;
		bottom: 16px !important;
		left: 50% !important;
		transform: translateX(-50%) !important;
		font-size: 11px !important;
		padding: 10px 18px !important;
		max-width: calc(100% - 32px) !important;
		border-radius: 16px !important;
		background: rgba(20, 20, 20, 0.85) !important;
		z-index: 85 !important;
	}

	.fleches p {
		gap: 8px !important;
		margin: 0 !important;
	}

	.fleches p img {
		width: 16px !important;
		height: 16px !important;
	}

	/* Quand les flèches sont visibles, la légende remonte encore */
	.fleches.visible ~ .image-caption {
		bottom: 140px !important;
	}

	/* Cacher le <br /> qui prend de la place */
	div[align="center"] br {
		display: none !important;
	}
}

/* ============================================================================
   ANIMATIONS GÉNÉRALES
   ============================================================================ */

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: scale(0.95);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

#img {
	animation: fadeIn 0.4s ease;
}

/* ============================================================================
   ACCESSIBILITÉ
   ============================================================================ */

a.menu:focus {
	outline: 2px solid var(--accent-color);
	outline-offset: 4px;
}

a.menu:focus-visible {
	opacity: 1;
	visibility: visible;
}