:root {
	--aswe-accent: var(--fnm-color-blue, #2271b1); /* brand color */
	--aswe-text: var(--fnm-color-black, #1d2327);
	--aswe-muted: #50575e;      /* contrasto > 7:1 su bianco */
	--aswe-border: var(--fnm-color-gray, #c3c4c7);
	--aswe-bg: var(--fnm-color-white, #fff);
	--aswe-bg-alt: var(--fnm-color-light-gray, #f6f7f7);
	--aswe-focus: var(--fnm-color-focus, #0a4b78);
}

html.aswe-open { overflow: hidden; }

/* Link convertito in button: aspetto neutro, :where() lascia prevalere le classi originali */
:where(.aswe-open-btn) {
	appearance: none;
	background: none;
	border: 0;
	padding: 0;
	margin: 0;
	font: inherit;
	color: inherit;
	text-align: inherit;
	cursor: pointer;
}

/* Testo solo per screen reader */
.aswe-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.aswe-overlay {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	flex-direction: column;
	background: var(--aswe-bg);
	color: var(--aswe-text);
	font-size: 16px;
	line-height: 1.5;
}
.aswe-overlay[hidden],
.aswe-overlay [hidden] { display: none !important; }

.aswe-overlay :focus-visible {
	outline: 3px solid var(--aswe-focus);
	outline-offset: 2px;
}

/* ---- Reset dei pulsanti: neutralizza gli stili globali del tema ---- */
.aswe-overlay .aswe-voice,
.aswe-overlay .aswe-close,
.aswe-overlay .aswe-more-btn,
.aswe-overlay .aswe-clear,
.aswe-overlay .aswe-filters-toggle {
	box-sizing: border-box;
	margin: 0;
	font-family: inherit;
	font-weight: 400;
	line-height: 1.2;
	letter-spacing: normal;
	text-transform: none;
	text-shadow: none;
	box-shadow: none;
	background-image: none;
	color: var(--aswe-text);
	background-color: var(--aswe-bg);
	border: 2px solid var(--aswe-muted);
	border-radius: 6px;
	cursor: pointer;
}
.aswe-overlay .aswe-voice:is(:hover, :focus),
.aswe-overlay .aswe-close:is(:hover, :focus),
.aswe-overlay .aswe-more-btn:is(:hover, :focus),
.aswe-overlay .aswe-clear:is(:hover, :focus),
.aswe-overlay .aswe-filters-toggle:is(:hover, :focus) {
	background-image: none;
	background-color: var(--aswe-bg-alt);
	color: var(--aswe-text);
	opacity: 0.7;
}

/* Header */
.aswe-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 24px;
	border-bottom: 1px solid var(--aswe-border);
}
.aswe-form {
	flex: 1;
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
}
.aswe-input {
	flex: 1;
	min-width: 0;
	min-height: 48px;
	padding: 8px 16px;
	font-size: 18px;
	color: inherit;
	background: var(--aswe-bg);
	border: 2px solid var(--aswe-muted);
	border-radius: 6px;
}
.aswe-overlay .aswe-voice,
.aswe-overlay .aswe-close {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
}
.aswe-overlay .aswe-close { border-color: transparent; }
.aswe-overlay .aswe-voice.is-listening {
	color: #fff;
	background-color: #b32d2e;
	border-color: #b32d2e;
}

/* Barra di avanzamento (indeterminata) */
.aswe-progress {
	height: 3px;
	overflow: hidden;
	visibility: hidden;
}
.aswe-progress span {
	display: block;
	width: 35%;
	height: 100%;
	background: var(--aswe-accent);
	transform: translateX(-100%);
}
.aswe-overlay.is-loading .aswe-progress { visibility: visible; }
.aswe-overlay.is-loading .aswe-progress span { animation: aswe-slide 1.1s ease-in-out infinite; }

@keyframes aswe-slide {
	from { transform: translateX(-100%); }
	to   { transform: translateX(300%); }
}
@keyframes aswe-spin {
	to { transform: rotate(360deg); }
}

.aswe-spinner {
	display: inline-block;
	width: 14px;
	height: 14px;
	margin-right: 8px;
	vertical-align: -2px;
	border: 2px solid var(--aswe-border);
	border-top-color: var(--aswe-accent);
	border-radius: 50%;
	animation: aswe-spin .8s linear infinite;
}

/* Layout: posizioni esplicite, indipendenti da eventuali elementi extra */
.aswe-layout {
	flex: 1;
	min-height: 0;
	display: grid;
	grid-template-columns: 300px minmax(0, 1fr);
	grid-template-rows: minmax(0, 1fr);
}
.aswe-overlay .aswe-layout > .aswe-filters-toggle { display: none !important; }
.aswe-sidebar {
	grid-column: 1;
	grid-row: 1;
	overflow-y: auto;
	padding: 20px 24px;
	border-right: 1px solid var(--aswe-border);
	background: var(--aswe-bg-alt);
}
.aswe-main {
	grid-column: 2;
	grid-row: 1;
	overflow-y: auto;
	padding: 20px 32px 40px;
}

/* "Cancella filtri": in cima ai filtri, sempre raggiungibile anche scorrendo la sidebar */
.aswe-clear-wrap {
	position: sticky;
	top: -20px;
	z-index: 1;
	margin: -20px -24px 16px;
	padding: 12px 24px;
	background: var(--aswe-bg-alt);
	border-bottom: 1px solid var(--aswe-border);
}
.aswe-overlay .aswe-clear {
	min-height: 40px;
	padding: 6px 14px;
	font-size: 14px;
	font-weight: 600;
}

/* Filtri */
.aswe-facet {
	margin: 0 0 24px;
	padding: 0;
	border: 0;
	min-width: 0;
}
.aswe-facet legend {
	padding: 0;
	margin-bottom: 8px;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: .05em;
	text-transform: uppercase;
	color: var(--aswe-muted);
}
.aswe-facet ul { margin: 0; padding: 0; list-style: none; }
.aswe-facet li {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 36px;
	margin: 0;
}
.aswe-facet input[type="checkbox"] {
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	margin: 0;
	accent-color: var(--aswe-accent);
}
.aswe-facet label {
	flex: 1;
	display: flex;
	justify-content: space-between;
	gap: 8px;
	padding: 4px 0;
	cursor: pointer;
}
.aswe-facet__count { color: var(--aswe-muted); font-size: 14px; }
.aswe-facet__note {
	margin: 0 0 8px;
	font-size: 14px;
	color: var(--aswe-muted);
}
.aswe-facet.is-disabled ul { opacity: .6; }
.aswe-facet input:disabled,
.aswe-facet input:disabled + label { cursor: not-allowed; }
.aswe-facet input:disabled + label { color: var(--aswe-muted); }

/* Aggiornamento sezioni: lista e filtri attenuati mentre si ricarica */
.aswe-list,
.aswe-facet ul { transition: opacity .15s; }
.aswe-overlay.is-refreshing .aswe-list { opacity: .4; }
.aswe-overlay.is-refreshing .aswe-facet ul { opacity: .6; }

/* Risultati */
.aswe-count { margin: 0 0 12px; min-height: 1.5em; font-size: 14px; color: var(--aswe-muted); }
.aswe-notice {
	margin: 0 0 16px;
	padding: 10px 14px;
	background: #fcf9e8;
	border-left: 4px solid #996800;
}
.aswe-list { margin: 0; padding: 0; list-style: none; }
.aswe-item {
	position: relative;
	display: flex;
	gap: 14px;
	margin: 0;
	padding: 14px 8px;
	border-bottom: 1px solid #dcdcde;
}
.aswe-item:hover { background: var(--aswe-bg-alt); }
.aswe-item:focus-within { outline: 3px solid var(--aswe-focus); outline-offset: -3px; }
.aswe-icon { flex: 0 0 auto; padding-top: 2px; color: var(--aswe-accent); }
.aswe-item--page .aswe-icon       { color: #1e6a21; }
.aswe-item--attachment .aswe-icon { color: #b32d2e; }
.aswe-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.aswe-title {
	font-weight: 600;
	font-size: 17px;
	color: var(--aswe-text);
	text-decoration: underline;
	text-underline-offset: 3px;
}
.aswe-title:focus-visible { outline: none; }
.aswe-title::after { content: ""; position: absolute; inset: 0; } /* l'intera card è cliccabile */
.aswe-meta { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--aswe-muted); }
.aswe-excerpt { margin: 4px 0 0; color: var(--aswe-muted); overflow-wrap: anywhere; }

/* Evidenziazione termini (Highlight Terms di SearchWP) */
.aswe-overlay mark {
	padding: 0 2px;
	color: var(--aswe-text);
	background: #ffe08a;
	border-radius: 2px;
	font-weight: inherit;
}

.aswe-empty { margin: 0; padding: 24px 8px; color: var(--aswe-muted); }

.aswe-more { padding: 20px 0; text-align: center; }
.aswe-overlay .aswe-more-btn {
	min-height: 44px;
	padding: 8px 24px;
	font-size: 16px;
}
.aswe-overlay .aswe-more-btn[aria-disabled="true"] { cursor: progress; opacity: .8; }

/* Mobile: i filtri si aprono con un pulsante */
@media (max-width: 768px) {
	.aswe-header { padding: 12px 16px; }
	.aswe-layout {
		display: block;
		overflow-y: auto;
	}
	.aswe-overlay .aswe-layout > .aswe-filters-toggle {
		display: block !important;
		width: calc(100% - 32px);
		margin: 12px 16px 0;
		min-height: 44px;
		padding: 8px 16px;
		font-size: 16px;
		text-align: left;
	}
	.aswe-overlay .aswe-layout > .aswe-filters-toggle[aria-expanded="true"] { background-color: var(--aswe-bg-alt); }
	.aswe-sidebar {
		display: none;
		max-height: 45vh;
		margin-top: 12px;
		border-right: 0;
		border-bottom: 1px solid var(--aswe-border);
	}
	.aswe-layout.is-filters-open .aswe-sidebar { display: block; }
	.aswe-main { padding: 16px; overflow-y: visible; }
}

@media (prefers-reduced-motion: reduce) {
	.aswe-spinner { animation: none; border-top-color: var(--aswe-border); border-right-color: var(--aswe-accent); }
	.aswe-overlay.is-loading .aswe-progress span { animation: none; transform: none; width: 100%; opacity: .5; }
	.aswe-list, .aswe-facet ul { transition: none; }
}

@media (forced-colors: active) {
	.aswe-overlay mark { outline: 1px solid; }
}
