/* ============================================================
   GERADORPIX — WIDGET DO MASCOTE (pixel companion)
   Canto inferior ESQUERDO (Chatwoot ocupa o direito).
   Escopo isolado sob #gpix-mascote — não toca arcade.css.
   Tokens reaproveitados do :root do site (--bg2, --glow, etc.)
   ============================================================ */

#gpix-mascote {
  position: fixed;
  left: clamp(12px, 3vw, 22px);
  bottom: clamp(12px, 3vw, 22px);
  z-index: 900;                 /* abaixo do header (999) e dos modais (1000) */
  display: flex;
  flex-direction: column;
  align-items: flex-start;      /* balão em cima, mascote embaixo */
  pointer-events: none;         /* só os filhos interativos captam clique */
  font-family: var(--font-body, system-ui, -apple-system, sans-serif);
  -webkit-user-select: none;
  user-select: none;
}

#gpix-mascote[hidden] { display: none; }
#gpix-mascote.gpix-mascote--control-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ---------------- Sprite ---------------- */
.gpix-masc__btn {
  pointer-events: auto;
  appearance: none;
  -webkit-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(--bg0, #050a0c), 0 0 0 4px var(--glow, #00e0c6);
}

.gpix-masc__sprite {
  display: block;
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
  /* base subtle drop shadow so it sits on the page */
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45));
  transform: translateZ(0);
  animation: gpix-masc-bob 3.4s var(--ease-elegant, cubic-bezier(.33,1,.68,1)) infinite;
}

@keyframes gpix-masc-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ---------------- Balloon ---------------- */
.gpix-masc__bubble {
  pointer-events: none;         /* click-through: nunca rouba o toque de um CTA embaixo */
  position: relative;
  max-width: 230px;
  margin-bottom: 12px;         /* alinha o rabinho perto da cabeça */
  padding: 11px 30px 12px 13px;
  background: var(--bg2, #101619);
  color: var(--ink2, #e6f6f3);
  border: 2px solid var(--teal, #00bfa5);
  border-radius: 12px;
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .7),
              0 0 0 1px rgba(0, 224, 198, .12),
              inset 0 0 0 1px rgba(0, 224, 198, .06);
  font-size: 13.5px;
  line-height: 1.42;
  letter-spacing: .1px;
  /* hidden by default; JS toggles .is-open */
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px) scale(.94);
  transform-origin: left bottom;
  transition: opacity .26s var(--ease-smooth, cubic-bezier(.16,1,.3,1)),
              transform .3s var(--ease-smooth, cubic-bezier(.16,1,.3,1)),
              visibility 0s linear .3s;
}

/* A casca pública fornece os tokens corretos também nas páginas que não
   carregam o arcade.css completo (políticas, status e denúncia). */
body.public-page .gpix-masc__bubble {
  background: var(--public-surface-2, var(--bg2, #101619));
  color: var(--public-ink-2, var(--ink2, #e6f6f3));
  border-color: var(--public-glow, var(--teal, #00bfa5));
}

body.public-page .gpix-masc__bubble::after {
  background: var(--public-surface-2, var(--bg2, #101619));
  border-color: var(--public-glow, var(--teal, #00bfa5));
}
.gpix-masc__bubble.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity .26s var(--ease-smooth, cubic-bezier(.16,1,.3,1)),
              transform .34s cubic-bezier(.34, 1.56, .64, 1),   /* pop com leve overshoot */
              visibility 0s;
}

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

/* rabinho apontando pro mascote (embaixo-esquerda) */
.gpix-masc__bubble::after {
  content: "";
  position: absolute;
  left: 20px;
  bottom: -9px;
  width: 14px;
  height: 14px;
  background: var(--bg2, #101619);
  border-right: 2px solid var(--teal, #00bfa5);
  border-bottom: 2px solid var(--teal, #00bfa5);
  transform: rotate(45deg);
  border-bottom-right-radius: 3px;
}

/* 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;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted, #8fb0aa);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.gpix-masc__close:hover { color: var(--ink, #ecfffb); background: rgba(0, 224, 198, .1); }
.gpix-masc__close:focus-visible {
  outline: none;
  color: var(--ink, #ecfffb);
  box-shadow: 0 0 0 2px var(--glow, #00e0c6);
}

/* ---------------- Mobile ---------------- */
@media (max-width: 560px) {
  #gpix-mascote {
    position: fixed;
    inset: auto auto max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    z-index: 898;
    width: auto;
    margin: 0;
    gap: 7px;
  }
  .gpix-masc__btn {
    min-width: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
  }
  .gpix-masc__sprite { width: 44px; height: 44px; }
  .gpix-masc__bubble {
    max-width: min(60vw, 190px);
    margin-bottom: 6px;
    padding: 8px 27px 8px 10px;
    font-size: 11.5px;
    line-height: 1.4;
  }
}

/* ---------------- Respeito: calmo / reduced-motion ---------------- */
[data-calm="1"] .gpix-masc__sprite { animation: none; }
[data-calm="1"] .gpix-masc__bubble,
[data-calm="1"] .gpix-masc__bubble.is-open {
  transition: opacity .12s linear, visibility 0s;
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .gpix-masc__sprite { animation: none; }
  .gpix-masc__bubble,
  .gpix-masc__bubble.is-open {
    transition: opacity .12s linear, visibility 0s;
    transform: none !important;
  }
}
