@font-face { font-family: "Plex"; font-weight: 400; font-display: swap; src: url("lib/fontes/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex"; font-weight: 500; font-display: swap; src: url("lib/fontes/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex"; font-weight: 600; font-display: swap; src: url("lib/fontes/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Plex Estreita"; font-weight: 600; font-display: swap; src: url("lib/fontes/ibm-plex-sans-condensed-latin-600-normal.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --chao: #eef1f0;
  --papel: #ffffff;
  --tinta: #16202b;
  --tinta-2: #4d5a66;
  --tinta-3: #7d8791;
  --fio: #dde2e5;
  --marca: #184f95;
  --marca-fraca: #e6eef8;
  --sem-dado: #e4e3dd;
  --largura-indice: 318px;
  --sombra: 0 1px 2px rgba(22, 32, 43, .08), 0 6px 20px rgba(22, 32, 43, .10);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-columns: var(--largura-indice) 1fr;
  font-family: "Plex", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--tinta);
  background: var(--chao);
}
button, input { font: inherit; color: inherit; }
a { color: var(--marca); }
:focus-visible { outline: 2px solid var(--marca); outline-offset: 2px; }
.so-leitor { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Índice de mapas ---------- */
#indice {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100vh;
  background: var(--papel);
  border-right: 1px solid var(--fio);
  z-index: 5;
}
.indice-topo { padding: 20px 20px 12px; border-bottom: 1px solid var(--fio); }
.indice-topo h1 {
  margin: 0 0 6px;
  font-family: "Plex Estreita", "Plex", sans-serif;
  font-size: 23px;
  line-height: 1.12;
  font-weight: 600;
  letter-spacing: -.005em;
}
.indice-topo p { margin: 0 0 14px; color: var(--tinta-2); font-size: 13px; }
.campo { display: block; }
.campo input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #c6cdd2;
  border-radius: 4px;
  background: var(--papel);
}
.campo input::placeholder { color: var(--tinta-3); }

#lista-mapas { flex: 1; overflow-y: auto; padding: 0 0 16px; scrollbar-width: thin; }
#lista-mapas h3 {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 14px 20px 6px;
  background: var(--papel);
  font-size: 12px;
  font-weight: 600;
  color: var(--tinta-3);
}
#lista-mapas button {
  display: grid;
  grid-template-columns: 26px 1fr;
  width: 100%;
  padding: 5px 20px 5px 14px;
  border: 0;
  border-left: 3px solid transparent;
  background: none;
  text-align: left;
  cursor: pointer;
}
#lista-mapas button .n { color: var(--tinta-3); font-variant-numeric: tabular-nums; font-size: 12px; padding-top: 1px; }
#lista-mapas button:hover { background: #f3f5f6; }
#lista-mapas button[aria-current="true"] {
  background: var(--marca-fraca);
  border-left-color: var(--marca);
  font-weight: 600;
}
#lista-mapas .vazio { padding: 16px 20px; color: var(--tinta-2); }
.indice-rodape { padding: 12px 20px 16px; border-top: 1px solid var(--fio); font-size: 12px; color: var(--tinta-2); }
.indice-rodape p { margin: 0 0 6px; }
#nota-site strong { color: var(--tinta); font-weight: 600; }

/* ---------- Palco ---------- */
#palco { position: relative; min-width: 0; height: 100vh; }
#mapa { position: absolute; inset: 0; background: var(--chao); }
#abrir-indice { display: none; }

#ficha, #legenda, #busca-mun {
  position: absolute;
  background: var(--papel);
  border-radius: 6px;
  box-shadow: var(--sombra);
  z-index: 2;
}
#ficha { top: 14px; left: 14px; width: min(440px, calc(100% - 28px)); padding: 12px 16px 14px; }
.ficha-linha { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#ficha-tema { font-size: 12px; font-weight: 500; color: var(--tinta-2); }
.passos { display: flex; gap: 4px; }
.passos button {
  width: 26px; height: 26px;
  border: 1px solid var(--fio); border-radius: 4px;
  background: var(--papel); cursor: pointer;
  font-size: 17px; line-height: 1;
}
.passos button:hover { background: #f3f5f6; }
#ficha-titulo {
  margin: 4px 0 6px;
  font-family: "Plex Estreita", "Plex", sans-serif;
  font-weight: 600;
  font-size: 19px;
  line-height: 1.2;
}
#ficha-nota { margin: 0; font-size: 12px; color: var(--tinta-2); }

#busca-mun { top: 14px; right: 54px; width: 250px; background: none; box-shadow: none; }
#busca-mun input { box-shadow: var(--sombra); border-color: transparent; }
#sugestoes {
  list-style: none; margin: 4px 0 0; padding: 4px;
  background: var(--papel); border-radius: 6px; box-shadow: var(--sombra);
  max-height: 280px; overflow-y: auto;
}
#sugestoes li { padding: 6px 8px; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#sugestoes li span { color: var(--tinta-3); }
#sugestoes li[aria-selected="true"], #sugestoes li:hover { background: var(--marca-fraca); }

/* ---------- Legenda ---------- */
#legenda { left: 14px; bottom: 28px; width: 300px; padding: 12px 14px 12px; }
#leg-alternar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  width: 100%; margin: 0 0 8px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
}
#leg-alternar span { flex: none; width: 8px; height: 8px; margin: 3px 2px 0; border-right: 1.5px solid var(--tinta-2); border-bottom: 1.5px solid var(--tinta-2); transform: rotate(45deg); }
#legenda.fechada #leg-alternar { margin-bottom: 0; }
#legenda.fechada #leg-alternar span { transform: rotate(-135deg); margin-top: 7px; }
#legenda.fechada #leg-corpo, #legenda.fechada #leg-opcoes { display: none; }
#leg-titulo { font-size: 13px; font-weight: 600; line-height: 1.25; }
#leg-opcoes { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--fio); }
.chave:has(input:disabled) { opacity: .45; cursor: default; }
#leg-fundo { display: grid; gap: 7px; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--fio); font-size: 12px; color: var(--tinta-2); }
#legenda.fechada #leg-fundo { display: none; }
.linha-opcao { display: flex; align-items: center; gap: 10px; }
.linha-opcao > span:first-child { flex: none; width: 76px; line-height: 1.2; }
.linha-opcao input[type="range"] { flex: 1; min-width: 0; accent-color: var(--marca); }
.linha-opcao output { flex: none; width: 34px; text-align: right; font-variant-numeric: tabular-nums; color: var(--tinta); }
.segmentos { display: flex; flex: 1; border: 1px solid #c6cdd2; border-radius: 4px; overflow: hidden; }
.segmentos label { flex: 1; cursor: pointer; }
.segmentos label + label { border-left: 1px solid #c6cdd2; }
.segmentos input { position: absolute; opacity: 0; pointer-events: none; }
.segmentos span { display: block; padding: 4px 6px; text-align: center; color: var(--tinta); white-space: nowrap; }
.segmentos input:checked + span { background: var(--marca); color: #fff; font-weight: 500; }
.segmentos input:focus-visible + span { outline: 2px solid var(--marca); outline-offset: -2px; }
.segmentos label:hover input:not(:checked) + span { background: #f3f5f6; }
.chave { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--tinta-2); white-space: nowrap; cursor: pointer; }
.chave input { margin: 0; accent-color: var(--marca); }

.hist { display: block; max-width: 100%; overflow: visible; }
.hist .eixo { stroke: #c3c9ce; stroke-width: 1; }
.hist .ref line { stroke: var(--tinta); stroke-width: 1; stroke-dasharray: 2 2; }
.hist .ref text, .hist .aqui text { font-size: 10.5px; fill: var(--tinta); }
.hist .aqui line { stroke: var(--tinta); stroke-width: 1.5; }
.hist .aqui circle { fill: var(--tinta); }
.hist-pe { display: flex; justify-content: space-between; gap: 6px; white-space: nowrap; margin: 2px 0 8px; font-size: 11px; color: var(--tinta-3); font-variant-numeric: tabular-nums; }

.classes { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-template-rows: repeat(4, auto); grid-auto-columns: 1fr; column-gap: 12px; row-gap: 3px; font-size: 12px; font-variant-numeric: tabular-nums; }
.classes.uma-coluna { grid-auto-flow: row; grid-template-rows: none; }
.classes li { display: flex; align-items: center; gap: 7px; min-width: 0; }
.classes li i { flex: none; width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(22, 32, 43, .12); }
.classes li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.classes li em { margin-left: auto; font-style: normal; color: var(--tinta-3); padding-left: 6px; }
.leg-brasil { margin: 8px 0 0; font-size: 12px; color: var(--tinta-2); }
.leg-brasil b { color: var(--tinta); font-weight: 600; }

/* ---------- Dica (tooltip) e avisos ---------- */
#dica {
  position: absolute; z-index: 4; pointer-events: none;
  max-width: 280px; padding: 9px 11px;
  background: var(--tinta); color: #fff; border-radius: 5px;
  font-size: 12.5px; line-height: 1.35;
  box-shadow: var(--sombra);
}
#dica .lugar { font-weight: 600; }
#dica .area { color: #c4ccd4; }
#dica .valor { margin-top: 5px; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
#dica .extra { color: #c4ccd4; }
#aviso {
  position: absolute; z-index: 6; left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 420px; padding: 16px 18px; background: var(--papel);
  border-radius: 6px; box-shadow: var(--sombra); border-left: 4px solid #d03b3b;
}

.maplibregl-ctrl-attrib { font-family: inherit; font-size: 11px; max-width: min(460px, calc(100vw - 380px)); }
@media (max-width: 820px) { .maplibregl-ctrl-attrib { max-width: 80vw; } }
.maplibregl-ctrl-group { box-shadow: var(--sombra) !important; }

/* ---------- Telas estreitas ---------- */
@media (max-width: 820px) {
  body { grid-template-columns: 1fr; }
  #indice {
    position: fixed; inset: 0 auto 0 0; width: min(88vw, 340px);
    transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: var(--sombra);
  }
  body.indice-aberto #indice { transform: none; }
  #abrir-indice {
    display: block; position: absolute; z-index: 3; top: 14px; left: 14px;
    padding: 8px 12px; border: 0; border-radius: 4px;
    background: var(--marca); color: #fff; font-weight: 600; cursor: pointer;
    box-shadow: var(--sombra);
  }
  #ficha { top: 58px; padding: 10px 12px; }
  #ficha-titulo { font-size: 16px; }
  #ficha-nota { display: none; }
  #busca-mun { top: 14px; left: 96px; right: 54px; width: auto; }
  #legenda { left: 8px; right: 8px; bottom: 34px; width: auto; padding: 10px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  #indice { transition: none; }
}
