/* =====================================================================
   ic-comuni-nav.css — Flyout "Comuni" nel header
   Due colonne: province (sx) → comuni della provincia (dx)
   Paletta AGID · scuro navy glass di default · override force-light
   ===================================================================== */

/* ── Trigger button nel nav ────────────────────────────────────────── */
.ic-nav-comuni-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.ic-nav-comuni-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  text-decoration: none;
  /* underline attivo stesso stile nav link */
  border-bottom: 2px solid transparent;
  padding-bottom: 4px;
  transition: color .18s, border-color .18s;
}
.ic-nav-comuni-btn:hover,
.ic-nav-comuni-btn[aria-expanded="true"] {
  color: #5BC4FF;
  border-bottom-color: #5BC4FF;
}
.ic-nav-comuni-btn:focus-visible {
  outline: 2px solid rgba(91,196,255,.55);
  outline-offset: 3px;
  border-radius: 3px;
}
/* caret arrow */
.ic-nav-comuni-btn__caret {
  font-size: 10px;
  opacity: .7;
  transition: transform .2s;
  pointer-events: none;
}
.ic-nav-comuni-btn[aria-expanded="true"] .ic-nav-comuni-btn__caret {
  transform: rotate(180deg);
}

/* ── Pannello flyout ───────────────────────────────────────────────── */
.ic-comuni-panel {
  position: fixed;
  top: var(--header-h, 64px);
  left: 50%;
  z-index: 400;
  width: min(720px, 98vw);
  margin-top: 8px;

  background: rgba(9, 28, 52, 0.97);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(91,196,255,.18);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(91,196,255,.06);
  overflow: hidden;

  /* animation */
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-8px);
  transition: opacity .18s ease, transform .18s ease;
}
.ic-comuni-panel.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* ── Layout interno ────────────────────────────────────────────────── */
.ic-comuni-panel__inner {
  display: flex;
  min-height: 260px;
}

/* ── Colonna sinistra: Province ────────────────────────────────────── */
.ic-cpanel__left {
  flex: 0 0 216px;
  padding: 10px 8px;
  border-right: 1px solid rgba(91,196,255,.12);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ic-cpanel__left-head {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(91,196,255,.60);
  padding: 6px 8px 8px;
}

.ic-cpanel__prov {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  color: rgba(255,255,255,.78);
  text-align: left;
  width: 100%;
  font-family: 'Titillium Web', system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  transition: background .14s, color .14s, border-color .14s;
  position: relative;
}
.ic-cpanel__prov:hover {
  background: rgba(91,196,255,.09);
  color: #fff;
}
.ic-cpanel__prov.is-active {
  background: rgba(91,196,255,.14);
  border-color: rgba(91,196,255,.28);
  color: #fff;
}
.ic-cpanel__prov.is-active::after {
  content: '';
  position: absolute;
  right: -9px;
  top: 50%;
  transform: translateY(-50%);
  width: 0; height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 8px solid rgba(91,196,255,.35);
}
.ic-cpanel__prov:focus-visible {
  outline: 2px solid rgba(91,196,255,.55);
  outline-offset: -2px;
  border-radius: 8px;
}

/* Province sigla pill */
.ic-cpanel__sigla {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(91,196,255,.13);
  border: 1px solid rgba(91,196,255,.22);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #5BC4FF;
  flex-shrink: 0;
  transition: background .14s;
}
.ic-cpanel__prov.is-active .ic-cpanel__sigla {
  background: rgba(91,196,255,.25);
  border-color: rgba(91,196,255,.4);
}

.ic-cpanel__prov-name {
  flex: 1;
}

.ic-cpanel__count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.55);
  flex-shrink: 0;
}
.ic-cpanel__prov.is-active .ic-cpanel__count {
  color: rgba(91,196,255,.7);
}

/* ── Colonna destra: Comuni ─────────────────────────────────────────── */
.ic-cpanel__right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ic-cpanel__right-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(91,196,255,.1);
  flex-shrink: 0;
}

.ic-cpanel__prov-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(91,196,255,.72);
}

.ic-cpanel__all-link {
  font-family: 'Titillium Web', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: rgba(91,196,255,.78);
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s;
}
.ic-cpanel__all-link:hover { color: #5BC4FF; }

/* Lista comuni */
.ic-cpanel__comuni-list {
  list-style: none;
  margin: 0;
  padding: 8px 12px 12px;
  overflow-y: auto;
  max-height: 380px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 4px;
  row-gap: 1px;
  /* scrollbar sottile */
  scrollbar-width: thin;
  scrollbar-color: rgba(91,196,255,.25) transparent;
}
.ic-cpanel__comuni-list::-webkit-scrollbar { width: 4px; }
.ic-cpanel__comuni-list::-webkit-scrollbar-thumb { background: rgba(91,196,255,.25); border-radius: 4px; }

/* singola colonna se pochi comuni (aggiunto via JS) */
.ic-cpanel__comuni-list.ic-cpanel--single-col {
  grid-template-columns: 1fr;
}

/* separatore capoluogo / resto */
.ic-cpanel__sep {
  grid-column: 1 / -1;
  height: 1px;
  background: rgba(91,196,255,.1);
  margin: 6px 0;
}

.ic-cpanel__comune-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: 6px;
  text-decoration: none;
  color: rgba(255,255,255,.72);
  font-family: 'Titillium Web', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.25;
  transition: background .12s, color .12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ic-cpanel__comune-link:hover {
  background: rgba(91,196,255,.1);
  color: #fff;
}
.ic-cpanel__comune-link:focus-visible {
  outline: 2px solid rgba(91,196,255,.5);
  outline-offset: -2px;
}

/* capoluogo */
.ic-cpanel__comune-link.is-capo {
  font-weight: 700;
  color: #fff;
}
.ic-cpanel__comune-link.is-capo::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #5BC4FF;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(91,196,255,.6);
}

/* ── Overlay scuro dietro il pannello ──────────────────────────────── */
.ic-comuni-overlay {
  position: fixed;
  inset: 0;
  z-index: 399;
  background: rgba(0,0,0,.3);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.ic-comuni-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Force-light overrides: dark navy AGID (alta leggibilità) ─────── */
html.force-light .ic-comuni-panel {
  background: rgba(9,28,52,.97) !important;
  border-color: rgba(91,196,255,.18) !important;
  box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(91,196,255,.06) !important;
}
html.force-light .ic-cpanel__left {
  border-right-color: rgba(91,196,255,.12) !important;
}
html.force-light .ic-cpanel__left-head {
  color: rgba(91,196,255,.60) !important;
}
html.force-light .ic-cpanel__prov {
  color: rgba(255,255,255,.78) !important;
}
html.force-light .ic-cpanel__prov:hover {
  background: rgba(91,196,255,.09) !important;
  color: rgba(255,255,255,.78) !important;
}
html.force-light .ic-cpanel__prov.is-active {
  background: rgba(91,196,255,.14) !important;
  border-color: rgba(91,196,255,.28) !important;
  color: #fff !important;
}
html.force-light .ic-cpanel__prov.is-active::after {
  border-left-color: rgba(91,196,255,.35) !important;
}
html.force-light .ic-cpanel__sigla {
  background: rgba(91,196,255,.13) !important;
  border-color: rgba(91,196,255,.22) !important;
  color: #5BC4FF !important;
}
html.force-light .ic-cpanel__prov.is-active .ic-cpanel__sigla {
  background: rgba(91,196,255,.25) !important;
  border-color: rgba(91,196,255,.4) !important;
}
html.force-light .ic-cpanel__count {
  color: rgba(255,255,255,.55) !important;
}
html.force-light .ic-cpanel__prov.is-active .ic-cpanel__count {
  color: rgba(91,196,255,.70) !important;
}
html.force-light .ic-cpanel__right-head {
  border-bottom-color: rgba(91,196,255,.10) !important;
}
html.force-light .ic-cpanel__prov-label {
  color: rgba(91,196,255,.72) !important;
}
html.force-light .ic-cpanel__all-link {
  color: rgba(91,196,255,.78) !important;
}
html.force-light .ic-cpanel__all-link:hover { color: #5BC4FF !important; }
html.force-light .ic-cpanel__sep {
  background: rgba(91,196,255,.10) !important;
}
html.force-light .ic-cpanel__comune-link {
  color: rgba(255,255,255,.72) !important;
}
html.force-light .ic-cpanel__comune-link:hover {
  background: rgba(91,196,255,.10) !important;
  color: #fff !important;
}
html.force-light .ic-cpanel__comune-link.is-capo {
  color: #fff !important;
}
html.force-light .ic-comuni-overlay {
  background: rgba(0,0,0,.30) !important;
}

/* ── Mobile: pannello full-width ───────────────────────────────────── */
@media (max-width: 767px) {
  .ic-comuni-panel {
    width: 100vw;
    left: 0;
    transform: none;
    border-radius: 0 0 14px 14px;
    margin-top: 0;
  }
  .ic-comuni-panel.is-open {
    transform: none;
  }
  .ic-comuni-panel__inner {
    flex-direction: column;
    min-height: unset;
  }
  .ic-cpanel__left {
    flex: none;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid rgba(91,196,255,.12);
    padding: 8px 10px;
    gap: 6px;
  }
  .ic-cpanel__left-head { display: none; }
  .ic-cpanel__prov {
    width: auto;
    padding: 6px 10px;
    flex-direction: row;
    gap: 6px;
  }
  .ic-cpanel__prov-name { display: none; }
  .ic-cpanel__count { display: none; }
  .ic-cpanel__prov.is-active::after { display: none; }
  .ic-cpanel__comuni-list {
    grid-template-columns: 1fr 1fr;
    max-height: 50vh;
  }
}
