/* =========================================================
   LE GUIDE — Virgilio (cornice lime) e Beatrice (cornice oro).
   Stati (classi su .guida, gestite da js/core/guide.js):
     is-away      fuori scena
     is-entering  prima entrata: luce che nasce, poi la guida emerge
                  (Beatrice: scintille che si raccolgono)
     is-talking   fumetto aperto
     is-cenno     piccola reazione (nuovo dialogo, terrazza, pianeta)
     is-leaving   congedo: la guida si dissolve in luce
   Gesti legati a un momento del viaggio:
     is-sale      la salita: la guida si alza appena
     is-luce      la vetta: un momento di luce
     is-pronto    dopo la vetta: pronta a lasciare la scena
     is-avanti    l'epilogo: si avvicina al centro dell'attenzione
     is-discreta  dopo l'epilogo e il saluto: lascia spazio ai contatti
   ========================================================= */
.guida { --sz: 50px; position: fixed; left: 12px; bottom: 76px; z-index: 95; display: flex; align-items: flex-end; gap: 12px; pointer-events: none; transform-origin: left bottom; transition: opacity .6s, transform .7s var(--ease); }
.guida[hidden], .is-intro .guida { display: none; }
.guida.guida.is-away { opacity: 0; transform: translateY(14px); }   /* fuori scena vince su ogni gesto */
.guida.is-away * { pointer-events: none !important; }
.guida--virgilio { --frame: var(--accent); --frame-bg: #14160c; }
.guida--beatrice { --frame: var(--gold); --frame-bg: #1a1508; }

/* il personaggio */
.guida__sigil { position: relative; flex: none; width: var(--sz); height: var(--sz); padding: 0; border: 2.5px solid var(--frame); border-radius: 50%; background: var(--frame-bg); overflow: hidden; cursor: pointer; pointer-events: auto; box-shadow: 0 0 0 4px color-mix(in srgb, var(--frame) 16%, transparent), 0 6px 20px rgba(0, 0, 0, .5); transition: transform .4s var(--ease), box-shadow .4s; }
.guida__face { display: block; width: 100%; height: 100%; animation: guida-idle 6s ease-in-out infinite; transform-origin: 50% 100%; }
.guida__face .guida__eyes { transform-box: fill-box; transform-origin: center; animation: guida-blink 5.2s infinite; }
@keyframes guida-idle { 50% { transform: translateY(-1px) rotate(-1.2deg); } }
@keyframes guida-blink { 0%, 93%, 100% { transform: scaleY(1); } 96% { transform: scaleY(.1); } }
@media (hover: hover) {
  .guida__sigil:hover { transform: scale(1.06); box-shadow: 0 0 0 5px color-mix(in srgb, var(--frame) 26%, transparent), 0 0 26px color-mix(in srgb, var(--frame) 30%, transparent), 0 6px 20px rgba(0, 0, 0, .5); }
}
.guida__sigil:focus-visible { outline: 2px solid var(--frame); outline-offset: 4px; }

/* la luce dietro il personaggio: respira piano, si accende quando parla */
.guida__luce { position: absolute; left: 0; bottom: 0; width: var(--sz); height: var(--sz); border-radius: 50%; pointer-events: none; background: radial-gradient(circle, color-mix(in srgb, var(--frame) 55%, #fff) 0%, color-mix(in srgb, var(--frame) 30%, transparent) 34%, transparent 68%); opacity: .3; transform: scale(1.7); animation: guida-respiro 5.5s ease-in-out infinite alternate; }
.guida.is-talking .guida__luce { animation-name: guida-respiro-forte; animation-duration: 2.6s; }
@keyframes guida-respiro { from { opacity: .2; } to { opacity: .38; } }
@keyframes guida-respiro-forte { from { opacity: .34; } to { opacity: .55; } }

/* prima entrata — Virgilio: una piccola luce nasce, cresce, e lui emerge */
.guida.is-entering .guida__luce { animation: guida-luce-nasce 1.15s var(--ease) both; }
.guida.is-entering .guida__sigil { animation: guida-emerge .8s var(--ease) .5s both; }
@keyframes guida-luce-nasce {
  0% { opacity: 0; transform: scale(.08); }
  50% { opacity: 1; transform: scale(.75); }
  100% { opacity: .3; transform: scale(1.7); }
}
@keyframes guida-emerge {
  from { opacity: 0; transform: translateY(12px) scale(.94); filter: brightness(1.8); }
  to { opacity: 1; transform: none; filter: none; }
}

/* prima entrata — Beatrice: scintille che si raccolgono, luce più calda, lei emerge */
.guida__scintille { position: absolute; left: 0; bottom: 0; width: var(--sz); height: var(--sz); pointer-events: none; }
.guida__scintille i { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; border-radius: 50%; background: #fff6d6; box-shadow: 0 0 8px 2px rgba(255, 215, 106, .8); opacity: 0; }
.guida--beatrice.is-entering .guida__scintille i { animation: guida-scintilla 1.15s var(--ease) var(--d) both; }
.guida--beatrice.is-entering .guida__luce { animation: guida-luce-raccoglie 1.5s var(--ease) both; }
.guida--beatrice.is-entering .guida__sigil { animation: guida-emerge-b .9s var(--ease) .75s both; }
@keyframes guida-scintilla {
  0% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(.6); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translate(0, 0) scale(.2); }
}
@keyframes guida-luce-raccoglie {
  0%, 25% { opacity: 0; transform: scale(2.4); }
  65% { opacity: .9; transform: scale(1.1); }
  100% { opacity: .3; transform: scale(1.7); }
}
@keyframes guida-emerge-b {
  from { opacity: 0; transform: translateY(8px) scale(.9); filter: brightness(2) saturate(.6); }
  to { opacity: 1; transform: none; filter: none; }
}

/* piccola reazione: un nuovo dialogo, una terrazza, un pianeta */
.guida.is-cenno .guida__sigil { animation: guida-cenno .75s var(--ease); }
@keyframes guida-cenno { 40% { transform: scale(1.07); filter: brightness(1.12); } }

/* congedo: il fumetto si chiude, la guida sale appena e si dissolve in luce */
.guida.is-leaving .guida__sigil { animation: guida-dissolve 1.5s ease-in forwards; }
.guida.is-leaving .guida__luce { animation: guida-luce-svanisce 1.7s ease-out forwards; }
@keyframes guida-dissolve {
  0% { opacity: 1; transform: none; filter: none; }
  100% { opacity: 0; transform: translateY(-16px) scale(.94); filter: brightness(1.9) blur(3px); }
}
@keyframes guida-luce-svanisce {
  0% { opacity: .3; transform: scale(1.7); }
  40% { opacity: .85; transform: scale(1.25); }
  100% { opacity: 0; transform: translateY(-16px) scale(.3); }
}

/* gesti */
.guida.is-sale { transform: translateY(-10px); }
.guida.is-luce .guida__luce { animation: guida-lampo 1.4s var(--ease) both, guida-respiro-forte 2.6s ease-in-out 1.4s infinite alternate; }
@keyframes guida-lampo { 0% { opacity: .3; transform: scale(1.7); } 45% { opacity: .95; transform: scale(2.3); } 100% { opacity: .5; transform: scale(1.8); } }
.guida.is-pronto { opacity: .78; }
.guida.is-pronto .guida__luce { animation: none; opacity: .12; transition: opacity 1.2s; }
.guida.is-avanti { transform: translate(14px, -12px) scale(1.06); }
.guida.is-discreta { opacity: .62; transform: scale(.9); }
.guida.is-discreta:hover, .guida.is-discreta:focus-within { opacity: 1; }

/* il fumetto: scuro, bordo sottile con un filo di luce, una punta verso la guida */
.guida__bubble { position: relative; max-width: min(300px, calc(100vw - var(--sz) - 40px)); margin-bottom: 6px; padding: 11px 38px 12px 14px; border: 1px solid color-mix(in srgb, var(--frame) 38%, transparent); border-radius: 14px; background: rgba(11, 11, 15, .86); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 0 22px color-mix(in srgb, var(--frame) 12%, transparent), 0 10px 30px rgba(0, 0, 0, .5); pointer-events: none; opacity: 0; transform: translateY(8px); visibility: hidden; transition: opacity .4s, transform .45s var(--ease), visibility 0s .45s; }
.guida__bubble::before { content: ""; position: absolute; left: -6px; bottom: 16px; width: 10px; height: 10px; border-left: 1px solid color-mix(in srgb, var(--frame) 38%, transparent); border-bottom: 1px solid color-mix(in srgb, var(--frame) 38%, transparent); background: rgb(14, 14, 18); transform: rotate(45deg); }
.guida.is-talking .guida__bubble { opacity: 1; transform: none; visibility: visible; transition-delay: 0s; }
.guida__name { font-size: .66rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--frame); }
.guida__text { margin-top: 3px; font-family: var(--font-verse); font-style: italic; font-size: .95rem; line-height: 1.38; }
/* il testo compare parola per parola, in fretta: si legge con il proprio ritmo */
.guida__text .w { opacity: 0; animation: guida-parola .45s ease forwards; animation-delay: calc(140ms + var(--i) * 24ms); }
@keyframes guida-parola { to { opacity: 1; } }
.guida__x { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; pointer-events: auto; }
.guida__x:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.guida:not(.is-talking) .guida__x { pointer-events: none; }

@media (min-width: 768px) {
  .guida { --sz: 64px; left: 20px; bottom: 20px; }
  .guida__bubble { margin-bottom: 10px; }
  .guida__text { font-size: .98rem; }
}
@media (max-width: 767px) {
  .guida.is-sale { transform: translateY(-6px); }
  .guida.is-avanti { transform: translate(6px, -8px) scale(1.04); }
}

/* movimento ridotto: le guide compaiono e scompaiono con una dissolvenza, niente altro */
@media (prefers-reduced-motion: reduce) {
  .guida, .guida * { animation: none !important; }
  .guida__text .w { opacity: 1; }
  .guida.is-sale, .guida.is-avanti { transform: none; }
}
