/* ==========================================================================
   Lupi — mascote e assistente ("Conversar com o Lupi").
   Usado no mapa (index.html) e nas páginas em PHP (eventos, cidades).
   Kit: _kit/mascote/guia-visual.html e _kit/assistente/especificacao.md.
   As cores do personagem (verde floresta, creme) só entram nas superfícies dele;
   o resto segue os tokens do site.
   ========================================================================== */
:root {
  --pode-forest: #244630;
  --pode-leaf: #e7ede0;
  --pode-cream: #faf7ef;
  --pode-ink: #222222;
  --pode-muted: #6a6a6a;
  --pode-line: #ebebeb;
  --pode-canvas: #f7f7f7;
  --pode-warn-ink: #92400e;
  --pode-warn-bg: #fef3c7;
  --pode-urgent-ink: #991b1b;
  --pode-urgent-bg: #fef2f2;
  --pode-font: 'DM Sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --pode-safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--safe-area-inset-bottom, 0px));
  --pode-safe-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
}

.pode-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Arte do Lupi dentro do site (estado vazio, erro, convite) ---------- */
.pode-art {
  display: block;
  width: 112px;
  height: 112px;
  margin: 0 auto 8px;
  object-fit: contain;
}

.pode-art[hidden] {
  display: none;
}

.pode-art-sm {
  width: 72px;
  height: 72px;
}

.pode-art-lg {
  width: 148px;
  height: 148px;
}

/* Cabeçalho da lista no desktop: o Lupi com o mapa ao lado do título. */
.pode-panel-art {
  flex: none;
  width: 68px;
  height: 68px;
  margin: -6px 0 -10px;
  object-fit: contain;
}

@media (max-width: 900px) {
  .pode-panel-art {
    display: none;
  }
}

/* Lista vazia já mostra o Lupi deitado: um só na tela. */
.places-panel:has(.listing-empty) .pode-panel-art {
  display: none;
}

/* Faixa de página (eventos, cidades): texto à esquerda, Lupi à direita. */
.pode-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.pode-hero > div {
  min-width: 0;
}

.pode-hero .pode-art {
  flex: none;
  margin: 0;
}

@media (max-width: 560px) {
  .pode-hero .pode-art {
    width: 84px;
    height: 84px;
  }
}

/* Movimentos pequenos, com pausas entre os gestos. Só transform: o espaço
   reservado à arte fica estável no mapa, nos diálogos e nas páginas. */
@media (prefers-reduced-motion: no-preference) {
  img[src^="/brand/pode/pose-"] {
    transform-origin: 50% 85%;
    animation: pode-breathe 5s ease-in-out infinite;
  }

  img[src$="/pose-ola.webp"] {
    animation: pode-greet 7s ease-in-out infinite;
  }

  img[src$="/pose-celebrar.webp"] {
    animation: pode-celebrate 5s ease-in-out infinite;
  }

  img[src$="/pose-pensar.webp"],
  img[src$="/pose-alerta.webp"],
  img[src$="/pose-mapa.webp"] {
    animation: pode-curious 8s ease-in-out infinite;
  }

  .pode-panel-art {
    animation-delay: -3s;
  }

  .pode-launcher img,
  .pode-head img {
    transform-origin: 50% 70%;
    animation: pode-peek 9s ease-in-out infinite;
  }
}

@keyframes pode-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.018, 1.035); }
}

@keyframes pode-greet {
  0%, 24%, 100% { transform: translateY(0) rotate(0); }
  5% { transform: translateY(-3px) rotate(-5deg); }
  10% { transform: translateY(-3px) rotate(4deg); }
  15% { transform: translateY(-2px) rotate(-3deg); }
  20% { transform: translateY(0) rotate(2deg); }
}

@keyframes pode-celebrate {
  0%, 30%, 100% { transform: translateY(0) scale(1); }
  5% { transform: translateY(1px) scale(1.025, .97); }
  11% { transform: translateY(-9px) scale(.985, 1.025); }
  17% { transform: translateY(0) scale(1.035, .975); }
  23% { transform: translateY(-4px) scale(1); }
}

@keyframes pode-curious {
  0%, 32%, 100% { transform: rotate(0) translateY(0); }
  10%, 18% { transform: rotate(-3deg) translateY(-2px); }
  25% { transform: rotate(1.5deg) translateY(0); }
}

@keyframes pode-peek {
  0%, 18%, 100% { transform: rotate(0); }
  5% { transform: rotate(-7deg); }
  10% { transform: rotate(5deg); }
  14% { transform: rotate(-2deg); }
}

.pode-empty {
  text-align: center;
}

/* ---------- Botão de abertura ---------- */
.pode-launcher {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + var(--pode-safe-bottom));
  z-index: 44;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px 0 4px;
  border: 0;
  border-radius: 9999px;
  background: #ffffff;
  color: var(--pode-ink);
  font: 600 14px/1 var(--pode-font);
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 2px 6px rgba(0, 0, 0, 0.08), 0 6px 16px rgba(0, 0, 0, 0.14);
  transition: transform 100ms ease-out, box-shadow 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.pode-launcher:hover {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 4px 10px rgba(0, 0, 0, 0.1), 0 10px 24px rgba(0, 0, 0, 0.18);
}

.pode-launcher:active {
  transform: scale(0.97);
}

.pode-launcher img {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background: var(--pode-leaf);
  object-fit: cover;
}

.pode-launcher[hidden],
.pode-panel[hidden] {
  display: none;
}

.pode-launcher:focus-visible,
.pode-panel :focus-visible {
  outline: 2px solid var(--pode-ink);
  outline-offset: 2px;
}

/* ---------- Painel ---------- */
.pode-panel {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + var(--pode-safe-bottom));
  z-index: 46;
  display: flex;
  flex-direction: column;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: min(640px, calc(100dvh - 32px));
  background: var(--pode-canvas);
  color: var(--pode-ink);
  font: 400 14px/1.43 var(--pode-font);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.pode-panel:focus {
  outline: none;
}

.pode-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 14px;
  background: var(--pode-leaf);
}

.pode-head img {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  background: #ffffff;
  object-fit: cover;
}

.pode-head-text {
  flex: 1;
  min-width: 0;
}

.pode-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--pode-forest);
}

.pode-subtitle {
  margin: 0;
  font-size: 12px;
  line-height: 1.3;
  color: #3d5a47;
}

.pode-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 9999px;
  background: transparent;
  color: var(--pode-forest);
  cursor: pointer;
}

.pode-close:hover {
  background: rgba(36, 70, 48, 0.1);
}

.pode-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}

.pode-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.pode-row-art {
  flex: none;
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.pode-row-gap {
  flex: none;
  width: 44px;
}

.pode-bubble {
  max-width: 100%;
  margin: 0;
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  background: #ffffff;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.pode-row.is-user {
  justify-content: flex-end;
}

.pode-row.is-user .pode-bubble {
  max-width: 82%;
  border-radius: 16px 16px 4px 16px;
  background: var(--pode-ink);
  color: #ffffff;
}

.pode-bubble.is-alert {
  background: var(--pode-warn-bg);
  color: var(--pode-warn-ink);
}

.pode-bubble.is-urgent {
  background: var(--pode-urgent-bg);
  color: var(--pode-urgent-ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(153, 27, 27, 0.25);
}

.pode-typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px;
}

.pode-typing span {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--pode-muted);
  animation: pode-blink 1.1s infinite ease-in-out;
}

.pode-typing span:nth-child(2) { animation-delay: 0.15s; }
.pode-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pode-blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* Fichas */
.pode-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-left: 52px;
}

.pode-card {
  padding: 12px 14px;
  border-radius: 12px;
  background: #ffffff;
}

.pode-card-name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.pode-card-where {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--pode-muted);
}

.pode-badge {
  display: inline-block;
  margin: 8px 0 0;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.pode-badge.is-ok {
  background: var(--pode-leaf);
  color: var(--pode-forest);
}

.pode-badge.is-confirm {
  background: var(--pode-warn-bg);
  color: var(--pode-warn-ink);
}

.pode-card-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.pode-card-lines li {
  padding: 2px 8px;
  border-radius: 9999px;
  background: var(--pode-canvas);
  font-size: 12px;
  line-height: 1.4;
}

.pode-card-detail {
  margin: 10px 0 0;
}

.pode-card-detail dt {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--pode-muted);
}

.pode-card-detail dd {
  margin: 2px 0 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.pode-card-link {
  display: inline-flex;
  align-items: center;
  height: 36px;
  margin-top: 10px;
  padding: 0 14px;
  border-radius: 9999px;
  background: var(--pode-ink);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.pode-card-link:hover {
  background: #000000;
}

/* Ações e opções */
.pode-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: 52px;
}

.pode-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 36px;
  max-width: 100%;
  padding: 6px 14px;
  border: 1px solid #d5d5d5;
  border-radius: 18px;
  background: #ffffff;
  color: var(--pode-ink);
  font: 500 13px/1.3 var(--pode-font);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.pode-chip:hover {
  border-color: var(--pode-ink);
}

.pode-chip small {
  font-size: 12px;
  font-weight: 400;
  color: var(--pode-muted);
}

.pode-chip:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Campo */
.pode-form {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px calc(10px + var(--pode-safe-bottom));
  background: #ffffff;
  border-top: 1px solid var(--pode-line);
}

.pode-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  border: 1px solid #d5d5d5;
  border-radius: 9999px;
  background: #ffffff;
  color: var(--pode-ink);
  font: 400 16px/1 var(--pode-font);
}

.pode-input::placeholder {
  color: #8a8a8a;
}

.pode-input:focus {
  outline: none;
  border-color: var(--pode-ink);
  box-shadow: 0 0 0 1px var(--pode-ink);
}

.pode-send {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 9999px;
  background: var(--pode-forest);
  color: #ffffff;
  cursor: pointer;
}

.pode-send:disabled {
  opacity: 0.45;
  cursor: default;
}

.pode-note {
  flex: none;
  margin: 0;
  padding: 0 14px 6px;
  background: #ffffff;
  font-size: 11px;
  line-height: 1.3;
  color: var(--pode-muted);
  text-align: center;
}

/* ---------- No mapa (index.html) ---------- */
@media (min-width: 901px) {
  /* Canto inferior esquerdo do mapa: o zoom e o crédito ficam do outro lado. */
  .app-body .pode-launcher,
  .app-body .pode-panel {
    right: auto;
    left: calc(var(--places-panel-w, 48%) + 16px);
  }

  .app-body .pode-panel {
    height: min(640px, calc(100dvh - 150px));
  }
}

@media (max-width: 900px) {
  /* Acima da folha de lugares; quando ela sobe, passa por cima do botão. */
  .app-body .pode-launcher {
    z-index: 15;
    right: calc(12px + env(safe-area-inset-right, 0px));
    bottom: min(calc(var(--sheet-h, 38dvh) + 12px), calc(100dvh - 240px));
  }

  .pode-launcher {
    height: 44px;
    padding-right: 14px;
    font-size: 13px;
  }

  .pode-launcher img {
    width: 36px;
    height: 36px;
  }

  .pode-panel,
  .app-body .pode-panel {
    inset: 0;
    width: auto;
    max-width: none;
    height: auto;
    border-radius: 0;
    z-index: 48;
  }

  .pode-head {
    padding-top: calc(10px + var(--pode-safe-top));
  }
}

@media (prefers-reduced-motion: reduce) {
  .pode-typing span {
    animation: none;
    opacity: 0.6;
  }

  .pode-launcher {
    transition: none;
  }
}

@media print {
  .pode-launcher,
  .pode-panel {
    display: none !important;
  }
}
