/* Atlas O Mundo Conhecido — mapa em tela cheia com painel flutuante minimo.
   Linguagem visual pergaminho/marrom herdada do portal. */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: Georgia, "Times New Roman", serif;
  color: #483824;
  background: #efe6cf;
  line-height: 1.45;
}

/* ---------- mapa em tela cheia ---------- */

.mapa-quadro {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

@supports (height: 100dvh) {
  .mapa-quadro {
    height: 100dvh;
  }
}

.mapa {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #dfd3b4;
}

.mapa .leaflet-container {
  background: #dfd3b4;
}

/* status/rotulos so para leitores de tela — a UI nao tem texto visivel
   de estado; o erro fatal continua visivel */
.sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.erro {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  max-width: min(560px, calc(100% - 32px));
  padding: 12px 14px;
  background: #f8e3e3;
  border: 1px solid #a00;
  border-radius: 4px;
  color: #7a1f1f;
}

.erro code {
  background: #fff;
  padding: 0 4px;
}

/* ---------- botoes ---------- */

.botao,
button.botao {
  display: inline-block;
  padding: 6px 12px;
  background: #f5ecd7;
  border: 1px solid #a08c6a;
  border-radius: 4px;
  color: #5a3c1a;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9em;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.botao:hover {
  background: #eadfc3;
}

.botao:focus-visible {
  outline: 3px solid #d6a241;
  outline-offset: 1px;
}

.botao:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ---------- painel flutuante ---------- */

.painel {
  background: #f5ecd7;
  border: 1px solid #a08c6a;
  border-radius: 4px;
}

.lateral {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 800;
  display: flex;
  flex-direction: column;
  width: 320px;
  max-width: calc(100vw - 28px);
  max-height: calc(100% - 28px);
  padding: 10px 14px 12px;
  overflow: hidden;
  box-shadow: 0 3px 14px rgba(60, 40, 10, 0.35);
}

.lateral-topo {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-bottom: 8px;
}

.lateral-titulo {
  margin: 0;
  margin-right: auto;
  font-size: 1.05em;
  font-weight: bold;
  color: #6b3d12;
}

/* "Mapa principal" (<a>) e "Recolher" (<button>) com caixas identicas */
.lateral-topo .botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 30px;
  line-height: 1.2;
}

.lateral-corpo {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* recolhido: so a linha do topo continua visivel (titulo + link + toggle) */
.lateral-fechada {
  width: auto;
  max-height: none;
  overflow: visible;
}

.lateral-fechada .lateral-topo {
  margin-bottom: 0;
}

.lateral-fechada .lateral-corpo {
  display: none;
}

.status {
  min-height: 1.2em;
  margin: 0 0 6px;
  font-size: 0.85em;
  font-style: italic;
  color: #6b3d12;
}

.status:empty {
  min-height: 0;
}

.nota {
  margin: 0 0 6px;
  font-size: 0.78em;
  color: #8a6f4a;
}

.nota:empty {
  display: none;
}

/* ---------- secoes ---------- */

.sec {
  border-top: 1px solid #cbbc9a;
  padding: 8px 0 10px;
}

.sec-titulo {
  margin: 0 0 6px;
  font-size: 0.95em;
  color: #6b3d12;
}

/* ---------- localidades ---------- */

#loc-busca {
  width: 100%;
  margin-bottom: 6px;
  padding: 6px 10px;
  background: #fff;
  border: 1px solid #a08c6a;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.92em;
  color: #483824;
}

.loc-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
  max-height: 140px;
  overflow-y: auto;
}

.loc-item {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
  padding: 5px 10px;
  background: #fff;
  border: 1px solid #a08c6a;
  border-radius: 4px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.loc-item:hover {
  background: #f5ecd7;
}

.loc-item:focus-visible {
  outline: 3px solid #d6a241;
  outline-offset: 1px;
}

.loc-item-nome {
  font-size: 0.95em;
  color: #483824;
}

.loc-item-orig {
  font-size: 0.72em;
  color: #8a6f4a;
}

.loc-controles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.loc-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92em;
  cursor: pointer;
  white-space: nowrap;
}

/* ---------- personagens ---------- */

.livro-linha {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 8px;
}

.livro-label {
  font-size: 0.85em;
  color: #6b3d12;
  white-space: nowrap;
}

#livro-select {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  background: #fff;
  border: 1px solid #a08c6a;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9em;
  color: #483824;
}

/* ---------- regiao ---------- */

.regiao-label {
  display: block;
}

#regiao-select {
  width: 100%;
  padding: 5px 8px;
  background: #fff;
  border: 1px solid #a08c6a;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9em;
  color: #483824;
}

.cap-linha {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0 2px;
}

.cap-linha .botao {
  padding: 4px 9px;
  font-size: 1em;
  line-height: 1;
}

#cap-slider {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: #a8741a;
}

.cap-titulo {
  margin: 0 0 8px;
  font-size: 0.95em;
  font-weight: bold;
  color: #483824;
  overflow-wrap: anywhere;
}

.pers-lista {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 4px;
}

.pers-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
}

.pers-item:hover {
  background: #f8f1df;
  border-color: #d9cba8;
}

.pers-cor {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid #6b3d12;
  display: inline-block;
}

.pers-nome {
  color: #483824;
}

.pers-atual {
  margin: 0 0 6px;
  font-size: 0.82em;
  color: #6b3d12;
}

.pers-atual:empty {
  display: none;
}

.pers-atual-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}

.pers-atual-item .pers-cor {
  width: 10px;
  height: 10px;
}

.pers-legenda {
  margin: 0 0 8px;
  font-size: 0.75em;
  color: #8a6d4b;
}

.pers-acoes {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin: 0 0 8px;
}

.pers-acoes .botao {
  flex: 1 1 0;
  min-width: 0;
  padding: 5px 4px;
  font-size: 0.82em;
  line-height: 1.15;
  justify-content: center;
  text-align: center;
  white-space: normal;
}

/* ---------- rodape do painel ---------- */

.painel-rodape {
  margin-top: 4px;
  border-top: 1px solid #cbbc9a;
  padding: 8px 0 2px;
  font-size: 0.72em;
  line-height: 1.35;
  color: #8a6d4b;
  overflow-wrap: break-word;
}

.painel-rodape a {
  color: #6b3d12;
}

.rodape-github {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}

/* ---------- popups e tooltip ---------- */

.loc-popup {
  max-width: 260px;
  font-family: Georgia, "Times New Roman", serif;
}

.loc-popup-orig {
  font-size: 0.85em;
  color: #8a6f4a;
}

.loc-popup-tipo {
  margin-top: 2px;
  font-size: 0.85em;
  color: #5a3c1a;
}

.loc-popup-resumo {
  margin-top: 4px;
  font-size: 0.88em;
  color: #483824;
}

.loc-popup-wiki {
  margin-top: 6px;
  font-size: 0.85em;
}

.loc-popup-wiki a {
  color: #7a1f1f;
}

.loc-popup-membros {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 0.85em;
}

.loc-popup-trecho {
  font-size: 0.92em;
  line-height: 1.35;
}

.perna-tooltip {
  font-size: 0.9em;
}

/* ---------- marcadores ---------- */

.loc-pin-wrap {
  background: none;
  border: none;
}

.loc-pin {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(214, 162, 65, 0.95);
  border: 2px solid #6b3d12;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

/* simbolo sem identificacao: pino vazado cinza — sem identidade
   inventada nem aparencia de cidade/castelo confirmados */
.loc-pin-simbolo {
  background: rgba(255, 255, 255, 0.55);
  border: 2px solid #8a8578;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}

/* tonalidades sutis por tipo identificado */
.loc-pin-castle { border-color: #5a4632; }
.loc-pin-city { border-color: #6b3d12; }
.loc-pin-village { border-color: #8a6f4a; }
.loc-pin-ruin { border-style: dotted; }
.loc-pin-settlement { border-color: #a08c6a; }

.loc-pin-jon {
  background: #7a1f1f;
  border-color: #fff;
  border-radius: 3px;
  transform: rotate(45deg);
}

.loc-pin-personagem {
  background: #8a5a1a;
  border-color: #fff;
  border-radius: 3px;
  transform: rotate(45deg);
}

.loc-pin-n {
  display: block;
  transform: rotate(-45deg);
  color: #fff;
  font: bold 10px/16px Arial, sans-serif;
  text-align: center;
}

.loc-label {
  background: rgba(245, 236, 215, 0.95);
  border: 1px solid #a08c6a;
  color: #483824;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.85em;
  box-shadow: none;
}

.loc-label::before {
  display: none;
}

.loc-label-jon {
  font-weight: bold;
  color: #7a1f1f;
}

/* ---------- handheld ---------- */

@media only screen and (max-width: 600px) {
  .lateral {
    top: 10px;
    right: 10px;
    width: 300px;
    max-width: calc(100vw - 20px);
    max-height: calc(100% - 20px);
    padding: 8px 12px 10px;
  }

  .botao,
  button.botao {
    padding: 7px 11px;
    font-size: 0.88em;
  }
}
