/*
 * Thoty, la guida in chat. Colori dalla palette del sito (verde "bava-testo", fondo "piano",
 * fascia "materia"); il giallo è quello della mascotte, per il pallino e le scintille.
 */
.thoty {
	--thoty-verde: #10583a;
	--thoty-verde-scuro: #0b3f2a;
	--thoty-piano: #f2f5f3;
	--thoty-materia: #dcebdf;
	--thoty-fascia: #b6d2ba;
	--thoty-testo: #1b2420;
	--thoty-secondario: #5c6862;
	--thoty-filetto: #dde3df;
	--thoty-giallo: #f8b800;
	--thoty-bianco: #fff;
	position: fixed;
	right: max(16px, env(safe-area-inset-right));
	bottom: max(16px, env(safe-area-inset-bottom));
	z-index: 9990;
	font-family: Manrope, system-ui, sans-serif;
	font-size: 15px;
	line-height: 1.45;
	letter-spacing: normal;
	text-transform: none;
	text-align: left;
	color: var(--thoty-testo);
}

.thoty button,
.thoty a,
.thoty summary {
	touch-action: manipulation;
}

.thoty *,
.thoty *::before,
.thoty *::after {
	box-sizing: border-box;
}

.thoty [hidden] {
	display: none !important;
}

/* Lanciatore */
.thoty__lanciatore {
	position: relative;
	display: grid;
	place-items: center;
	width: 64px;
	height: 64px;
	padding: 0;
	border: 3px solid var(--thoty-bianco);
	border-radius: 50%;
	background: var(--thoty-verde);
	box-shadow: 0 6px 20px rgb(16 88 58 / 35%), 0 1px 3px rgb(0 0 0 / 20%);
	cursor: pointer;
}

@media (prefers-reduced-motion: no-preference) {
	.thoty__lanciatore {
		transition: transform 0.15s ease, background-color 0.15s ease;
	}
}

.thoty__lanciatore:hover {
	background: var(--thoty-verde-scuro);
	transform: translateY(-2px);
}

.thoty__lanciatore img {
	width: auto;
	height: 44px;
	pointer-events: none;
}

.thoty__pallino {
	position: absolute;
	top: -3px;
	right: -3px;
	width: 16px;
	height: 16px;
	border: 2px solid var(--thoty-bianco);
	border-radius: 50%;
	background: var(--thoty-giallo);
}

/* Focus: verde scuro sui fondi chiari (il giallo su bianco ha un contrasto di 1,8:1), giallo solo sul verde. */
.thoty button:focus-visible,
.thoty a:focus-visible,
.thoty input:focus-visible,
.thoty summary:focus-visible,
.thoty__nome:focus-visible {
	outline: 3px solid var(--thoty-verde-scuro);
	outline-offset: 2px;
}

.thoty__lanciatore:focus-visible {
	outline: 3px solid var(--thoty-verde-scuro);
	outline-offset: 4px;
	box-shadow: 0 0 0 7px var(--thoty-bianco), 0 6px 20px rgb(16 88 58 / 35%);
}

.thoty__testata :focus-visible {
	outline-color: var(--thoty-giallo);
}

/* Fumetto d'invito: a sinistra del lanciatore, con la coda verso di lui */
.thoty__invito {
	position: absolute;
	right: 76px;
	bottom: 10px;
	display: flex;
	align-items: flex-start;
	width: max-content;
	max-width: min(260px, calc(100vw - 110px));
	border-radius: 16px;
	background: var(--thoty-bianco);
	box-shadow: 0 8px 28px rgb(16 36 28 / 22%), 0 1px 4px rgb(0 0 0 / 12%);
}

.thoty__invito::after {
	content: "";
	position: absolute;
	right: -7px;
	bottom: 18px;
	width: 14px;
	height: 14px;
	background: var(--thoty-bianco);
	transform: rotate(45deg);
	border-radius: 2px;
}

.thoty__invito-testo {
	padding: 12px 4px 12px 14px;
	border: 0;
	background: none;
	font: inherit;
	font-size: 14px;
	color: var(--thoty-testo);
	text-align: left;
	cursor: pointer;
}

.thoty__invito-chiudi {
	display: grid;
	flex: none;
	place-items: center;
	width: 32px;
	height: 32px;
	margin: 2px 2px 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var(--thoty-secondario);
	cursor: pointer;
}

.thoty__invito-chiudi svg {
	width: 14px;
	height: 14px;
}

@media (prefers-reduced-motion: no-preference) {
	.thoty__invito {
		animation: thoty-sale 0.25s ease-out;
	}
}

/* Con Thoty in pagina, la freccia "torna su" sale sopra il lanciatore invece di coprirlo. */
body:has(#thoty) .thotale-torna-su {
	right: calc(max(16px, env(safe-area-inset-right)) + 8px);
	bottom: calc(max(16px, env(safe-area-inset-bottom)) + 76px);
}

@media (max-width: 480px) {
	body:has(#thoty) .thotale-torna-su {
		right: 17px;
		bottom: 82px;
	}
}

/* Pannello */
.thoty__pannello {
	position: absolute;
	right: 0;
	bottom: 78px;
	display: flex;
	flex-direction: column;
	width: min(390px, calc(100vw - 32px));
	height: min(640px, calc(100dvh - 120px));
	overflow: hidden;
	border-radius: 18px;
	background: var(--thoty-bianco);
	box-shadow: 0 18px 50px rgb(16 36 28 / 28%), 0 2px 8px rgb(0 0 0 / 12%);
}

@media (prefers-reduced-motion: no-preference) {
	.thoty__pannello:not([hidden]) {
		animation: thoty-sale 0.18s ease-out;
	}
}

@keyframes thoty-sale {
	from {
		opacity: 0;
		transform: translateY(10px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}

.thoty__testata {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px 10px 14px;
	background: var(--thoty-verde);
	color: var(--thoty-bianco);
}

.thoty__testata img {
	width: auto;
	height: 40px;
	flex: none;
}

.thoty__titoli {
	min-width: 0;
	flex: 1;
}

.thoty__nome {
	margin: 0;
	font-family: Fraunces, Georgia, serif;
	font-size: 20px;
	font-weight: 600;
	line-height: 1.1;
}

.thoty__sotto {
	margin: 2px 0 0;
	font-size: 12.5px;
	opacity: 0.85;
}

.thoty__comando {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: inherit;
	cursor: pointer;
}

.thoty__comando:hover {
	background: rgb(255 255 255 / 16%);
}

.thoty__comando svg {
	width: 18px;
	height: 18px;
}

/* Conversazione */
.thoty__log {
	flex: 1;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 14px 14px 8px;
	background: var(--thoty-bianco);
	scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
	.thoty__log {
		scroll-behavior: auto;
	}
}

.thoty__riga {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	margin: 0 0 10px;
}

.thoty__riga--utente {
	justify-content: flex-end;
}

.thoty__avatar {
	width: 34px;
	flex: none;
}

.thoty__avatar img {
	display: block;
	width: auto;
	height: 44px;
	margin-left: -4px;
}

.thoty__avatar--vuoto {
	height: 1px;
}

.thoty__bolla {
	max-width: 84%;
	padding: 10px 13px;
	border-radius: 16px 16px 16px 4px;
	background: var(--thoty-piano);
	overflow-wrap: anywhere;
}

.thoty__bolla p {
	margin: 0;
}

.thoty__bolla p + p {
	margin-top: 6px;
}

.thoty__riga--utente .thoty__bolla {
	border-radius: 16px 16px 4px 16px;
	background: var(--thoty-verde);
	color: var(--thoty-bianco);
}

.thoty__piccolo {
	font-size: 12.5px;
	color: var(--thoty-secondario);
}

.thoty__nota {
	margin-top: 8px;
	padding-left: 10px;
	border-left: 3px solid var(--thoty-giallo);
	font-size: 13.5px;
}

/* Pulsanti rapidi */
.thoty__scelte {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 12px 42px;
}

.thoty__scelte--elenco {
	flex-direction: column;
	align-items: stretch;
}

.thoty__scelta {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	padding: 9px 14px;
	border: 1px solid var(--thoty-fascia);
	border-radius: 999px;
	background: var(--thoty-materia);
	color: var(--thoty-testo);
	font: inherit;
	font-size: 14.5px;
	text-align: left;
	cursor: pointer;
	transition: background-color 0.12s ease;
}

.thoty__scelta:hover {
	background: var(--thoty-fascia);
}

.thoty__scelta[disabled] {
	opacity: 0.55;
	cursor: default;
}

.thoty__scelta svg {
	width: 22px;
	height: 22px;
	flex: none;
	color: var(--thoty-verde);
}

.thoty__scelta--link {
	text-decoration: none;
}

/* Scheda prodotto nella chat */
.thoty__scheda {
	margin: 0 0 12px 42px;
	padding: 12px 13px;
	border: 1px solid var(--thoty-filetto);
	border-radius: 14px;
	background: var(--thoty-bianco);
	box-shadow: 0 1px 4px rgb(16 36 28 / 8%);
}

.thoty__scheda-nome {
	margin: 0;
	font-family: Fraunces, Georgia, serif;
	font-size: 17px;
	font-weight: 600;
	line-height: 1.25;
}

.thoty__scheda-linea {
	margin: 2px 0 0;
	font-size: 13px;
	color: var(--thoty-secondario);
}

.thoty__scheda-contiene {
	margin: 8px 0 0;
	font-size: 13.5px;
}

.thoty__scheda-prezzo {
	margin: 8px 0 0;
	font-size: 13.5px;
	font-weight: 700;
}

.thoty__scheda-avviso {
	margin: 8px 0 0;
	padding: 6px 9px;
	border-radius: 8px;
	background: #fff6dc;
	font-size: 13px;
}

.thoty__scheda-azioni {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px;
}

.thoty__azione {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 8px 16px;
	border: 1px solid var(--thoty-verde);
	border-radius: 999px;
	background: var(--thoty-verde);
	color: var(--thoty-bianco);
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
}

.thoty__azione:hover {
	background: var(--thoty-verde-scuro);
	color: var(--thoty-bianco);
}

.thoty__azione--secondaria {
	background: var(--thoty-bianco);
	color: var(--thoty-verde);
}

.thoty__azione--secondaria:hover {
	background: var(--thoty-materia);
	color: var(--thoty-verde);
}

.thoty__scheda details {
	margin-top: 10px;
	font-size: 13px;
}

.thoty__scheda summary {
	display: flex;
	align-items: center;
	min-height: 44px;
	cursor: pointer;
	font-weight: 600;
	color: var(--thoty-verde);
}

.thoty__fuori {
	white-space: pre;
}

.thoty__errore {
	position: absolute;
	right: 0;
	bottom: 78px;
	width: min(320px, calc(100vw - 32px));
	margin: 0;
	box-shadow: 0 8px 30px rgb(0 0 0 / 20%);
	background: var(--thoty-piano);
}

.thoty__scheda details p {
	margin: 6px 0 0;
	color: var(--thoty-testo);
	overflow-wrap: anywhere;
}

/* Barra di scrittura */
.thoty__form {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px 12px;
	border-top: 1px solid var(--thoty-filetto);
	background: var(--thoty-bianco);
}

.thoty__campo {
	flex: 1;
	min-width: 0;
	padding: 10px 14px;
	border: 1px solid #8a958f;
	border-radius: 999px;
	background: var(--thoty-bianco);
	color: var(--thoty-testo);
	font: inherit;
	/* 16 px: sotto questa misura iOS ingrandisce la pagina quando si tocca il campo. */
	font-size: 16px;
}

.thoty__invia {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	flex: none;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--thoty-verde);
	color: var(--thoty-bianco);
	cursor: pointer;
}

.thoty__invia:hover {
	background: var(--thoty-verde-scuro);
}

.thoty__invia svg {
	width: 18px;
	height: 18px;
}

.thoty__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Schermi bassi (telefono in orizzontale, zoom alto): il pannello occupa tutta l'altezza disponibile */
@media (max-height: 520px) {
	.thoty__pannello {
		position: fixed;
		inset: 8px 8px 8px auto;
		width: min(390px, calc(100vw - 16px));
		height: auto;
	}

	.thoty__lanciatore {
		width: 52px;
		height: 52px;
	}
}

/* Telefoni: il pannello occupa la larghezza disponibile */
@media (max-width: 480px) {
	.thoty {
		right: 12px;
		bottom: 12px;
	}

	.thoty__pannello {
		right: -4px;
		width: calc(100vw - 16px);
		height: min(620px, calc(100dvh - 104px));
	}

	.thoty__lanciatore {
		width: 58px;
		height: 58px;
	}

	.thoty__lanciatore img {
		height: 40px;
	}

	.thoty__pannello {
		bottom: 70px;
	}
}

@media print {
	.thoty {
		display: none;
	}
}
