/* ==========================================================================
   PlusHaut Accessibility — Frontend
   ========================================================================== */

/* ---------- Bouton flottant ---------- */
.pha11y-btn {
	all: initial;                     /* reset complet pour éviter les conflits avec le thème */
	position: fixed !important;
	top: var(--pha11y-pos-top, auto);
	bottom: var(--pha11y-pos-bottom, 20px);
	left: var(--pha11y-pos-left, auto);
	right: var(--pha11y-pos-right, 20px);
	width: var(--pha11y-btn-size, 56px) !important;
	height: var(--pha11y-btn-size, 56px) !important;
	min-width: var(--pha11y-btn-size, 56px) !important;
	min-height: var(--pha11y-btn-size, 56px) !important;
	border-radius: 50% !important;
	background: var(--pha11y-btn-bg, #1a73e8) !important;
	color: var(--pha11y-btn-fg, #fff) !important;
	border: 0 !important;
	padding: 0 !important;
	margin: 0 !important;
	cursor: pointer !important;
	z-index: 2147483600 !important;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25) !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	transition: transform 0.18s ease, box-shadow 0.18s ease !important;
	font-family: inherit;
	box-sizing: border-box !important;
}
.pha11y-btn:hover,
.pha11y-btn:focus-visible {
	transform: scale(1.08);
	box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35) !important;
	outline: 3px solid var(--pha11y-accent, #1a73e8) !important;
	outline-offset: 3px !important;
}

/* Icône — taille en pixels (calc) pour éviter les soucis de % en flex */
.pha11y-btn svg {
	width: calc(var(--pha11y-btn-size, 56px) * 0.55) !important;
	height: calc(var(--pha11y-btn-size, 56px) * 0.55) !important;
	color: var(--pha11y-btn-fg, #fff) !important;
	fill: currentColor !important;
	stroke: none !important;
	display: block !important;
	pointer-events: none;
	flex-shrink: 0;
}
.pha11y-btn svg path,
.pha11y-btn svg circle,
.pha11y-btn svg rect {
	fill: currentColor !important;
}

/* ---------- Tooltip au survol / focus ---------- */
.pha11y-tooltip {
	position: fixed;
	z-index: 2147483600;
	background: rgba(15, 23, 42, 0.95);
	color: #fff;
	padding: 8px 12px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 500;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transform: translateY(4px);
	transition: opacity 0.18s ease, transform 0.18s ease;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.pha11y-tooltip.is-visible {
	opacity: 1;
	transform: translateY(0);
}
.pha11y-tooltip::after {
	content: "";
	position: absolute;
	width: 0;
	height: 0;
	border: 6px solid transparent;
}
.pha11y-tooltip[data-side="left"]::after {
	right: -12px;
	top: 50%;
	transform: translateY(-50%);
	border-left-color: rgba(15, 23, 42, 0.95);
}
.pha11y-tooltip[data-side="right"]::after {
	left: -12px;
	top: 50%;
	transform: translateY(-50%);
	border-right-color: rgba(15, 23, 42, 0.95);
}

/* ---------- Pulsation à l'arrivée pour signaler le bouton ---------- */
@keyframes pha11y-pulse {
	0%, 100% { box-shadow: 0 6px 16px rgba(0,0,0,0.25), 0 0 0 0 var(--pha11y-btn-bg, #1a73e8); }
	50%      { box-shadow: 0 6px 16px rgba(0,0,0,0.25), 0 0 0 14px rgba(26,115,232,0); }
}
.pha11y-btn.pha11y-pulse {
	animation: pha11y-pulse 1.6s ease-out 3;
}
@media (prefers-reduced-motion: reduce) {
	.pha11y-btn.pha11y-pulse { animation: none; }
}

/* ---------- Panneau ---------- */
.pha11y-panel {
	position: fixed;
	top: 0;
	right: 0;
	width: 380px;
	max-width: 92vw;
	height: 100vh;
	background: var(--pha11y-panel-bg, #fff);
	color: var(--pha11y-panel-fg, #111);
	box-shadow: -4px 0 20px rgba(0, 0, 0, 0.18);
	z-index: 2147483601;
	transform: translateX(100%);
	transition: transform 0.3s ease;
	display: flex;
	flex-direction: column;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
}
.pha11y-panel.is-open {
	transform: translateX(0);
}
.pha11y-panel.pha11y-pos-left {
	left: 0;
	right: auto;
	box-shadow: 4px 0 20px rgba(0, 0, 0, 0.18);
	transform: translateX(-100%);
}
.pha11y-panel.pha11y-pos-left.is-open {
	transform: translateX(0);
}

.pha11y-header {
	padding: 18px 20px;
	background: var(--pha11y-accent, #1a73e8);
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}
.pha11y-header h2 {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	color: #fff;
}
.pha11y-header p {
	margin: 4px 0 0;
	font-size: 13px;
	opacity: 0.9;
}
.pha11y-close {
	all: initial;                       /* reset complet — neutralise les styles du thème */
	box-sizing: border-box !important;
	background: transparent !important;
	border: 2px solid rgba(255, 255, 255, 0.45) !important;
	color: #fff !important;
	width: 36px !important;
	height: 36px !important;
	min-width: 36px !important;
	min-height: 36px !important;
	border-radius: 50% !important;
	cursor: pointer !important;
	padding: 0 !important;
	margin: 0 !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	flex-shrink: 0;
	transition: background-color 0.18s ease, border-color 0.18s ease;
}
.pha11y-close:hover,
.pha11y-close:focus-visible {
	background: rgba(255, 255, 255, 0.15) !important;
	border-color: #fff !important;
	outline: none !important;
}
.pha11y-close svg {
	width: 18px !important;
	height: 18px !important;
	fill: currentColor !important;
	display: block !important;
	pointer-events: none;
}
.pha11y-close svg path {
	fill: currentColor !important;
}

.pha11y-body {
	padding: 18px 20px 100px;
	overflow-y: auto;
	flex: 1;
}

.pha11y-section {
	margin-bottom: 22px;
}
.pha11y-section h3 {
	margin: 0 0 10px;
	font-size: 13px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--pha11y-panel-fg, #111);
	opacity: 0.7;
}

.pha11y-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}

.pha11y-tool {
	background: transparent;
	border: 2px solid rgba(0, 0, 0, 0.08);
	border-radius: 12px;
	padding: 12px 10px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	color: inherit;
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	text-align: center;
	transition: all 0.15s ease;
	min-height: 76px;
}
.pha11y-tool:hover {
	border-color: var(--pha11y-accent, #1a73e8);
	background: rgba(26, 115, 232, 0.04);
}
.pha11y-tool:focus-visible {
	outline: 3px solid var(--pha11y-accent, #1a73e8);
	outline-offset: 2px;
}
.pha11y-tool[aria-pressed="true"] {
	background: var(--pha11y-accent, #1a73e8);
	border-color: var(--pha11y-accent, #1a73e8);
	color: #fff;
}
.pha11y-tool svg {
	width: 22px;
	height: 22px;
	fill: currentColor;
	flex-shrink: 0;
}

.pha11y-footer {
	padding: 14px 20px;
	border-top: 1px solid rgba(0, 0, 0, 0.08);
	display: flex;
	flex-direction: column;
	gap: 8px;
	background: var(--pha11y-panel-bg, #fff);
}
.pha11y-reset {
	background: transparent;
	border: 2px solid var(--pha11y-accent, #1a73e8);
	color: var(--pha11y-accent, #1a73e8);
	padding: 10px 14px;
	border-radius: 8px;
	font-weight: 600;
	cursor: pointer;
	font-family: inherit;
	font-size: 14px;
}
.pha11y-reset:hover,
.pha11y-reset:focus-visible {
	background: var(--pha11y-accent, #1a73e8);
	color: #fff;
	outline: none;
}
.pha11y-statement {
	color: var(--pha11y-accent, #1a73e8);
	text-decoration: underline;
	font-size: 13px;
	text-align: center;
}

/* ---------- Overlay ---------- */
.pha11y-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.35);
	z-index: 2147483599;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease;
}
.pha11y-overlay.is-open {
	opacity: 1;
	pointer-events: auto;
}

/* ==========================================================================
   Modes appliqués au <html> via classes pha11y-*
   ========================================================================== */

/* ---------- Tailles de texte ----------
   Géré côté JavaScript (cf. applyTextScale dans frontend.js) :
   on lit la taille calculée d'origine de chaque élément textuel,
   on la multiplie par un facteur (0.8 à 1.5), et on restaure
   à l'identique sur reset. Cette approche fonctionne sur tous les
   thèmes, qu'ils soient en em, rem, %, ou px purs, et n'affecte
   que la typographie sans modifier images ou mise en page. */

/* ---------- Espacement (lettres, mots, lignes) ---------- */
html.pha11y-spacing-1 body > *:not([class^="pha11y-"]):not([id^="pha11y-"]),
html.pha11y-spacing-1 body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) * {
	letter-spacing: 0.05em !important;
	word-spacing: 0.1em !important;
	line-height: 1.7 !important;
}
html.pha11y-spacing-2 body > *:not([class^="pha11y-"]):not([id^="pha11y-"]),
html.pha11y-spacing-2 body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) * {
	letter-spacing: 0.1em !important;
	word-spacing: 0.2em !important;
	line-height: 2 !important;
}

/* ==========================================================================
   Modes appliqués UNIQUEMENT aux contenus du site, pas à notre widget.
   Tous nos éléments ont une classe / un id qui commence par "pha11y-".
   ========================================================================== */

/* ---- Contraste élevé ---- */
html.pha11y-contrast body > *:not([class^="pha11y-"]):not([id^="pha11y-"]),
html.pha11y-contrast body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) * {
	background-color: #000 !important;
	color: #fff !important;
	border-color: #fff !important;
}
html.pha11y-contrast body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) a,
html.pha11y-contrast body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) a * {
	color: #ffe600 !important;
	text-decoration: underline !important;
}
html.pha11y-contrast { background-color: #000; }

/* ---- Inversion ---- */
html.pha11y-invert body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) {
	filter: invert(1) hue-rotate(180deg);
}
html.pha11y-invert body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) img,
html.pha11y-invert body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) video,
html.pha11y-invert body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) iframe,
html.pha11y-invert body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) picture {
	filter: invert(1) hue-rotate(180deg);
}
html.pha11y-invert { background-color: #fff; }

/* ---- Mode nuit ---- */
html.pha11y-dark body > *:not([class^="pha11y-"]):not([id^="pha11y-"]),
html.pha11y-dark body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) * {
	background-color: #1a1a1a !important;
	color: #e6e6e6 !important;
	border-color: #444 !important;
}
html.pha11y-dark body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) a,
html.pha11y-dark body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) a * {
	color: #8ab4f8 !important;
}
html.pha11y-dark { background-color: #1a1a1a; }

/* ---- Niveaux de gris ---- */
html.pha11y-grayscale body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) {
	filter: grayscale(1);
}

/* ---- Filtres daltonisme (defs SVG injectées par JS) ---- */
html.pha11y-protanopia body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) {
	filter: url("#pha11y-protanopia");
}
html.pha11y-deuteranopia body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) {
	filter: url("#pha11y-deuteranopia");
}
html.pha11y-tritanopia body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) {
	filter: url("#pha11y-tritanopia");
}

/* ---------- Police dyslexie ---------- */
html.pha11y-dyslexia body > *:not([class^="pha11y-"]):not([id^="pha11y-"]),
html.pha11y-dyslexia body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) * {
	font-family: "Atkinson Hyperlegible", "Comic Sans MS", "OpenDyslexic", Verdana, sans-serif !important;
	letter-spacing: 0.04em !important;
	word-spacing: 0.16em !important;
	line-height: 1.75 !important;
}

/* ---------- Liens soulignés ---------- */
html.pha11y-underline body > *:not([class^="pha11y-"]):not([id^="pha11y-"]) a {
	text-decoration: underline !important;
}

/* Curseur agrandi */
html.pha11y-bigcursor,
html.pha11y-bigcursor * {
	cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'><polygon points='8,4 8,40 18,30 24,42 30,40 24,28 38,28' fill='black' stroke='white' stroke-width='2'/></svg>") 4 4, auto !important;
}

/* Pause animations */
html.pha11y-pauseanim *,
html.pha11y-pauseanim *::before,
html.pha11y-pauseanim *::after {
	animation-duration: 0s !important;
	animation-iteration-count: 1 !important;
	transition-duration: 0s !important;
	scroll-behavior: auto !important;
}

/* Guide de lecture */
.pha11y-reading-guide {
	position: fixed;
	left: 0;
	right: 0;
	height: 60px;
	background: rgba(0, 0, 0, 0.55);
	pointer-events: none;
	z-index: 2147483598;
	border-top: 2px solid #ffe600;
	border-bottom: 2px solid #ffe600;
	display: none;
}
html.pha11y-readingguide .pha11y-reading-guide {
	display: block;
}

/* Focus très visible quand un mode est actif */
html.pha11y-contrast a:focus-visible,
html.pha11y-dark a:focus-visible,
html.pha11y-invert a:focus-visible {
	outline: 3px solid #ffe600 !important;
	outline-offset: 3px !important;
}

/* ==========================================================================
   Mobile : panneau en "bottom sheet" pour laisser voir la page derrière
   ========================================================================== */
@media (max-width: 768px) {
	.pha11y-panel {
		/* Tiroir ancré en bas, occupe 75 % de la hauteur */
		top: auto !important;
		right: 0 !important;
		left: 0 !important;
		bottom: 0 !important;
		width: 100% !important;
		max-width: 100% !important;
		height: 75vh !important;
		max-height: 75vh !important;
		border-top-left-radius: 18px;
		border-top-right-radius: 18px;
		box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.22);
		transform: translateY(100%);
	}
	.pha11y-panel.is-open {
		transform: translateY(0);
	}
	/* Position "gauche" ignorée sur mobile, on vient toujours du bas */
	.pha11y-panel.pha11y-pos-left {
		left: 0 !important;
		right: 0 !important;
		transform: translateY(100%);
		box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.22);
	}
	.pha11y-panel.pha11y-pos-left.is-open {
		transform: translateY(0);
	}

	/* Petite poignée visuelle en haut du tiroir */
	.pha11y-panel::before {
		content: "";
		position: absolute;
		top: 8px;
		left: 50%;
		transform: translateX(-50%);
		width: 44px;
		height: 4px;
		background: rgba(255, 255, 255, 0.55);
		border-radius: 2px;
		pointer-events: none;
		z-index: 2;
	}

	.pha11y-header {
		padding-top: 22px;
	}

	/* Overlay très léger pour ne pas masquer la page visible au-dessus */
	.pha11y-overlay {
		background: rgba(0, 0, 0, 0.15);
	}

	/* Le bouton flottant reste accessible quand le panneau est ouvert */
	.pha11y-btn {
		z-index: 2147483602;
	}
}

/* Très petits écrans : on grignote un peu plus pour voir la page */
@media (max-width: 380px) {
	.pha11y-panel {
		height: 80vh !important;
		max-height: 80vh !important;
	}
}

/* Respect des préférences système quand le panneau est fermé */
@media (prefers-reduced-motion: reduce) {
	.pha11y-panel,
	.pha11y-btn,
	.pha11y-overlay {
		transition: none !important;
	}
}
