/*
 * Aestivo - MAG
 * Liste des magazines municipaux, classés par année.
 */

.aestivo-mag {
	--aestivo-mag-accent: #82c0c7;
	--aestivo-mag-encre: #1c2b30;
	--aestivo-mag-doux: #6b7d83;
	--aestivo-mag-trait: #e4eaec;
	--aestivo-mag-fond: #ffffff;
	--aestivo-mag-largeur: 190px;
	/* Hauteurs mesurées en JS : éléments fixes du thème (en-tête Divi, barre admin)... */
	--aestivo-mag-offset: 0px;
	/* ...et barre des années. Valeur d'attente réaliste : le JS écrit la mesure
	   exacte, mais sans lui l'ancre doit déjà tomber sous la barre. */
	--aestivo-mag-barre: 52px;

	color: var(--aestivo-mag-encre);
}


/* ------------------------------------------------------------------ */
/* Barre des années (collante)                                         */
/* ------------------------------------------------------------------ */

.aestivo-mag-barre {
	position: -webkit-sticky;
	position: sticky;
	top: var(--aestivo-mag-offset, 0px);
	z-index: 30;
	margin: 0 0 6px 0;
	padding: 9px 0;
	background: var(--aestivo-mag-fond);
	border-bottom: 1px solid var(--aestivo-mag-trait);
}

/* Léger débord pour que le fond couvre toute la largeur de la colonne */
.aestivo-mag-barre::before {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	left: -20px;
	right: -20px;
	z-index: -1;
	background: var(--aestivo-mag-fond);
}

.aestivo-mag-piste {
	position: relative;
}

/* Dégradés indiquant que la liste continue, d'un côté ou de l'autre */
.aestivo-mag-piste::before,
.aestivo-mag-piste::after {
	content: '';
	position: absolute;
	top: 0;
	z-index: 2;
	width: 54px;
	height: 100%;
	opacity: 0;
	pointer-events: none;
	transition: opacity .2s ease;
}

.aestivo-mag-piste::before {
	left: 0;
	background: linear-gradient(to right, var(--aestivo-mag-fond), rgba(255, 255, 255, 0));
}

.aestivo-mag-piste::after {
	right: 0;
	background: linear-gradient(to left, var(--aestivo-mag-fond), rgba(255, 255, 255, 0));
}

.aestivo-mag-piste.deborde-gauche::before,
.aestivo-mag-piste.deborde-droite::after {
	opacity: 1;
}


/* Chevrons : masqués tant que le JS n'a pas constaté un débordement */
.aestivo-mag-fleche {
	position: absolute;
	top: 50%;
	z-index: 3;
	display: none;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	margin: 0;
	padding: 0;
	transform: translateY(-50%);
	border: 1px solid var(--aestivo-mag-trait);
	border-radius: 50%;
	background: var(--aestivo-mag-fond);
	color: var(--aestivo-mag-encre);
	box-shadow: 0 1px 5px rgba(20, 40, 45, .18);
	cursor: pointer;
	transition: background-color .2s ease;
}

.aestivo-mag-fleche:hover {
	background: var(--aestivo-mag-trait);
}

.aestivo-mag-fleche:focus-visible {
	outline: 2px solid var(--aestivo-mag-accent);
	outline-offset: 2px;
}

.aestivo-mag-fleche-gauche {
	left: 0;
}

.aestivo-mag-fleche-droite {
	right: 0;
}

.aestivo-mag-js .deborde-gauche > .aestivo-mag-fleche-gauche,
.aestivo-mag-js .deborde-droite > .aestivo-mag-fleche-droite {
	display: flex;
}

/* Sur écran tactile, le glissement suffit : les chevrons masqueraient des années */
@media (hover: none) {
	.aestivo-mag-fleche {
		display: none !important;
	}
}

.aestivo-mag-nav {
	display: flex;
	gap: 6px;
	margin: 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	scrollbar-width: none;
	-ms-overflow-style: none;
	-webkit-overflow-scrolling: touch;
}

.aestivo-mag-nav::-webkit-scrollbar {
	display: none;
}

.aestivo-mag-nav li {
	flex: 0 0 auto;
	margin: 0;
	padding: 0;
	list-style: none;
}

.aestivo-mag-nav a {
	display: block;
	padding: 5px 13px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.45;
	white-space: nowrap;
	color: var(--aestivo-mag-doux);
	text-decoration: none;
	transition: background-color .2s ease, color .2s ease;
}

.aestivo-mag-nav a:hover,
.aestivo-mag-nav a:focus {
	color: var(--aestivo-mag-encre);
	background: var(--aestivo-mag-trait);
	text-decoration: none;
}

.aestivo-mag-nav a.est-actif {
	color: #fff;
	background: var(--aestivo-mag-accent);
}


/* ------------------------------------------------------------------ */
/* Une année                                                           */
/* ------------------------------------------------------------------ */

.aestivo-mag-annee {
	display: flex;
	align-items: flex-start;
	gap: 34px;
	/*
	 * Le retrait haut dégage l'année de la barre collante. C'est lui qui garantit
	 * la lisibilité à l'arrivée d'une ancre, quel que soit le script qui a fini
	 * par positionner la page (Divi anime lui aussi les liens d'ancre, après nous).
	 */
	padding: 75px 0 45px 0;
	border-top: 1px solid var(--aestivo-mag-trait);
	/* Seul l'en-tête du thème reste à compenser : la barre l'est par le retrait */
	scroll-margin-top: var(--aestivo-mag-offset, 0px);
}

.aestivo-mag-annee:first-child {
	border-top: 0;
}

.aestivo-mag-rail {
	flex: 0 0 118px;
	padding-top: 2px;
}

.aestivo-mag-annee-num {
	display: block;
	margin: 0;
	font-size: 2.1em;
	font-weight: 700;
	line-height: 1;
	letter-spacing: -.02em;
	color: var(--aestivo-mag-encre);
}

.aestivo-mag-annee-num::after {
	content: '';
	display: block;
	width: 28px;
	height: 3px;
	margin-top: 11px;
	border-radius: 2px;
	background: var(--aestivo-mag-accent);
}

.aestivo-mag-annee-compte {
	display: block;
	margin-top: 9px;
	font-size: .8em;
	line-height: 1.4;
	color: var(--aestivo-mag-doux);
}


/* ------------------------------------------------------------------ */
/* Les couvertures                                                     */
/* ------------------------------------------------------------------ */

.aestivo-mag-grille {
	display: flex;
	flex-wrap: wrap;
	gap: 30px;
}

.aestivo-mag-item {
	flex: 0 0 var(--aestivo-mag-largeur);
	width: var(--aestivo-mag-largeur);
	color: inherit;
	text-decoration: none;
}

.aestivo-mag-item:hover,
.aestivo-mag-item:focus {
	text-decoration: none;
}

.aestivo-mag-vignette {
	position: relative;
	display: block;
	aspect-ratio: 1 / 1.414;
	border-radius: 3px;
	overflow: hidden;
	background: #eef1f2;
	box-shadow: 0 1px 2px rgba(20, 40, 45, .16), 0 8px 18px -10px rgba(20, 40, 45, .4);
	transition: transform .28s ease, box-shadow .28s ease;
}

/* Navigateurs sans aspect-ratio */
@supports not (aspect-ratio: 1 / 1) {
	.aestivo-mag-vignette {
		height: 0;
		padding-bottom: 141.4%;
	}
}

.aestivo-mag-vignette img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Ombre de pliure, côté reliure */
.aestivo-mag-vignette::before {
	content: '';
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 7px;
	z-index: 2;
	background: linear-gradient(to right, rgba(0, 0, 0, .17), rgba(0, 0, 0, 0));
}

.aestivo-mag-numero {
	position: absolute;
	top: 8px;
	right: 8px;
	z-index: 3;
	padding: 3px 8px;
	border-radius: 999px;
	background: rgba(28, 43, 48, .82);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: .03em;
	line-height: 1.4;
}

.aestivo-mag-legende {
	display: block;
	margin-top: 12px;
}

.aestivo-mag-saison {
	display: block;
	font-weight: 700;
	line-height: 1.3;
	color: var(--aestivo-mag-encre);
}

.aestivo-mag-action {
	display: block;
	margin-top: 2px;
	font-size: .8em;
	line-height: 1.4;
	color: var(--aestivo-mag-doux);
	opacity: 0;
	transform: translateY(-3px);
	transition: opacity .25s ease, transform .25s ease;
}

.aestivo-mag-item:hover .aestivo-mag-vignette,
.aestivo-mag-item:focus-visible .aestivo-mag-vignette {
	transform: translateY(-6px);
	box-shadow: 0 2px 4px rgba(20, 40, 45, .16), 0 18px 30px -12px rgba(20, 40, 45, .5);
}

.aestivo-mag-item:hover .aestivo-mag-action,
.aestivo-mag-item:focus-visible .aestivo-mag-action {
	opacity: 1;
	transform: none;
}

.aestivo-mag-item:focus-visible .aestivo-mag-vignette {
	outline: 2px solid var(--aestivo-mag-accent);
	outline-offset: 3px;
}


/* ------------------------------------------------------------------ */
/* Écrans étroits                                                      */
/* ------------------------------------------------------------------ */

@media (max-width: 780px) {
	.aestivo-mag {
		--aestivo-mag-largeur: 136px;
	}

	.aestivo-mag-annee {
		display: block;
		/* Même dégagement qu'en grand écran : la barre y fait la même hauteur */
		padding: 68px 0 32px 0;
	}

	.aestivo-mag-rail {
		display: flex;
		align-items: baseline;
		gap: 12px;
		margin-bottom: 15px;
	}

	.aestivo-mag-annee-num {
		font-size: 1.55em;
	}

	.aestivo-mag-annee-num::after {
		display: none;
	}

	.aestivo-mag-annee-compte {
		margin-top: 0;
	}

	.aestivo-mag-grille {
		gap: 18px;
	}

	.aestivo-mag-action {
		display: none;
	}
}


@media (prefers-reduced-motion: reduce) {

	.aestivo-mag-vignette,
	.aestivo-mag-action,
	.aestivo-mag-nav a {
		transition: none;
	}

	.aestivo-mag-item:hover .aestivo-mag-vignette,
	.aestivo-mag-item:focus-visible .aestivo-mag-vignette {
		transform: none;
	}
}
