/* prof.css — il «Prof» in piedi: pupazzetto 3D (figura Gemini scontornata) che cade dall'alto,
   si posa sul pulsante del chatbot e parla in un fumetto (bozza del 20/11/2026).
   Posizione calcolata da prof.js (--prof-destra, --prof-basso, --prof-alto); z 46: sopra il pulsante (45),
   sotto la testata (50) e l'avviso dimostrativo (70). */
.prof3d { position: fixed; z-index: 46; right: var(--prof-destra, 40px); bottom: var(--prof-basso, 64px);
  width: calc(var(--prof-alto, 150px) * .836); height: var(--prof-alto, 150px); pointer-events: none; }
.prof3d[hidden] { display: none; }

.prof3d-figura { position: absolute; inset: 0; margin: 0; padding: 0; border: 0; background: none; cursor: pointer;
  pointer-events: auto; perspective: 520px; -webkit-tap-highlight-color: transparent; }
.prof3d-figura:focus-visible { outline: 2px solid var(--accento, #C8B27C); outline-offset: 4px; border-radius: 12px; }
.prof3d-corpo { position: absolute; inset: 0; transform-origin: 50% 100%; transform-style: preserve-3d; }
.prof3d-corpo img { width: 100%; height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none;
  /* filo d'oro attorno alla sagoma: il blu del berretto e della veste non si perde nel fondo scuro */
  filter: drop-shadow(0 0 1px rgba(200, 178, 124, .9)) drop-shadow(0 0 10px rgba(200, 178, 124, .28));
  transition: transform .35s ease; transform: rotateY(var(--prof-gira, 0deg)) rotateX(var(--prof-china, 0deg)); }
.prof3d-ombra { position: absolute; left: 18%; right: 18%; bottom: -5px; height: 12px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, .7), rgba(0, 0, 0, 0)); transform-origin: 50% 50%; }

/* caduta: dall'alto dello schermo, con rotazione, schiacciamento all'urto e due rimbalzi */
.prof3d.cade .prof3d-corpo { animation: prof-cade 1.5s both; }
.prof3d.cade .prof3d-ombra { animation: prof-ombra 1.5s both; }
@keyframes prof-cade {
  0%   { transform: translateY(calc(-100vh - 120%)) rotate(-14deg); animation-timing-function: cubic-bezier(.5, 0, .9, .45); }
  56%  { transform: translateY(0) rotate(5deg) scale(1, 1); animation-timing-function: ease-out; }
  62%  { transform: translateY(0) rotate(2deg) scale(1.12, .8); animation-timing-function: ease-out; }
  74%  { transform: translateY(-18%) rotate(-3deg) scale(.96, 1.05); animation-timing-function: ease-in; }
  84%  { transform: translateY(0) rotate(1deg) scale(1.05, .93); animation-timing-function: ease-out; }
  92%  { transform: translateY(-4%) rotate(0) scale(.99, 1.01); animation-timing-function: ease-in; }
  100% { transform: none; }
}
@keyframes prof-ombra {
  0%, 30% { opacity: 0; transform: scale(.25); }
  56%  { opacity: 1; transform: scale(1.1); }
  74%  { opacity: .6; transform: scale(.8); }
  84%, 100% { opacity: 1; transform: scale(1); }
}
/* a terra: respira e dondola appena */
.prof3d.a-terra .prof3d-corpo { animation: prof-dondola 3.2s ease-in-out infinite alternate; }
@keyframes prof-dondola { from { transform: rotate(-1.6deg) scale(1, 1); } to { transform: rotate(1.6deg) scale(1, 1.015); } }
.prof3d.a-terra .prof3d-figura:hover .prof3d-corpo, .prof3d.a-terra .prof3d-figura:focus-visible .prof3d-corpo { animation: prof-salta .5s ease-out; }
@keyframes prof-salta { 0%, 100% { transform: none; } 40% { transform: translateY(-9%) scale(.97, 1.04); } 70% { transform: scale(1.04, .95); } }

/* ritiro: si rimpicciolisce dentro il ritratto del pulsante */
.prof3d.si-ritira .prof3d-corpo { animation: prof-ritira .55s ease-in both; }
.prof3d.si-ritira .prof3d-ombra { opacity: 0; transition: opacity .2s; }
@keyframes prof-ritira { to { transform: translateY(42%) scale(.3); opacity: 0; } }
.prof3d.via, .prof3d.via-prologo { opacity: 0; visibility: hidden; transition: opacity .25s, visibility 0s .25s; }

/* il fumetto, a sinistra del Prof */
.prof3d-fumetto { position: absolute; right: calc(100% + 10px); bottom: 42%; width: max-content;
  max-width: min(290px, calc(100vw - var(--prof-destra, 40px) - var(--prof-alto, 150px) * .836 - 30px));
  margin: 0; padding: 12px 34px 12px 15px; border: 1px solid var(--accento, #C8B27C); border-radius: 16px 16px 4px 16px;
  background: #F6F1E7; color: #1B2A4A; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  font: 400 .95rem/1.42 var(--font-testo, system-ui, sans-serif); pointer-events: auto; cursor: pointer;
  transform-origin: 100% 80%; opacity: 0; transform: scale(.6) translateY(10px); transition: opacity .25s ease, transform .35s cubic-bezier(.3, 1.5, .5, 1); }
.prof3d-fumetto::after { content: ""; position: absolute; right: -8px; bottom: 14px; width: 14px; height: 14px; background: #F6F1E7;
  border-right: 1px solid var(--accento, #C8B27C); border-top: 1px solid var(--accento, #C8B27C); transform: rotate(45deg); }
.prof3d-fumetto p { margin: 0; max-width: none; }
.prof3d-fumetto strong { display: block; margin-bottom: 2px; font-family: var(--font-titoli, serif); font-size: 1.02rem; color: #1B2A4A; }
.prof3d.parla .prof3d-fumetto { opacity: 1; transform: none; }
.prof3d-fumetto[hidden] { display: block; visibility: hidden; }
.prof3d-zitto { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: #1B2A4A; font-size: 1.15rem; line-height: 1; cursor: pointer; }
.prof3d-zitto:hover, .prof3d-zitto:focus-visible { background: rgba(27, 42, 74, .1); outline: none; }

/* «Deve essere oro chiusa, e poi scende Prof e ci si appoggia sopra» (Avvocato, 20/11): il pulsante non mostra
   la faccia prima della caduta (si capirebbe) né mentre il Prof ci sta sopra; il ritratto compare solo quando
   il Prof vi rientra. Regola senza classi d'attesa, così non c'è nemmeno un lampo del ritratto al caricamento. */
.cb-apri .cb-avatar-bottone { visibility: hidden; }
.prof3d-rientrato .cb-apri .cb-avatar-bottone { visibility: visible; }
.cb-aperto .prof3d { display: none; }

/* al telefono il fumetto sta sopra la testa, largo quanto lo schermo consente (meno righe, meno ingombro) */
@media (max-width: 480px) {
  .prof3d-fumetto { right: calc(12px - var(--prof-destra, 40px)); bottom: calc(100% + 4px); max-width: min(330px, calc(100vw - 24px));
    font-size: .88rem; padding: 10px 30px 10px 12px; border-radius: 16px; transform-origin: 70% 100%; }
  .prof3d-fumetto::after { right: calc(var(--prof-destra, 40px) - 12px + var(--prof-alto, 112px) * .418 - 7px); bottom: -8px;
    border-right: 1px solid var(--accento, #C8B27C); border-bottom: 1px solid var(--accento, #C8B27C); border-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .prof3d.cade .prof3d-corpo, .prof3d.cade .prof3d-ombra, .prof3d.a-terra .prof3d-corpo,
  .prof3d.a-terra .prof3d-figura:hover .prof3d-corpo, .prof3d.si-ritira .prof3d-corpo { animation: none; }
  .prof3d.cade { animation: prof-appare .4s ease both; }
  .prof3d.si-ritira { opacity: 0; transition: opacity .3s; }
  .prof3d-corpo img { transition: none; transform: none; }
  .prof3d-fumetto { transform: none; transition: opacity .3s; }
}
@keyframes prof-appare { from { opacity: 0; } to { opacity: 1; } }
@media print { .prof3d { display: none !important; } }
