/*
 * Alma Consent - mobile-first. Usa i token del tema se presenti, con fallback (plugin riutilizzabile).
 * I pulsanti «Rifiuta», «Personalizza» e «Accetta» hanno lo stesso stile e lo stesso peso visivo (Garante 2021).
 */
.alma-consent, .alma-consent-panel, .alma-consent-ph, .alma-consent-recall {
	--cc-ink: var(--wp--preset--color--ink, #1e1b16);
	--cc-paper: var(--wp--preset--color--white, #fff);
	--cc-muted: var(--wp--preset--color--muted, #5b554b);
	--cc-accent: var(--wp--preset--color--accent-dark, #8a3b1e);
	--cc-line: rgba(30, 27, 22, 0.14);
	--cc-radius: var(--alma-radius, 12px);
	--cc-radius-btn: var(--alma-radius-btn, 10px);
	--cc-bottom: var(--alma-bottom-nav-h, 0px);
}

/* ---------- banner ---------- */
.alma-consent {
	position: fixed; left: 0; right: 0; z-index: 100000;
	bottom: calc(var(--cc-bottom) + env(safe-area-inset-bottom, 0px)); /* sopra la barra mobile */
	padding: 0.5rem;
}
.alma-consent[hidden], .alma-consent-panel[hidden] { display: none; }
.alma-consent__box {
	position: relative; max-width: 960px; margin: 0 auto; max-height: 70vh; overflow-y: auto;
	background: var(--cc-paper); color: var(--cc-ink);
	border: 1px solid var(--cc-line); border-radius: var(--cc-radius);
	box-shadow: 0 8px 30px rgba(30, 27, 22, 0.22);
	padding: 1rem 1rem 1rem;
}
.alma-consent__title { margin: 0 2.75rem 0.375rem 0; padding: 0; font-weight: 700; font-size: 1.125rem; line-height: 1.3; color: var(--cc-ink); }
.alma-consent__text { margin: 0 0 0.75rem; font-size: 0.9375rem; line-height: 1.5; }
.alma-consent a, .alma-consent-panel a { color: var(--cc-accent); text-decoration: underline; }

.alma-consent__actions { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }
.alma-consent__btn {
	min-height: 44px; padding: 0.625rem 1rem; cursor: pointer;
	font: inherit; font-weight: 600; font-size: 0.9375rem; line-height: 1.2;
	color: var(--cc-paper); background: var(--cc-ink);
	border: 2px solid var(--cc-ink); border-radius: var(--cc-radius-btn);
}
.alma-consent__btn:hover { background: var(--cc-accent); border-color: var(--cc-accent); }
.alma-consent__link {
	min-height: 44px; padding: 0.5rem 0.25rem; cursor: pointer; background: none; border: 0;
	font: inherit; font-weight: 600; color: var(--cc-accent); text-decoration: underline;
}
.alma-consent__x {
	position: absolute; top: 0.375rem; right: 0.375rem; width: 44px; height: 44px; cursor: pointer;
	background: none; border: 0; border-radius: 50%; font-size: 1.25rem; line-height: 1; color: var(--cc-ink);
}
.alma-consent__x:hover { background: rgba(30, 27, 22, 0.08); }

@media (min-width: 768px) {
	.alma-consent { --cc-bottom: 0px; padding: 1rem; }
	.alma-consent__box { padding: 1.25rem 1.5rem; }
	.alma-consent__actions { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- pannello preferenze ---------- */
.alma-consent-lock, .alma-consent-lock body { overflow: hidden; }
.alma-consent-panel {
	position: fixed; inset: 0; z-index: 100001;
	display: flex; align-items: flex-end; justify-content: center;
	background: rgba(30, 27, 22, 0.55);
}
.alma-consent-panel__box {
	position: relative; width: 100%; max-width: 680px; max-height: 92vh; overflow-y: auto;
	background: var(--cc-paper); color: var(--cc-ink);
	border-radius: var(--cc-radius) var(--cc-radius) 0 0;
	padding: 1.25rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
}
.alma-consent-panel__box:focus { outline: none; }
.alma-consent-panel__title { margin: 0 2.75rem 0.5rem 0; font-size: 1.375rem; }
.alma-consent-panel__state { margin: 0 0 1rem; font-size: 0.875rem; color: var(--cc-muted); }
.alma-consent-panel__links { margin: 1rem 0 0; font-size: 0.875rem; }
@media (min-width: 768px) {
	.alma-consent-panel { align-items: center; padding: 1rem; }
	.alma-consent-panel__box { border-radius: var(--cc-radius); padding: 1.5rem 1.75rem; }
	.alma-consent-panel .alma-consent__actions { grid-template-columns: repeat(3, 1fr); }
}

.alma-consent-cat { margin: 0 0 0.75rem; padding: 0.75rem 0 0; border: 0; border-top: 1px solid var(--cc-line); }
.alma-consent-cat__head { display: flex; align-items: center; gap: 0.75rem; min-height: 44px; cursor: pointer; }
.alma-consent-cat__head input { width: 1.375rem; height: 1.375rem; flex: none; accent-color: var(--cc-accent); }
.alma-consent-cat__head input:disabled { cursor: not-allowed; }
.alma-consent-cat__label { font-weight: 700; flex: 1; }
.alma-consent-cat__state { font-size: 0.8125rem; color: var(--cc-muted); }
.alma-consent-cat__desc { margin: 0.25rem 0 0.375rem; font-size: 0.9375rem; line-height: 1.5; }
.alma-consent-cat__list { font-size: 0.875rem; }
.alma-consent-cat__list summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--cc-accent); font-weight: 600; }
.alma-consent-cat__list ul { margin: 0 0 0.5rem; padding-left: 1.25rem; }
.alma-consent-cat__list li { margin-bottom: 0.375rem; }

/* ---------- segnaposto dei contenuti esterni bloccati ---------- */
.alma-consent-ph {
	display: flex; flex-direction: column; justify-content: center; gap: 0.5rem;
	min-height: 200px; padding: 1.25rem; margin: 0 0 1rem;
	background: repeating-linear-gradient(45deg, rgba(30, 27, 22, 0.03) 0 12px, rgba(30, 27, 22, 0.06) 12px 24px);
	border: 1px dashed var(--cc-line); border-radius: var(--cc-radius); color: var(--cc-ink);
}
.alma-consent-ph p { margin: 0; }
.alma-consent-ph__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }

/* ---------- link legali aggiunti al footer (temi senza link propri) ---------- */
.alma-consent-legal { max-width: 1200px; margin: 0 auto; padding: 0.5rem 1rem; font-size: 0.875rem; text-align: center; }
.alma-consent-legal a { display: inline-flex; align-items: center; min-height: 44px; color: inherit; text-decoration: underline; }

/* ---------- richiamo preferenze (cookie policy) e tabella ---------- */
.alma-consent-recall { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.alma-consent-recall [data-alma-consent-state] { font-size: 0.875rem; color: var(--cc-muted); }
.alma-consent-table { overflow-x: auto; margin: 0 0 1.5rem; }
.alma-consent-table table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.alma-consent-table th, .alma-consent-table td { text-align: left; vertical-align: top; padding: 0.5rem; border-bottom: 1px solid rgba(30, 27, 22, 0.14); }
.alma-consent-table code { white-space: normal; word-break: break-word; }

@media (prefers-reduced-motion: no-preference) {
	.alma-consent__box { animation: alma-consent-in 0.2s ease-out; }
	@keyframes alma-consent-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* ---------- focus visibile (WCAG 2.4.7) ---------- */
.alma-consent :focus-visible, .alma-consent-panel :focus-visible, .alma-consent-ph :focus-visible, .alma-consent-recall :focus-visible, .alma-consent-legal :focus-visible {
	outline: 3px solid var(--cc-focus, #1d3a2e); outline-offset: 2px; box-shadow: 0 0 0 5px #fff;
}
.alma-consent-cat__head input[aria-disabled="true"] { cursor: not-allowed; opacity: .75; }
.alma-consent-ph__title { font-weight: 700; }
.alma-consent-ph__actions a.alma-consent__link { display: inline-flex; align-items: center; }
