/*
Theme Name: Le 107 Télé-Accueil
Theme URI: https://www.tele-accueil.be
Author: eZoulou pour Pause Communication
Author URI: https://ezoulou.com
Description: Thème de blocs (FSE) sur mesure pour le 107 Télé-Accueil. La mise en forme se règle dans l'éditeur (Apparence › Éditeur › Styles) : couleurs, polices, espacements et variations de blocs sont dans theme.json. Ce fichier ne contient que ce que les blocs ne savent pas faire : la barre du bas fixe et le mode sombre.
Version: 1.0.0
Requires at least: 7.0
Tested up to: 7.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: le107
*/

/*
 * Mode sombre : on inverse les couleurs « qui changent » de la palette.
 * La classe est posée sur <html> par functions.php + assets/js/theme.js.
 */
html.le107-sombre {
	--wp--preset--color--fond: #2b2d31;
	--wp--preset--color--texte: #f0a53b;
	--wp--preset--color--fond-accent: #2b2d31;
	--wp--preset--color--texte-accent: #f0a53b;
	--wp--preset--color--surface: #3a3d42;
	--wp--preset--color--trait: #f0a53b;
	color-scheme: dark;
}


/*
 * Kadence Blocks : ses boutons (formulaire, etc.) prennent les couleurs du thème.
 */
:root {
	--global-palette-btn-bg: var(--wp--preset--color--orange);
	--global-palette-btn: var(--wp--preset--color--anthracite);
	--global-palette-btn-bg-hover: var(--wp--preset--color--anthracite);
	--global-palette-btn-hover: var(--wp--preset--color--orange);
}
.wp-block-kadence-advanced-form .kb-adv-form-submit-button {
	border-radius: 999px;
	padding: 10px 24px;
	font-family: inherit;
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 600;
}

/*
 * Apparition au défilement des blocs du contenu (classes posées par theme.js ; sans JavaScript, rien n'est caché).
 */
.le107-revele {
	opacity: 0;
	transform: translateY(28px);
	transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.le107-revele.est-visible {
	opacity: 1;
	transform: none;
}

/*
 * Barre du bas (Appeler / Chatter) : fixe. Quand on descend, elle devient une barre fine
 * avec le petit logo au centre ; elle revient en entier quand on remonte (assets/js/theme.js).
 */
.le107-barre {
	position: fixed;
	inset: auto 0 0 0;
	z-index: 50;
	transition: padding 0.3s ease;
}
/* Retour en entier : le logo revient à gauche, puis reprend sa taille. */
.le107-barre .wp-block-site-logo {
	transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.le107-barre .wp-block-site-logo img {
	transition: width 0.25s ease 0.3s;
}
.le107-barre .wp-block-buttons {
	transition: opacity 0.2s ease, transform 0.2s ease;
}
/* Passage en petit : les boutons s'effacent, le logo rétrécit, puis glisse au milieu. */
.le107-barre.est-repliee {
	padding-top: 6px !important;
	padding-bottom: 6px !important;
}
.le107-barre.est-repliee .wp-block-buttons {
	position: absolute;
	right: 32px;
	opacity: 0;
	transform: translateY(28px);
	pointer-events: none;
}
.le107-barre.est-repliee .wp-block-site-logo img {
	width: 64px !important;
	transition: width 0.25s ease;
}
.le107-barre.est-repliee .wp-block-site-logo {
	transform: translateX(calc(50vw - 32px - 32px)); /* demi-logo réduit + marge de la barre */
	transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) 0.22s;
}
/* Les boutons réapparaissent en glissant (classe .a-bouge posée par theme.js au premier repli). */
.le107-barre.a-bouge:not(.est-repliee) .wp-block-button {
	animation: le107-deplie 0.4s cubic-bezier(0.3, 1.4, 0.5, 1) 0.15s both;
}
.le107-barre.a-bouge:not(.est-repliee) .wp-block-button:nth-child(2) {
	animation-delay: 0.22s;
}
@keyframes le107-deplie {
	from { opacity: 0; transform: translateY(18px) scale(0.8); }
	to { opacity: 1; transform: none; }
}
/*
 * Apparition de la barre du bas à chaque page (classe le107-intro, comme l'en-tête) :
 * la barre monte du bord bas, puis le logo arrive de la gauche et les boutons surgissent l'un après l'autre.
 * Remplissage « backwards » seulement : une fois finie, l'animation ne gêne pas le repli au défilement.
 */
html.le107-intro .le107-barre {
	animation: le107-monte 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s backwards;
}
html.le107-intro .le107-barre .wp-block-site-logo img {
	animation: le107-glisse 0.5s cubic-bezier(0.3, 1.3, 0.5, 1) 0.4s backwards;
}
html.le107-intro .le107-barre .wp-block-button {
	animation: le107-surgit 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) 0.55s backwards;
}
html.le107-intro .le107-barre .wp-block-button:nth-child(2) {
	animation-delay: 0.67s;
}
@keyframes le107-monte {
	from { transform: translateY(100%); }
	to { transform: none; }
}
@keyframes le107-glisse {
	from { opacity: 0; transform: translateX(-60px); }
	to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
	html.le107-intro .le107-barre,
	html.le107-intro .le107-barre * { animation: none !important; }
}
body {
	padding-bottom: var(--wp--custom--barre--hauteur);
}
/* Ordinateur (au-delà de 782 px, comme WordPress) : la barre du bas est masquée, on ne lui réserve plus de place. */
@media (width > 782px) {
	html:root {
		--wp--custom--barre--hauteur: 0px;
	}
}

/* Accueil : la section (fond gris de page) couvre tout l’écran, la barre du bas passe par-dessus. */
body.home {
	padding-bottom: 0;
}
/* Accueil sur ordinateur : fond orange (gris de page sur mobile). Passe en sombre tout seul avec le mode sombre. */
@media (width > 782px) {
	.le107-accueil {
		background-color: var(--wp--preset--color--fond-accent);
		color: var(--wp--preset--color--texte-accent);
	}
	.le107-accueil main a:where(:not(.wp-element-button)) {
		color: var(--wp--preset--color--texte-accent);
	}
}

.le107-barre a {
	-webkit-tap-highlight-color: transparent;
}

@media (prefers-reduced-motion: reduce) {
	.le107-barre,
	.le107-barre .wp-block-site-logo img { transition: none; }
	.le107-barre *,
	.le107-barre .wp-block-button { animation: none !important; transition: none !important; }
}

/*
 * En-tête fixe au défilement. Une fois la page défilée (classe est-defile posée par theme.js),
 * l'interrupteur clair/sombre s'efface pour ne pas flotter sur le contenu ; il revient en haut de page.
 */
header.wp-block-template-part {
	position: sticky;
	top: var(--wp-admin--admin-bar--height, 0px);
	z-index: 60;
}
header.wp-block-template-part > .wp-block-buttons {
	transition: opacity 0.25s ease, transform 0.25s ease;
}
html.est-defile header.wp-block-template-part > .wp-block-buttons {
	opacity: 0;
	transform: translateY(-12px);
	pointer-events: none;
}

/*
 * Apparition de l'en-tête à chaque page (classe le107-intro posée par functions.php) :
 * la bande noire se déroule d'abord, vide ; puis les liens tombent un à un de son bord haut,
 * suivis du bouton menu, du logo et de l'interrupteur.
 */
html.le107-intro header > .has-anthracite-background-color {
	overflow: clip; /* les éléments sortent du bord haut de la bande */
	animation: le107-bande 0.35s cubic-bezier(0.4, 0, 0.2, 1) backwards; /* « backwards » : rien ne reste rogné après (le menu plein écran) */
}
html.le107-intro header .le107-menus .is-style-liens-pointilles .wp-block-navigation-item,
html.le107-intro header .wp-block-navigation__responsive-container-open,
html.le107-intro header .wp-block-site-logo {
	animation: le107-tombe 0.55s cubic-bezier(0.3, 1.4, 0.5, 1) 0.35s both;
}
html.le107-intro header .le107-menus .is-style-liens-pointilles .wp-block-navigation-item:nth-child(2) { animation-delay: 0.45s; }
html.le107-intro header .wp-block-navigation__responsive-container-open { animation-delay: 0.55s; }
html.le107-intro header .wp-block-site-logo { animation-delay: 0.6s; }
html.le107-intro header .is-style-interrupteur .le107-icone {
	animation: le107-surgit 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) 0.75s both;
}
@keyframes le107-bande {
	from { clip-path: inset(0 0 100% 0); }
	to { clip-path: inset(0); }
}
@keyframes le107-tombe {
	from { opacity: 0.4; transform: translateY(-110px); }
	to { opacity: 1; transform: none; }
}
@keyframes le107-surgit {
	from { opacity: 0; transform: scale(0.4); }
	to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
	html.le107-intro header,
	html.le107-intro header * { animation: none !important; }
}

/*
 * En-tête : gris foncé sur ordinateur, orange sur mobile et tablette (maquette header-mobile).
 * Les couleurs « fond-accent / texte-accent » s'inversent toutes seules en mode sombre.
 */
@media (width <= 782px) {
	header.wp-block-template-part > .has-anthracite-background-color {
		background-color: var(--wp--preset--color--fond-accent) !important;
		color: var(--wp--preset--color--texte-accent) !important;
	}
	header.wp-block-template-part > .has-anthracite-background-color a:where(:not(.wp-element-button)) {
		color: var(--wp--preset--color--texte-accent) !important;
	}
}

/*
 * En-tête sur mobile (comme WordPress : jusqu'à 480 px, là où le logo est masqué) :
 * les deux liens et le bouton menu se répartissent sur toute la largeur.
 */
@media (width <= 480px) {
	header.wp-block-template-part > .has-anthracite-background-color {
		padding-top: 20px !important; /* passe devant le réglage du bloc */
		padding-bottom: 20px !important;
	}
	.le107-menus {
		flex: 1 1 auto;
		justify-content: space-between;
	}
	.le107-menus > .is-style-liens-pointilles {
		flex: 1 1 auto;
	}
	.le107-menus > .is-style-liens-pointilles .wp-block-navigation__container {
		width: 100%;
	}
	.le107-menus > .is-style-liens-pointilles .wp-block-navigation-item {
		font-size: 19px;
		flex: 1 1 0;
		max-width: none;
		justify-content: center;
	}
	.le107-menus > .is-style-liens-pointilles .wp-block-navigation-item:first-child {
		justify-content: flex-start;
	}
}

/*
 * Menu plein écran (bouton 3 lignes de l'en-tête).
 * Sélecteurs renforcés : les styles du bloc Navigation de WordPress passent sinon devant.
 */
.wp-block-navigation .wp-block-navigation__responsive-container-open svg {
	width: 40px;
	height: 40px;
}
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) {
	z-index: 100;
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
	text-transform: none;
}
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) .wp-block-navigation__responsive-container-close {
	top: 0;
	right: 0;
	padding: 6px;
	border: 2px solid currentColor;
	border-radius: 50%;
}
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) .wp-block-navigation__responsive-container-close svg {
	width: 26px;
	height: 26px;
}
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) .wp-block-navigation__responsive-container-content {
	padding-top: 56px;
}
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) .wp-block-navigation__container {
	text-transform: none;
	gap: 0;
	width: 100%;
	max-width: 640px;
}
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) .wp-block-navigation-item {
	width: 100%;
	padding: 12px 0;
	border-bottom: 2px dotted currentColor;
	font-size: var(--wp--preset--font-size--large);
	font-weight: 500;
	line-height: 1.1;
}
/* Menu plein écran en mode sombre : fond anthracite, texte orange ; bande des 3 entrées principales en gris un peu plus clair. */
html.le107-sombre body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) {
	background-color: var(--wp--preset--color--fond) !important;
	color: var(--wp--preset--color--texte) !important;
}
html.le107-sombre body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) .wp-block-navigation-item.is-principal {
	background: var(--wp--preset--color--surface) !important;
	box-shadow: -40px 0 0 var(--wp--preset--color--surface), 40px 0 0 var(--wp--preset--color--surface);
}
/* Ouverture du menu : le volet jaune glisse depuis la gauche, d'un bloc (pas d'effet propre aux liens). Remplace le fondu de WordPress. */
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) {
	animation: le107-volet 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
	overflow-x: clip; /* la bande orange des 3 entrées principales (box-shadow) ne dépasse pas du volet */
}
/* Fermeture : le volet repart vers la gauche (classe se-ferme posée par theme.js, qui ferme le menu à la fin). */
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open.se-ferme:not(.disable-default-overlay) {
	animation: le107-volet-sort 0.35s cubic-bezier(0.4, 0, 1, 1) both;
}
@keyframes le107-volet-sort {
	from { transform: none; }
	to { transform: translateX(-100%); }
}
@keyframes le107-volet {
	from { transform: translateX(-100%); }
	to { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
	body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) { animation: none; }
}
/* Les 3 entrées principales (classe is-principal) : plus grandes, sur une bande orange. */
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) .wp-block-navigation-item.is-principal {
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 700;
	background: var(--wp--preset--color--orange) !important; /* WordPress force un fond transparent sur les entrées du menu */
	box-shadow: -40px 0 0 var(--wp--preset--color--orange), 40px 0 0 var(--wp--preset--color--orange);
}
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) .wp-block-navigation-item.is-principal + .wp-block-navigation-item:not(.is-principal) {
	margin-top: var(--wp--preset--spacing--40);
}
/* Entrées secondaires (classe is-mineur, ex. Politique de confidentialité) : plus petites, sans pointillés, détachées du reste. */
body .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay) .wp-block-navigation-item.is-mineur {
	font-size: var(--wp--preset--font-size--small);
	font-weight: 400;
	border-bottom: 0;
	margin-top: var(--wp--preset--spacing--30);
}

/*
 * Icônes SVG animées (assets/img/*.svg, insérées dans les boutons par functions.php).
 * Chaque partie du dessin a une classe : .combine, .bulle, .point, .croix, .piste, .bouton, .lune, .soleil.
 */
.le107-svg * {
	transform-box: fill-box;
	transform-origin: center;
}

/* Interrupteur : le rond glisse à gauche en mode sombre. */
.le107-svg-interrupteur .bouton {
	transition: transform 0.3s cubic-bezier(0.5, 1.6, 0.5, 1);
}
html.le107-sombre .le107-svg-interrupteur .bouton {
	transform: translateX(-26px);
}
/* Mode sombre : piste bleu clair (maquette). */
.le107-svg-interrupteur .piste {
	transition: fill 0.3s;
}
html.le107-sombre .le107-svg-interrupteur .piste {
	fill: #93b5d8;
}

/* Boutons Appeler / Chatter : la forme de la maquette (entre cercle et carré) est dessinée en SVG
   dans le fond de l'icône (styles/blocks/appeler.json et chatter.json). */

/* Appeler : le combiné sonne au survol. */
.is-style-appeler a:hover .le107-icone,
.is-style-chatter a:hover .le107-icone,
.is-style-chatter-grand a:hover .le107-icone {
	transform: scale(1.08);
}
.is-style-appeler a:hover .combine {
	animation: le107-sonne 0.6s ease-in-out infinite;
}

/* Chatter : les trois points « en train d'écrire ». */
.is-style-chatter a:hover .point,
.is-style-chatter-grand a:hover .point,
.is-style-chatter-grand .point {
	animation: le107-ecrit 1.2s ease-in-out infinite;
}
.le107-svg-chatter .point-2 { animation-delay: 0.15s !important; }
.le107-svg-chatter .point-3 { animation-delay: 0.3s !important; }

/* Fermer : la croix pivote au survol. */
.le107-svg-fermer .croix {
	transition: transform 0.3s ease;
}
.is-style-fermer a:hover .croix {
	transform: rotate(90deg);
}

@keyframes le107-sonne {
	0%, 100% { transform: rotate(0); }
	20% { transform: rotate(-14deg); }
	40% { transform: rotate(12deg); }
	60% { transform: rotate(-8deg); }
	80% { transform: rotate(6deg); }
}
@keyframes le107-ecrit {
	0%, 60%, 100% { transform: translateY(0); }
	30% { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
	.le107-svg *,
	.le107-icone {
		animation: none !important;
		transition: none !important;
	}
}
