/* Cartes — mise en page. Les couleurs, tailles et polices viennent de config-style.php (variables --t1…, --f1…, --c1…). */

html,
body {
	margin: 0;
	background: var(--fond-page);
}

/* La page est une scène fixe : les cartes défilent à l'intérieur. */
.cartes-page {
	position: fixed;
	inset: 0;
	/* Hauteur d'une carte : tient dans l'écran, au format 2/3 (largeur/hauteur). */
	--h: min(calc(100dvh - 8.75rem), calc((100vw - 3rem) * 1.5));
	--w: calc(var(--h) * 2 / 3);
	background: var(--fond-page);
	color: var(--encre);
	font-family: var(--police-base);
}

@supports not (height: 100dvh) {
	.cartes-page {
		--h: min(calc(100vh - 8.75rem), calc((100vw - 3rem) * 1.5));
	}
}

.admin-bar .cartes-page {
	top: 32px;
}

@media (max-width: 782px) {
	.admin-bar .cartes-page {
		top: 46px;
	}
}

/* Rangée de cartes */
.cartes {
	position: absolute;
	inset: 0;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	gap: 1.25rem;
	padding: 1rem max(1.5rem, calc((100vw - var(--w)) / 2)) 5rem;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-snap-type: x mandatory;
	overscroll-behavior-x: contain;
	scrollbar-width: none;
	outline: none;
}

.cartes::-webkit-scrollbar {
	display: none;
}

.cartes-page--seule .cartes {
	justify-content: center;
	overflow: hidden;
}

/* Un groupe = le rectangle de date + la carte. C'est lui qui défile et qui s'accroche. */
.carte-groupe {
	flex: 0 0 var(--w);
	width: var(--w);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.6rem;
	scroll-snap-align: center;
	container-type: inline-size;
}

/* Date et heure : un rectangle à part, détaché de la carte, de la même largeur qu'elle */
.carte__date {
	flex: none;
	width: 100%;
	padding: 0.45rem 0.75rem;
	background: var(--fond-carte);
	color: var(--encre);
	font-size: min(0.8rem, 3.6cqw);
	line-height: 1.2;
	text-align: center;
}

/* Une carte */
.carte {
	position: relative;
	flex: none;
	width: 100%;
	height: var(--h);
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--fond-carte);
	border-radius: 3px;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 8px 22px rgba(0, 0, 0, 0.12);
	container-type: inline-size;
}

/* Image seule : centrée verticalement. */
.carte--image {
	justify-content: center;
}

.carte__image {
	flex: none;
	width: 100%;
	aspect-ratio: 1;
}

.carte__image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover; /* au cas où une image ne serait pas carrée */
}

/* Texte : prend le dernier tiers (avec image) ou toute la carte (texte seul), toujours centré verticalement. */
.carte__texte {
	flex: 1 1 0;
	min-height: 0;
	display: flex;
	padding: 4cqw 6cqw;
	overflow-y: auto;
	overflow-wrap: break-word;
	text-align: center;
	line-height: 1.25;
	scrollbar-width: thin;
}

.carte__texte p {
	margin: auto; /* centre sans rogner le haut si le texte déborde */
	font-size: var(--base-mixte);
}

.carte--texte .carte__texte {
	padding: 8cqw;
}

.carte--texte .carte__texte p {
	font-size: var(--base-texte);
}

/* Mots mis en forme : taille, police et couleur sont fixées en ligne par les variables. */
.mot {
	line-height: 1.05;
}

/* Liens dans le texte : comme le reste du texte, mais soulignés */
.carte__texte a {
	color: inherit;
	font: inherit;
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

/* Petite icône de lien (chaîne) devant chaque lien, à la couleur du texte */
.carte__texte a::before {
	content: "";
	display: inline-block;
	width: 0.85em;
	height: 0.85em;
	margin-right: 0.25em;
	vertical-align: -0.08em;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E") center / contain no-repeat;
}

.cartes__vide {
	margin: auto;
	font-size: 1rem;
}

/* Flèches, en bas de l'écran : précédente à gauche, suivante à droite.
   Une flèche sans destination est masquée, mais garde sa place pour que l'autre ne bouge pas. */
.cartes__fleches {
	position: absolute;
	z-index: 2;
	left: 0;
	right: 0;
	bottom: 1rem;
	display: flex;
	justify-content: center;
	gap: 1.25rem;
	pointer-events: none;
}

.cartes__fleche {
	width: 3.25rem;
	height: 3.25rem;
	padding: 0;
	display: grid;
	place-items: center;
	border: 2px solid var(--encre);
	border-radius: 50%;
	background: var(--fond-carte);
	color: var(--encre);
	cursor: pointer;
	pointer-events: auto;
	-webkit-tap-highlight-color: transparent;
}

.cartes__fleche--precedent {
	transform: rotate(180deg); /* même dessin, retourné */
}

.cartes__fleche.est-masque {
	visibility: hidden;
}

.cartes__fleche svg {
	width: 1.9rem;
	height: 1.9rem;
	animation: cartes-pousse 2.4s ease-in-out infinite;
}

/* Bouton de partage, au milieu : pas d'animation */
.cartes__fleche--partager svg {
	animation: none;
	width: 1.5rem;
	height: 1.5rem;
}

/* Petit message (« Lien copié ») au-dessus des boutons */
.cartes__info {
	position: absolute;
	z-index: 3;
	left: 50%;
	bottom: 5rem;
	padding: 0.4rem 0.9rem;
	border-radius: 3px;
	background: var(--encre);
	color: var(--fond-carte);
	font-size: 0.85rem;
	white-space: nowrap;
	opacity: 0;
	transform: translateX(-50%) translateY(0.4rem);
	transition: opacity 0.2s, transform 0.2s;
	pointer-events: none;
}

.cartes__info.est-visible {
	opacity: 1;
	transform: translateX(-50%);
}

/* Sur la page d'une carte seule, la flèche est un simple retour : pas d'animation. */
.cartes__fleche--retour svg {
	animation: none;
}

.cartes__fleche:focus-visible,
.carte__texte a:focus-visible {
	outline: 3px solid var(--encre);
	outline-offset: 3px;
}

@keyframes cartes-pousse {
	0%,
	100% {
		transform: translateX(-2px);
	}
	50% {
		transform: translateX(3px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.cartes__fleche svg {
		animation: none !important;
	}
}
