/**
 * PW Accessibility — styles du panneau et des fonctions.
 *
 * Le panneau utilise des unités en px : il garde sa taille quand le visiteur
 * agrandit le texte. Les fonctions s'appliquent au contenu du site, jamais
 * au panneau (sélecteur :not(.pwa-ui …)).
 */

/* =========================================================================
   Panneau
   ========================================================================= */

#pwa-root {
	--pwa-color: var(--wp--preset--color--primary, #1f1d3a);
	--pwa-on-color: var(--pwm-on-primary, #ffffff);
	--pwa-ink: #1f2937;
	--pwa-muted: #4b5563;
	--pwa-bg: #f3f4f6;
	--pwa-card: #ffffff;
	--pwa-tile: #f1f2f4;
	--pwa-radius: 22px;
	--pwa-size: 56px;
	--pwa-x: 20px;
	--pwa-y: 20px;
	--pwa-focus: #ffbf00;

	position: fixed;
	z-index: 2147483000;
	bottom: var(--pwa-y);
	width: 0;
	height: 0;
}

#pwa-root.pwa--left {
	left: var(--pwa-x);
}

#pwa-root.pwa--right {
	right: var(--pwa-x);
}

#pwa-root.pwa--small {
	--pwa-size: 46px;
}

#pwa-root.pwa--large {
	--pwa-size: 66px;
}

#pwa-root[hidden] {
	display: none;
}

/* Réinitialisation : le panneau n'hérite pas des styles du site ni des réglages. */
#pwa-root,
#pwa-root *,
#pwa-root *::before,
#pwa-root *::after {
	box-sizing: border-box;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
	letter-spacing: normal !important;
	word-spacing: normal !important;
	text-transform: none;
	text-shadow: none;
}

/* Main sur tout élément cliquable du panneau, icônes comprises. */
#pwa-root :is(button, a),
#pwa-root :is(button, a) * {
	cursor: pointer !important;
}

#pwa-root button[disabled],
#pwa-root button[disabled] * {
	cursor: not-allowed !important;
}

#pwa-root button {
	margin: 0;
	border: 0;
	font: inherit;
	color: inherit;
	background: none;
	-webkit-appearance: none;
	appearance: none;
}

#pwa-root .pwa-icon {
	display: block;
	flex: none;
	width: 24px;
	height: 24px;
}

#pwa-root :focus {
	outline: none;
}

#pwa-root :focus-visible {
	outline: 3px solid var(--pwa-focus) !important;
	outline-offset: 2px !important;
	box-shadow: 0 0 0 6px #111827 !important;
}

.pwa-sr {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0, 0, 0, 0) !important;
	white-space: nowrap !important;
	border: 0 !important;
}

/* Bouton flottant */
#pwa-root .pwa-trigger {
	position: absolute;
	bottom: 0;
	display: grid;
	place-items: center;
	width: var(--pwa-size);
	height: var(--pwa-size);
	border-radius: 50%;
	background: var(--pwa-color);
	color: var(--pwa-on-color);
	box-shadow: 0 0 0 3px #ffffff, 0 8px 24px rgb(0 0 0 / 0.25);
	transition: transform 180ms ease, box-shadow 180ms ease;
}

#pwa-root.pwa--left .pwa-trigger {
	left: 0;
}

#pwa-root.pwa--right .pwa-trigger {
	right: 0;
}

#pwa-root .pwa-trigger:hover {
	transform: scale(1.06);
}

#pwa-root .pwa-trigger .pwa-icon {
	width: 58%;
	height: 58%;
	stroke-width: 2;
}

/* Panneau */
#pwa-root .pwa-panel {
	position: absolute;
	bottom: calc(var(--pwa-size) + 14px);
	display: flex;
	flex-direction: column;
	width: 420px;
	max-width: calc(100vw - 2 * var(--pwa-x));
	max-height: calc(100vh - var(--pwa-size) - var(--pwa-y) - 40px);
	overflow: hidden;
	border-radius: var(--pwa-radius);
	background: var(--pwa-bg);
	color: var(--pwa-ink);
	font-size: 15px;
	line-height: 1.35;
	text-align: left;
	box-shadow: 0 24px 60px rgb(0 0 0 / 0.3), 0 0 0 1px rgb(0 0 0 / 0.06);
	animation: pwa-in 180ms ease;
}

#pwa-root .pwa-panel:focus,
#pwa-root .pwa-panel:focus-visible {
	outline: none !important;
	box-shadow: 0 24px 60px rgb(0 0 0 / 0.3), 0 0 0 1px rgb(0 0 0 / 0.06) !important;
}

#pwa-root .pwa-panel[hidden] {
	display: none;
}

#pwa-root.pwa--left .pwa-panel {
	left: 0;
}

#pwa-root.pwa--right .pwa-panel {
	right: 0;
}

@keyframes pwa-in {
	from {
		opacity: 0;
		transform: translateY(10px) scale(0.98);
	}
}

#pwa-root .pwa-head {
	display: flex;
	flex: none;
	align-items: center;
	gap: 12px;
	padding: 18px 16px 18px 20px;
	background: var(--pwa-color);
	color: var(--pwa-on-color);
}

#pwa-root .pwa-head__logo {
	display: grid;
	flex: none;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--pwa-on-color);
	color: var(--pwa-color);
}

#pwa-root .pwa-head__logo .pwa-icon {
	width: 22px;
	height: 22px;
	stroke-width: 2.2;
}

#pwa-root .pwa-title {
	flex: 1;
	margin: 0;
	padding: 0;
	color: inherit;
	font-size: 21px !important;
	font-weight: 700;
	line-height: 1.2;
}

#pwa-root .pwa-head__actions {
	display: flex;
	align-items: center;
	gap: 2px;
}

#pwa-root .pwa-head__sep {
	width: 1px;
	height: 22px;
	margin: 0 6px;
	background: currentColor;
	opacity: 0.35;
}

#pwa-root .pwa-iconbtn {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	transition: background-color 150ms ease;
}

#pwa-root .pwa-iconbtn:hover {
	background: rgb(255 255 255 / 0.16);
}

#pwa-root .pwa-body {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 14px;
}

#pwa-root .pwa-view[hidden] {
	display: none;
}

#pwa-root .pwa-group {
	margin-bottom: 12px;
	padding: 16px;
	border-radius: 20px;
	background: var(--pwa-card);
	box-shadow: 0 1px 3px rgb(0 0 0 / 0.05);
}

#pwa-root .pwa-group:last-child {
	margin-bottom: 0;
}

#pwa-root .pwa-group__title {
	margin: 0 0 12px;
	padding: 0;
	color: var(--pwa-muted);
	font-size: 15px !important;
	font-weight: 600;
	line-height: 1.3;
}

#pwa-root .pwa-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

/* Tuile de fonction */
#pwa-root .pwa-card {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 76px;
	padding: 12px 12px 14px;
	border: 2px solid transparent;
	border-radius: 16px;
	background: var(--pwa-tile);
	color: var(--pwa-ink);
	font-size: 14.5px;
	line-height: 1.3;
	text-align: left;
	transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

#pwa-root .pwa-card:hover {
	border-color: color-mix(in srgb, var(--pwa-color) 35%, transparent);
}

#pwa-root .pwa-card.is-active {
	border-color: var(--pwa-color);
	background: var(--pwa-color);
	color: var(--pwa-on-color);
}

#pwa-root .pwa-card[disabled] {
	opacity: 0.45;
}

#pwa-root .pwa-card__icon {
	display: grid;
	flex: none;
	place-items: center;
	width: 42px;
	height: 42px;
	border-radius: 50%;
	background: #ffffff;
	color: var(--pwa-ink);
}

#pwa-root .pwa-card.is-active .pwa-card__icon {
	color: var(--pwa-color);
}

#pwa-root .pwa-card__text {
	display: flex;
	flex: 1;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

#pwa-root .pwa-card__label {
	font-weight: 500;
}

#pwa-root .pwa-card__value {
	font-size: 12.5px;
	font-weight: 700;
	opacity: 0.9;
}

#pwa-root .pwa-card__value:empty {
	display: none;
}

#pwa-root .pwa-card--action {
	grid-column: span 2;
	min-height: 60px;
}

#pwa-root .pwa-card__chevron {
	flex: none;
	opacity: 0.6;
}

/* Indicateur de niveau */
#pwa-root .pwa-steps {
	position: absolute;
	right: 12px;
	bottom: 8px;
	left: 66px;
	display: flex;
	gap: 4px;
}

#pwa-root .pwa-steps span {
	flex: 1;
	height: 4px;
	border-radius: 4px;
	background: rgb(0 0 0 / 0.12);
}

#pwa-root .pwa-card.is-active .pwa-steps span {
	background: rgb(255 255 255 / 0.3);
}

#pwa-root .pwa-card.is-active .pwa-steps span.is-on {
	background: var(--pwa-on-color);
}

/* Structure de la page */
#pwa-root .pwa-structure {
	padding: 16px;
	border-radius: 20px;
	background: var(--pwa-card);
}

#pwa-root .pwa-back {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 14px;
	padding: 6px 12px 6px 6px;
	border-radius: 999px;
	background: var(--pwa-tile);
	font-size: 14px;
	font-weight: 600;
}

#pwa-root .pwa-back .pwa-icon {
	width: 20px;
	height: 20px;
}

#pwa-root .pwa-structure__list {
	margin: 0 0 16px;
	padding: 0;
	list-style: none;
}

#pwa-root .pwa-structure__list li {
	margin: 0;
	padding: 0 0 0 calc(var(--pwa-indent, 0) * 12px);
}

#pwa-root .pwa-structure__item {
	display: flex;
	align-items: baseline;
	gap: 8px;
	width: 100%;
	padding: 8px 10px;
	border-radius: 10px;
	font-size: 14.5px;
	text-align: left;
}

#pwa-root .pwa-structure__item:hover {
	background: var(--pwa-tile);
}

#pwa-root .pwa-structure__level {
	flex: none;
	min-width: 28px;
	padding: 1px 6px;
	border-radius: 6px;
	background: var(--pwa-color);
	color: var(--pwa-on-color);
	font-size: 11px;
	font-weight: 700;
	text-align: center;
}

#pwa-root .pwa-structure__empty {
	margin: 0 0 16px;
	color: var(--pwa-muted);
}

/* Pied du panneau */
#pwa-root .pwa-foot {
	display: flex;
	flex: none;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 6px 14px;
	padding: 12px 20px;
	background: var(--pwa-color);
	color: var(--pwa-on-color);
	font-size: 13px;
}

#pwa-root .pwa-foot__links {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 14px;
}

#pwa-root .pwa-foot a {
	color: inherit;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 3px;
}

#pwa-root .pwa-foot__shortcut {
	opacity: 0.8;
}

/* Mobile : le panneau s'ouvre en bas de l'écran, sur toute la largeur. */
@media (max-width: 600px) {
	#pwa-root.pwa--hide-mobile {
		display: none;
	}

	#pwa-root.is-open {
		inset: auto 0 0 0;
		width: auto;
	}

	#pwa-root.is-open .pwa-trigger {
		display: none;
	}

	#pwa-root .pwa-panel {
		position: fixed;
		inset: auto 0 0 0;
		width: 100%;
		max-width: none;
		max-height: 88vh;
		border-radius: var(--pwa-radius) var(--pwa-radius) 0 0;
	}

	#pwa-root .pwa-card {
		min-height: 68px;
		font-size: 14px;
	}

	#pwa-root .pwa-card__icon {
		width: 36px;
		height: 36px;
	}

	#pwa-root .pwa-steps {
		left: 60px;
	}
}

/* Message « bouton masqué » */
.pwa-toast {
	position: fixed;
	z-index: 2147483001;
	bottom: 20px;
	max-width: min(360px, calc(100vw - 40px));
	padding: 14px 18px;
	border-radius: 14px;
	background: #111827;
	color: #ffffff;
	font: 500 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
	box-shadow: 0 12px 32px rgb(0 0 0 / 0.3);
	transition: opacity 400ms ease;
}

.pwa-toast--left {
	left: 20px;
}

.pwa-toast--right {
	right: 20px;
}

.pwa-toast.is-leaving {
	opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
	#pwa-root .pwa-panel {
		animation: none;
	}

	#pwa-root .pwa-trigger {
		transition: none;
	}
}

/* =========================================================================
   Fonctions (appliquées au contenu du site, jamais au panneau)
   Raccourci : « .pwa-c » = tout élément de la page hors panneau.
   ========================================================================= */

/* --- Texte plus grand (le site doit utiliser des rem pour en profiter pleinement) */
html.pwa-text-1 {
	font-size: 110% !important;
}

html.pwa-text-2 {
	font-size: 125% !important;
}

html.pwa-text-3 {
	font-size: 150% !important;
}

/* --- Hauteur de ligne */
html.pwa-lineheight-1 body :not(#pwa-root, #pwa-root *) {
	line-height: 1.75 !important;
}

html.pwa-lineheight-2 body :not(#pwa-root, #pwa-root *) {
	line-height: 2 !important;
}

html.pwa-lineheight-3 body :not(#pwa-root, #pwa-root *) {
	line-height: 2.5 !important;
}

/* --- Espacement des lettres et des mots (critère WCAG 1.4.12) */
html.pwa-spacing-1 body :not(#pwa-root, #pwa-root *) {
	letter-spacing: 0.06em !important;
	word-spacing: 0.1em !important;
}

html.pwa-spacing-2 body :not(#pwa-root, #pwa-root *) {
	letter-spacing: 0.12em !important;
	word-spacing: 0.16em !important;
}

html.pwa-spacing-3 body :not(#pwa-root, #pwa-root *) {
	letter-spacing: 0.2em !important;
	word-spacing: 0.3em !important;
}

/* --- Alignement */
html.pwa-align-1 body :not(#pwa-root, #pwa-root *) {
	text-align: left !important;
}

html.pwa-align-2 body :not(#pwa-root, #pwa-root *) {
	text-align: center !important;
}

html.pwa-align-3 body :not(#pwa-root, #pwa-root *) {
	text-align: right !important;
}

/* --- Police lisible / dyslexie (les polices d'icônes sont épargnées) */
html.pwa-font-1 body :not(#pwa-root, #pwa-root *, i, [class*="icon"], [class*="dashicons"], [class*="fa-"], code, pre, kbd) {
	font-family: "PWA Lisible", Verdana, sans-serif !important;
}

html.pwa-font-2 body :not(#pwa-root, #pwa-root *, i, [class*="icon"], [class*="dashicons"], [class*="fa-"], code, pre, kbd) {
	font-family: "PWA Dyslexie", "Comic Sans MS", Verdana, sans-serif !important;
}

/* --- Contraste : sombre */
html.pwa-contrast-1,
html.pwa-contrast-1 body,
html.pwa-contrast-1 body :not(#pwa-root, #pwa-root *, .pwa-overlay-mask, .pwa-overlay-guide, .pwa-toast) {
	background-color: #000000 !important;
	color: #ffffff !important;
	border-color: #ffffff !important;
	box-shadow: none !important;
	text-shadow: none !important;
}

html.pwa-contrast-1 body :is(a, a *):not(#pwa-root *) {
	color: #ffff00 !important;
}

html.pwa-contrast-1 body :is(button, .button, .wp-element-button, input, select, textarea):not(#pwa-root *) {
	border: 2px solid #ffffff !important;
}

html.pwa-contrast-1 body svg:not(#pwa-root *) {
	color: #ffffff !important;
}

/* --- Contraste : clair */
html.pwa-contrast-2,
html.pwa-contrast-2 body,
html.pwa-contrast-2 body :not(#pwa-root, #pwa-root *, .pwa-overlay-mask, .pwa-overlay-guide, .pwa-toast) {
	background-color: #ffffff !important;
	color: #000000 !important;
	border-color: #000000 !important;
	box-shadow: none !important;
	text-shadow: none !important;
}

html.pwa-contrast-2 body :is(a, a *):not(#pwa-root *) {
	color: #0000c8 !important;
}

html.pwa-contrast-2 body :is(button, .button, .wp-element-button, input, select, textarea):not(#pwa-root *) {
	border: 2px solid #000000 !important;
}

/* Contrastes sombre et clair : les images de fond gênent la lecture. */
html:is(.pwa-contrast-1, .pwa-contrast-2) body :not(#pwa-root, #pwa-root *) {
	background-image: none !important;
}

/* --- Contraste inversé (filtre sur <html>, appliqué par le script) :
       les images et le panneau sont ré-inversés pour rester naturels. */
html.pwa-contrast-3 :is(img, video, picture, iframe, [style*="background-image"]):not(#pwa-root *),
html.pwa-contrast-3 #pwa-root {
	filter: invert(1) hue-rotate(180deg);
}

/* --- Masquer les images */
html.pwa-images body :is(img, picture, video, iframe, figure svg, [role="img"]:not(svg)):not(#pwa-root *) {
	visibility: hidden !important;
}

html.pwa-images body :not(#pwa-root, #pwa-root *) {
	background-image: none !important;
}

/* --- Mettre en pause les animations */
html.pwa-animations *:not(#pwa-root, #pwa-root *),
html.pwa-animations *:not(#pwa-root, #pwa-root *)::before,
html.pwa-animations *:not(#pwa-root, #pwa-root *)::after {
	animation-play-state: paused !important;
	animation-duration: 0.001ms !important;
	animation-iteration-count: 1 !important;
	transition: none !important;
	scroll-behavior: auto !important;
}

/* --- Mettre en évidence les liens */
html.pwa-links body a:not(#pwa-root *) {
	outline: 2px solid #111827 !important;
	outline-offset: 2px !important;
	background-color: #fff200 !important;
	color: #111827 !important;
	text-decoration: underline !important;
	text-decoration-thickness: 2px !important;
	text-underline-offset: 3px !important;
}

html.pwa-links body a:not(#pwa-root *) * {
	color: #111827 !important;
}

/* --- Mettre en évidence le focus */
html.pwa-focus body :focus:not(#pwa-root *) {
	outline: 4px solid var(--pwa-focus, #ffbf00) !important;
	outline-offset: 3px !important;
	box-shadow: 0 0 0 8px #111827 !important;
}

/* --- Grand curseur (noir ou blanc) */
html.pwa-cursor-1,
html.pwa-cursor-1 *,
html.pwa-cursor-1 #pwa-root :is(button, a),
html.pwa-cursor-1 #pwa-root :is(button, a) * {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M4 2l16 8.5-7 2-3.5 7z' fill='%23000' stroke='%23fff' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E") 4 2, auto !important;
}

html.pwa-cursor-2,
html.pwa-cursor-2 *,
html.pwa-cursor-2 #pwa-root :is(button, a),
html.pwa-cursor-2 #pwa-root :is(button, a) * {
	cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath d='M4 2l16 8.5-7 2-3.5 7z' fill='%23fff' stroke='%23000' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E") 4 2, auto !important;
}

/* --- Masque de lecture */
.pwa-overlay-mask {
	position: fixed;
	z-index: 2147482000;
	right: 0;
	left: 0;
	background: rgb(0 0 0 / 0.65);
	pointer-events: none;
}

.pwa-overlay-mask--top {
	top: 0;
}

.pwa-overlay-mask--bottom {
	bottom: 0;
}

/* --- Guide de lecture */
.pwa-overlay-guide {
	position: fixed;
	z-index: 2147482000;
	top: 0;
	right: 0;
	left: 0;
	height: 12px;
	margin-top: -6px;
	border-top: 3px solid #111827;
	border-bottom: 3px solid #111827;
	background: #ffbf00;
	opacity: 0.85;
	pointer-events: none;
	will-change: transform;
}

/* --- Lecture à voix haute : élément en cours de lecture */
html.pwa-speech body :is(p, li, h1, h2, h3, h4, h5, h6, td, th, dt, dd, figcaption, blockquote, label, legend, a, button, summary, caption):not(#pwa-root *):hover {
	outline: 2px dashed var(--pwa-hover, #6b7280);
	outline-offset: 2px;
	cursor: help;
}

.pwa-speaking {
	outline: 3px solid #ffbf00 !important;
	outline-offset: 3px !important;
	background-color: rgb(255 191 0 / 0.18) !important;
}
