/*
 * Mapa de CEPs de Guarabira.
 * O mapa ocupa a tela inteira; busca, controles e rodape ficam por cima, discretos.
 * Nenhuma fonte, imagem ou folha de estilo externa: tudo aqui roda offline.
 */

:root {
  --primaria: #003da5;
  --primaria-escura: #002f80;
  --primaria-suave: #e9effa;
  --destaque: #f5c800;

  --texto: #172033;
  --texto-2: #4a5468;
  --texto-3: #6b7589;
  --borda: #dde2ea;
  --borda-forte: #c9d0db;
  --superficie: #ffffff;
  --hover: #f2f5f9;
  --sucesso: #178a4f;
  --atencao: #b7791f;
  --fundo-mapa: #f3f1ec;

  --raio: 10px;
  --raio-p: 6px;
  --sombra: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 16px -4px rgba(16, 24, 40, 0.14);
  --foco: 0 0 0 3px rgba(0, 61, 165, 0.28);
  --fonte: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--fonte);
  font-size: 14px;
  color: var(--texto);
  background: var(--fundo-mapa);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.mapa {
  position: fixed;
  inset: 0;
  background: var(--fundo-mapa);
  outline: none;
}
.mapa:focus-visible { box-shadow: inset var(--foco); }

/* ------------------------------------------------------------ superficies */

.painel {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
}

/* --------------------------------------------------------- coluna esquerda */

.lateral {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: 360px;
  max-height: calc(100% - 12px - 44px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none; /* o mapa continua clicavel em volta */
}
.lateral > * { pointer-events: auto; }

.busca {
  position: relative;
  display: flex;
  align-items: center;
  height: 44px;
  flex: none;
  padding: 0 8px 0 38px;
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.busca:focus-within { border-color: var(--primaria); box-shadow: var(--sombra), var(--foco); }
.busca-icone { position: absolute; left: 13px; color: var(--texto-3); pointer-events: none; }
.busca input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  color: var(--texto);
}
.busca input::placeholder { color: var(--texto-3); }
.busca input::-webkit-search-cancel-button { display: none; }
.busca-atalho {
  flex: none;
  font: 500 11px var(--fonte);
  color: var(--texto-3);
  border: 1px solid var(--borda);
  border-radius: 4px;
  padding: 1px 6px;
  background: #fafbfc;
}
.busca:focus-within .busca-atalho { display: none; }
.busca-limpar:not([hidden]) + .busca-atalho { display: none; }
.busca-limpar {
  flex: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--raio-p);
  background: transparent;
  color: var(--texto-3);
  cursor: pointer;
}
.busca-limpar:hover { background: var(--hover); color: var(--texto); }
.busca-limpar:focus-visible { outline: 0; box-shadow: var(--foco); }

/* ----------------------------------------------------------- resultados */

.resultados {
  min-height: 0;
  overflow-y: auto;
  padding: 4px 0 6px;
}
.resultados-grupo {
  margin: 0;
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--texto-3);
}
.resultado {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 12px;
  width: 100%;
  padding: 7px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.resultado:hover, .resultado[aria-selected="true"] { background: var(--hover); }
.resultado[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--primaria); }
.resultado:focus-visible { outline: 0; box-shadow: inset var(--foco); }
.resultado-nome {
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.resultado-nome mark { background: none; color: var(--primaria); font-weight: 600; }
.resultado-sub {
  grid-column: 1;
  font-size: 12px;
  color: var(--texto-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.resultado-cep {
  grid-column: 2;
  grid-row: 1 / span 2;
  font: 600 12.5px var(--fonte);
  font-variant-numeric: tabular-nums;
  color: var(--primaria);
}
.resultado-cep.sem { color: var(--texto-3); font-weight: 500; }
.resultados-vazio, .resultados-mais {
  margin: 0;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--texto-3);
}
.resultados-mais { padding-top: 6px; font-size: 12px; }

/* --------------------------------------------------------------- cartao */

.cartao {
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px 16px;
  animation: entrar 0.16s ease-out;
}
.cartao-topo { display: flex; align-items: flex-start; gap: 8px; }
.cartao-topo > div { flex: 1; min-width: 0; }
.cartao-tipo {
  margin: 0 0 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--texto-3);
}
.cartao h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.fechar {
  flex: none;
  width: 30px;
  height: 30px;
  margin: -4px -6px 0 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--raio-p);
  background: transparent;
  color: var(--texto-3);
  cursor: pointer;
}
.fechar:hover { background: var(--hover); color: var(--texto); }
.fechar:focus-visible { outline: 0; box-shadow: var(--foco); }

.cep {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 12px;
  padding: 10px 12px;
  border-radius: var(--raio-p);
  background: var(--primaria-suave);
}
.cep-rotulo { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--texto-2); }
.cep-valor {
  display: block;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--primaria);
}
.cep.sem { background: var(--hover); }
.cep.sem .cep-valor { font-size: 14px; font-weight: 500; color: var(--texto-2); }

.botao {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--borda-forte);
  border-radius: var(--raio-p);
  background: var(--superficie);
  font-size: 13px;
  font-weight: 500;
  color: var(--texto);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s, border-color 0.12s;
}
.botao:hover { background: var(--hover); border-color: var(--texto-3); }
.botao:active { background: #e8ecf2; }
.botao:focus-visible { outline: 0; box-shadow: var(--foco); }
.botao.ok { border-color: var(--sucesso); color: var(--sucesso); }

.dados { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.dados dt { font-size: 12.5px; color: var(--texto-3); }
.dados dd { margin: 0; font-size: 13.5px; overflow-wrap: anywhere; }

.secao { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--borda); }
.secao-titulo { margin: 0 0 6px; font-size: 12.5px; font-weight: 600; color: var(--texto-2); }
.lista { margin: 0 -8px; padding: 0; list-style: none; }
.lista button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--raio-p);
  background: transparent;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
}
.lista button:hover { background: var(--hover); }
.lista button:focus-visible { outline: 0; box-shadow: var(--foco); }
.lista .nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista .valor { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--primaria); }
.lista .valor.sem { font-weight: 500; color: var(--texto-3); }

/* -------------------------------------------------------------- controles */

.controles {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.grupo {
  display: flex;
  flex-direction: column;
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
}
.ctl {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--texto-2);
  cursor: pointer;
  transition: background-color 0.12s, color 0.12s;
}
.ctl + .ctl { border-top: 1px solid var(--borda); }
.grupo > .ctl:first-child { border-radius: var(--raio) var(--raio) 0 0; }
.grupo > .ctl:last-child { border-radius: 0 0 var(--raio) var(--raio); }
.grupo > .ctl:only-child { border-radius: var(--raio); }
.ctl:hover { background: var(--hover); color: var(--texto); }
.ctl:active { background: #e8ecf2; }
.ctl:focus-visible { outline: 0; box-shadow: var(--foco); z-index: 1; }
.ctl[aria-expanded="true"], .ctl[aria-pressed="true"] { color: var(--primaria); background: var(--primaria-suave); }
.ctl .ico-recolher { display: none; }
.ctl[aria-pressed="true"] .ico-expandir { display: none; }
.ctl[aria-pressed="true"] .ico-recolher { display: block; }

/* Dica ao lado do botao: aparece no hover e no foco pelo teclado. */
.ctl[data-dica]::after {
  content: attr(data-dica);
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  border-radius: 5px;
  background: #1f2937;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s 0.25s;
}
.ctl[data-dica]:hover::after, .ctl[data-dica]:focus-visible::after { opacity: 1; }
.ctl[aria-expanded="true"]::after { display: none; }

.camadas {
  position: absolute;
  top: 12px;
  right: 60px;
  z-index: 11;
  width: 260px;
  padding: 10px 6px 8px;
  animation: entrar 0.14s ease-out;
}
.camadas-titulo { margin: 0 8px 6px; font-size: 13px; font-weight: 600; }
.camadas hr { margin: 6px 8px; border: 0; border-top: 1px solid var(--borda); }
.camada {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--raio-p);
  font-size: 13px;
  cursor: pointer;
}
.camada:hover { background: var(--hover); }
.camada input { margin: 0; accent-color: var(--primaria); width: 15px; height: 15px; cursor: pointer; }
.camada input:focus-visible { outline: 0; box-shadow: var(--foco); border-radius: 3px; }
.camada span:nth-of-type(1) { flex: 1; }
.camada .cont { flex: none; font-size: 12px; color: var(--texto-3); font-variant-numeric: tabular-nums; }
.amostra { flex: none; width: 18px; height: 12px; border-radius: 2px; }
.amostra-rua { height: 3px; background: #1f55b8; border-radius: 2px; }
.amostra-rua-sem { height: 2px; background: #9aa3b0; border-radius: 2px; }
.amostra-bairro { border: 1.5px dashed #6b7589; background: transparent; }
.amostra-cores { background: linear-gradient(90deg, #8fc9a9 0 33%, #fcaa5f 33% 66%, #b9e3a9 66%); opacity: 0.8; }
.amostra-faixa { width: 10px; height: 10px; margin: 0 4px; border-radius: 50%; background: var(--primaria); box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--primaria); }
.amostra-base { background: linear-gradient(135deg, #ebe7e0 0 50%, #dcebd2 50%); box-shadow: inset 0 0 0 1px #d9d1c4; }

/* ----------------------------------------------------------------- rodape */

.rodape {
  position: absolute;
  left: 12px;
  bottom: 10px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px;
  border-radius: var(--raio-p);
  background: rgba(255, 255, 255, 0.88);
  font-size: 11.5px;
  color: var(--texto-2);
}
.escala .ol-scale-line {
  position: static;
  padding: 0;
  background: none;
  border-radius: 0;
}
.escala .ol-scale-line-inner {
  margin: 0;
  border: 1.5px solid var(--texto-2);
  border-top: 0;
  color: var(--texto-2);
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
  will-change: auto;
}
.status { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--sucesso); box-shadow: 0 0 0 2px rgba(23, 138, 79, 0.18); }
.status.parcial i { background: var(--atencao); box-shadow: 0 0 0 2px rgba(183, 121, 31, 0.2); }

.creditos {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 5;
  margin: 0;
  max-width: 55%;
  padding: 3px 8px;
  border-radius: var(--raio-p);
  background: rgba(255, 255, 255, 0.8);
  font-size: 10.5px;
  color: var(--texto-3);
  text-align: right;
}

/* ----------------------------------------------------------------- estados */

.estado {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--fundo-mapa);
  font-size: 13.5px;
  color: var(--texto-2);
  transition: opacity 0.25s;
}
.estado.saindo { opacity: 0; pointer-events: none; }
.giro {
  width: 16px;
  height: 16px;
  border: 2px solid var(--borda-forte);
  border-top-color: var(--primaria);
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}
.estado-erro { flex-direction: column; gap: 4px; text-align: center; padding: 24px; }
.estado-erro svg { color: var(--texto-3); margin-bottom: 8px; }
.estado-erro h1 { margin: 0 0 6px; font-size: 17px; font-weight: 600; color: var(--texto); }
.estado-erro p { margin: 0; max-width: 360px; }

@keyframes girar { to { transform: rotate(360deg); } }
@keyframes entrar { from { opacity: 0; transform: translateY(-4px); } }

/* ----------------------------------------------------------- responsivo */

@media (max-width: 1023px) {
  .lateral { width: 320px; }
}

@media (max-width: 640px) {
  .lateral { top: 8px; left: 8px; right: 58px; width: auto; max-height: calc(100% - 16px); }
  .controles { top: 8px; right: 8px; }
  .camadas { top: 8px; right: 58px; left: 8px; width: auto; }
  .resultados { max-height: 55vh; }
  /* No celular o detalhe vira uma folha na base da tela. */
  .cartao {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 55vh;
    border-radius: 14px 14px 0 0;
    border-bottom: 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    animation: subir 0.18s ease-out;
  }
  .rodape { left: 8px; bottom: 8px; }
  .creditos { display: none; }
  .ctl[data-dica]::after { display: none; }
}
@keyframes subir { from { transform: translateY(24px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
