/* =====================================================
   Barre d'outils d'accessibilité AFG CAA
   ===================================================== */

.afg-caa-barre {
	position: fixed;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Bouton principal qui ouvre/ferme le panneau — attaché au bord gauche */
.afg-caa-barre .afg-caa-toggle {
	flex-direction: column;
	width: 66px;
	height: 66px;
	border-radius: 0 18px 18px 0;
	box-shadow: 4px 4px 14px rgba(18, 63, 86, 0.30);
}

.afg-caa-barre .afg-caa-toggle .afg-caa-label {
	font-size: 0.65rem;
}

/* Boutons en général */
.afg-caa-bouton {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	width: 100%;
	padding: 0.7rem 1rem;
	margin: 0;
	border: 2px solid transparent;
	border-radius: 12px;
	background: #1f6f92;
	color: #ffffff;
	font-size: 1rem;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease, transform 0.15s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.2s ease;
}

.afg-caa-bouton:hover {
	background: #3a9bbd;
}

.afg-caa-bouton:active {
	transform: scale(0.95);
}

.afg-caa-bouton:focus-visible {
	outline: 3px solid #f4c95d;
	outline-offset: 2px;
}

.afg-caa-bouton[aria-pressed="true"] {
	background: #123f56;
	border-color: #f4c95d;
}

.afg-caa-picto {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.8rem;
}
.afg-caa-svg { width: 22px; height: 22px; flex: 0 0 auto; }
.afg-caa-toggle .afg-caa-svg { width: 30px; height: 30px; }

/* Panneau d'options — s'ouvre vers la droite depuis le bord gauche */
.afg-caa-panneau {
	position: fixed;
	left: 66px;
	top: 50%;
	transform: translateY(-50%) translateX(-12px);
	display: flex;
	flex-direction: column;
	gap: 0.55rem;
	width: 250px;
	padding: 1.1rem;
	border-radius: 0 18px 18px 18px;
	background: #ffffff;
	box-shadow: 4px 12px 32px rgba(18, 63, 86, 0.28);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s ease, visibility 0s linear 0.35s;
}
.afg-caa-panneau.afg-caa-panneau-ouvert {
	transform: translateY(-50%) translateX(0);
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s ease, visibility 0s linear 0s;
}

.afg-caa-panneau-titre {
	margin: 0 0 0.3rem;
	color: #123f56;
	font-size: 1rem;
	font-weight: 700;
}

.afg-caa-reset {
	background: #6b7280;
}

.afg-caa-reset:hover {
	background: #4b5563;
}

/* =====================================================
   Mode contraste élevé (appliqué à toute la page)
   ===================================================== */

html.afg-contraste,
html.afg-contraste body {
	background: #000000 !important;
	color: #ffff00 !important;
}

html.afg-contraste a {
	color: #00ffff !important;
}

html.afg-contraste img {
	filter: grayscale(20%) contrast(1.1);
}

html.afg-contraste .afg-caa-panneau {
	background: #000000 !important;
	border: 2px solid #ffff00;
}

html.afg-contraste .afg-caa-panneau-titre {
	color: #ffff00 !important;
}

/* =====================================================
   Police lisible (confort de lecture / dyslexie)
   ===================================================== */

html.afg-dyslexie body {
	font-family: "Comic Sans MS", "Trebuchet MS", Verdana, sans-serif !important;
	letter-spacing: 0.05em;
	line-height: 1.8 !important;
	word-spacing: 0.1em;
}

/* =====================================================
   Surlignage du texte en cours de lecture vocale
   ===================================================== */

.afg-caa-lecture-active {
	background: #ffe6a3 !important;
	color: #000000 !important;
	box-shadow: 0 0 0 3px #ffe6a3;
}

/* Petits écrans : la barre reste accessible */
@media (max-width: 600px) {
	.afg-caa-panneau {
		width: 200px;
	}
}

/* Empêche l'overflow du panneau sur petits écrans à gauche */
@media (max-width: 340px) {
	.afg-caa-panneau {
		width: calc(100vw - 2rem);
	}
}

/* =====================================================
   Style « vivant » de la barre d'accessibilité
   ===================================================== */
.afg-caa-toggle {
	background: linear-gradient(135deg, #3a9bbd, #1f6f92) !important;
	position: relative;
	transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), background 0.2s ease;
	animation: afg-caa-flotte 2.4s ease-in-out infinite;
}
.afg-caa-toggle:hover { transform: scale(1.14) rotate(-4deg); }
.afg-caa-toggle:active { transform: scale(0.94); }
.afg-caa-toggle .afg-caa-svg {
	animation: afg-caa-icone 2.4s ease-in-out infinite;
}
.afg-caa-toggle::after,
.afg-caa-toggle::before {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: 50%;
	pointer-events: none;
	animation: afg-caa-ring 2.2s ease-out infinite;
}
.afg-caa-toggle::before { animation-delay: 1.1s; }

@keyframes afg-caa-ring {
	0%   { box-shadow: 0 0 0 0 rgba(58,155,189,0.55); }
	70%  { box-shadow: 0 0 0 20px rgba(58,155,189,0); }
	100% { box-shadow: 0 0 0 0 rgba(58,155,189,0); }
}
@keyframes afg-caa-flotte {
	0%, 100% { transform: translateY(0); }
	50%      { transform: translateY(-6px); }
}
@keyframes afg-caa-icone {
	0%, 100% { transform: rotate(0deg); }
	25%      { transform: rotate(-8deg); }
	75%      { transform: rotate(8deg); }
}

/* Pictogrammes animés au survol */
.afg-caa-picto { transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1); }
.afg-caa-panneau .afg-caa-bouton:hover {
	transform: translateX(6px) scale(1.04);
	box-shadow: 0 6px 16px rgba(18,63,86,0.22);
}
.afg-caa-panneau .afg-caa-bouton:hover .afg-caa-picto { transform: scale(1.35) rotate(-10deg); }

/* Couleurs distinctes par action (repères visuels clairs) */
.afg-caa-bouton[data-action="texte-plus"],
.afg-caa-bouton[data-action="texte-moins"] { background: linear-gradient(135deg, #379c76, #2a7f62); }
.afg-caa-bouton[data-action="contraste"] { background: linear-gradient(135deg, #8069c2, #6b4fa0); }
.afg-caa-bouton[data-action="dyslexie"] { background: linear-gradient(135deg, #d1893f, #b5651d); }
.afg-caa-bouton[data-action="lecture"] { background: linear-gradient(135deg, #3a9bbd, #1f6f92); }
.afg-caa-bouton[data-action="texte-plus"]:hover,
.afg-caa-bouton[data-action="texte-moins"]:hover { background: #35a07c; }
.afg-caa-bouton[data-action="contraste"]:hover { background: #7d5fb8; }
.afg-caa-bouton[data-action="dyslexie"]:hover { background: #cf7620; }
.afg-caa-bouton[data-action="lecture"]:hover { background: #3a9bbd; }

/* On conserve un état « activé » bien visible, avec un léger halo qui pulse */
.afg-caa-panneau .afg-caa-bouton[aria-pressed="true"] {
	background: #123f56 !important;
	border-color: #f4c95d;
	animation: afg-caa-actif 1.6s ease-in-out infinite;
}
@keyframes afg-caa-actif {
	0%, 100% { box-shadow: 0 0 0 0 rgba(244,201,93,0.5); }
	50%      { box-shadow: 0 0 0 7px rgba(244,201,93,0); }
}

/* Apparition en douceur des boutons quand le panneau s'ouvre */
.afg-caa-panneau.afg-caa-panneau-ouvert .afg-caa-bouton {
	opacity: 0;
	animation: afg-caa-item-in 0.4s ease forwards;
}
.afg-caa-panneau.afg-caa-panneau-ouvert .afg-caa-bouton:nth-child(2) { animation-delay: 0.04s; }
.afg-caa-panneau.afg-caa-panneau-ouvert .afg-caa-bouton:nth-child(3) { animation-delay: 0.08s; }
.afg-caa-panneau.afg-caa-panneau-ouvert .afg-caa-bouton:nth-child(4) { animation-delay: 0.12s; }
.afg-caa-panneau.afg-caa-panneau-ouvert .afg-caa-bouton:nth-child(5) { animation-delay: 0.16s; }
.afg-caa-panneau.afg-caa-panneau-ouvert .afg-caa-bouton:nth-child(6) { animation-delay: 0.20s; }
@keyframes afg-caa-item-in {
	from { opacity: 0; transform: translateX(10px); }
	to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
	.afg-caa-toggle::after, .afg-caa-toggle::before,
	.afg-caa-toggle, .afg-caa-toggle .afg-caa-svg,
	.afg-caa-panneau,
	.afg-caa-panneau.afg-caa-panneau-ouvert .afg-caa-bouton,
	.afg-caa-panneau .afg-caa-bouton[aria-pressed="true"] { animation: none; }
	.afg-caa-panneau.afg-caa-panneau-ouvert .afg-caa-bouton { opacity: 1; }
	.afg-caa-toggle, .afg-caa-bouton, .afg-caa-picto,
	.afg-caa-panneau, .afg-caa-panneau.afg-caa-panneau-ouvert { transition: none; }
}

/* ===== LOADER ===== */
.afg-loader {
	position: fixed;
	inset: 0;
	z-index: 999999;
	background: linear-gradient(135deg, #0d3347 0%, #1f6f92 60%, #3a9bbd 100%);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity 0.55s ease, visibility 0.55s ease;
}
.afg-loader.afg-loader-cache {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}
.afg-loader-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 1.2rem;
}
.afg-loader-logo {
	width: 80px;
	height: 80px;
	animation: afg-loader-pulse 1.6s ease-in-out infinite;
	filter: drop-shadow(0 4px 18px rgba(0,0,0,0.35));
}
@keyframes afg-loader-pulse {
	0%, 100% { transform: scale(1); opacity: 0.9; }
	50%       { transform: scale(1.08); opacity: 1; }
}
.afg-loader-texte {
	color: rgba(255,255,255,0.9);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 1rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	margin: 0;
}
.afg-loader-slogan {
    color: rgba(255,255,255,0.72);
    font-size: 0.82rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin: -0.6rem 0 0;
    font-style: italic;
    animation: afg-loader-pulse 1.6s ease-in-out infinite;
    animation-delay: 0.4s;
}
.afg-loader-barre {
	width: 160px;
	height: 4px;
	background: rgba(255,255,255,0.2);
	border-radius: 4px;
	overflow: hidden;
}
.afg-loader-progress {
	height: 100%;
	border-radius: 4px;
	background: linear-gradient(90deg, #f4c95d, #ffffff);
	animation: afg-loader-fill 1.4s ease-out forwards;
}
@keyframes afg-loader-fill {
	from { width: 0%; }
	to   { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
	.afg-loader-logo { animation: none; }
	.afg-loader-progress { animation: none; width: 100%; }
}
