/* ============================================================
   Ferramenta: Mapa de Portugal detalhado
   (18 distritos · 308 municípios · 3.091 freguesias)
   Re-tematizada do tema ESCURO original para a paleta CLARA do
   site (forest + gold), usando os tokens globais. Layout, função,
   IDs/classes e dados IDÊNTICOS ao original — apenas cores/tipografia.
   O SVG/mapa é uma imagem raster (JPEG base64) com rótulos clicáveis
   sobrepostos (.dl/.dp); a interatividade é preservada 100%.
   ============================================================ */

/* ─── CONTAINER (fluido; sem fundo/largura que brigue com .jt-wrap) ─── */
#pg {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 4px 0 32px;
  color: var(--text-700);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

/* ─── HERO ─── */
.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px 24px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--sh-sm);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(var(--gold-rgb), .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--gold-rgb), .05) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 0%, black 30%, transparent 100%);
  mask-image: radial-gradient(ellipse 80% 80% at 50% 0%, black 30%, transparent 100%);
  pointer-events: none;
}
.hi {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.hb {
  display: inline-flex;
  align-items: center;
  background: var(--gold-bg);
  border: 1px solid rgba(var(--gold-rgb), .35);
  border-radius: 50px;
  padding: 4px 13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold-deep);
  margin-bottom: 9px;
}
.ht {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.5vw, 2.3rem);
  font-weight: 800;
  color: var(--forest-900);
  letter-spacing: -.03em;
  line-height: 1.1;
  margin-bottom: 6px;
}
.ht em { color: var(--gold-deep); font-style: normal; }
.hd { font-size: 14px; color: var(--text-500); line-height: 1.6; }
.hs-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 12px; }
.hs {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 12px;
  text-align: center;
  flex: 1;
  min-width: 58px;
}
.hv {
  font-family: var(--font-num);
  font-size: .9rem;
  font-weight: 800;
  color: var(--forest-900);
  display: block;
}
.hl {
  font-size: 9px;
  color: var(--text-400);
  text-transform: uppercase;
  letter-spacing: .08em;
  display: block;
  margin-top: 1px;
}

/* ─── BUSCA ─── */
.sw {
  position: relative;
  min-width: 0;
  width: 100%;
  max-width: 210px;
  align-self: flex-start;
}
.sw svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--text-400);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
#si {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 9px 12px 9px 30px;
  color: var(--text-900);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  font-weight: 500;
  transition: border-color .2s, box-shadow .2s;
}
#si:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(var(--gold-rgb), .18);
}
#si::placeholder { color: var(--text-400); }

/* ─── LAYOUT (mapa + painel) ─── */
.lay { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: start; }

.mb {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 11px 9px;
  box-shadow: var(--sh-sm);
}
.mw { position: relative; display: block; width: 100%; max-width: 280px; margin: 0 auto; }
.mw img { width: 100%; display: block; border-radius: 9px; }

/* ─── RÓTULOS SOBRE O MAPA ─── */
.dl { position: absolute; transform: translate(-50%, -50%); cursor: pointer; z-index: 10; }
.dp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .92);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 9px;
  font-weight: 700;
  color: var(--forest-900);
  white-space: nowrap;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  letter-spacing: .01em;
  transition: all .18s;
  box-shadow: 0 1px 6px rgba(16, 37, 22, .18);
}
.dl:hover .dp,
.dl.act .dp {
  background: var(--gold);
  border-color: var(--gold-deep);
  color: var(--forest-900);
  transform: scale(1.1);
}
.dl.act .dp { transform: scale(1); box-shadow: 0 0 0 2px rgba(var(--gold-rgb), .3); }
.mh {
  text-align: center;
  font-size: 9px;
  color: var(--text-400);
  margin-top: 7px;
  letter-spacing: .07em;
  text-transform: uppercase;
  font-weight: 700;
}

/* ─── PAINEL LATERAL ─── */
.pn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  min-height: 420px;
  box-shadow: var(--sh-sm);
}
.pi { padding: 18px; }

.bc {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-500);
  margin-bottom: 11px;
  flex-wrap: wrap;
}
.lk { color: var(--gold-deep); cursor: pointer; font-weight: 700; }
.lk:hover { text-decoration: underline; }
.sp { color: var(--text-400); }

.bb {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 50px;
  padding: 5px 12px;
  font-size: 11px;
  color: var(--text-700);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all .18s;
  margin-bottom: 11px;
}
.bb:hover { color: var(--gold-deep); border-color: var(--gold); }
.bb svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ─── GRID DE DISTRITOS ─── */
.dg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dc {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 10px 10px 13px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  overflow: hidden;
}
.dc:hover {
  border-color: rgba(var(--gold-rgb), .45);
  transform: translateY(-1px);
  box-shadow: var(--sh-sm);
}
.ac { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; } /* cor de acento por distrito (inline via JS) */
.dn { font-size: .78rem; font-weight: 800; color: var(--forest-900); line-height: 1.3; margin-bottom: 2px; }
.dm { font-size: 9px; color: var(--text-500); font-weight: 600; }

/* ─── DETALHE DO DISTRITO ─── */
.sc {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-500);
  margin-bottom: 7px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--line);
}
.dt {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
  margin-bottom: 4px;
} /* cor de acento por distrito (inline via JS) */
.dr { font-size: 11px; margin-bottom: 11px; }
.st { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 13px; }
.sb { background: var(--paper); border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; }
.sb .sv { font-family: var(--font-num); font-size: .83rem; font-weight: 800; color: var(--forest-900); display: block; margin-bottom: 1px; }
.sb .sl { font-size: 9px; color: var(--text-500); text-transform: uppercase; letter-spacing: .08em; display: block; }

/* ─── LISTA DE MUNICÍPIOS ─── */
.ml { display: flex; flex-direction: column; gap: 3px; }
.mi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 11px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-700);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all .15s;
  font-weight: 500;
  gap: 7px;
}
.mi:hover { border-color: rgba(var(--gold-rgb), .5); color: var(--forest-900); padding-left: 14px; }
.ia { color: var(--text-400); font-size: 12px; flex-shrink: 0; }
.mi:hover .ia { color: var(--gold-deep); }
.fc { font-size: 9px; color: var(--text-500); font-weight: 600; flex-shrink: 0; }

/* ─── DETALHE DO MUNICÍPIO / FREGUESIAS ─── */
.mt { font-family: var(--font-display); font-size: 1.2rem; font-weight: 800; color: var(--forest-900); margin-bottom: 3px; letter-spacing: -.02em; }
.ms { font-size: 12px; margin-bottom: 11px; font-weight: 600; color: var(--text-500); }
.fh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 7px; }
.fh .sc { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.fct {
  background: var(--gold-bg);
  border: 1px solid rgba(var(--gold-rgb), .3);
  border-radius: 50px;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 700;
  color: var(--gold-deep);
}
.fg { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 3px; margin-top: 3px; }
.fi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-700);
  line-height: 1.3;
}
.fi:hover { color: var(--forest-900); }

/* ─── RESULTADOS DE BUSCA ─── */
.srl { display: flex; flex-direction: column; gap: 4px; }
.sri {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  cursor: pointer;
  transition: all .15s;
}
.sri:hover { border-color: rgba(var(--gold-rgb), .45); transform: translateX(2px); }
.srm { font-size: 13px; font-weight: 700; color: var(--forest-900); }
.srd { font-size: 10px; color: var(--text-500); margin-top: 2px; }
.em { text-align: center; padding: 30px 14px; color: var(--text-500); font-size: 13px; }

/* ─── CHIPS DE REGIÃO (acentos por região; tons ajustados p/ leitura sobre claro) ─── */
.rt { display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 2px 7px; border-radius: 50px; border: 1px solid; }
.rn { color: #1d4ed8; border-color: rgba(29, 78, 216, .30); background: rgba(59, 130, 246, .10); }   /* Norte */
.rc { color: #047857; border-color: rgba(4, 120, 87, .30);  background: rgba(16, 185, 129, .10); }   /* Centro */
.rl { color: #a16207; border-color: rgba(161, 98, 7, .30);  background: rgba(234, 179, 8, .12); }    /* Lisboa */
.ra { color: #c2410c; border-color: rgba(194, 65, 12, .30); background: rgba(249, 115, 22, .10); }   /* Alentejo */
.rg { color: #7e22ce; border-color: rgba(126, 34, 206, .30); background: rgba(168, 85, 247, .10); }  /* Algarve */

/* ─── RESPONSIVO ─── */
@media (max-width: 720px) {
  .lay { grid-template-columns: 1fr; }
  .mb { max-width: 340px; margin: 0 auto; }
  .mw { max-width: 260px; }
  .sw { max-width: 100%; }
}
@media (max-width: 440px) {
  #pg { padding: 4px 0 24px; }
  .hero { padding: 20px 14px 18px; }
  .pi { padding: 12px; }
  .dg { grid-template-columns: 1fr; }
}

/* Título do distrito no drill-down: acento inline (ex.: Lisboa #fde047) fica
   ilegível sobre fundo claro. Força cor escura legível; o acento segue nas
   barras/chips dos cards. */
#pg .dt{color:var(--forest-900)!important}
