/* Stampino, la mascotte che passeggia in fondo alla pagina. Il JS lo sposta in orizzontale. */

.nz-pet { --pet: 104px; position: fixed; left: 0; bottom: 14px; z-index: 45; width: var(--pet); pointer-events: none; }
.nz-pet > * { pointer-events: auto; }
/* il pulsante "Assistenza" lascia il posto a Stampino (il link nel piede resta) */
.nz-pet-on .nz-help__toggle { display: none; }

.nz-pet__body { position: relative; display: block; width: var(--pet); height: var(--pet); padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.nz-pet__body:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 50%; }
.nz-pet__sprite { display: block; width: 100%; height: 100%; transform-origin: 50% 100%; }
.nz-pet__sprite img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 6px color-mix(in srgb, var(--ink-strong) 22%, transparent)); /* taste-skill-ignore: ombra del personaggio a terra */ }

/* fermo: respira piano; mentre parla saltella; quando dorme si abbassa */
@media (prefers-reduced-motion: no-preference) {
	.nz-pet:not(.is-walking):not(.is-sleeping) .nz-pet__sprite img { animation: nz-pet-breathe 2.6s ease-in-out infinite; }
	.nz-pet.is-talking:not(.is-walking) .nz-pet__sprite img { animation: nz-pet-hop 0.6s ease-in-out 2; }
	/* reazioni al mouse: piroetta e timidezza */
	.nz-pet.is-spin .nz-pet__sprite img { animation: nz-pet-spin 0.7s cubic-bezier(0.4, 0, 0.3, 1); }
	.nz-pet.is-shy .nz-pet__sprite img { animation: nz-pet-shy 0.9s ease-in-out; }
}
@keyframes nz-pet-breathe { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.03, 0.97); } }
@keyframes nz-pet-hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-10px) scale(0.98, 1.03); } }
@keyframes nz-pet-spin { 0% { transform: translateY(0) scaleX(1); } 25% { transform: translateY(-14px) scaleX(0.1); } 50% { transform: translateY(-18px) scaleX(-1); } 75% { transform: translateY(-14px) scaleX(-0.1); } 100% { transform: translateY(0) scaleX(1); } }
@keyframes nz-pet-shy { 0%, 100% { transform: scale(1, 1); } 30%, 70% { transform: translateY(5px) scale(1.06, 0.9); } }
html.nz-a-still .nz-pet__sprite img { animation: none !important; }

.nz-pet.is-sleeping .nz-pet__sprite { opacity: 0.92; }
.nz-pet__zzz { display: none; position: absolute; right: -4px; top: -6px; font: 800 16px/1 var(--font); color: var(--ink); letter-spacing: 0; }
.nz-pet__zzz i, .nz-pet__zzz b { font-style: normal; display: inline-block; }
.nz-pet__zzz i { font-size: 13px; transform: translate(2px, -8px); }
.nz-pet__zzz b { font-size: 10px; transform: translate(4px, -16px); }
.nz-pet.is-sleeping .nz-pet__zzz { display: block; }
@media (prefers-reduced-motion: no-preference) { .nz-pet.is-sleeping .nz-pet__zzz { animation: nz-pet-zzz 2.4s ease-in-out infinite; } }
@keyframes nz-pet-zzz { 0%, 100% { opacity: 0.4; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }

/* scontrino: esce dalla fessura di Stampino, si legge come una ricevuta e si strappa via */
/* larghezza fissa: il testo si stampa lettera per lettera, lo scontrino non deve allargarsi oltre il bordo */
.nz-pet__bubble { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); width: min(250px, calc(100vw - 24px)); cursor: pointer; }
.nz-pet__bubble[hidden] { display: none; }
.nz-tk {
	--zig: 7px;
	position: relative; padding: 12px 14px calc(12px + var(--zig)); color: var(--ink-strong);
	background:
		radial-gradient(circle at 50% calc(100% + 3px), transparent 4px, #fffcf4 4.5px) bottom / 10px var(--zig) repeat-x,
		linear-gradient(#fffcf4, #fffcf4) top / 100% calc(100% - var(--zig) + 1px) no-repeat;
	filter: drop-shadow(0 4px 6px color-mix(in srgb, var(--ink-strong) 20%, transparent)); /* taste-skill-ignore: un foglio sollevato */
	transform-origin: 50% 100%;
}
/* linea di strappo tratteggiata in cima, come le ricevute */
.nz-tk::before { content: ""; position: absolute; left: 10px; right: 10px; top: 5px; border-top: 1.5px dashed color-mix(in srgb, var(--ink) 55%, transparent); }
.nz-tk__head { display: flex; justify-content: space-between; gap: 12px; margin: 4px 0 6px; font: 700 10px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink); }
.nz-tk__text { margin: 0; font: 600 var(--step-small)/1.38 var(--font); text-align: left; min-height: 1.38em; }
.nz-tk__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nz-tk__go { display: inline-block; margin-top: 8px; padding: 5px 12px; border-radius: var(--r-pill); background: var(--ink); color: var(--bg) !important; font: 700 12px/1.2 var(--font); text-decoration: none; transform: rotate(-2deg); }
.nz-tk__go:hover { background: var(--ink-strong); }
.nz-tk__go[hidden] { display: none; }
@media (prefers-reduced-motion: no-preference) {
	.nz-pet__bubble .nz-tk { animation: nz-tk-print 520ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
	.nz-tk.is-torn { animation: nz-tk-tear 420ms cubic-bezier(0.5, 0, 0.8, 0.4) forwards; }
	.nz-tk__go:not([hidden]) { animation: nz-tk-stamp 380ms cubic-bezier(0.3, 1.6, 0.5, 1) both; }
}
/* sale fuori dalla fessura a scatti, come carta che avanza */
@keyframes nz-tk-print {
	0% { clip-path: inset(100% 0 0 0); transform: translateY(18px); }
	35% { clip-path: inset(60% 0 0 0); transform: translateY(10px); }
	55% { clip-path: inset(55% 0 0 0); transform: translateY(9px); }
	100% { clip-path: inset(0 0 0 0); transform: translateY(0); }
}
@keyframes nz-tk-tear { to { opacity: 0; transform: translate(26px, -34px) rotate(14deg) scale(0.9); } }
@keyframes nz-tk-stamp { from { opacity: 0; transform: rotate(-2deg) scale(1.6); } to { opacity: 1; transform: rotate(-2deg) scale(1); } }
/* il codino dello scontrino punta alla fessura */
.nz-pet__bubble::after { content: ""; position: absolute; left: calc(50% - var(--shift, 0px)); /* il codino resta sopra Stampino anche se lo scontrino si sposta */ top: calc(100% - 2px); width: 18px; height: 8px; margin-left: -9px; background: #fffcf4; clip-path: polygon(0 0, 100% 0, 60% 100%, 40% 100%); }

/* chat */
.nz-pet__chat {
	position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%);
	width: min(360px, calc(100vw - 24px)); max-height: min(560px, calc(100svh - 140px));
	display: flex; flex-direction: column; overflow: hidden;
	background: var(--bg); color: var(--text, var(--ink)); border: 2px solid var(--ink-strong); border-radius: var(--r-card);
	box-shadow: 0 18px 48px color-mix(in srgb, var(--ink-strong) 25%, transparent); /* taste-skill-ignore: finestra che si apre sopra la pagina */
}
.nz-pet__chat[hidden] { display: none; }
.nz-pet__head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; background: var(--surface); }
.nz-pet__head img { width: 40px; height: 40px; object-fit: contain; }
.nz-pet__title { flex: 1; margin: 0; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; color: var(--ink); }
.nz-pet__title span { display: block; font-size: var(--step-small); font-weight: 500; color: var(--muted); letter-spacing: 0; }
.nz-pet__close { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--ink-strong); cursor: pointer; }
.nz-pet__close:hover { background: var(--ink); color: var(--bg); }
.nz-pet__log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; font-size: var(--step-small); line-height: 1.4; }
.nz-tk--small { align-self: flex-start; max-width: 90%; --zig: 6px; padding: 10px 12px calc(10px + var(--zig)); filter: drop-shadow(0 2px 3px color-mix(in srgb, var(--ink-strong) 14%, transparent)); /* taste-skill-ignore: foglio */ }
.nz-tk--small .nz-tk__head { font-size: 9px; margin-top: 2px; }
.nz-tk--small .nz-tk__text { font-weight: 500; }
@media (prefers-reduced-motion: no-preference) { .nz-tk--small { animation: nz-tk-print 480ms cubic-bezier(0.2, 0.8, 0.2, 1) both; } }
/* le tue domande: un timbro rosso un po' storto */
.nz-pet__stamp {
	align-self: flex-end; max-width: 80%; padding: 7px 12px; border: 2px solid var(--ink); border-radius: 8px;
	color: var(--ink); font: 800 12px/1.25 var(--font); letter-spacing: 0.02em; text-transform: uppercase; transform: rotate(-2.5deg);
	background: color-mix(in srgb, var(--ink) 6%, transparent);
}
@media (prefers-reduced-motion: no-preference) { .nz-pet__stamp { animation: nz-tk-stamp-in 320ms cubic-bezier(0.3, 1.6, 0.5, 1) both; } }
@keyframes nz-tk-stamp-in { from { opacity: 0; transform: rotate(-2.5deg) scale(1.5); } to { opacity: 1; transform: rotate(-2.5deg) scale(1); } }
/* "stampa in corso" con tre puntini che saltellano */
.nz-pet__typing { align-self: flex-start; display: flex; align-items: center; gap: 4px; padding: 4px 2px; font: 700 10px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.nz-pet__typing span { margin-right: 4px; }
.nz-pet__typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
	.nz-pet__typing i { animation: nz-tk-dot 900ms ease-in-out infinite; }
	.nz-pet__typing i:nth-child(3) { animation-delay: 150ms; }
	.nz-pet__typing i:nth-child(4) { animation-delay: 300ms; }
}
@keyframes nz-tk-dot { 0%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-5px); opacity: 1; } }
.nz-pet__log { background: repeating-linear-gradient(transparent 0 27px, color-mix(in srgb, var(--ink) 7%, transparent) 27px 28px); }
.nz-pet__choices { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px 14px; border-top: 1.5px dashed color-mix(in srgb, var(--ink) 40%, transparent); }
.nz-pet__choice {
	display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: var(--r-pill);
	background: none; color: var(--ink); font: 600 13px/1.1 var(--font); text-decoration: none; cursor: pointer;
}
.nz-pet__choice:hover { background: var(--ink); color: var(--bg); }
.nz-pet__choice--ink { background: var(--ink); color: var(--bg); }
.nz-pet__choice--ink:hover { background: var(--ink-strong); border-color: var(--ink-strong); color: var(--bg); }
.nz-pet__choice--line { border-style: dashed; color: var(--muted); border-color: var(--muted); }

/* telefono: più piccolo; la chat diventa un foglio dal basso */
@media (max-width: 700px) {
	.nz-pet { --pet: 64px; bottom: 10px; }
	.nz-pet__chat { position: fixed; left: 8px; right: 8px; bottom: 84px; transform: none; width: auto; }
}

/* palpebre: coprono gli occhi "^ ^" della posa fermo per un attimo e lasciano una riga chiusa */
.nz-pet__sprite { position: relative; }
.nz-pet__lid { position: absolute; left: 34.5%; top: 35.5%; width: 11.5%; height: 7.5%; border-radius: 40%; background: #141414; opacity: 0; pointer-events: none; }
.nz-pet__lid--r { left: 54.5%; }
.nz-pet__lid::after { content: ""; position: absolute; left: 8%; right: 8%; top: 58%; height: 2px; border-radius: 2px; background: #f4f1ea; }
.nz-pet.is-blinking[data-pose="fermo"] .nz-pet__lid { opacity: 1; }

/* scia: impronte, gocce, ritagli e stelline che svaniscono */
.nz-pet-trail { position: fixed; left: 0; right: 0; bottom: 0; height: 0; z-index: 44; pointer-events: none; }
.nz-pet-p { position: fixed; display: block; pointer-events: none; }
.nz-pet-p--print { width: 12px; height: 6px; margin-left: -6px; border-radius: 50%; background: var(--ink); animation: nz-pet-print 1.8s ease-out forwards; }
.nz-pet-p--drop { width: 7px; height: 8px; margin-left: -3px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: var(--ink); animation: nz-pet-fly 1.1s cubic-bezier(0.3, 0.6, 0.5, 1) both; }
.nz-pet-p--paper { width: 7px; height: 9px; margin-left: -3px; background: var(--bg); border: 1.5px solid var(--ink-strong); border-radius: 1px; animation: nz-pet-fly 1.4s cubic-bezier(0.3, 0.6, 0.5, 1) both; }
.nz-pet-p--heart { width: 14px; height: 14px; margin-left: -7px; animation: nz-pet-fly 1.3s cubic-bezier(0.3, 0.6, 0.5, 1) both; }
.nz-pet-p--heart::before { content: "♥"; display: block; font: 16px/14px var(--font); color: var(--ink); text-align: center; }
.nz-pet-p--star { width: 10px; height: 10px; margin-left: -5px; background: var(--ink-strong); clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); animation: nz-pet-fly 1.2s cubic-bezier(0.3, 0.6, 0.5, 1) both; }
@keyframes nz-pet-print {
	0% { opacity: 0.7; transform: rotate(var(--r, 0deg)) scale(1.2, 0.9); }
	100% { opacity: 0; transform: rotate(var(--r, 0deg)) scale(0.6, 0.5); }
}
/* sale con una curva e ricade, girando e svanendo */
@keyframes nz-pet-fly {
	0% { opacity: 0; transform: translate(0, 0) rotate(0) scale(0.6); }
	12% { opacity: 1; }
	45% { transform: translate(calc(var(--dx, 0px) * 0.6), calc(var(--dy, 30px) * -1)) rotate(calc(var(--rot, 0deg) * 0.5)) scale(1); }
	100% { opacity: 0; transform: translate(var(--dx, 0px), calc(var(--dy, 30px) * -0.15)) rotate(var(--rot, 0deg)) scale(0.5); }
}
@media (prefers-reduced-motion: reduce) { .nz-pet-trail { display: none; } }
html.nz-a-still .nz-pet-trail { display: none; }

@media print { .nz-pet, .nz-pet-trail { display: none; } }
