/* ---------- Avatar disegnato animato ---------- */
.pf-hero-skin { justify-content: center; }
.pf-avatar { position: relative; z-index: 1; aspect-ratio: 1; }
.pf-avatar--hero { width: min(100%, 470px, 66vh); margin-bottom: 38px; }
.pf-avatar--contact { width: min(300px, 60vw, 42vh); }
.pf-avatar-float { width: 100%; height: 100%; animation: pf-av-float 5s ease-in-out infinite; }
.pf-avatar-tilt { width: 100%; height: 100%; will-change: transform; }
.pf-avatar-bounce { position: relative; width: 100%; height: 100%; cursor: pointer; outline-offset: 6px; }
.pf-avatar-bounce-on { animation: pf-av-bounce 0.65s cubic-bezier(0.34, 1.56, 0.64, 1); }
.pf-avatar-frame { position: absolute; inset: 0; overflow: hidden; background: #942b2f; border: 6px solid #fff; border-radius: 38% 62% 56% 44% / 44% 42% 58% 56%; box-shadow: 0 34px 60px -22px rgba(var(--shadow-rgb), 0.6), 0 0 0 2px rgba(var(--acc-rgb), 0.35); animation: pf-av-morph 10s ease-in-out infinite; }
.pf-avatar-img { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.pf-avatar-face, .pf-avatar-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.pf-avatar-breathe-mouth { transform-box: fill-box; transform-origin: center; animation: pf-av-breath 2.2s ease-in-out infinite; }
.pf-fx-rise, .pf-fx-twinkle, .pf-fx-pop { transform-box: fill-box; transform-origin: center; animation-fill-mode: both; opacity: 0; }
.pf-fx-rise { animation-name: pf-fx-rise; animation-duration: 2.4s; animation-timing-function: ease-out; }
.pf-fx-twinkle { animation-name: pf-fx-twinkle; animation-duration: 2s; animation-timing-function: ease-in-out; }
.pf-fx-pop { animation-name: pf-fx-pop; animation-duration: 2.2s; animation-timing-function: ease-out; }
@keyframes pf-av-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes pf-av-morph {
  0%, 100% { border-radius: 38% 62% 56% 44% / 44% 42% 58% 56%; }
  33% { border-radius: 52% 48% 40% 60% / 56% 44% 56% 44%; }
  66% { border-radius: 44% 56% 62% 38% / 40% 58% 42% 60%; }
}
@keyframes pf-av-bounce { 0% { transform: scale(1); } 30% { transform: scale(0.93, 1.06); } 60% { transform: scale(1.05, 0.96); } 100% { transform: scale(1); } }
@keyframes pf-av-breath { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.4); } }
@keyframes pf-fx-rise { 0% { opacity: 0; transform: translateY(20px) scale(0.4); } 25% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-54px) scale(1.1); } }
@keyframes pf-fx-twinkle { 0% { opacity: 0; transform: scale(0) rotate(0); } 30% { opacity: 1; transform: scale(1.15) rotate(45deg); } 65% { opacity: 1; transform: scale(0.85) rotate(90deg); } 100% { opacity: 0; transform: scale(0) rotate(180deg); } }
@keyframes pf-fx-pop { 0% { opacity: 0; transform: scale(0.3) rotate(-15deg); } 22% { opacity: 1; transform: scale(1.25) rotate(6deg); } 40% { transform: scale(1) rotate(0); } 82% { opacity: 1; } 100% { opacity: 0; transform: scale(0.9) translateY(-14px); } }
/* alone e ombra dietro l'avatar: centrati e sincronizzati con il movimento */
.pf-skin-halo { top: 50%; left: 50%; width: min(520px, 90%); height: auto; aspect-ratio: 1; margin-top: -19px; animation: pf-av-halo 5s ease-in-out infinite; }
@keyframes pf-av-halo { 0%, 100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } }
.pf-hero-skin-ground { bottom: 12px; width: 240px; animation: pf-av-ground 5s ease-in-out infinite; }
@keyframes pf-av-ground { 0%, 100% { opacity: 0.9; transform: scaleX(1); } 50% { opacity: 0.5; transform: scaleX(0.82); } }

@media (prefers-reduced-motion: reduce) {
  .pf-avatar-float, .pf-avatar-frame, .pf-avatar-breathe-mouth, .pf-skin-halo, .pf-hero-skin-ground { animation: none !important; }
  .pf-skin-halo { transform: translate(-50%, -50%); }
}

/* Contatti: sfondo quasi opaco per leggere bene, avatar più grande */
.pf-contact-bg { background: radial-gradient(ellipse 900px 700px at 50% 40%, rgba(var(--acc-rgb), 0.16), rgba(var(--bg-rgb), 0.97) 75%), rgba(var(--bg-rgb), 0.96); }
.pf-avatar--contact { width: min(380px, 60vw, 52vh); }

/* ---- Avatar a mezzo busto, senza cornice ---- */
.pf-avatar-frame { background: none !important; border: none !important; border-radius: 0 !important; box-shadow: none !important; animation: none !important; overflow: visible !important; -webkit-mask-image: linear-gradient(#000 82%, transparent 100%); mask-image: linear-gradient(#000 82%, transparent 100%); }
.pf-avatar-img { object-fit: contain; }
@keyframes pf-av-sway { 0%, 100% { transform: translateY(0) rotate(-1.6deg); } 50% { transform: translateY(-9px) rotate(1.6deg); } }
.pf-avatar-float { transform-origin: 50% 100%; animation: pf-av-sway 6s ease-in-out infinite; }
.pf-avatar--hero { margin-bottom: 14px; width: min(100%, 520px, 70vh); }
.pf-avatar--mini { width: 100%; }
/* ---- Compagno che ti segue ---- */
.pf-comp { position: fixed; left: 0; bottom: 0; z-index: 45; width: clamp(92px, 12vw, 150px); transition: transform 0.95s cubic-bezier(0.16, 1, 0.3, 1); will-change: transform; pointer-events: none; }
.pf-comp .pf-avatar { pointer-events: auto; }
.pf-comp-bubble { position: absolute; bottom: 86%; width: max-content; max-width: 220px; padding: 10px 14px; font: 500 13px/1.35 'Inter', sans-serif; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 14px 30px -12px rgba(var(--shadow-rgb), 0.5); opacity: 0; transform: translateY(8px) scale(0.9); transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); pointer-events: none; }
.pf-comp-bubble.show { opacity: 1; transform: none; pointer-events: auto; }
.pf-comp--l .pf-comp-bubble { left: 58%; transform-origin: 0 100%; border-bottom-left-radius: 4px; }
.pf-comp--r .pf-comp-bubble { right: 58%; transform-origin: 100% 100%; border-bottom-right-radius: 4px; }
/* ---- Switcher tema ---- */
.pf-theme-btn { width: 40px; height: 40px; flex-shrink: 0; margin-left: 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s, color 0.3s; }
.pf-theme-btn:hover { transform: rotate(25deg) scale(1.08); background: var(--green); color: #fff; }
.pf-theme-btn svg { animation: pf-theme-spin 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes pf-theme-spin { from { transform: rotate(-120deg) scale(0.4); opacity: 0; } to { transform: none; opacity: 1; } }
html.pf-theme-anim *, html.pf-theme-anim *::before, html.pf-theme-anim *::after { transition: background-color 0.45s ease, color 0.45s ease, border-color 0.45s ease !important; }

@media (prefers-reduced-motion: reduce) { .pf-avatar-float { animation: none !important; } }
