/* Page /gifs/ : le mur de GIF (maquette A) et la fiche au clic (maquette D). Voir inc/gifs.php. */

.lpe-gifs {
	--g-nuit: #0E163A;
	--g-nuit-2: #1A2558;
	--g-ligne: #2B3878;
	--g-or: #F6B93B;
	--g-or-clair: #FFD678;
	--g-or-texte: #8A5E00;
	--g-creme: #F5F1E6;
	--g-brume: #B9C0DE;
	--g-encre: #141A3A;
	--g-encre-douce: #555D7E;
	--g-trait: #DADDEA;
	--g-titre: var(--wp--preset--font-family--titre, "Baloo 2", system-ui, sans-serif);
	--g-haut: var(--wp-admin--admin-bar--height, 0px);
	--lpe-focus: var(--g-or-clair);
	background: var(--g-nuit);
	color: var(--g-creme);
	margin-block: 0 !important;
	padding-bottom: 8px;
}
.lpe-gifs a { color: var(--g-or-clair); }
.lpe-gifs h1, .lpe-gifs h2, .lpe-gifs h3 { font-family: var(--g-titre); font-weight: 800; }

.lpe-gifs__entete,
.lpe-gifs__pastilles > div,
.lpe-gifs__mur,
.lpe-gifs__pied {
	box-sizing: border-box;
	max-width: 1248px;
	margin-inline: auto;
	padding-inline: 24px;
}

/* En-tête */
.lpe-gifs__entete { padding-top: 48px; padding-bottom: 20px; }
.lpe-gifs__h1 { margin: 0; color: var(--g-creme); font-size: clamp(2rem, 5vw, 3.1rem); line-height: 1.1; }
.lpe-gifs__intro { margin: 14px 0 0; max-width: 700px; font-size: 1.125rem; line-height: 1.55; color: var(--g-brume); }
.lpe-gifs__langues { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.lpe-gifs a.lpe-gifs__langue {
	display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px;
	border-radius: 999px; border: 1.5px solid var(--g-ligne); color: var(--g-creme);
	font-weight: 800; font-size: .9375rem; text-decoration: none;
}
.lpe-gifs a.lpe-gifs__langue span { color: var(--g-brume); font-weight: 700; }
.lpe-gifs a.lpe-gifs__langue[aria-current="page"] { background: var(--g-creme); border-color: var(--g-creme); color: var(--g-nuit); }
.lpe-gifs a.lpe-gifs__langue[aria-current="page"] span { color: var(--g-encre-douce); }

/* Une seule langue à la fois quand le script tourne (sans script : les deux, l'une sous l'autre). */
.lpe-gifs.js[data-langue-active="fr"] .lpe-gifs__intro[data-langue="en"],
.lpe-gifs.js[data-langue-active="fr"] .lpe-gifs__vue[data-langue="en"],
.lpe-gifs.js[data-langue-active="en"] .lpe-gifs__intro[data-langue="fr"],
.lpe-gifs.js[data-langue-active="en"] .lpe-gifs__vue[data-langue="fr"] { display: none; }
.lpe-gifs:not(.js) .lpe-gifs__vue + .lpe-gifs__vue { margin-top: 48px; border-top: 1px solid var(--g-nuit-2); }

/* Pastilles d'occasions, collées en haut */
.lpe-gifs__pastilles {
	position: sticky; top: var(--g-haut); z-index: 20;
	background: var(--g-nuit); border-bottom: 1px solid var(--g-nuit-2);
}
.lpe-gifs__pastilles > div { display: flex; flex-wrap: wrap; gap: 8px; padding-block: 12px; }
.lpe-gifs__pastilles a {
	display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px;
	border-radius: 999px; background: var(--g-nuit-2); color: var(--g-creme) !important;
	font-weight: 700; font-size: .875rem; text-decoration: none; white-space: nowrap;
}
.lpe-gifs__pastilles a span { color: var(--g-brume); }
.lpe-gifs__pastilles a:hover { background: var(--g-ligne); }
.lpe-gifs__pastilles a[aria-current="true"] { background: var(--g-or); color: var(--g-nuit) !important; font-weight: 800; }
.lpe-gifs__pastilles a[aria-current="true"] span { color: var(--g-nuit); opacity: .7; }

/* Le mur */
/* Un seul mur continu : les sections et leurs listes s'effacent (display: contents), les tuiles se suivent.
   Pas de « dense » : il bouchait les trous avec la vignette suivante, même si elle était d'une autre section
   (le GIF Je t'aime remontait dans Bonne nuit). Au pire, une case vide avant une tuile-titre. */
.lpe-gifs__mur {
	display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; grid-auto-flow: row; padding-top: 24px;
}
.lpe-gifs__section, .lpe-gifs__section > ul { display: contents; }
.lpe-gifs__section > ul { list-style: none; }
.lpe-gifs__titre { scroll-margin-top: calc(var(--g-haut) + 76px); }
.lpe-gifs__titre {
	grid-column: span 2; box-sizing: border-box; border-radius: 16px; padding: 20px 22px;
	display: flex; flex-direction: column; justify-content: center; gap: 6px; background: var(--g-nuit-2);
}
.lpe-gifs__titre h2 { margin: 0; color: var(--g-creme); font-size: 1.375rem; line-height: 1.15; }
.lpe-gifs__titre p { margin: 0; font-size: .875rem; line-height: 1.5; color: var(--g-brume); }
.lpe-gifs__nb { font-weight: 800; font-size: .8125rem; color: var(--g-or-clair); }
.lpe-gifs__titre--vedette {
	grid-row: span 2; justify-content: flex-end; gap: 12px; padding: 28px;
	background: radial-gradient(120% 90% at 100% 0%, rgba(246, 185, 59, .28), rgba(246, 185, 59, 0) 60%), var(--g-nuit-2);
}
.lpe-gifs__titre--vedette h2 { font-size: 2rem; line-height: 1.1; }
.lpe-gifs__titre--vedette p { font-size: .9375rem; line-height: 1.55; }
.lpe-gifs__titre--vedette .lpe-gifs__nb { font-size: .875rem; }
.lpe-gifs__moment {
	align-self: flex-start; padding: 4px 12px; border-radius: 999px;
	background: var(--g-or); color: var(--g-nuit); font-weight: 800; font-size: .8125rem;
}

/* Une vignette */
.lpe-gif { position: relative; aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: var(--g-nuit-2); }
.lpe-gif--vedette { grid-column: span 2; grid-row: span 2; border-radius: 16px; }
.lpe-gif__lien { display: block; width: 100%; height: 100%; border-radius: inherit; }
.lpe-gif__lien picture, .lpe-gif__lien img { display: block; width: 100%; height: 100%; }
.lpe-gif__lien img { object-fit: cover; transition: transform .3s, opacity .3s; }
.lpe-gif:hover .lpe-gif__lien img { transform: scale(1.04); }
.lpe-gif__lien:focus-visible { outline-offset: -4px !important; }
/* En attendant l'image : un carré qui scintille doucement. */
.lpe-gifs.js .lpe-gif__lien:not(.est-charge) {
	background: linear-gradient(100deg, var(--g-nuit-2) 30%, var(--g-ligne) 50%, var(--g-nuit-2) 70%);
	background-size: 200% 100%;
	animation: lpe-gifs-luit 1.8s linear infinite;
}
.lpe-gifs.js .lpe-gif__lien:not(.est-charge) img { opacity: 0; }
@keyframes lpe-gifs-luit { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.lpe-gif__badge {
	position: absolute; bottom: 8px; right: 8px; padding: 2px 8px; border-radius: 999px; pointer-events: none;
	background: rgba(14, 22, 58, .78); color: var(--g-creme); font-weight: 800; font-size: .625rem; letter-spacing: .04em;
}
.lpe-gif--vedette .lpe-gif__badge { bottom: 10px; right: 10px; padding: 3px 9px; font-size: .6875rem; }

/* Au survol (souris seulement) : le personnage et deux téléchargements rapides. */
.lpe-gif__voile {
	position: absolute; left: 0; right: 0; bottom: 0; padding: 32px 8px 8px; box-sizing: border-box;
	display: none; flex-direction: column; gap: 6px; pointer-events: none;
	background: linear-gradient(rgba(14, 22, 58, 0), rgba(14, 22, 58, .94));
	opacity: 0; transition: opacity .2s;
}
@media (hover: hover) and (pointer: fine) {
	.lpe-gif__voile { display: flex; }
	.lpe-gif:hover .lpe-gif__badge { opacity: 0; }
	.lpe-gif:hover .lpe-gif__voile { opacity: 1; }
	.lpe-gif:hover .lpe-gif__dl { pointer-events: auto; }
}
.lpe-gif__nom { font-weight: 800; font-size: .75rem; color: var(--g-creme); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lpe-gif__nom span { font-weight: 400; color: var(--g-brume); }
.lpe-gif:not(.lpe-gif--vedette) .lpe-gif__nom { font-weight: 800; }
.lpe-gif__boutons { display: flex; gap: 4px; }
.lpe-gifs a.lpe-gif__dl {
	flex: 1; display: inline-flex; justify-content: center; align-items: center; gap: 6px; min-height: 34px;
	border-radius: 999px; border: 1.5px solid var(--g-brume); color: var(--g-creme);
	font-weight: 800; font-size: .75rem; text-decoration: none; pointer-events: none;
}
.lpe-gifs a.lpe-gif__dl--or { background: var(--g-or); border-color: var(--g-or); color: var(--g-nuit); }
.lpe-gifs a.lpe-gif__dl:hover { filter: brightness(1.08); }
.lpe-gif--vedette .lpe-gif__voile { padding: 40px 14px 14px; gap: 10px; }
.lpe-gif--vedette .lpe-gif__nom { font-size: 1rem; }
.lpe-gif--vedette .lpe-gif__boutons { gap: 8px; }
.lpe-gifs .lpe-gif--vedette a.lpe-gif__dl { min-height: 44px; font-size: .875rem; }
.lpe-gif__dl svg { width: 16px; height: 16px; }

/* Pied */
.lpe-gifs__pied {
	display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px;
	margin-top: 56px; padding-top: 36px; padding-bottom: 48px; border-top: 1px solid var(--g-nuit-2);
	font-size: .9375rem; line-height: 1.55;
}
.lpe-gifs__pied h2 { margin: 0 0 8px; color: var(--g-creme); font-size: 1.25rem; }
.lpe-gifs__pied p { margin: 0; color: var(--g-brume); }
.lpe-gifs__pied > div { scroll-margin-top: calc(var(--g-haut) + 76px); }

.lpe-gifs__annonce { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }

/* ------------------------------------------------------------------ */
/* La fiche                                                            */
/* ------------------------------------------------------------------ */

.lpe-fiche {
	display: none; position: fixed; inset: 0; z-index: 100000;
	align-items: center; justify-content: center; gap: 20px; padding: 24px;
	color: var(--g-encre); font-size: 1rem;
}
.lpe-fiche:target, .lpe-fiche.est-ouverte { display: flex; }
/* Avec le script, c'est lui qui ouvre et ferme (pas l'adresse). */
.lpe-gifs.js .lpe-fiche:target:not(.est-ouverte) { display: none; }
html.lpe-fiche-ouverte, html.lpe-fiche-ouverte body { overflow: hidden; }

.lpe-fiche__fond { position: absolute; inset: 0; background: rgba(8, 12, 32, .78); cursor: default; }
.lpe-fiche__boite {
	position: relative; box-sizing: border-box; flex: 0 1 1000px; max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); overflow: auto;
	display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 32px; align-items: start;
	background: #FFFFFF; border-radius: 28px; padding: 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
	overscroll-behavior: contain;
}
.lpe-fiche__poignee { display: none; }
.lpe-fiche a.lpe-fiche__fermer {
	position: absolute; top: 16px; right: 16px; z-index: 2; width: 44px; height: 44px; border-radius: 50%;
	display: flex; align-items: center; justify-content: center; background: #F8F8FC; color: var(--g-encre);
}
.lpe-fiche a.lpe-fiche__fermer:hover { background: var(--g-trait); }
.lpe-fiche__nav {
	position: relative; flex: none; width: 52px; height: 52px; border-radius: 50%; border: 0; cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	background: rgba(255, 255, 255, .14); color: var(--g-creme);
}
.lpe-fiche__nav[hidden] { display: none; }
.lpe-fiche__nav:hover { background: rgba(255, 255, 255, .24); }

.lpe-fiche__media { margin: 0; }
.lpe-fiche__media picture, .lpe-fiche__media img, .lpe-fiche__media video {
	display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 20px; background: var(--g-nuit-2);
}
.lpe-fiche__media.a-video img { display: none; }
.lpe-fiche__media figcaption { margin-top: 10px; font-size: .8125rem; color: var(--g-encre-douce); }

.lpe-fiche__texte { min-width: 0; display: flex; flex-direction: column; padding-top: 8px; }
.lpe-fiche a.lpe-fiche__section { align-self: flex-start; margin-right: 52px; color: var(--g-or-texte); font-weight: 800; font-size: .875rem; text-decoration: none; }
.lpe-fiche a.lpe-fiche__section:hover { text-decoration: underline; }
.lpe-fiche__titre { margin: 6px 0 0; color: var(--g-encre); font-size: clamp(1.75rem, 4vw, 2.625rem); line-height: 1.05; }
.lpe-fiche__perso { margin: 4px 0 0; font-weight: 700; color: var(--g-encre-douce); }
.lpe-fiche__desc { margin: 14px 0 0; line-height: 1.6; }

.lpe-fiche__partager, .lpe-fiche a.lpe-fiche__bouton {
	box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; padding: 8px 18px;
	border-radius: 999px; border: 1.5px solid var(--g-trait); background: #FFFFFF; color: var(--g-encre);
	font: inherit; font-weight: 800; font-size: 1.0625rem; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer;
}
.lpe-fiche__partager[hidden] { display: none; }
.lpe-fiche__partager, .lpe-fiche a.lpe-fiche__bouton--or { background: var(--g-or); border-color: var(--g-or); color: var(--g-nuit); }
.lpe-fiche a.lpe-fiche__bouton:hover { border-color: var(--g-encre-douce); }
.lpe-fiche a.lpe-fiche__bouton--or:hover, .lpe-fiche__partager:hover { background: var(--g-or-clair); border-color: var(--g-or-clair); }
.lpe-fiche__partager { margin-top: 22px; }
.lpe-fiche__dl { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.lpe-fiche__partager:not([hidden]) + .lpe-fiche__dl { margin-top: 10px; }
/* Quand on peut partager le fichier, les téléchargements passent au second plan. */
.lpe-fiche__partager:not([hidden]) + .lpe-fiche__dl a.lpe-fiche__bouton--or { background: #FFFFFF; border-color: var(--g-trait); }
.lpe-fiche__astuce { margin: 0; text-align: center; font-size: .8125rem; color: var(--g-encre-douce); }

.lpe-fiche__copier {
	margin-top: 14px; align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 4px;
	border: 0; background: none; color: var(--g-encre); font: inherit; font-weight: 800; font-size: .9375rem; cursor: pointer;
}
.lpe-fiche__copier[hidden] { display: none; }
.lpe-fiche__copier:hover span { text-decoration: underline; }

.lpe-fiche__serie { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--g-trait); }
.lpe-fiche__serie > p { margin: 0; font-weight: 800; font-size: .875rem; color: var(--g-encre-douce); }
.lpe-fiche__serie ul { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.lpe-fiche__serie a { display: block; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: var(--g-trait); }
.lpe-fiche__serie img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .2s; }
.lpe-fiche__serie a:hover img { transform: scale(1.06); }
.lpe-fiche__usage { margin: 12px 0 0; font-size: .75rem; line-height: 1.5; color: var(--g-encre-douce); }

/* ------------------------------------------------------------------ */
/* Tablette et téléphone                                               */
/* ------------------------------------------------------------------ */

@media (max-width: 1023px) {
	.lpe-gifs__mur { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.lpe-gifs__pied { grid-template-columns: 1fr; gap: 24px; }
}

@media (max-width: 699px) {
	.lpe-gifs__entete, .lpe-gifs__mur, .lpe-gifs__pied { padding-inline: 12px; }
	.lpe-gifs__entete { padding-top: 22px; padding-bottom: 14px; }
	.lpe-gifs__h1 { font-size: 1.875rem; }
	.lpe-gifs__intro { margin-top: 8px; font-size: .9375rem; line-height: 1.5; }
	.lpe-gifs__langues { margin-top: 14px; }
	.lpe-gifs__pastilles > div { flex-wrap: nowrap; overflow-x: auto; padding: 10px 12px; scrollbar-width: none; }
	.lpe-gifs__pastilles > div::-webkit-scrollbar { display: none; }
	/* Sur téléphone, chaque section garde son ordre : la tuile-titre prend toute la ligne. */
	.lpe-gifs__mur { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; grid-auto-flow: row; padding-top: 12px; }
	.lpe-gifs__titre, .lpe-gifs__titre--vedette { grid-column: 1 / -1; grid-row: auto; gap: 4px; padding: 14px 14px 12px; border-radius: 14px; }
	.lpe-gifs__titre--vedette h2 { font-size: 1.375rem; }
	.lpe-gifs__titre h2 { font-size: 1.1875rem; }
	/* Le texte reste entier pour Google ; à l'écran, trois lignes suffisent. */
	.lpe-gifs__titre p, .lpe-gifs__titre--vedette p {
		font-size: .8125rem; line-height: 1.45;
		display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
	}
	.lpe-gifs__moment { font-size: .75rem; padding: 2px 10px; }
	.lpe-gifs__titre--vedette { flex-direction: column; }
	.lpe-gifs__nb { display: none; }
	.lpe-gif { border-radius: 10px; }
	.lpe-gif--vedette { border-radius: 12px; }
	.lpe-gifs__pied { margin-top: 36px; }

	/* La fiche devient un panneau qui monte du bas. */
	.lpe-fiche { align-items: flex-end; padding: 0; }
	.lpe-fiche__nav { display: none !important; }
	.lpe-fiche__boite {
		flex: 1 1 auto; grid-template-columns: 1fr; gap: 0; max-height: calc(100vh - 56px); max-height: calc(100dvh - 56px);
		border-radius: 24px 24px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
		box-shadow: 0 -12px 40px rgba(0, 0, 0, .35);
	}
	.lpe-fiche.est-ouverte .lpe-fiche__boite { animation: lpe-fiche-monte .28s ease-out; }
	.lpe-fiche__poignee { display: block; justify-self: center; width: 44px; height: 5px; border-radius: 3px; background: var(--g-trait); }
	.lpe-fiche a.lpe-fiche__fermer { top: 12px; right: 12px; }
	.lpe-fiche__media { margin: 18px auto 0; width: min(290px, 78vw); }
	.lpe-fiche__media figcaption { text-align: center; }
	.lpe-fiche__texte { padding-top: 12px; }
	.lpe-fiche a.lpe-fiche__section { margin-right: 0; }
	.lpe-fiche__titre { font-size: 1.75rem; }
	.lpe-fiche__perso { font-size: .9375rem; }
	.lpe-fiche__desc { font-size: .9375rem; margin-top: 10px; }
	.lpe-fiche__partager, .lpe-fiche a.lpe-fiche__bouton { min-height: 50px; font-size: 1rem; }
	.lpe-fiche__partager { margin-top: 16px; }
	.lpe-fiche__dl { margin-top: 16px; }
	.lpe-fiche__serie a { width: 58px; height: 58px; }
}
@keyframes lpe-fiche-monte { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
	.lpe-gifs.js .lpe-gif__lien:not(.est-charge) { animation: none; }
	.lpe-gif__lien img, .lpe-gif__voile, .lpe-fiche__serie img { transition: none; }
	.lpe-gif:hover .lpe-gif__lien img, .lpe-fiche__serie a:hover img { transform: none; }
	.lpe-fiche.est-ouverte .lpe-fiche__boite { animation: none; }
}
