/* ==========================================================================
   WIDGET ACCESSIBILITÀ
   Conforme WCAG 2.1 AA / Direttiva UE 2016/2102 / Legge Stanca 4/2004
   ========================================================================== */

:root {
	--a11y-bg:        #101010;
	--a11y-accent:    #dc7518;
	--a11y-text:      #ffffff;
	--a11y-surface:   #ffffff;
	--a11y-surface-2: #f4f4f7;
	--a11y-border:    #e5e5e5;
	--a11y-z-panel:   9998;
	--a11y-z-button:  9997;
	--a11y-z-guide:   9996;
}

/* ==========================================================================
   1. PULSANTE FLOTTANTE
   ========================================================================== */
.a11y-fab {
	position: fixed;
	left: 16px;
	bottom: 16px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: 2px solid var(--a11y-surface);
	background: var(--a11y-accent);
	color: var(--a11y-surface);
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: var(--a11y-z-button);
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
	transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 220ms ease;
	padding: 0;
}
.a11y-fab:hover,
.a11y-fab:focus-visible {
	transform: translateY(-2px) scale(1.05);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
	outline: 3px solid #ffffff;
	outline-offset: 3px;
}
.a11y-fab svg {
	width: 32px;
	height: 32px;
	fill: currentColor;
}

@media (max-width: 575px) {
	.a11y-fab {
		width: 52px;
		height: 52px;
		left: 12px;
		bottom: 12px;
	}
	.a11y-fab svg { width: 28px; height: 28px; }
}

/* ==========================================================================
   2. OVERLAY + PANNELLO
   ========================================================================== */
.a11y-overlay {
	position: fixed;
	inset: 0;
	background: rgba(16, 16, 16, 0.5);
	opacity: 0;
	pointer-events: none;
	transition: opacity 280ms ease;
	z-index: calc(var(--a11y-z-panel) - 1);
}
.a11y-overlay.is-open {
	opacity: 1;
	pointer-events: auto;
}

.a11y-panel {
	position: fixed;
	top: 0;
	left: 0;
	width: 360px;
	max-width: 92vw;
	height: 100vh;
	background: var(--a11y-surface);
	color: #1a1a1a;
	z-index: var(--a11y-z-panel);
	transform: translateX(-100%);
	transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1);
	display: flex;
	flex-direction: column;
	box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
	font-family: 'Poppins', system-ui, -apple-system, sans-serif;
}
.a11y-panel.is-open {
	transform: translateX(0);
}

.a11y-panel__header {
	background: var(--a11y-bg);
	color: var(--a11y-text);
	padding: 20px 20px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	flex-shrink: 0;
}
.a11y-panel__title {
	font-size: 18px;
	font-weight: 700;
	margin: 0;
	display: flex;
	align-items: center;
	gap: 10px;
}
.a11y-panel__title svg {
	width: 24px;
	height: 24px;
	fill: var(--a11y-accent);
	flex-shrink: 0;
}
.a11y-panel__close {
	background: transparent;
	border: 2px solid rgba(255,255,255,0.3);
	color: var(--a11y-text);
	width: 40px;
	height: 40px;
	border-radius: 50%;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 200ms ease, border-color 200ms ease;
}
.a11y-panel__close:hover,
.a11y-panel__close:focus-visible {
	background: var(--a11y-accent);
	border-color: var(--a11y-accent);
	outline: none;
}

.a11y-panel__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px;
	background: var(--a11y-surface-2);
}

.a11y-panel__footer {
	padding: 12px 16px;
	border-top: 1px solid var(--a11y-border);
	background: var(--a11y-surface);
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex-shrink: 0;
}
.a11y-reset-btn {
	background: var(--a11y-bg);
	color: var(--a11y-text);
	border: 2px solid var(--a11y-bg);
	padding: 10px 16px;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	min-height: 44px;
	transition: background 200ms ease;
}
.a11y-reset-btn:hover,
.a11y-reset-btn:focus-visible {
	background: var(--a11y-accent);
	border-color: var(--a11y-accent);
	outline: none;
}
.a11y-declaration {
	font-size: 13px;
	color: #555;
	text-align: center;
}
.a11y-declaration a {
	color: var(--a11y-accent);
	text-decoration: underline;
}

/* ==========================================================================
   3. GRIGLIA OPZIONI
   ========================================================================== */
.a11y-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.a11y-option {
	background: var(--a11y-surface);
	border: 2px solid var(--a11y-border);
	border-radius: 8px;
	padding: 12px 10px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	font-size: 13px;
	font-weight: 500;
	color: #333;
	text-align: center;
	min-height: 88px;
	transition: border-color 200ms ease, background 200ms ease, color 200ms ease;
	font-family: inherit;
	line-height: 1.25;
}
.a11y-option svg {
	width: 26px;
	height: 26px;
	flex-shrink: 0;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}
.a11y-option:hover,
.a11y-option:focus-visible {
	border-color: var(--a11y-accent);
	outline: none;
}
.a11y-option[aria-pressed="true"] {
	background: var(--a11y-bg);
	border-color: var(--a11y-bg);
	color: var(--a11y-text);
}
.a11y-option[aria-pressed="true"] svg {
	stroke: var(--a11y-accent);
}

.a11y-option__value {
	display: block;
	font-size: 11px;
	opacity: 0.7;
	font-weight: 600;
	margin-top: 2px;
}

/* ==========================================================================
   4. READING GUIDE
   ========================================================================== */
.a11y-reading-guide {
	position: fixed;
	left: 0;
	right: 0;
	height: 36px;
	background: rgba(0, 0, 0, 0.4);
	pointer-events: none;
	z-index: var(--a11y-z-guide);
	display: none;
	border-top: 1px solid rgba(220, 117, 24, 0.8);
	border-bottom: 1px solid rgba(220, 117, 24, 0.8);
}
body.a11y-reading-guide-on .a11y-reading-guide {
	display: block;
}

/* ==========================================================================
   5. OVERRIDE GLOBALI ATTIVATI DA CLASSI SUL BODY
   ========================================================================== */

/* 5.1 Dimensione testo */
body.a11y-text-scale-110 { zoom: 1.10; }
body.a11y-text-scale-125 { zoom: 1.25; }
body.a11y-text-scale-150 { zoom: 1.50; }

/* Il widget stesso NON deve zoomare (controesempio annidato in body) */
body.a11y-text-scale-110 .a11y-fab,
body.a11y-text-scale-110 .a11y-panel,
body.a11y-text-scale-110 .a11y-overlay,
body.a11y-text-scale-125 .a11y-fab,
body.a11y-text-scale-125 .a11y-panel,
body.a11y-text-scale-125 .a11y-overlay,
body.a11y-text-scale-150 .a11y-fab,
body.a11y-text-scale-150 .a11y-panel,
body.a11y-text-scale-150 .a11y-overlay {
	zoom: 1;
}

/* 5.2 Contrasto alto */
body.a11y-high-contrast {
	background: #000 !important;
	color: #fff !important;
}
body.a11y-high-contrast *:not(.a11y-panel):not(.a11y-panel *):not(.a11y-fab):not(.a11y-fab *):not(.a11y-overlay):not(.a11y-reading-guide) {
	background-color: #000 !important;
	color: #fff !important;
	border-color: #fff !important;
	box-shadow: none !important;
	text-shadow: none !important;
}
body.a11y-high-contrast a:not(.a11y-panel a):not(.a11y-fab) {
	color: #ffd54a !important;
	text-decoration: underline !important;
}
body.a11y-high-contrast img:not(.a11y-panel img):not(.a11y-fab img) {
	filter: grayscale(100%) contrast(1.2);
}

/* 5.3 Scala di grigi */
body.a11y-grayscale {
	filter: grayscale(100%);
}
/* Il filter su body impatterebbe anche il widget: lo neutralizziamo */
body.a11y-grayscale .a11y-panel,
body.a11y-grayscale .a11y-fab,
body.a11y-grayscale .a11y-overlay {
	filter: grayscale(0%);
}

/* 5.4 Contrasto invertito (colori invertiti) */
body.a11y-invert {
	filter: invert(100%) hue-rotate(180deg);
}
body.a11y-invert .a11y-panel,
body.a11y-invert .a11y-fab,
body.a11y-invert .a11y-overlay {
	filter: invert(100%) hue-rotate(180deg);
}
body.a11y-invert img,
body.a11y-invert video,
body.a11y-invert picture {
	filter: invert(100%) hue-rotate(180deg);
}

/* 5.5 Link evidenziati */
body.a11y-highlight-links a:not(.a11y-panel a):not(.a11y-fab) {
	text-decoration: underline !important;
	text-decoration-thickness: 2px !important;
	text-underline-offset: 3px !important;
	outline: 2px dashed var(--a11y-accent) !important;
	outline-offset: 2px !important;
	background-color: rgba(255, 235, 150, 0.3) !important;
}

/* 5.6 Stop animazioni */
body.a11y-pause-animations *,
body.a11y-pause-animations *::before,
body.a11y-pause-animations *::after {
	animation-duration: 0s !important;
	animation-delay: 0s !important;
	animation-iteration-count: 1 !important;
	transition-duration: 0s !important;
	transition-delay: 0s !important;
	scroll-behavior: auto !important;
}
body.a11y-pause-animations .animate-style {
	opacity: 1 !important;
	transform: none !important;
	filter: none !important;
}
body.a11y-pause-animations .skeleton,
body.a11y-pause-animations .skeleton-img,
body.a11y-pause-animations .skeleton-text,
body.a11y-pause-animations .skeleton-title {
	animation: none !important;
	background-image: none !important;
}

/* 5.7 Cursore grande */
body.a11y-big-cursor,
body.a11y-big-cursor * {
	cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path fill='%23000' stroke='%23fff' stroke-width='1.5' stroke-linejoin='round' d='M3 2l7 18 2.5-7.5L20 10z'/></svg>") 0 0, auto !important;
}
body.a11y-big-cursor a,
body.a11y-big-cursor button,
body.a11y-big-cursor [role="button"],
body.a11y-big-cursor input,
body.a11y-big-cursor label,
body.a11y-big-cursor select,
body.a11y-big-cursor textarea {
	cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'><path fill='%23dc7518' stroke='%23fff' stroke-width='1.5' stroke-linejoin='round' d='M9 2v8H3l9 12 9-12h-6V2z'/></svg>") 0 0, pointer !important;
}

/* 5.8 Spaziatura testo (WCAG 1.4.12) */
body.a11y-text-spacing,
body.a11y-text-spacing p,
body.a11y-text-spacing span,
body.a11y-text-spacing li,
body.a11y-text-spacing a,
body.a11y-text-spacing h1,
body.a11y-text-spacing h2,
body.a11y-text-spacing h3,
body.a11y-text-spacing h4,
body.a11y-text-spacing h5,
body.a11y-text-spacing h6 {
	line-height: 1.8 !important;
	letter-spacing: 0.12em !important;
	word-spacing: 0.16em !important;
}
body.a11y-text-spacing p {
	margin-bottom: 2em !important;
}

/* 5.9 Font leggibile (per dislessia) — stack sicuro senza download */
body.a11y-readable-font,
body.a11y-readable-font * {
	font-family: Verdana, Tahoma, Arial, sans-serif !important;
}

/* Il pannello a11y mantiene il proprio font in ogni caso */
body.a11y-readable-font .a11y-panel,
body.a11y-readable-font .a11y-panel * {
	font-family: 'Poppins', system-ui, sans-serif !important;
}
