/**
 * Cookie Sentinel — stili del banner.
 * Le variabili --csnt-* sono iniettate dal PHP a partire dalle impostazioni.
 */

.csnt-root,
.csnt-badge {
	--csnt-accent: #1d4ed8;
	--csnt-accent-contrast: #ffffff;
	--csnt-bg: #ffffff;
	--csnt-text: #111827;
	--csnt-radius: 14px;
	--csnt-muted: rgba( 17, 24, 39, 0.66 );
	--csnt-border: rgba( 17, 24, 39, 0.14 );
	--csnt-shadow: 0 18px 48px -12px rgba( 15, 23, 42, 0.35 );
	--csnt-z: 999900;
}

/* L'attributo hidden deve vincere sui display flex/grid dichiarati sotto. */
.csnt-root [hidden],
.csnt-root[hidden],
.csnt-badge[hidden] {
	display: none !important;
}

.csnt-root *,
.csnt-root *::before,
.csnt-root *::after {
	box-sizing: border-box;
}

/* --------------------------------------------------------------------- */
/* Overlay                                                               */
/* --------------------------------------------------------------------- */

.csnt-overlay {
	position: fixed;
	inset: 0;
	background: rgba( 15, 23, 42, 0.55 );
	backdrop-filter: blur( 2px );
	z-index: var( --csnt-z );
	animation: csnt-fade 0.2s ease-out;
}

.csnt-overlay.is-blocking {
	cursor: not-allowed;
}

/* --------------------------------------------------------------------- */
/* Banner                                                                */
/* --------------------------------------------------------------------- */

.csnt-banner {
	position: fixed;
	z-index: calc( var( --csnt-z ) + 1 );
	background: var( --csnt-bg );
	color: var( --csnt-text );
	border-radius: var( --csnt-radius );
	box-shadow: var( --csnt-shadow );
	border: 1px solid var( --csnt-border );
	font-family: inherit;
	font-size: 15px;
	line-height: 1.55;
	animation: csnt-rise 0.28s cubic-bezier( 0.16, 1, 0.3, 1 );
}

.csnt-banner__inner {
	padding: 22px 24px;
}

.csnt-banner__title {
	margin: 0 0 8px;
	font-size: 1.05rem;
	font-weight: 700;
	line-height: 1.3;
	color: var( --csnt-text );
}

.csnt-banner__text {
	margin: 0 0 16px;
	color: var( --csnt-muted );
	font-size: 0.92rem;
}

.csnt-banner__text p {
	margin: 0 0 8px;
}

.csnt-banner__text p:last-child {
	margin-bottom: 0;
}

.csnt-banner__text a,
.csnt-banner__policy a {
	color: var( --csnt-accent );
	text-decoration: underline;
	text-underline-offset: 2px;
}

.csnt-banner__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

/* Riquadro angolare. */
.csnt-layout-box .csnt-banner {
	width: min( 440px, calc( 100vw - 32px ) );
}

.csnt-layout-box.csnt-pos-bottom-left .csnt-banner {
	bottom: 16px;
	left: 16px;
}

.csnt-layout-box.csnt-pos-bottom-right .csnt-banner {
	bottom: 16px;
	right: 16px;
}

.csnt-layout-box.csnt-pos-top-left .csnt-banner {
	top: 16px;
	left: 16px;
}

.csnt-layout-box.csnt-pos-top-right .csnt-banner {
	top: 16px;
	right: 16px;
}

/* Barra a tutta larghezza. */
.csnt-layout-bar .csnt-banner {
	left: 0;
	right: 0;
	bottom: 0;
	border-radius: 0;
	border-left: 0;
	border-right: 0;
	border-bottom: 0;
}

.csnt-layout-bar .csnt-banner__inner {
	max-width: 1180px;
	margin: 0 auto;
	display: flex;
	align-items: center;
	gap: 24px;
	flex-wrap: wrap;
}

.csnt-layout-bar .csnt-banner__text {
	flex: 1 1 420px;
	margin-bottom: 0;
}

.csnt-layout-bar .csnt-banner__title {
	flex: 1 0 100%;
	margin-bottom: 4px;
}

/* Riquadro centrale. */
.csnt-layout-center .csnt-banner {
	top: 50%;
	left: 50%;
	transform: translate( -50%, -50% );
	width: min( 520px, calc( 100vw - 32px ) );
	max-height: calc( 100vh - 48px );
	overflow-y: auto;
}

/* --------------------------------------------------------------------- */
/* Pulsanti                                                              */
/* --------------------------------------------------------------------- */

.csnt-btn {
	appearance: none;
	border: 1px solid transparent;
	border-radius: calc( var( --csnt-radius ) * 0.55 );
	padding: 10px 18px;
	font: inherit;
	font-size: 0.9rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
	min-height: 44px;
}

.csnt-btn:focus-visible {
	outline: 3px solid var( --csnt-accent );
	outline-offset: 2px;
}

.csnt-btn:active {
	transform: translateY( 1px );
}

.csnt-btn--primary {
	background: var( --csnt-accent );
	color: var( --csnt-accent-contrast );
}

/* Il rifiuto ha lo stesso peso visivo dell'accettazione: requisito EDPB. */
.csnt-btn--secondary {
	background: transparent;
	color: var( --csnt-text );
	border-color: currentColor;
}

.csnt-btn--ghost {
	background: transparent;
	color: var( --csnt-muted );
	text-decoration: underline;
	text-underline-offset: 3px;
	padding-left: 8px;
	padding-right: 8px;
}

/* Tenuta dei colori contro gli stili del tema.
 *
 * Molti temi colorano tutti i <button> negli stati interattivi con una regola
 * del tipo "button:hover, button:focus { background: ...; color: ... }".
 * Quel selettore ha specificità (0,1,1) e batte una singola classe (0,1,0):
 * senza queste dichiarazioni i pulsanti del banner cambiano colore appena il
 * puntatore li sfiora o ricevono il focus, e accetta e rifiuta finiscono per
 * apparire identici. Ridichiarare ogni stato come classe + pseudo-classe
 * (0,2,0) riporta la decisione al plugin.
 */
.csnt-btn--primary,
.csnt-btn--primary:hover,
.csnt-btn--primary:focus,
.csnt-btn--primary:active {
	background-color: var( --csnt-accent );
	color: var( --csnt-accent-contrast );
	border-color: transparent;
}

.csnt-btn--secondary,
.csnt-btn--secondary:hover,
.csnt-btn--secondary:focus,
.csnt-btn--secondary:active {
	background-color: transparent;
	color: var( --csnt-text );
	border-color: currentColor;
}

.csnt-btn--ghost,
.csnt-btn--ghost:hover,
.csnt-btn--ghost:focus,
.csnt-btn--ghost:active {
	background-color: transparent;
	color: var( --csnt-muted );
}

/* Riscritti dopo i blocchi sopra: stessa specificità, quindi vince il feedback. */
.csnt-btn--primary:hover {
	filter: brightness( 0.92 );
}

.csnt-btn--secondary:hover {
	background-color: rgba( 17, 24, 39, 0.06 );
}

.csnt-btn--ghost:hover {
	color: var( --csnt-text );
}

.csnt-layout-bar .csnt-banner__actions {
	flex: 0 1 auto;
}

/* --------------------------------------------------------------------- */
/* Pannello preferenze                                                   */
/* --------------------------------------------------------------------- */

.csnt-modal {
	position: fixed;
	inset: 0;
	z-index: calc( var( --csnt-z ) + 2 );
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}

.csnt-modal__panel {
	background: var( --csnt-bg );
	color: var( --csnt-text );
	border-radius: var( --csnt-radius );
	box-shadow: var( --csnt-shadow );
	width: min( 560px, 100% );
	max-height: min( 640px, calc( 100vh - 32px ) );
	display: flex;
	flex-direction: column;
	animation: csnt-rise 0.28s cubic-bezier( 0.16, 1, 0.3, 1 );
}

.csnt-modal__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 20px 24px 12px;
	border-bottom: 1px solid var( --csnt-border );
}

.csnt-modal__title {
	margin: 0;
	font-size: 1.05rem;
	font-weight: 700;
}

.csnt-modal__close {
	appearance: none;
	background: transparent;
	border: 0;
	font-size: 26px;
	line-height: 1;
	color: var( --csnt-muted );
	cursor: pointer;
	width: 44px;
	height: 44px;
	border-radius: 50%;
}

/* All'apertura del pannello il focus va al primo elemento, che è questo
 * pulsante. Con il focus dato via JavaScript dopo un clic del mouse il
 * browser applica :focus ma non :focus-visible, quindi difendersi con il solo
 * :focus-visible non basta: il "button:focus" del tema vincerebbe e la X
 * comparirebbe come cerchio scuro appena si aprono le preferenze.
 */
.csnt-modal__close,
.csnt-modal__close:hover,
.csnt-modal__close:focus,
.csnt-modal__close:active {
	background-color: transparent;
	color: var( --csnt-muted );
	border: 0;
}

.csnt-modal__close:hover {
	background-color: rgba( 15, 23, 42, 0.07 );
	color: var( --csnt-text );
}

.csnt-modal__close:focus-visible {
	outline: 3px solid var( --csnt-accent );
	outline-offset: 2px;
}

.csnt-modal__body {
	padding: 8px 24px 16px;
	overflow-y: auto;
	flex: 1 1 auto;
}

.csnt-modal__foot {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: flex-end;
	padding: 14px 24px 20px;
	border-top: 1px solid var( --csnt-border );
}

.csnt-cat {
	padding: 16px 0;
	border-bottom: 1px solid var( --csnt-border );
}

.csnt-cat:last-child {
	border-bottom: 0;
}

.csnt-cat__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 6px;
}

.csnt-cat__label {
	font-weight: 650;
	font-size: 0.98rem;
}

.csnt-cat__locked {
	font-size: 0.78rem;
	color: var( --csnt-muted );
	background: rgba( 15, 23, 42, 0.06 );
	padding: 4px 10px;
	border-radius: 999px;
	white-space: nowrap;
}

.csnt-cat__desc {
	margin: 0;
	font-size: 0.87rem;
	color: var( --csnt-muted );
}

/* Interruttore accessibile: l'input resta focalizzabile, non display:none. */
.csnt-switch {
	position: relative;
	display: inline-flex;
	flex: 0 0 auto;
	cursor: pointer;
}

.csnt-switch input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	margin: 0;
	cursor: pointer;
}

.csnt-switch__track {
	display: block;
	width: 48px;
	height: 28px;
	border-radius: 999px;
	background: rgba( 15, 23, 42, 0.22 );
	transition: background-color 0.18s ease;
	pointer-events: none;
}

.csnt-switch__thumb {
	display: block;
	width: 22px;
	height: 22px;
	margin: 3px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba( 15, 23, 42, 0.4 );
	transition: transform 0.18s ease;
}

.csnt-switch input:checked + .csnt-switch__track {
	background: var( --csnt-accent );
}

.csnt-switch input:checked + .csnt-switch__track .csnt-switch__thumb {
	transform: translateX( 20px );
}

.csnt-switch input:focus-visible + .csnt-switch__track {
	outline: 3px solid var( --csnt-accent );
	outline-offset: 2px;
}

/* --------------------------------------------------------------------- */
/* Badge flottante                                                       */
/* --------------------------------------------------------------------- */

.csnt-badge {
	position: fixed;
	left: 16px;
	bottom: 16px;
	z-index: calc( var( --csnt-z ) - 1 );
	width: 44px;
	height: 44px;
	border-radius: 50%;
	border: 1px solid var( --csnt-border );
	background: var( --csnt-bg );
	color: var( --csnt-text );
	display: inline-flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	box-shadow: 0 6px 18px -6px rgba( 15, 23, 42, 0.4 );
	padding: 0;
	line-height: 0;
	opacity: 0.92;
	transition: opacity 0.15s ease, transform 0.15s ease;
}

/* L'icona deve avere una dimensione propria e non negoziabile.
 *
 * Senza queste regole vale il solo attributo height="20" del tag <svg>, che
 * qualsiasi tema può scavalcare con un banale "svg { height: auto }" (regola
 * diffusissima, pensata per le immagini responsive). Dentro un contenitore
 * flex l'altezza automatica fa collassare l'icona a pochi pixel: il badge
 * resta visibile come cerchio ma il simbolo del cookie sparisce.
 */
.csnt-badge svg {
	width: 22px;
	height: 22px;
	min-width: 22px;
	min-height: 22px;
	max-width: none;
	max-height: none;
	flex: 0 0 auto;
	display: block;
	fill: currentColor;
	/* I clic devono raggiungere il button, non il disegno. */
	pointer-events: none;
}

/* Il badge sta fuori da .csnt-root: la doppia classe porta la specificità a
 * (0,2,0) e batte il "button:focus" del tema anche negli stati interattivi.
 */
.csnt-badge.csnt-badge,
.csnt-badge.csnt-badge:hover,
.csnt-badge.csnt-badge:focus,
.csnt-badge.csnt-badge:active {
	background-color: var( --csnt-bg );
	color: var( --csnt-text );
}

.csnt-badge:hover {
	opacity: 1;
	transform: scale( 1.05 );
}

.csnt-badge:focus-visible {
	outline: 3px solid var( --csnt-accent );
	outline-offset: 2px;
	opacity: 1;
}

.csnt-badge .screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect( 1px, 1px, 1px, 1px );
	clip-path: inset( 50% );
	white-space: nowrap;
}

/* --------------------------------------------------------------------- */
/* Segnaposto contenuti bloccati                                         */
/* --------------------------------------------------------------------- */

.csnt-embed {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 220px;
	padding: 24px;
	border: 1px dashed rgba( 15, 23, 42, 0.25 );
	border-radius: 12px;
	background: rgba( 15, 23, 42, 0.04 );
	text-align: center;
}

.csnt-embed__notice {
	max-width: 460px;
}

.csnt-embed__title {
	margin: 0 0 6px;
	font-weight: 700;
}

.csnt-embed__text {
	margin: 0 0 4px;
	font-size: 0.9rem;
	opacity: 0.8;
}

.csnt-embed__service {
	margin: 0 0 14px;
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	opacity: 0.6;
}

.csnt-embed__btn {
	appearance: none;
	border: 0;
	border-radius: 8px;
	background: var( --csnt-accent, #1d4ed8 );
	color: var( --csnt-accent-contrast, #fff );
	font: inherit;
	font-weight: 600;
	font-size: 0.9rem;
	padding: 11px 20px;
	min-height: 44px;
	cursor: pointer;
}

.csnt-embed__btn,
.csnt-embed__btn:hover,
.csnt-embed__btn:focus,
.csnt-embed__btn:active {
	background-color: var( --csnt-accent, #1d4ed8 );
	color: var( --csnt-accent-contrast, #fff );
	border: 0;
}

.csnt-embed__btn:hover {
	filter: brightness( 0.92 );
}

.csnt-embed__btn:focus-visible {
	outline: 3px solid var( --csnt-accent, #1d4ed8 );
	outline-offset: 2px;
}

/* --------------------------------------------------------------------- */
/* Tabella cookie policy e pulsante inline                               */
/* --------------------------------------------------------------------- */

.csnt-policy__table {
	width: 100%;
	border-collapse: collapse;
	margin: 0 0 28px;
	font-size: 0.9rem;
}

.csnt-policy__table th,
.csnt-policy__table td {
	border: 1px solid rgba( 15, 23, 42, 0.14 );
	padding: 9px 12px;
	text-align: left;
	vertical-align: top;
}

.csnt-policy__table th {
	background: rgba( 15, 23, 42, 0.04 );
	font-weight: 650;
}

.csnt-policy__desc {
	margin: 0 0 10px;
	opacity: 0.8;
}

.csnt-link-button {
	appearance: none;
	background: none;
	border: 0;
	padding: 0;
	font: inherit;
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}

/* --------------------------------------------------------------------- */
/* Animazioni e responsive                                               */
/* --------------------------------------------------------------------- */

@keyframes csnt-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes csnt-rise {
	from {
		opacity: 0;
		transform: translateY( 12px );
	}
	to {
		opacity: 1;
		transform: translateY( 0 );
	}
}

.csnt-layout-center .csnt-banner {
	animation: csnt-fade 0.24s ease-out;
}

@media ( max-width: 600px ) {
	.csnt-layout-box .csnt-banner,
	.csnt-layout-center .csnt-banner {
		left: 8px;
		right: 8px;
		bottom: 8px;
		top: auto;
		width: auto;
		transform: none;
		max-height: 82vh;
		overflow-y: auto;
	}

	.csnt-banner__actions .csnt-btn {
		flex: 1 1 100%;
	}

	.csnt-modal__foot .csnt-btn {
		flex: 1 1 100%;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.csnt-banner,
	.csnt-modal__panel,
	.csnt-overlay,
	.csnt-switch__track,
	.csnt-switch__thumb,
	.csnt-btn,
	.csnt-badge {
		animation: none !important;
		transition: none !important;
	}
}

@media print {
	.csnt-root,
	.csnt-badge {
		display: none !important;
	}
}
