/**
 * Cookie Consent Manager — pannello di consenso, segnaposto e tabella della
 * cookie policy. I colori arrivano dalle variabili impostate dal pannello.
 */

:root {
	--ccm-bg: #ffffff;
	--ccm-text: #1f2933;
	--ccm-accent: #2563eb;
	--ccm-accent-text: #ffffff;
	--ccm-border: rgba(31, 41, 51, .14);
	--ccm-muted: rgba(31, 41, 51, .62);
	--ccm-font: Arial, Helvetica, sans-serif;
	--ccm-radius: 12px;
	--ccm-shadow: 0 18px 48px rgba(15, 23, 42, .22);
}

/* Blocca lo scorrimento del sito mentre il pannello è aperto. */
html.ccm-open,
html.ccm-open body {
	overflow: hidden;
}

.ccm-root[aria-hidden="true"] {
	display: none;
}

.ccm-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, .55);
	z-index: 99998;
}

.ccm-dialog {
	position: fixed;
	z-index: 99999;
	box-sizing: border-box;
	width: min(460px, calc(100vw - 32px));
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	padding: 22px 22px 18px;
	background: var(--ccm-bg);
	color: var(--ccm-text);
	border-radius: var(--ccm-radius);
	box-shadow: var(--ccm-shadow);
	font-size: 14px;
	line-height: 1.55;
	/*
	 * Font dichiarato, non ereditato: con 'inherit' il banner cambiava
	 * aspetto da tema a tema e finiva per usare caratteri pensati per i
	 * titoli, poco leggibili al corpo del testo di un banner.
	 */
	font-family: var(--ccm-font);
	-webkit-overflow-scrolling: touch;
}

.ccm-dialog *,
.ccm-dialog *::before,
.ccm-dialog *::after {
	box-sizing: border-box;
}

/* Posizioni */
.ccm-pos-bottom-left  { bottom: 16px; left: 16px; }
.ccm-pos-bottom-right { bottom: 16px; right: 16px; }
.ccm-pos-top-left     { top: 16px; left: 16px; }
.ccm-pos-top-right    { top: 16px; right: 16px; }

/* Layout a barra */
.ccm-layout-bar {
	width: calc(100vw - 32px);
	max-width: none;
	left: 16px;
	right: 16px;
}

/* Layout centrato */
.ccm-layout-center {
	top: 50%;
	left: 50%;
	bottom: auto;
	right: auto;
	transform: translate(-50%, -50%);
	width: min(560px, calc(100vw - 32px));
}

.ccm-close {
	font-family: var(--ccm-font);
	position: absolute;
	top: 8px;
	right: 10px;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--ccm-muted);
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	border-radius: 8px;
}

.ccm-close:hover,
.ccm-close:focus-visible {
	background: rgba(31, 41, 51, .08);
	color: var(--ccm-text);
}

.ccm-title {
	margin: 0 28px 8px 0;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.3;
	color: inherit;
}

.ccm-message {
	margin: 0 0 12px;
	color: inherit;
}

.ccm-links {
	margin: 0 0 14px;
	font-size: 13px;
}

.ccm-links a {
	color: var(--ccm-accent);
	text-decoration: underline;
}

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

.ccm-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: center;
	margin-top: 14px;
}

.ccm-btn {
	flex: 1 1 auto;
	min-height: 42px;
	padding: 10px 16px;
	border: 1px solid transparent;
	border-radius: 8px;
	font-family: var(--ccm-font);
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: filter .15s ease, background-color .15s ease;
}

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

.ccm-btn-primary {
	background: var(--ccm-accent);
	color: var(--ccm-accent-text);
}

.ccm-btn-primary:hover {
	filter: brightness(.94);
}

/*
 * Il rifiuto ha la stessa dimensione e la stessa evidenza dell'accettazione:
 * un "rifiuta" reso meno visibile del "accetta" rende il consenso non libero.
 */
.ccm-btn-deny {
	background: transparent;
	color: var(--ccm-text);
	border-color: var(--ccm-border);
}

.ccm-btn-deny:hover {
	background: rgba(31, 41, 51, .06);
}

.ccm-btn-link {
	flex: 0 0 auto;
	background: none;
	border: 0;
	color: var(--ccm-accent);
	font-weight: 600;
	text-decoration: underline;
	min-height: auto;
	padding: 10px 6px;
}

/* --- Categorie -------------------------------------------------------- */

.ccm-cats {
	margin: 4px 0 8px;
}

.ccm-cat {
	padding: 12px 0;
	border-top: 1px solid var(--ccm-border);
}

.ccm-cat:first-child {
	border-top: 0;
}

.ccm-cat-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.ccm-cat-label {
	font-weight: 700;
	cursor: pointer;
}

.ccm-cat-desc {
	margin: 4px 0 8px;
	font-size: 13px;
	color: var(--ccm-muted);
}

.ccm-always {
	flex: 0 0 auto;
	font-size: 12px;
	font-weight: 600;
	color: var(--ccm-muted);
	white-space: nowrap;
}

/* Interruttore */
.ccm-switch {
	position: relative;
	flex: 0 0 auto;
	display: inline-block;
	width: 42px;
	height: 24px;
}

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

.ccm-switch-track {
	position: absolute;
	inset: 0;
	background: rgba(31, 41, 51, .24);
	border-radius: 999px;
	transition: background-color .18s ease;
	pointer-events: none;
}

.ccm-switch-track::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	background: #fff;
	border-radius: 50%;
	box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
	transition: transform .18s ease;
}

.ccm-switch input:checked + .ccm-switch-track {
	background: var(--ccm-accent);
}

.ccm-switch input:checked + .ccm-switch-track::after {
	transform: translateX(18px);
}

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

/* --- Dettaglio dei servizi e dei cookie ------------------------------- */

.ccm-service {
	margin: 6px 0;
	border: 1px solid var(--ccm-border);
	border-radius: 8px;
	overflow: hidden;
}

.ccm-service > summary {
	padding: 8px 10px;
	font-size: 13px;
	cursor: pointer;
	list-style: none;
}

.ccm-service > summary::-webkit-details-marker {
	display: none;
}

.ccm-service > summary::before {
	content: "\25B8";
	display: inline-block;
	margin-right: 6px;
	color: var(--ccm-muted);
	transition: transform .15s ease;
}

.ccm-service[open] > summary::before {
	transform: rotate(90deg);
}

.ccm-dim {
	color: var(--ccm-muted);
	font-weight: 400;
}

.ccm-count {
	display: inline-block;
	min-width: 18px;
	padding: 0 5px;
	background: rgba(31, 41, 51, .1);
	border-radius: 999px;
	font-size: 11px;
	text-align: center;
}

.ccm-table-scroll {
	overflow-x: auto;
}

.ccm-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 12px;
}

.ccm-table th,
.ccm-table td {
	padding: 6px 10px;
	text-align: left;
	vertical-align: top;
	border-top: 1px solid var(--ccm-border);
}

.ccm-table th {
	font-weight: 600;
	color: var(--ccm-muted);
	white-space: nowrap;
}

.ccm-table code {
	font-size: 11px;
	background: rgba(31, 41, 51, .07);
	padding: 1px 4px;
	border-radius: 4px;
	word-break: break-all;
}

.ccm-note,
.ccm-empty,
.ccm-privacy {
	margin: 8px 10px;
	font-size: 12px;
	color: var(--ccm-muted);
}

.ccm-privacy a {
	color: var(--ccm-accent);
}

/* --- Pulsante flottante ---------------------------------------------- */

.ccm-toggle {
	position: fixed;
	z-index: 99990;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--ccm-accent);
	color: var(--ccm-accent-text);
	box-shadow: 0 6px 18px rgba(15, 23, 42, .26);
	cursor: pointer;
}

.ccm-toggle--bottom-left  { bottom: 16px; left: 16px; }
.ccm-toggle--bottom-right { bottom: 16px; right: 16px; }

.ccm-toggle:hover {
	filter: brightness(.94);
}

.ccm-toggle.ccm-is-hidden {
	display: none;
}

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

.ccm-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-height: 180px;
	padding: 24px 18px;
	background: rgba(31, 41, 51, .05);
	border: 1px dashed var(--ccm-border);
	border-radius: var(--ccm-radius);
	font-family: var(--ccm-font);
	text-align: center;
}

.ccm-placeholder-text {
	margin: 0;
	font-size: 14px;
	color: var(--ccm-muted);
}

.ccm-placeholder-btn {
	padding: 9px 16px;
	border: 0;
	border-radius: 8px;
	background: var(--ccm-accent);
	color: var(--ccm-accent-text);
	font-family: var(--ccm-font);
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
}

/* L'iframe bloccato non deve occupare spazio accanto al segnaposto. */
iframe[data-ccm-category][data-ccm-src] {
	display: none !important;
}

/* --- Tabella nella cookie policy ------------------------------------- */

.ccm-policy-title {
	margin: 1.6em 0 .3em;
}

.ccm-policy-desc {
	margin: 0 0 .8em;
	opacity: .8;
}

.ccm-policy-scroll {
	overflow-x: auto;
	margin-bottom: 1.4em;
}

.ccm-policy-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.ccm-policy-table th,
.ccm-policy-table td {
	padding: 8px 10px;
	text-align: left;
	vertical-align: top;
	border: 1px solid var(--ccm-border);
}

.ccm-policy-table th {
	background: rgba(31, 41, 51, .05);
	font-weight: 600;
	white-space: nowrap;
}

.ccm-policy-table code {
	word-break: break-all;
}

.ccm-policy-provider {
	font-size: 12px;
	opacity: .7;
}

.ccm-policy-sources {
	font-size: 13px;
	opacity: .8;
}

.ccm-open-prefs {
	padding: 9px 16px;
	border: 1px solid var(--ccm-border);
	border-radius: 8px;
	background: transparent;
	color: inherit;
	font-family: var(--ccm-font);
	font-size: 14px;
	cursor: pointer;
}

.ccm-open-prefs:hover {
	background: rgba(31, 41, 51, .06);
}

.ccm-status-line {
	margin: 0 0 .6em;
}

/* --- Schermi piccoli -------------------------------------------------- */

@media (max-width: 520px) {
	.ccm-dialog,
	.ccm-layout-bar,
	.ccm-layout-center {
		left: 8px;
		right: 8px;
		bottom: 8px;
		top: auto;
		transform: none;
		width: auto;
		max-height: calc(100vh - 16px);
		padding: 18px 16px 14px;
	}

	.ccm-actions .ccm-btn {
		flex: 1 1 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ccm-btn,
	.ccm-switch-track,
	.ccm-switch-track::after,
	.ccm-service > summary::before {
		transition: none;
	}
}
