/**
 * YIC Consent — front-end (banner + modale preferenze).
 * Mobile-first: base = mobile; desktop via min-width.
 * Accent: --yic-consent-accent (admin / filtro PHP).
 */

.yic-consent-banner,
.yic-consent-modal {
	--yic-accent: var(--yic-consent-accent, #63001b);
	--yic-accent-outline: #e0bfc0;
	--yic-ink: #1f1315;
	--yic-muted: #6b5a5d;
	--yic-surface: #ffffff;
	--yic-border: #ece0e1;
	box-sizing: border-box;
	font-family: inherit;
}

.yic-consent-banner *,
.yic-consent-modal * {
	box-sizing: border-box;
}

/* ---------- Banner (mobile base) ---------- */

.yic-consent-banner {
	position: fixed;
	z-index: 999998;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	justify-content: center;
	padding: 12px;
	padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
	padding-left: max(12px, env(safe-area-inset-left, 0px));
	padding-right: max(12px, env(safe-area-inset-right, 0px));
	pointer-events: none;
}

.yic-consent-banner[hidden] {
	display: none;
}

.yic-consent-wall {
	position: fixed;
	inset: 0;
	z-index: 999997;
	background: rgba(20, 10, 12, 0.45);
	backdrop-filter: blur(2px);
	pointer-events: auto;
}

.yic-consent-wall[hidden] {
	display: none;
}

html.yic-consent-wall-open {
	overflow: hidden;
}

.yic-consent-banner--wall {
	z-index: 999999;
}

.yic-consent-btn--link {
	background: transparent !important;
	border: 0 !important;
	color: var(--yic-muted) !important;
	text-decoration: underline;
	box-shadow: none !important;
	padding-left: 4px !important;
	padding-right: 4px !important;
	white-space: normal !important;
	flex: 1 1 100%;
	text-align: center;
}

.yic-consent-dns-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0.25em 0;
	padding: 10px 14px;
	border: 1px solid var(--yic-border, #ece0e1);
	border-radius: 10px;
	background: #fff;
	color: var(--yic-ink, #1f1315);
	cursor: pointer;
	font: inherit;
	max-width: 100%;
}

.yic-consent-banner__inner {
	pointer-events: auto;
	background: var(--yic-surface);
	color: var(--yic-ink);
	border: 1px solid var(--yic-border);
	border-radius: 14px;
	box-shadow: 0 12px 40px rgba(20, 8, 10, 0.18);
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 14px;
	padding: 16px;
	max-width: 1080px;
	width: 100%;
	animation: yic-consent-rise 0.35s ease-out;
}

.yic-consent-banner--box {
	justify-content: flex-end;
	align-items: stretch;
}

.yic-consent-banner--box .yic-consent-banner__inner {
	max-width: 100%;
	margin: 0;
}

@keyframes yic-consent-rise {
	from {
		opacity: 0;
		transform: translateY(16px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.yic-consent-banner__body {
	flex: 1 1 auto;
	min-width: 0;
}

.yic-consent-banner__title {
	margin: 0 0 4px;
	font-weight: 700;
	font-size: 15px;
	color: var(--yic-ink);
}

.yic-consent-banner__text {
	margin: 0;
	font-size: 13.5px;
	line-height: 1.5;
	color: var(--yic-muted);
}

.yic-consent-banner__link {
	color: var(--yic-accent);
	text-decoration: underline;
	font-weight: 600;
}

.yic-consent-banner__actions {
	flex: 0 0 auto;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: stretch;
}

.yic-consent-banner__actions .yic-consent-btn {
	flex: 1 1 calc(50% - 4px);
	text-align: center;
	min-width: 0;
}

.yic-consent-banner__actions .yic-consent-btn--ghost {
	flex: 1 1 100%;
	order: 3;
}

.yic-consent-banner__actions .yic-consent-btn--outline {
	order: 1;
}

.yic-consent-banner__actions .yic-consent-btn--solid {
	order: 2;
}

.yic-consent-banner__actions .yic-consent-btn--link {
	order: 4;
}

/* ---------- Bottoni ---------- */

.yic-consent-btn {
	appearance: none;
	border-radius: 999px;
	font-size: 13.5px;
	font-weight: 600;
	line-height: 1.2;
	padding: 12px 16px;
	cursor: pointer;
	white-space: normal;
	/* Solo proprietà composite: evita audit Lighthouse "animazioni non composte" (color/background). */
	transition: transform 0.15s ease, opacity 0.15s ease;
}

.yic-consent-btn:focus-visible {
	outline: 2px solid var(--yic-accent);
	outline-offset: 2px;
}

.yic-consent-btn--solid {
	background: var(--yic-accent);
	border: 1px solid var(--yic-accent);
	color: #fff;
}

.yic-consent-btn--solid:hover {
	transform: translateY(-1px);
	opacity: 0.96;
}

.yic-consent-btn--outline {
	background: transparent;
	border: 1px solid var(--yic-accent-outline);
	color: var(--yic-ink);
}

.yic-consent-btn--outline:hover {
	transform: translateY(-1px);
	opacity: 0.92;
}

.yic-consent-btn--ghost {
	background: transparent;
	border: 1px solid transparent;
	color: var(--yic-ink);
	text-decoration: underline;
	padding-left: 8px;
	padding-right: 8px;
	opacity: 0.78;
}

.yic-consent-btn--ghost:hover {
	opacity: 1;
}

/* ---------- Modale preferenze (mobile base) ---------- */

.yic-consent-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	align-items: flex-end;
	justify-content: center;
	padding: 0;
}

.yic-consent-modal.is-open {
	display: flex;
}

.yic-consent-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(24, 10, 12, 0.55);
	backdrop-filter: blur(2px);
}

.yic-consent-modal__panel {
	position: relative;
	background: var(--yic-surface);
	color: var(--yic-ink);
	border-radius: 16px 16px 0 0;
	max-width: 560px;
	width: 100%;
	max-height: min(92dvh, 92vh);
	display: flex;
	flex-direction: column;
	box-shadow: 0 24px 64px rgba(20, 8, 10, 0.3);
	animation: yic-consent-sheet 0.28s ease-out;
	padding-bottom: env(safe-area-inset-bottom, 0px);
}

@keyframes yic-consent-sheet {
	from {
		opacity: 0;
		transform: translateY(24px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.yic-consent-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 16px 14px;
	border-bottom: 1px solid var(--yic-border);
}

.yic-consent-modal__header h2 {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.3;
}

.yic-consent-modal__close {
	appearance: none;
	background: transparent;
	border: none;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	color: var(--yic-muted);
	padding: 4px 8px;
	border-radius: 8px;
	flex: 0 0 auto;
}

.yic-consent-modal__close:hover {
	color: var(--yic-ink);
	background: rgba(0, 0, 0, 0.05);
}

.yic-consent-modal__close:focus-visible {
	outline: 2px solid var(--yic-accent);
	outline-offset: 2px;
}

.yic-consent-modal__body {
	padding: 4px 16px 12px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
}

.yic-consent-category {
	padding: 14px 0;
	border-bottom: 1px solid var(--yic-border);
}

.yic-consent-category:last-child {
	border-bottom: none;
}

.yic-consent-category__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.yic-consent-category__label {
	font-weight: 600;
	font-size: 14px;
	min-width: 0;
}

.yic-consent-category__always {
	display: block;
	font-style: normal;
	font-weight: 400;
	font-size: 11.5px;
	color: var(--yic-muted);
	margin-top: 2px;
}

.yic-consent-category__desc {
	margin: 8px 0 0;
	font-size: 13px;
	line-height: 1.5;
	color: var(--yic-muted);
}

.yic-consent-toggle {
	position: relative;
	display: inline-flex;
	flex: 0 0 auto;
	cursor: pointer;
}

.yic-consent-toggle input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
}

/* Etichetta solo per screen reader: non dipendere dal tema per .screen-reader-text */
.yic-consent-toggle .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
}

.yic-consent-toggle__track {
	width: 42px;
	height: 24px;
	background: #d9cfd0;
	border-radius: 999px;
	position: relative;
	transition: background-color 0.2s ease;
	display: inline-block;
}

.yic-consent-toggle__thumb {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
	transition: transform 0.2s ease;
}

.yic-consent-toggle input:checked + .yic-consent-toggle__track {
	background: var(--yic-accent);
}

.yic-consent-toggle input:checked + .yic-consent-toggle__track .yic-consent-toggle__thumb {
	transform: translateX(18px);
}

.yic-consent-toggle input:disabled + .yic-consent-toggle__track {
	opacity: 0.55;
	cursor: not-allowed;
}

.yic-consent-toggle input:focus-visible + .yic-consent-toggle__track {
	outline: 2px solid var(--yic-accent);
	outline-offset: 2px;
}

.yic-consent-modal__footer {
	display: flex;
	flex-direction: column-reverse;
	gap: 8px;
	padding: 12px 16px 16px;
	border-top: 1px solid var(--yic-border);
}

.yic-consent-modal__footer .yic-consent-btn {
	width: 100%;
	text-align: center;
}

/* Bottone "Gestisci preferenze cookie" (shortcode) */

.yic-consent-manage-btn {
	appearance: none;
	background: transparent;
	border: 1px solid var(--yic-accent-outline, #e0bfc0);
	color: inherit;
	border-radius: 999px;
	padding: 10px 18px;
	font-size: max(13.5px, 0.84375rem); /* in pagina: segue il testo del sito, mai sotto il valore px */
	font-weight: 600;
	cursor: pointer;
	max-width: 100%;
}

.yic-consent-manage-btn:hover,
.yic-consent-manage-btn:focus {
	background: rgba(140, 5, 43, 0.08);
	border-color: var(--yic-accent, #8c052b);
	color: var(--yic-accent, #8c052b);
}

/* ---------- Tabella cookie (mobile = card) ---------- */

.yic-consent-cookies-table-wrap {
	margin: 1em 0;
	overflow: visible;
}

.yic-consent-cookies-table {
	width: 100%;
	border-collapse: collapse;
	font-size: max(14px, 0.875rem);
}

.yic-consent-cookies-table,
.yic-consent-cookies-table thead,
.yic-consent-cookies-table tbody,
.yic-consent-cookies-table tr,
.yic-consent-cookies-table th,
.yic-consent-cookies-table td {
	display: block;
	width: 100%;
}

.yic-consent-cookies-table thead {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	border: 0;
}

.yic-consent-cookies-table tbody {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.yic-consent-cookies-table tr {
	border: 1px solid #ece0e1;
	border-radius: 4px;
	padding: 12px 14px;
	background: #faf6f7;
}

.yic-consent-cookies-table td {
	display: grid;
	grid-template-columns: minmax(5.5rem, 32%) 1fr;
	gap: 6px 10px;
	padding: 6px 0;
	border: 0;
	border-bottom: 1px solid #ece0e1;
	text-align: left;
	vertical-align: top;
	word-break: break-word;
}

.yic-consent-cookies-table td:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.yic-consent-cookies-table td::before {
	content: attr(data-label);
	font-size: max(11px, 0.6875rem);
	font-weight: 700;
	letter-spacing: 0.03em;
	text-transform: uppercase;
	opacity: 0.7;
}

.yic-consent-cookies-table th {
	background: #faf6f7;
}

/* ---------- Placeholder iframe / embed ---------- */

.yic-consent-embed {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 180px;
	margin: 1rem 0;
	padding: 20px 16px;
	box-sizing: border-box;
	background:
		linear-gradient(180deg, rgba(140, 5, 43, 0.04), rgba(140, 5, 43, 0.08)),
		#faf6f7;
	border: 1px solid #ece0e1;
	border-radius: 14px;
	text-align: center;
}

.yic-consent-embed__card {
	max-width: 420px;
	width: 100%;
}

.yic-consent-embed__title {
	margin: 0 0 8px;
	font-size: max(15px, 0.9375rem);
	font-weight: 700;
	color: #1f1315;
}

.yic-consent-embed__text {
	margin: 0 0 16px;
	font-size: max(13.5px, 0.84375rem);
	line-height: 1.5;
	color: #6b5a5d;
}

.yic-consent-embed__actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.yic-consent-embed .yic-consent-btn {
	appearance: none;
	border-radius: 999px;
	font-size: max(13.5px, 0.84375rem);
	font-weight: 600;
	line-height: 1.2;
	padding: 12px 16px;
	cursor: pointer;
	width: 100%;
	text-align: center;
	white-space: normal;
}

.yic-consent-embed .yic-consent-btn--solid {
	background: var(--yic-consent-accent, #63001b);
	border: 1px solid var(--yic-consent-accent, #63001b);
	color: #fff;
}

.yic-consent-embed .yic-consent-btn--outline {
	background: transparent;
	border: 1px solid #e0bfc0;
	color: #1f1315;
}

.yic-consent-embed .yic-consent-btn:focus-visible {
	outline: 2px solid var(--yic-consent-accent, #63001b);
	outline-offset: 2px;
}

/* ---------- Desktop / tablet ---------- */

@media (min-width: 641px) {
	.yic-consent-banner {
		padding: 16px;
		padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
	}

	.yic-consent-banner__inner {
		flex-direction: row;
		align-items: center;
		gap: 20px;
		padding: 18px 22px;
	}

	.yic-consent-banner--box {
		justify-content: flex-start;
		padding: 16px 16px 20px 20px;
	}

	.yic-consent-banner--box .yic-consent-banner__inner {
		max-width: 420px;
		flex-direction: column;
		align-items: stretch;
		margin-right: auto;
	}

	.yic-consent-banner__actions {
		align-items: center;
	}

	.yic-consent-banner__actions .yic-consent-btn {
		flex: 0 0 auto;
		white-space: nowrap;
	}

	.yic-consent-banner__actions .yic-consent-btn--ghost,
	.yic-consent-banner__actions .yic-consent-btn--outline,
	.yic-consent-banner__actions .yic-consent-btn--solid,
	.yic-consent-banner__actions .yic-consent-btn--link {
		order: 0;
		flex: 0 0 auto;
	}

	.yic-consent-btn--link {
		flex: 0 0 auto;
		text-align: left;
	}

	.yic-consent-modal {
		align-items: center;
		padding: 20px;
	}

	.yic-consent-modal__panel {
		border-radius: 16px;
		max-height: min(640px, 90vh);
		animation-name: yic-consent-pop;
		padding-bottom: 0;
	}

	@keyframes yic-consent-pop {
		from {
			opacity: 0;
			transform: scale(0.97) translateY(6px);
		}
		to {
			opacity: 1;
			transform: scale(1) translateY(0);
		}
	}

	.yic-consent-modal__header {
		padding: 18px 22px;
	}

	.yic-consent-modal__header h2 {
		font-size: 17px;
	}

	.yic-consent-modal__body {
		padding: 6px 22px 18px;
	}

	.yic-consent-modal__footer {
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: flex-end;
		padding: 16px 22px;
	}

	.yic-consent-modal__footer .yic-consent-btn {
		width: auto;
	}

	.yic-consent-embed__actions {
		flex-direction: row;
		flex-wrap: wrap;
		justify-content: center;
	}

	.yic-consent-embed .yic-consent-btn {
		width: auto;
	}

	.yic-consent-cookies-table-wrap {
		overflow: hidden;
		border: 1px solid #ece0e1;
		border-radius: 4px;
	}

	.yic-consent-cookies-table {
		display: table;
	}

	.yic-consent-cookies-table thead {
		position: static;
		width: auto;
		height: auto;
		margin: 0;
		padding: 0;
		overflow: visible;
		clip: auto;
		display: table-header-group;
	}

	.yic-consent-cookies-table tbody {
		display: table-row-group;
	}

	.yic-consent-cookies-table tr {
		display: table-row;
		border: 0;
		border-radius: 0;
		padding: 0;
		background: transparent;
	}

	.yic-consent-cookies-table th,
	.yic-consent-cookies-table td {
		display: table-cell;
		width: auto;
		border: 1px solid #ece0e1;
		padding: 10px 12px;
		grid-template-columns: none;
	}

	.yic-consent-cookies-table td::before {
		content: none;
	}

	.yic-consent-cookies-table th {
		background: #faf6f7;
	}
}
