/* Autor: Telmo Correia - TCSi Solutions (https://www.tcsi-solutions.pt/) */
/* ==========================================================================
   Menu de acessibilidade – Tema Lacerfer
   Todos os efeitos aplicam-se ao site (body > *) e nunca ao próprio menu.
   ========================================================================== */

/* ---------- Efeitos na página ---------- */

/* Altura da linha */
html.lfa-lineh-1 body > *:not(#lf-a11y) * { line-height: 1.75 !important; }
html.lfa-lineh-2 body > *:not(#lf-a11y) * { line-height: 2 !important; }
html.lfa-lineh-3 body > *:not(#lf-a11y) * { line-height: 2.5 !important; }

/* Alinhamento */
html.lfa-align-1 body > *:not(#lf-a11y) * { text-align: left !important; }
html.lfa-align-2 body > *:not(#lf-a11y) * { text-align: center !important; }
html.lfa-align-3 body > *:not(#lf-a11y) * { text-align: right !important; }

/* Fonte legível */
html.lfa-font body > *:not(#lf-a11y),
html.lfa-font body > *:not(#lf-a11y) * {
	font-family: Verdana, Tahoma, Arial, sans-serif !important;
	letter-spacing: .03em !important;
	word-spacing: .08em !important;
}

/* Contraste escuro */
html.lfa-contrast-1 body,
html.lfa-contrast-1 body > *:not(#lf-a11y),
html.lfa-contrast-1 body > *:not(#lf-a11y) *:not(svg):not(path):not(circle):not(rect) {
	background-color: #000 !important;
	color: #fff !important;
	border-color: #fff !important;
	text-shadow: none !important;
	box-shadow: none !important;
}
html.lfa-contrast-1 body > *:not(#lf-a11y) a[href],
html.lfa-contrast-1 body > *:not(#lf-a11y) a[href] * { color: #ffeb3b !important; }
html.lfa-contrast-1 body > *:not(#lf-a11y) input[name],
html.lfa-contrast-1 body > *:not(#lf-a11y) textarea[name] { border: 1px solid #fff !important; }
html.lfa-contrast-1 .hero__overlay,
html.lfa-contrast-1 .shape-divider { display: none !important; }
html.lfa-contrast-1 body > *:not(#lf-a11y) .hero__content { background-color: rgba(0,0,0,.7) !important; }

/* Contraste claro */
html.lfa-contrast-2 body,
html.lfa-contrast-2 body > *:not(#lf-a11y),
html.lfa-contrast-2 body > *:not(#lf-a11y) *:not(svg):not(path):not(circle):not(rect) {
	background-color: #fff !important;
	color: #000 !important;
	border-color: #000 !important;
	text-shadow: none !important;
	box-shadow: none !important;
}
html.lfa-contrast-2 body > *:not(#lf-a11y) a[href],
html.lfa-contrast-2 body > *:not(#lf-a11y) a[href] * { color: #0000c8 !important; }
html.lfa-contrast-2 body > *:not(#lf-a11y) input[name],
html.lfa-contrast-2 body > *:not(#lf-a11y) textarea[name] { border: 1px solid #000 !important; }
html.lfa-contrast-2 .hero__overlay,
html.lfa-contrast-2 .shape-divider { display: none !important; }
html.lfa-contrast-2 body > *:not(#lf-a11y) .hero__content { background-color: rgba(255,255,255,.85) !important; }

/* Cores invertidas e escala de cinza (filtros combináveis) */
html.lfa-contrast-3 body > *:not(#lf-a11y) { filter: invert(1) hue-rotate(180deg); }
html.lfa-gray body > *:not(#lf-a11y) { filter: grayscale(1); }
html.lfa-gray.lfa-contrast-3 body > *:not(#lf-a11y) { filter: invert(1) hue-rotate(180deg) grayscale(1); }
html.lfa-contrast-3 body > *:not(#lf-a11y) img,
html.lfa-contrast-3 body > *:not(#lf-a11y) video,
html.lfa-contrast-3 .hero__bg { filter: invert(1) hue-rotate(180deg); }
html.lfa-contrast-3 body { background: #000; }

/* Esconder imagens */
html.lfa-noimg body > *:not(#lf-a11y) img,
html.lfa-noimg body > *:not(#lf-a11y) picture,
html.lfa-noimg body > *:not(#lf-a11y) video,
html.lfa-noimg body > *:not(#lf-a11y) iframe { opacity: 0 !important; }
html.lfa-noimg body > *:not(#lf-a11y) [style*="background-image"],
html.lfa-noimg .hero__bg { background-image: none !important; }

/* Pausar animações */
html.lfa-pause body > *:not(#lf-a11y),
html.lfa-pause body > *:not(#lf-a11y) *,
html.lfa-pause body > *:not(#lf-a11y) *::before,
html.lfa-pause body > *:not(#lf-a11y) *::after {
	animation: none !important;
	transition: none !important;
}
html.lfa-pause { scroll-behavior: auto !important; }
html.lfa-pause [data-animate] { opacity: 1 !important; transform: none !important; }

/* Destacar links */
html.lfa-links body > *:not(#lf-a11y) a[href] {
	background-color: #ffeb3b !important;
	color: #000 !important;
	text-decoration: underline !important;
	text-underline-offset: 3px;
	outline: 2px solid #000 !important;
	outline-offset: 1px;
}
html.lfa-links body > *:not(#lf-a11y) a[href] * { color: #000 !important; background-color: transparent !important; }

/* Contorno de foco */
html.lfa-focus body > *:not(#lf-a11y) :focus,
html.lfa-focus body > *:not(#lf-a11y) :focus-visible {
	outline: 4px solid #ff9800 !important;
	outline-offset: 3px !important;
	box-shadow: 0 0 0 7px #000 !important;
}

/* Alvo da "Estrutura da página" */
.lfa-target { outline: 4px dashed #ff9800 !important; outline-offset: 4px !important; }

/* ---------- Máscara de leitura ---------- */
.lfa-rmask { display: none; }
html.lfa-mask .lfa-rmask { display: block; }
.lfa-rmask__top,
.lfa-rmask__bottom {
	position: fixed; left: 0; right: 0; z-index: 99990;
	background: rgba(0, 0, 0, .6); pointer-events: none;
}
.lfa-rmask__top { top: 0; height: 40vh; }
.lfa-rmask__bottom { bottom: 0; height: 40vh; }

/* ---------- Botão e painel ---------- */
#lf-a11y {
	--lfa-color: #2847f3;
	--lfa-text: #0c0d0e;
	--lfa-muted: #69727d;
	font-family: Roboto, Arial, Helvetica, sans-serif;
	font-size: 16px;
	line-height: 1.4;
	color: var(--lfa-text);
	text-align: left;
	letter-spacing: normal;
}
#lf-a11y *,
#lf-a11y *::before,
#lf-a11y *::after { box-sizing: border-box; }
#lf-a11y button { font-family: inherit; cursor: pointer; margin: 0; }
#lf-a11y [hidden] { display: none !important; }

.lfa-toggle {
	position: fixed; z-index: 99998;
	width: 56px; height: 56px; padding: 0;
	display: flex; align-items: center; justify-content: center;
	border: 0; border-radius: 50%;
	background: var(--lfa-color); color: #fff;
	box-shadow: 0 0 0 3px #fff, 0 6px 16px rgba(0, 0, 0, .3);
	transition: transform .2s;
}
.lfa-toggle:hover { transform: scale(1.06); }
.lfa-toggle:focus-visible { outline: 3px solid #ff9800; outline-offset: 4px; }
.lfa-toggle .lfa-icon { width: 34px; height: 34px; stroke-width: 2; }

.lfa-panel {
	position: fixed; z-index: 99999;
	width: 380px; max-width: calc(100vw - 20px);
	max-height: min(680px, calc(100vh - 110px));
	display: flex; flex-direction: column;
	background: #f3f4f7; border-radius: 18px;
	box-shadow: 0 12px 40px rgba(0, 0, 0, .3);
	overflow: hidden;
	animation: lfa-in .2s ease-out;
}
@keyframes lfa-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Posições */
.lfa--bottom-left .lfa-toggle { left: 20px; bottom: 20px; }
.lfa--bottom-left .lfa-panel { left: 20px; bottom: 90px; }
.lfa--bottom-right .lfa-toggle { right: 20px; bottom: 20px; }
.lfa--bottom-right .lfa-panel { right: 20px; bottom: 90px; }
.lfa--bottom-center .lfa-toggle { left: 50%; bottom: 20px; margin-left: -28px; }
.lfa--bottom-center .lfa-panel { left: 50%; bottom: 90px; transform: translateX(-50%); animation: none; }
.lfa--middle-left .lfa-toggle { left: 15px; top: 50%; margin-top: -28px; }
.lfa--middle-left .lfa-panel { left: 85px; top: 50%; transform: translateY(-50%); animation: none; }
.lfa--middle-right .lfa-toggle { right: 15px; top: 50%; margin-top: -28px; }
.lfa--middle-right .lfa-panel { right: 85px; top: 50%; transform: translateY(-50%); animation: none; }

.lfa-head {
	display: flex; align-items: center; justify-content: space-between;
	padding: 16px 16px 12px 20px; background: #fff;
	border-bottom: 1px solid #e3e5ea;
}
#lf-a11y .lfa-title { margin: 0; font-size: 20px; font-weight: 500; line-height: 1.3; color: var(--lfa-text); font-family: inherit; }
.lfa-icon-btn {
	width: 40px; height: 40px; padding: 0; display: flex; align-items: center; justify-content: center;
	background: transparent; border: 0; border-radius: 50%; color: var(--lfa-text);
}
.lfa-icon-btn:hover { background: #eceef2; }

.lfa-view { overflow-y: auto; padding: 8px 14px 14px; flex: 1; }

.lfa-group { background: #fff; border-radius: 14px; padding: 14px; margin-top: 10px; }
#lf-a11y .lfa-group__title { margin: 0 0 10px; font-size: 16px; font-weight: 500; color: var(--lfa-text); font-family: inherit; line-height: 1.3; }

.lfa-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lfa-grid li { margin: 0; padding: 0; }

.lfa-opt {
	position: relative; width: 100%; height: 100%; min-height: 96px;
	display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px;
	padding: 12px 6px 14px;
	background: #f7f8fa; border: 2px solid transparent; border-radius: 12px;
	color: var(--lfa-text); font-size: 13px; line-height: 1.25; text-align: center;
	transition: background .15s, border-color .15s;
}
.lfa-opt:hover { background: #eceef2; }
.lfa-opt:focus-visible { outline: 3px solid #ff9800; outline-offset: 2px; }
.lfa-opt .lfa-icon { width: 26px; height: 26px; }
.lfa-opt__state { font-size: 11px; color: var(--lfa-color); min-height: 0; }
.lfa-opt__state:empty { display: none; }
.lfa-opt[aria-pressed="true"] {
	background: #eef1fe;
	background: color-mix(in srgb, var(--lfa-color) 10%, #fff);
	border-color: var(--lfa-color);
	color: var(--lfa-color);
}
.lfa-opt__dots { position: absolute; bottom: 6px; left: 0; right: 0; display: flex; justify-content: center; gap: 4px; }
.lfa-opt__dots i { width: 6px; height: 6px; border-radius: 50%; background: #c9ccd3; }
.lfa-opt[data-level="1"] .lfa-opt__dots i:nth-child(-n+1),
.lfa-opt[data-level="2"] .lfa-opt__dots i:nth-child(-n+2),
.lfa-opt[data-level="3"] .lfa-opt__dots i:nth-child(-n+3) { background: var(--lfa-color); }

/* Sub-páginas */
.lfa-back {
	display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 12px !important; padding: 6px 10px 6px 4px;
	background: transparent; border: 0; border-radius: 8px; font-size: 17px; font-weight: 500; color: var(--lfa-text);
}
.lfa-back:hover { background: #eceef2; }
.lfa-sitemap, .lfa-structure { list-style: none; margin: 0; padding: 12px 14px; background: #fff; border-radius: 14px; }
.lfa-sitemap ul { list-style: none; margin: 0 0 4px; padding-left: 18px; border-left: 2px solid #e3e5ea; }
.lfa-sitemap li { margin: 0; }
#lf-a11y .lfa-sitemap a { display: block; padding: 7px 4px; color: var(--lfa-text); text-decoration: none; font-size: 15px; border-radius: 6px; }
#lf-a11y .lfa-sitemap a:hover, #lf-a11y .lfa-sitemap a:focus-visible { background: #eef1fe; color: var(--lfa-color); }

.lfa-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.lfa-tab { flex: 1; padding: 8px 6px; background: #fff; border: 2px solid transparent; border-radius: 10px; font-size: 14px; color: var(--lfa-text); }
.lfa-tab[aria-selected="true"] { border-color: var(--lfa-color); color: var(--lfa-color); }
.lfa-structure li { margin: 0; }
.lfa-structure button {
	display: flex; gap: 8px; align-items: baseline; width: 100%; padding: 7px 4px;
	background: transparent; border: 0; border-radius: 6px; font-size: 14px; text-align: left; color: var(--lfa-text);
}
.lfa-structure button:hover, .lfa-structure button:focus-visible { background: #eef1fe; color: var(--lfa-color); }
.lfa-structure .lfa-tag { flex-shrink: 0; min-width: 34px; padding: 1px 5px; border-radius: 4px; background: #eceef2; font-size: 11px; font-weight: 600; text-align: center; color: var(--lfa-muted); }
.lfa-structure .lfa-empty { padding: 8px 4px; color: var(--lfa-muted); font-size: 14px; }

/* Rodapé do painel */
.lfa-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; background: #fff; border-top: 1px solid #e3e5ea; }
.lfa-foot__btn {
	display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
	background: #f3f4f7; border: 0; border-radius: 10px; font-size: 14px; color: var(--lfa-text);
}
.lfa-foot__btn:hover { background: #e3e5ea; }
.lfa-foot__btn .lfa-icon { width: 18px; height: 18px; }
#lf-a11y .lfa-statement { margin-left: auto; font-size: 13px; color: var(--lfa-text); text-decoration: underline; }
#lf-a11y .lfa-statement:hover { color: var(--lfa-color); }

/* Telemóvel */
@media (max-width: 480px) {
	.lfa-toggle { width: 50px; height: 50px; }
	.lfa--bottom-center .lfa-toggle { margin-left: -25px; }
	.lfa-panel,
	.lfa--bottom-center .lfa-panel,
	.lfa--middle-left .lfa-panel,
	.lfa--middle-right .lfa-panel {
		left: 10px !important; right: 10px !important; width: auto; max-width: none;
		top: auto !important; bottom: 80px; transform: none; max-height: calc(100vh - 100px);
	}
	.lfa-grid { gap: 6px; }
	.lfa-opt { font-size: 12px; min-height: 90px; }
	#lf-a11y .lfa-statement { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
	.lfa-panel { animation: none; }
	.lfa-toggle { transition: none; }
}

@media print {
	#lf-a11y { display: none !important; }
}

/* Botão arrastável */
#lf-a11y[data-drag="1"] .lfa-toggle { touch-action: none; cursor: grab; }
.lfa--dragging .lfa-toggle { cursor: grabbing; transform: scale(1.1); transition: none; box-shadow: 0 0 0 3px #fff, 0 12px 28px rgba(0, 0, 0, .4); }
.lfa-repos { display: none !important; }
.lfa--moved .lfa-repos { display: inline-flex !important; }
