/* HUD do mapa (FEAT-21.T11, plano seção 11): barra de ícones embaixo, botões redondos à direita, som no alto e os
   painéis Jornada e Peregrino na moldura de madeira. Usado por mapa.html; a lógica fica em js/mapa.js e js/mapa-paineis.js. */

/* ── Medidas da barra: 84 px de altura mais a área segura do aparelho ── */
:root {
  --hud-bar-height: 84px;
  --hud-bar-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  /* Até 68 px; no celular encolhe para caberem 6 botões (com o de Moderação) sem esconder o último à direita. */
  --hud-slot: min(68px, calc((100vw - 16px) / 6));
  --hud-round: 48px;
  --hud-gold: #f6d77a;
  --hud-ink: #3b2410;
  --hud-ink-soft: #7a5426;
}

.hud-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
}

/* ── Botão redondo: moldura pintada; o + e o − são desenhados pelo site (não há glifo pintado deles) ── */
.hud-round {
  width: var(--hud-round);
  height: var(--hud-round);
  padding: 0;
  border: none;
  border-radius: 50%;
  background: url("/assets/map/v3/hud/botao-redondo.webp") center / contain no-repeat;
  display: grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .45));
  transition: transform 120ms ease;
}

.hud-round:hover {
  transform: scale(1.06);
}

.hud-round:focus-visible,
.hud-bar-item:focus-visible,
.map-panel-close:focus-visible,
.map-panel-action:focus-visible {
  outline: 3px solid var(--hud-gold);
  outline-offset: 3px;
}

.hud-glyph {
  width: 54%;
  height: 54%;
  object-fit: contain;
  pointer-events: none;
}

.hud-zoom-btn span {
  font-family: var(--font-heading, 'Cinzel', serif);
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
  color: var(--hud-gold);
  text-shadow: 0 0 2px #2a1808, 0 0 2px #2a1808, 0 1px 2px #2a1808;
}

/* ── Som: canto de cima à direita; a fita aparece quando o som está desligado ── */
.hud-sound {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(12px + env(safe-area-inset-right, 0px));
}

.hud-sound .sound-off,
.hud-sound.is-muted .sound-on {
  display: none;
}

.hud-sound.is-muted .sound-off {
  display: block;
}

/* ── Aproximar, afastar e centralizar: coluna à direita, logo acima da barra ── */
.hud-zoom-group {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right, 0px));
  bottom: calc(var(--hud-bar-bottom) + var(--hud-bar-height) + 10px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Barra de ícones: 5 vagas de 68 px; Doação e Moderação, quando aparecem, deslizam para o lado no celular ── */
.hud-bar {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: var(--hud-bar-bottom);
  height: var(--hud-bar-height);
  display: flex;
  justify-content: safe center;
  align-items: flex-end;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  pointer-events: auto;
}

.hud-bar::-webkit-scrollbar {
  display: none;
}

.hud-bar-item {
  flex: 0 0 var(--hud-slot);
  height: var(--hud-bar-height);
  padding: 0;
  border: none;
  border-radius: 10px;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  cursor: pointer;
  text-decoration: none;
  scroll-snap-align: center;
  -webkit-tap-highlight-color: transparent;
}

.hud-bar-item[hidden] {
  display: none;
}

.hud-bar-icon {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .5));
  transition: transform 120ms ease;
  pointer-events: none;
}

.hud-bar-item:hover > .hud-bar-icon,
.hud-bar-item:hover > .hud-bar-art {
  transform: translateY(-2px) scale(1.05);
}

.hud-bar-item[aria-expanded="true"] > .hud-bar-icon,
.hud-bar-item[aria-expanded="true"] > .hud-bar-art {
  transform: translateY(-3px) scale(1.08);
}

/* Ícone Peregrino: a moldura de louros tem o centro vazio para o rosto do peregrino (círculo a 41% da altura). */
.hud-bar-art {
  position: relative;
  width: 52px;
  height: 52px;
  transition: transform 120ms ease;
}

.hud-bar-face {
  position: absolute;
  left: 50%;
  top: 41%;
  width: 29px;
  height: 29px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  background: radial-gradient(circle at 40% 32%, #f6e2a6, #c69a45);
  pointer-events: none;
}

/* Recorte da cabeça: o quadro 2:3 do peregrino com o dobro da largura do círculo, ancorado no topo. */
.hud-bar-face .character-stack {
  flex: none;
  width: 58px;
  margin-top: 1px;
}

/* Plaquinha de madeira com o nome em 11 px (texto do site, não da arte). */
.hud-bar-label {
  width: var(--hud-slot);
  height: 19px;
  margin-top: -3px;
  background: url("/assets/map/v3/hud/placa-rotulo.webp") center / 100% 100% no-repeat;
  font-family: var(--font-body, Georgia, serif);
  font-weight: 700;
  /* 11 px no computador; no slot estreito do celular "Comunidade" e "Moderação" ainda cabem na placa. */
  font-size: min(11px, calc(var(--hud-slot) * .165));
  line-height: 19px;
  text-align: center;
  white-space: nowrap;
  color: #fbeccb;
  text-shadow: 0 1px 1px #2a1808;
  pointer-events: none;
}

/* Dica de mouse: só no computador, no canto de cima à esquerda (vazio desde que os cartões saíram). */
.hud-hint {
  position: absolute;
  top: 18px;
  left: 20px;
  max-width: 260px;
  margin: 0;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 12.5px;
  color: rgba(240, 228, 200, .7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

@media (max-width: 640px), (hover: none) {
  .hud-hint {
    display: none;
  }
}

/* Computador: a barra fica centralizada com até 720 px; os 7 ícones cabem. */
@media (min-width: 641px) {
  .hud-bar {
    left: 50%;
    right: auto;
    width: min(720px, calc(100vw - 16px));
    transform: translateX(-50%);
  }
}

/* ── Painéis Jornada e Peregrino: folha que sobe no celular, janela central no computador ── */
.map-panel {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.map-panel[hidden] {
  display: none;
}

.map-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 4, .55);
}

/* Moldura em 9 fatias: os cantos dourados ficam inteiros e o pergaminho estica. */
.map-panel-sheet {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-height: min(78vh, 620px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 30px solid transparent;
  border-image: url("/assets/map/v3/hud/painel-moldura.webp") 100 fill / 30px stretch;
  padding: 6px 8px 10px;
  color: var(--hud-ink);
  font-family: var(--font-body);
  animation: map-panel-rise 220ms ease-out;
}

@keyframes map-panel-rise {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (min-width: 641px) {
  .map-panel {
    align-items: center;
  }

  .map-panel-sheet {
    width: 520px;
    max-height: min(640px, calc(100vh - 32px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-panel-sheet {
    animation: none;
  }
}

/* ── Janela das outras telas (js/mapa-janela.js): a mesma moldura, mais alta, com a tela num quadro dentro ── */
/* Fundo mais claro que o dos painéis: o mapa continua à vista em volta da janela. */
.map-window .map-panel-backdrop {
  background: rgba(10, 8, 4, .35);
}

.map-window .map-panel-sheet {
  display: flex;
  flex-direction: column;
  height: 92dvh;
  max-height: none;
  overflow: hidden;
  padding: 40px 4px 6px;
}

/* A tela de dentro já mostra o próprio nome no topo: o título da janela fica só para o leitor de tela e o foco. */
.map-window .map-panel-title {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.map-window-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  background: var(--bg-page, #f4ead2);
  opacity: 0;
  transition: opacity 160ms ease-out;
}

/* Some até a tela carregar: sem isso a troca de tela pisca em branco. */
.map-window-frame.ready {
  opacity: 1;
}

@media (min-width: 641px) {
  .map-window .map-panel-sheet {
    width: min(880px, calc(100vw - 48px));
    height: min(860px, calc(100dvh - 48px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .map-window-frame {
    transition: none;
  }
}

.map-panel-close {
  position: absolute;
  top: 0;
  right: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: url("/assets/map/v3/hud/botao-redondo.webp") center / contain no-repeat;
  color: var(--hud-gold);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  text-shadow: 0 0 2px #2a1808, 0 1px 2px #2a1808;
}

.map-panel-title {
  margin: 0 40px 12px;
  text-align: center;
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #4a2a0e;
}

.map-panel-title:focus {
  outline: none;
}

.map-panel-action {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  padding: 10px 18px;
  border: 1px solid #a97521;
  border-radius: 10px;
  background: linear-gradient(180deg, #f0d488, #d8ab45);
  box-shadow: 0 4px 10px rgba(60, 35, 10, .3), inset 0 1px 0 rgba(255, 255, 255, .5);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
  color: #241a0c;
  cursor: pointer;
}

/* ── Jornada: selo e nome da fase, progresso, nível e próxima missão ── */
.journey-phase {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.journey-phase p {
  margin: 0;
}

.journey-seal {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #6e4a1c;
  background: radial-gradient(circle at 36% 30%, #f6e2a6, #d8ab45 55%, #a97521);
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  color: #4a3212;
}

.journey-phase-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.2;
}

.journey-phase-sub {
  font-style: italic;
  font-size: 14px;
  color: var(--hud-ink-soft);
}

.hud-progress-header,
.hud-xp-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
  font-family: var(--font-heading);
}

.hud-progress-label,
.hud-next-mission-label {
  font-family: var(--font-heading);
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--hud-ink-soft);
}

.hud-progress-pct {
  font-weight: 700;
  font-size: 16px;
}

.hud-progress-bar,
.hud-xp-bar {
  height: 8px;
  border-radius: 4px;
  background: rgba(90, 55, 20, .2);
  overflow: hidden;
}

.hud-progress-fill {
  height: 100%;
  width: 5.88%;
  border-radius: 4px;
  background: linear-gradient(90deg, #b8862d, #e3b85a);
  transition: width 300ms ease;
}

.hud-progress-etapa {
  margin-top: 4px;
  font-style: italic;
  font-size: 13px;
  color: var(--hud-ink-soft);
}

.hud-xp,
.hud-next-mission {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(122, 84, 38, .3);
}

.hud-next-mission[hidden],
.hud-next-mission-status[hidden],
.hud-next-mission-prompt[hidden],
.hud-next-mission-link[hidden],
.hud-next-mission-destination[hidden] {
  display: none;
}

.hud-xp-level {
  font-weight: 700;
  font-size: 15px;
}

.hud-xp-value {
  font-size: 13px;
  color: var(--hud-ink-soft);
  white-space: nowrap;
}

.hud-xp-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #4f8a3a, #7fb069);
  transition: width 300ms ease;
}

.hud-next-mission-label {
  display: block;
}

.hud-next-mission-destination {
  display: block;
  margin-top: 4px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.hud-next-mission-prompt,
.hud-next-mission-status {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.hud-next-mission-status {
  display: block;
}

.hud-next-mission-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 14px;
  color: #7a3d0c;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Peregrino: o personagem montado, o nome, o Clube e a armadura ── */
.pilgrim-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.pilgrim-head p {
  margin: 0;
}

.pilgrim-figure {
  flex: none;
  width: 92px;
}

.pilgrim-figure .character-stack {
  display: block;
  width: 100%;
}

.pilgrim-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.pilgrim-head .hud-clube-badge {
  width: fit-content;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 9px;
  background: linear-gradient(90deg, #d8ab45, #f0d488);
  font-family: var(--font-heading);
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #1c150c;
}

.hud-clube-badge[hidden] {
  display: none;
}

.pilgrim-head .inventory-level {
  margin-top: 6px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--hud-ink-soft);
}

.inventory-heading {
  margin: 6px 0 4px;
  font-family: var(--font-heading);
  font-size: 16px;
  letter-spacing: 1px;
}

.inventory-empty {
  margin: 4px 0;
  font-style: italic;
  font-size: 14px;
  color: var(--hud-ink-soft);
}

.inventory-empty[hidden] {
  display: none;
}

.inventory-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(122, 84, 38, .25);
}

.inventory-row:first-of-type {
  border-top: none;
}

.inventory-piece-icon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #a97521;
  background: #f6e7c4;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.inventory-piece-icon img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.inventory-piece-name {
  flex: 1;
  margin: 0;
  font-weight: 700;
  font-size: 15px;
}

.inventory-equipped-badge {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: #3f6e2c;
}

.inventory-action-btn {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid #6a4c22;
  border-radius: 8px;
  background: linear-gradient(160deg, #2b2113, #1c150c);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  color: #e7c273;
  cursor: pointer;
}

.inventory-error {
  display: none;
  margin: 6px 0 0;
  font-size: 14px;
  color: #9b1c1c;
}

/* ── Som do mapa (FEAT-22): volumes e créditos no painel Jornada ── */
.journey-sound {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid rgba(169, 117, 33, .45);
}

.journey-sound-title {
  margin: 0 0 8px;
  font-family: var(--font-heading);
  font-size: 16px;
  color: #4a2a0e;
}

.journey-sound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  font-size: 15px;
  color: #3a240c;
}

.journey-sound-row input[type="range"] {
  flex: 1;
  max-width: 60%;
  min-height: 44px;
  accent-color: var(--gold-bronze);
}

.journey-credits {
  margin: 10px 0 0;
  padding: 0 0 0 18px;
  max-height: 220px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.45;
  color: #3a240c;
}

.journey-credits li + li {
  margin-top: 6px;
}

.journey-credits a {
  color: #6b3d0c;
}
