/**
 * PCRT Cookie Consent — banner, preferenze, riquadri dei contenuti bloccati.
 * I colori arrivano dalle impostazioni come custom property sul contenitore
 * (#pcrtcookie). Si possono sovrascrivere anche dal CSS del tema:
 *   #pcrtcookie, .pcrtcookie-ph { --pcrtcookie-cta-bg: #0b4f8a; }
 */

.pcrtcookie,
.pcrtcookie-ph {
	--pcrtcookie-bg: #f5f5f3;
	--pcrtcookie-border: #dcdbd6;
	--pcrtcookie-heading: #161616;
	--pcrtcookie-text: #4a4a47;
	--pcrtcookie-accent: #1f5fd6;
	--pcrtcookie-cta-bg: #1f5fd6;
	--pcrtcookie-cta-text: #ffffff;
	--pcrtcookie-cta-hover: color-mix(in srgb, var(--pcrtcookie-cta-bg) 84%, #000);
	--pcrtcookie-radius: 8px;
	--pcrtcookie-btn-radius: 6px;
	--pcrtcookie-font: inherit;
	--pcrtcookie-shadow: 0 10px 34px rgba(17, 17, 17, .14), 0 2px 6px rgba(17, 17, 17, .06);
}

/* ---------- contenitore e posizione ---------- */

.pcrtcookie {
	position: fixed;
	z-index: 2147483000;
	bottom: 16px;
	left: 16px;
	width: min(420px, calc(100vw - 32px));
	font-family: var(--pcrtcookie-font);
	font-size: 15px;
	line-height: 1.5;
	color: var(--pcrtcookie-text);
	text-align: left;
	opacity: 0;
	transform: translateY(12px);
	transition: opacity .2s ease, transform .2s ease;
}

.pcrtcookie[hidden] { display: none; }
.pcrtcookie.is-visible { opacity: 1; transform: none; }
.pcrtcookie--box-right { left: auto; right: 16px; }

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

.pcrtcookie .pcrtcookie__card {
	/* difesa dai temi che stilano gli elementi in generale (es. section { min-height: 90vh; display: grid }) */
	display: block;
	float: none;
	width: auto;
	height: auto;
	min-height: 0;
	gap: 0;
	grid-template-columns: none;
	margin: 0;
	max-height: calc(100vh - 32px);
	max-height: calc(100dvh - 32px);
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 24px;
	background: var(--pcrtcookie-bg);
	border: 1px solid var(--pcrtcookie-border);
	border-radius: var(--pcrtcookie-radius);
	box-shadow: var(--pcrtcookie-shadow);
}

.pcrtcookie .pcrtcookie__card:focus,
.pcrtcookie .pcrtcookie__card:focus-visible { outline: none; } /* contenitore: il focus visibile è su pulsanti e link */

/* ---------- testi ---------- */

.pcrtcookie .pcrtcookie__eyebrow {
	margin: 0 0 8px;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: .18em;
	text-transform: uppercase;
	color: var(--pcrtcookie-accent);
}

.pcrtcookie .pcrtcookie__title {
	margin: 0 0 8px;
	padding: 0;
	font-family: inherit;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: 0;
	text-transform: none;
	color: var(--pcrtcookie-heading);
}

.pcrtcookie .pcrtcookie__text {
	margin: 0;
	font-size: 14px;
	line-height: 1.7;
	color: var(--pcrtcookie-text);
}

.pcrtcookie a {
	color: var(--pcrtcookie-heading);
	text-decoration: underline;
	text-decoration-color: var(--pcrtcookie-accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

.pcrtcookie a:hover { color: var(--pcrtcookie-accent); }

/* ---------- pulsanti ---------- */

.pcrtcookie .pcrtcookie__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px;
	margin-top: 20px;
}

.pcrtcookie .pcrtcookie__btn, .pcrtcookie-ph .pcrtcookie__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 40px;
	margin: 0;
	padding: 8px 18px;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	text-transform: none;
	letter-spacing: 0;
	border: 1px solid transparent;
	border-radius: var(--pcrtcookie-btn-radius);
	cursor: pointer;
	box-shadow: none;
	transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

/*
 * Colori dei pulsanti: selettori con il contenitore e !important solo sui colori.
 * Molti temi azzerano lo sfondo dei pulsanti (es. reset di Tailwind:
 * [type='button'] { background-color: transparent }) e, caricati dopo,
 * vincerebbero su una regola di pari peso lasciando la CTA trasparente.
 */
.pcrtcookie .pcrtcookie__btn--primary,
.pcrtcookie-ph .pcrtcookie__btn--primary,
.pcrtcookie.pcrtcookie--sec-filled .pcrtcookie__btn--secondary {
	background-color: var(--pcrtcookie-cta-bg) !important;
	background-image: none !important;
	border-color: var(--pcrtcookie-cta-bg) !important;
	color: var(--pcrtcookie-cta-text) !important;
}

.pcrtcookie .pcrtcookie__btn--primary:hover,
.pcrtcookie-ph .pcrtcookie__btn--primary:hover,
.pcrtcookie.pcrtcookie--sec-filled .pcrtcookie__btn--secondary:hover {
	background-color: var(--pcrtcookie-cta-hover) !important;
	border-color: var(--pcrtcookie-cta-hover) !important;
	color: var(--pcrtcookie-cta-text) !important;
}

/* browser senza color-mix() (Safari < 16.2, Firefox < 113): hover più scuro con filter */
@supports not (color: color-mix(in srgb, red 50%, blue)) {
	.pcrtcookie .pcrtcookie__btn--primary:hover,
.pcrtcookie-ph .pcrtcookie__btn--primary:hover,
.pcrtcookie.pcrtcookie--sec-filled .pcrtcookie__btn--secondary:hover {
		background-color: var(--pcrtcookie-cta-bg) !important;
		border-color: var(--pcrtcookie-cta-bg) !important;
		filter: brightness(.88);
	}
}

/* «Solo necessari»: contorno (predefinito) o pieno come «Accetta tutto» (sopra) */
.pcrtcookie.pcrtcookie--sec-outline .pcrtcookie__btn--secondary {
	background-color: transparent !important;
	background-image: none !important;
	border-color: var(--pcrtcookie-border) !important;
	color: var(--pcrtcookie-heading) !important;
}

.pcrtcookie.pcrtcookie--sec-outline .pcrtcookie__btn--secondary:hover {
	background-color: rgba(0, 0, 0, .03) !important;
	border-color: var(--pcrtcookie-heading) !important;
}

.pcrtcookie .pcrtcookie__btn--block, .pcrtcookie-ph .pcrtcookie__btn--block { width: 100%; }

.pcrtcookie .pcrtcookie__link, .pcrtcookie-ph .pcrtcookie__link {
	min-height: 40px;
	margin: 0;
	padding: 8px 6px;
	font: inherit;
	font-size: 14px;
	line-height: 1.2;
	text-transform: none;
	letter-spacing: 0;
	color: var(--pcrtcookie-text);
	background: none;
	border: 0;
	border-radius: var(--pcrtcookie-btn-radius);
	text-decoration: underline;
	text-decoration-color: currentColor;
	text-decoration-thickness: 1px;
	text-underline-offset: 4px;
	cursor: pointer;
	box-shadow: none;
}

.pcrtcookie .pcrtcookie__link,
.pcrtcookie-ph .pcrtcookie__link {
	background-color: transparent !important;
	background-image: none !important;
	color: var(--pcrtcookie-text) !important;
}

.pcrtcookie .pcrtcookie__link:hover,
.pcrtcookie-ph .pcrtcookie__link:hover { color: var(--pcrtcookie-accent) !important; }
.pcrtcookie .pcrtcookie__link[aria-expanded="true"] { color: var(--pcrtcookie-heading) !important; }

.pcrtcookie .pcrtcookie__btn:focus-visible,
.pcrtcookie-ph .pcrtcookie__btn:focus-visible,
.pcrtcookie .pcrtcookie__link:focus-visible,
.pcrtcookie-ph .pcrtcookie__link:focus-visible,
.pcrtcookie a:focus-visible,
.pcrtcookie .pcrtcookie__switch:focus-visible,
.pcrtcookie-footer-link:focus-visible {
	outline: 2px solid var(--pcrtcookie-accent, #1f5fd6);
	outline-offset: 2px;
}

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

.pcrtcookie .pcrtcookie__prefs {
	margin-top: 20px;
	padding-top: 4px;
	border-top: 1px solid var(--pcrtcookie-border);
}

.pcrtcookie .pcrtcookie__prefs[hidden] { display: none; }

.pcrtcookie .pcrtcookie__cats {
	margin: 0;
	padding: 0;
	list-style: none;
}

.pcrtcookie .pcrtcookie__cat {
	margin: 0;
	padding: 14px 0;
	border-bottom: 1px solid var(--pcrtcookie-border);
}

.pcrtcookie .pcrtcookie__cat-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.pcrtcookie .pcrtcookie__cat-name {
	margin: 0;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.3;
	color: var(--pcrtcookie-heading);
	cursor: pointer;
}

.pcrtcookie .pcrtcookie__cat-desc {
	margin: 4px 0 0;
	padding-right: 60px;
	font-size: 13px;
	line-height: 1.55;
	color: var(--pcrtcookie-text);
}

/* interruttore: checkbox nativo (role="switch") ridisegnato */
.pcrtcookie .pcrtcookie__switch {
	-webkit-appearance: none;
	appearance: none;
	flex: 0 0 auto;
	position: relative;
	width: 44px;
	height: 24px;
	margin: 0;
	border: 0;
	border-radius: 999px;
	background: #8a8a86;
	cursor: pointer;
	transition: background-color .15s ease;
}

.pcrtcookie .pcrtcookie__switch::before {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
	transition: transform .15s ease;
}

.pcrtcookie .pcrtcookie__switch:checked { background: var(--pcrtcookie-accent); }
.pcrtcookie .pcrtcookie__switch:checked::before { transform: translateX(20px); }
.pcrtcookie .pcrtcookie__switch:disabled { cursor: not-allowed; opacity: .5; }

.pcrtcookie .pcrtcookie__prefs .pcrtcookie__btn--block { margin-top: 20px; }

.pcrtcookie .pcrtcookie__policy {
	margin: 14px 0 0;
	font-size: 14px;
	line-height: 1.4;
}

.pcrtcookie .pcrtcookie__policy a {
	color: var(--pcrtcookie-text);
	text-decoration-color: currentColor;
}

/* solo per gli screen reader */
.pcrtcookie__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;
}

/* ---------- barra in basso (desktop) ---------- */

@media (min-width: 900px) {
	.pcrtcookie--bar {
		left: 0;
		right: 0;
		bottom: 0;
		width: auto;
	}

	.pcrtcookie--bar .pcrtcookie__card {
		border-width: 1px 0 0;
		border-radius: 0;
		padding: 20px max(24px, calc((100vw - 1200px) / 2));
		max-height: 85vh;
	}

	.pcrtcookie--bar .pcrtcookie__inner {
		display: flex;
		align-items: center;
		gap: 32px;
	}

	.pcrtcookie--bar .pcrtcookie__intro { flex: 1 1 auto; max-width: 760px; }
	.pcrtcookie--bar .pcrtcookie__actions { flex: 0 0 auto; margin-top: 0; flex-wrap: nowrap; }

	.pcrtcookie--bar .pcrtcookie__prefs { max-width: 760px; }
}

/* ---------- mobile: foglio in basso a tutta larghezza ---------- */

@media (max-width: 599px) {
	.pcrtcookie,
.pcrtcookie--box-right,
.pcrtcookie--bar {
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
	}

	.pcrtcookie .pcrtcookie__card {
		max-height: 85vh;
		max-height: 85dvh;
		padding: 20px 16px calc(16px + env(safe-area-inset-bottom, 0px));
		border-width: 1px 0 0;
		border-radius: 14px 14px 0 0;
	}

	.pcrtcookie .pcrtcookie__actions {
		display: grid;
		grid-template-columns: 1fr;
		gap: 8px;
	}

	.pcrtcookie .pcrtcookie__btn, .pcrtcookie-ph .pcrtcookie__btn { min-height: 48px; width: 100%; }
	.pcrtcookie .pcrtcookie__link, .pcrtcookie-ph .pcrtcookie__link { min-height: 44px; justify-self: center; }
	.pcrtcookie .pcrtcookie__cat-desc { padding-right: 0; }
}

/* ---------- anteprima nel back end ---------- */

.pcrtcookie--preview {
	position: static;
	width: 100%;
	max-width: 420px;
	opacity: 1;
	transform: none;
}

.pcrtcookie--preview.pcrtcookie--bar { max-width: 100%; }
.pcrtcookie--preview .pcrtcookie__card { max-height: none; }

/* ---------- riquadro al posto di video e mappe ---------- */

.pcrtcookie-ph {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	width: 100%;
	min-height: 200px;
	margin: 0 0 1em;
	padding: 24px;
	font-family: var(--pcrtcookie-font);
	text-align: center;
	color: var(--pcrtcookie-text);
	background: var(--pcrtcookie-bg);
	border: 1px solid var(--pcrtcookie-border);
	border-radius: var(--pcrtcookie-radius);
}

.pcrtcookie-ph p {
	max-width: 46ch;
	margin: 0;
	font-size: 14px;
	line-height: 1.6;
}

.pcrtcookie-ph__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
}

/* ---------- link «Preferenze cookie» aggiunto nel footer ---------- */

.pcrtcookie-footer { margin: 12px 0 0; text-align: center; font-size: 14px; }
.pcrtcookie-footer-link { cursor: pointer; }

/* ---------- movimento ridotto ---------- */

@media (prefers-reduced-motion: reduce) {
	.pcrtcookie,
.pcrtcookie .pcrtcookie__switch,
.pcrtcookie .pcrtcookie__switch::before,
.pcrtcookie .pcrtcookie__btn,
.pcrtcookie-ph .pcrtcookie__btn { transition: none; }
	.pcrtcookie { transform: none; }
}
