/* ============================================================
   GERADORPIX — MASCOTE do PAINEL (pixel companion)
   Canto inferior ESQUERDO. Escopo isolado sob #gpix-mascote.
   Reaproveita os tokens do painel (styles.css / :root inline das
   páginas de auth): --bg-1, --txt-1, --pix-1/3, --muted, --ring.
   Adapta ao data-theme (dark E light). Estático em reduced-motion.
   ============================================================ */

#gpix-mascote {
  position: fixed;
  left: clamp(10px, 3vw, 20px);
  bottom: clamp(10px, 3vw, 20px);
  z-index: 850;                 /* acima do conteúdo, abaixo de modais (que o escondem) */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  pointer-events: none;         /* só filhos interativos captam clique */
  -webkit-user-select: none;
  user-select: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#gpix-mascote[hidden] { display: none; }

/* ---------------- Sprite (botão) ---------------- */
.gpix-masc__btn {
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  line-height: 0;
  border-radius: 8px;
}
.gpix-masc__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-0, #0b1012), 0 0 0 4px var(--pix-3, #00e0c6);
}
.gpix-masc__sprite {
  display: block;
  width: 60px;
  height: 60px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
  transform: translateZ(0);
  animation: gpix-masc-bob 3.4s cubic-bezier(0.33, 1, 0.68, 1) infinite;
}
@keyframes gpix-masc-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}

/* ---------------- Balão ---------------- */
.gpix-masc__bubble {
  pointer-events: none;
  position: relative;
  max-width: 240px;
  margin-bottom: 12px;
  padding: 11px 30px 12px 13px;
  background: var(--bg-1, #101619);
  color: var(--txt-1, #e6f6f3);
  border: 2px solid var(--pix-1, #00bfa5);
  border-radius: 12px;
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, 0.7),
              0 0 0 1px rgba(0, 224, 198, 0.12),
              inset 0 0 0 1px rgba(0, 224, 198, 0.06);
  font-size: 13.5px;
  line-height: 1.42;
  letter-spacing: 0.1px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px) scale(0.94);
  transform-origin: left bottom;
  transition: opacity 0.26s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0s linear 0.3s;
}
.gpix-masc__bubble.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity 0.26s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1),
              visibility 0s;
}
[data-theme="light"] .gpix-masc__bubble {
  background: var(--card-bg, #ffffff);
  color: var(--txt-1, #0a1a18);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.28),
              0 0 0 1px rgba(0, 191, 165, 0.14);
}

.gpix-masc__text { display: block; margin: 0; }

/* rabinho apontando pro mascote */
.gpix-masc__bubble::after {
  content: "";
  position: absolute;
  left: 20px;
  bottom: -9px;
  width: 14px;
  height: 14px;
  background: var(--bg-1, #101619);
  border-right: 2px solid var(--pix-1, #00bfa5);
  border-bottom: 2px solid var(--pix-1, #00bfa5);
  transform: rotate(45deg);
  border-bottom-right-radius: 3px;
}
[data-theme="light"] .gpix-masc__bubble::after { background: var(--card-bg, #ffffff); }

/* botão de fechar / mute */
.gpix-masc__close {
  pointer-events: auto;
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted, #8fb0aa);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.gpix-masc__close:hover { color: var(--txt-1, #ecfffb); background: rgba(0, 224, 198, 0.1); }
.gpix-masc__close:focus-visible {
  outline: none;
  color: var(--txt-1, #ecfffb);
  box-shadow: 0 0 0 2px var(--pix-3, #00e0c6);
}

/* ---------------- Mobile ---------------- */
@media (max-width: 560px) {
  #gpix-mascote { left: 10px; bottom: 10px; }
  .gpix-masc__sprite { width: 56px; height: 56px; }
  .gpix-masc__bubble {
    max-width: min(66vw, 220px);
    font-size: 12.5px;
    margin-bottom: 8px;
    padding: 10px 26px 10px 11px;
  }
}

/* ---------------- Desktop com sidebar fixa ----------------
   Nas páginas logadas a .sidebar é fixa (260px, left:0, z-index acima do
   mascote), então o mascote no canto inferior esquerdo ficava ESCONDIDO
   atrás dela em desktop (no mobile a sidebar é off-canvas, por isso aparece).
   A ≥901px, quando existe .sidebar na página, o mascote passa a viver DENTRO
   da área de conteúdo — logo à direita da sidebar. As páginas de auth
   (login/cadastro/recuperar) NÃO têm .sidebar → mantêm o left padrão. */
@media (min-width: 901px) {
  body:has(.sidebar) #gpix-mascote {
    left: calc(var(--sidebar-w, 260px) + 20px);
  }
}

/* ---------------- Reduced-motion / estático ---------------- */
@media (prefers-reduced-motion: reduce) {
  .gpix-masc__sprite { animation: none; }
  .gpix-masc__bubble,
  .gpix-masc__bubble.is-open {
    transition: opacity 0.12s linear, visibility 0s;
    transform: none !important;
  }
}
