/* ═══════════════════════════════════════════════════════════════════════════
   comune-hub.css — Stili pagina hub multi-comune (es. /alghero)
   Prefisso classi: ch-* (e ed-comune-* per overrides hero specifici)
   Riusa variabili da style.css e componenti da editorial.css.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Hero (overrides minimi rispetto a editorial-layouts) ─────────────────── */
.ed-comune-hero {
  position: relative;
  min-height: 380px;
  color: #fff;
  display: flex;
  align-items: flex-end;
  margin-bottom: 0;
}
.ed-comune-hero .ed-hero-photo {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}
.ed-comune-hero .ed-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.65) 100%);
  z-index: 1;
}
.ed-comune-hero .ed-hero-inner {
  position: relative;
  z-index: 2;
  padding: 64px 0 48px;
}
.ed-comune-hero .hd-crumbs a {
  color: rgba(255, 255, 255, 0.85);
}
.ed-comune-hero .hd-crumbs a:hover {
  color: #fff;
}
.ed-comune-hero h1 {
  color: #fff;
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  margin: 16px 0 12px;
}
.ed-comune-hero h1 em {
  color: var(--color-primary, #c04428);
  font-style: italic;
}
.ed-comune-hero .hd-hero-lead {
  color: rgba(255, 255, 255, 0.92);
  max-width: 640px;
  font-size: 1.05rem;
  line-height: 1.6;
}

/* ── Layout principale: main + sidebar ─────────────────────────────────────── */
.ch-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
  margin: 48px auto;
  max-width: 1200px;
}
@media (min-width: 980px) {
  .ch-layout {
    grid-template-columns: 1fr 280px;
    gap: 48px;
  }
}

.ch-main {
  min-width: 0;
}

/* ── Sezioni numerate ──────────────────────────────────────────────────────── */
.ch-sec {
  background: var(--color-bg-card, #fff);
  border: 1px solid var(--color-border, #e0d8c8);
  border-radius: 14px;
  padding: 32px;
  margin-bottom: 24px;
}
.ch-sec .hd-sec-num {
  display: inline-block;
  font-family: var(--font-mono, monospace);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  color: var(--color-primary, #c04428);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.ch-sec h2 {
  font-family: var(--font-heading, 'Fraunces');
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--color-text, #2a1f15);
}
.ch-sec-lead {
  color: var(--color-text-soft, #6b5e4f);
  font-size: 1rem;
  line-height: 1.6;
  margin: 0 0 24px;
  max-width: 56ch;
}

/* ── Identita: due colonne contenuto + glossario ──────────────────────────── */
.ch-identita-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}
@media (min-width: 720px) {
  .ch-identita-grid {
    grid-template-columns: 1.4fr 1fr;
  }
}
.ch-identita-text p {
  margin-bottom: 12px;
  line-height: 1.65;
}
.ch-identita-text p em {
  font-style: italic;
  color: var(--color-primary, #c04428);
}
.ch-identita-glossario {
  background: var(--color-bg-soft, #f5f1e8);
  border-radius: 10px;
  padding: 20px;
}
.ch-identita-glossario h3 {
  margin-top: 0;
  font-family: var(--font-heading, 'Fraunces');
}
.ch-side-lead {
  font-size: 0.9rem;
  color: var(--color-text-soft, #6b5e4f);
  margin: 4px 0 16px;
}
.ch-gloss-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}
.ch-gloss-list > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--color-border, #e0d8c8);
}
.ch-gloss-list > div:last-child {
  border-bottom: none;
}
.ch-gloss-list dt {
  font-weight: 600;
  font-style: italic;
  color: var(--color-primary, #c04428);
}
.ch-gloss-list dd {
  margin: 0;
  font-size: 0.92rem;
  color: var(--color-text-soft, #6b5e4f);
}

/* ── Photo credit (attribuzione licenza CC) ───────────────────────────────── */
.ch-photo-credit {
  margin: 12px 0 0;
  font-size: 0.78rem;
  color: var(--color-text-muted, #8a7e6f);
  font-style: italic;
}
.ch-photo-credit a {
  color: var(--color-text-soft, #6b5e4f);
  text-decoration: underline;
  text-decoration-color: var(--color-border, #e0d8c8);
}
.ch-photo-credit a:hover {
  color: var(--color-primary, #c04428);
  text-decoration-color: currentColor;
}

/* ── Card grids (servizi, cultura, eventi, voices, emergenza) ────────────── */
.ch-emergenza-grid,
.ch-servizi-grid,
.ch-cultura-grid,
.ch-eventi-grid,
.ch-voices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.ch-card {
  background: var(--color-bg-soft, #f5f1e8);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ch-card-title {
  font-weight: 600;
  font-family: var(--font-heading, 'Fraunces');
  margin: 0;
  font-size: 1rem;
}
.ch-card-meta {
  font-size: 0.85rem;
  color: var(--color-text-soft, #6b5e4f);
}
.ch-card a {
  color: var(--color-primary, #c04428);
  text-decoration: none;
}
.ch-card a:hover {
  text-decoration: underline;
}

/* ── Card emergenza specifiche ─────────────────────────────────────────────── */
.ch-emergenza-card {
  background: var(--color-bg-card, #fff);
  border: 1px solid var(--color-border, #e0d8c8);
  border-left: 4px solid var(--color-status-alert, #d9534f);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ch-emergenza-card.is-urgente {
  border-left-color: #d9534f;
}
.ch-emergenza-card.is-locale {
  border-left-color: var(--color-primary, #c04428);
}
.ch-emergenza-numero {
  font-family: var(--font-mono, monospace);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-primary, #c04428);
}
.ch-emergenza-numero a {
  color: inherit;
  text-decoration: none;
}
.ch-emergenza-label {
  font-weight: 600;
  font-size: 0.95rem;
}
.ch-emergenza-meta {
  font-size: 0.82rem;
  color: var(--color-text-soft, #6b5e4f);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ch-badge {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--color-bg-soft, #f5f1e8);
}
.ch-badge--ambito-nazionale {
  background: #e8f1e8;
  color: #2a6b2a;
}
.ch-badge--ambito-locale {
  background: #f5e8d4;
  color: #8a5a1a;
}

/* ── Mappa Leaflet container ──────────────────────────────────────────────── */
.ch-map {
  width: 100%;
  height: 460px;
  border-radius: 10px;
  background: var(--color-bg-soft, #f5f1e8);
  border: 1px solid var(--color-border, #e0d8c8);
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* ── Marker pin (divIcon CSP-safe, no PNG bundled) ────────────────────────── */
.ch-map-pin {
  position: relative;
  cursor: pointer;
}
.ch-map-pin-dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(0, 0, 0, 0.08);
  transform: translate(2px, 2px);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease;
}
.ch-map-pin-shadow {
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 14px;
  height: 4px;
  margin-left: -7px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 50%;
  filter: blur(1px);
  pointer-events: none;
}
.ch-map-pin:hover .ch-map-pin-dot {
  transform: translate(2px, 2px) scale(1.25);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.1);
  z-index: 999;
}

/* ── Popup styling (coerente con design system) ───────────────────────────── */
.ch-popup-wrap .leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  background: var(--color-bg-card, #fff);
  color: var(--color-text, #2a1f15);
  padding: 0;
}
.ch-popup-wrap .leaflet-popup-content {
  margin: 14px 16px;
  font-family: var(--font-body, system-ui, sans-serif);
  line-height: 1.45;
}
.ch-popup-wrap .leaflet-popup-tip {
  background: var(--color-bg-card, #fff);
}
.ch-popup-wrap .leaflet-popup-close-button {
  color: var(--color-text-soft, #6b5e4f);
  padding: 8px 8px 0 0;
}
.ch-popup-title {
  margin: 0 0 6px;
  font-family: var(--font-heading, 'Fraunces');
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary, #c04428);
  line-height: 1.3;
}
.ch-popup-addr {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--color-text-soft, #6b5e4f);
}
.ch-popup-phone,
.ch-popup-link {
  margin: 4px 0;
  font-size: 0.88rem;
}
.ch-popup-phone a,
.ch-popup-link a {
  color: var(--color-primary, #c04428);
  text-decoration: none;
  font-weight: 500;
}
.ch-popup-phone a:hover,
.ch-popup-link a:hover {
  text-decoration: underline;
}
.ch-popup-desc {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--color-text-soft, #6b5e4f);
  line-height: 1.45;
  font-style: italic;
}

/* ── Attribution discreta ─────────────────────────────────────────────────── */
.ch-map .leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.85);
  padding: 2px 6px;
  border-radius: 4px 0 0 0;
}
.ch-map .leaflet-control-attribution a {
  color: var(--color-text-soft, #6b5e4f);
}

/* ── CTA row ──────────────────────────────────────────────────────────────── */
.ch-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.ch-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 88px;
  align-self: start;
}
.ch-side-block {
  background: var(--color-bg-card, #fff);
  border: 1px solid var(--color-border, #e0d8c8);
  border-radius: 12px;
  padding: 18px;
}
.ch-side-block h3 {
  margin: 0 0 12px;
  font-family: var(--font-heading, 'Fraunces');
  font-size: 1rem;
  font-weight: 600;
}
.ch-side-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.ch-side-list li {
  display: flex;
  flex-direction: column;
}
.ch-side-list a {
  color: var(--color-primary, #c04428);
  text-decoration: none;
}
.ch-side-list a:hover {
  text-decoration: underline;
}
.ch-side-n {
  font-size: 1.6rem;
  font-weight: 600;
  font-family: var(--font-heading, 'Fraunces');
  color: var(--color-primary, #c04428);
}
.ch-side-l {
  font-size: 0.85rem;
  color: var(--color-text-soft, #6b5e4f);
}
.ch-side-istituzionale {
  margin: 0;
  font-size: 0.92rem;
}

/* ── Skeleton stati ──────────────────────────────────────────────────────── */
.ch-skel {
  padding: 24px;
  text-align: center;
  color: var(--color-text-soft, #6b5e4f);
  font-style: italic;
  background: var(--color-bg-soft, #f5f1e8);
  border-radius: 8px;
}
.ch-empty {
  padding: 24px;
  text-align: center;
  color: var(--color-text-soft, #6b5e4f);
  font-size: 0.92rem;
}

/* ── Mobile (≤640px) ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .ch-sec {
    padding: 20px 16px;
  }
  .ed-comune-hero {
    min-height: 320px;
  }
  .ed-comune-hero .ed-hero-inner {
    padding: 32px 0 24px;
  }
  .ch-sidebar {
    position: static;
  }
}
