/* ==========================================================================
   com_breizh — pages intercommunalités (/intercommunalites, /intercommunalites/<alias>)
   Jetons du gabarit demat_* (template.css) avec valeurs de repli, comme breizh.css.
   Signature reprise de la page « Actualités » : barres, numéro de département en filigrane.
   ========================================================================== */

.com-breizh-epci {
  --bz-encre: var(--hermine, #12100e);
  --bz-fond: var(--blanc-ecume, #fbfaf7);
  --bz-nuit: var(--noir-goemon, #001e26);
  --bz-glaz: var(--bleu-glaz, #0e7d8c);
  --bz-glaz-fonce: var(--bleu-glaz-fonce, #0a5f6b);
  --bz-sable: var(--sable, #e8ddc8);
  --bz-granit: var(--granit, #5f6e73);
  --bz-ligne: var(--ligne, rgba(18, 16, 14, 0.12));
  --bz-titre: var(--police-titre, 'Bricolage Grotesque', system-ui, sans-serif);
  --bz-donnees: var(--police-donnees, ui-monospace, 'SF Mono', Menlo, monospace);

  /* Un ton pâle par département (carte, pastilles, filets) */
  --dept-22: #cfe5e2;
  --dept-29: #d3e0ec;
  --dept-35: #efe2c8;
  --dept-56: #dcd8ec;
  --dept-44: #ecd5cd;

  color: var(--bz-encre);
  min-width: 0;
  margin-bottom: 2.5rem;
}

.com-breizh-epci [data-dept="22"] { --zone: var(--dept-22); }
.com-breizh-epci [data-dept="29"] { --zone: var(--dept-29); }
.com-breizh-epci [data-dept="35"] { --zone: var(--dept-35); }
.com-breizh-epci [data-dept="56"] { --zone: var(--dept-56); }
.com-breizh-epci [data-dept="44"] { --zone: var(--dept-44); }

.com-breizh-epci .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* --- Entête ---------------------------------------------------------------- */

.epci-entete {
  position: relative;
  isolation: isolate;
  padding-block: clamp(1rem, 3vw, 2rem) 0.5rem;
}

.epci-filigrane {
  position: absolute;
  z-index: -1;
  top: -0.05em;
  right: 0;
  font-family: var(--bz-titre);
  font-weight: 800;
  font-size: clamp(6rem, 15vw, 12rem);
  letter-spacing: -0.05em;
  line-height: 0.8;
  color: var(--bz-glaz);
  opacity: 0.12;
  pointer-events: none;
  user-select: none;
}

.epci-surtitre {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.9rem;
  font-family: var(--bz-donnees);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bz-granit);
}

.epci-surtitre a { color: inherit; text-decoration: none; border-bottom: 1px solid currentColor; }
.epci-surtitre a:hover { color: var(--bz-glaz); }

/* Trois barres, la signature du site */
.epci-barres {
  flex: none;
  width: 1.4rem;
  height: 0.8rem;
  background:
    linear-gradient(var(--bz-glaz) 0 0) 0 0 / 100% 2px no-repeat,
    linear-gradient(var(--bz-glaz) 0 0) 0 50% / 100% 2px no-repeat,
    linear-gradient(var(--bz-glaz) 0 0) 0 100% / 100% 2px no-repeat;
}

.epci-titre {
  max-width: 20ch;
  margin: 0 0 1rem;
  font-family: var(--bz-titre);
  font-size: clamp(2.2rem, 5.5vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
  text-wrap: balance;
}

.epci-intro {
  max-width: 56ch;
  margin: 0 0 1.25rem;
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  line-height: 1.6;
  color: var(--bz-granit);
}

.epci-chiffres {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem clamp(1.5rem, 4vw, 3rem);
  margin: 1.5rem 0 0;
  padding: 1.1rem 0 0;
  border-top: 1px solid var(--bz-ligne);
  list-style: none;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bz-granit);
}

.epci-chiffres strong {
  display: block;
  font-family: var(--bz-donnees);
  font-variant-numeric: tabular-nums;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--bz-encre);
}

.epci-h2 {
  margin: 0 0 1rem;
  font-family: var(--bz-titre);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-wrap: balance;
}

/* --- Carte ------------------------------------------------------------------ */

.epci-carte {
  position: relative;
  margin: 1.5rem 0 2.5rem;
  padding: clamp(0.5rem, 2vw, 1.25rem);
  border: 1px solid var(--bz-ligne);
  border-radius: 24px;
  background: #eef4f5;
}

.epci-carte svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 78vh;
  margin-inline: auto;
}

.epci-carte--mini { margin: 0; padding: 0.25rem; }
.epci-carte--mini svg { max-height: 26rem; }

.epci-carte svg path {
  fill-rule: evenodd;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.epci-zone path {
  fill: var(--zone, #e3e9ea);
  stroke: #fff;
  stroke-width: 1.1px;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill 0.15s ease;
}

/* Triangle de Demat : Lannion-Trégor, Guingamp-Paimpol, Morlaix */
.epci-zone.is-home path {
  fill: color-mix(in srgb, var(--zone, #e3e9ea) 62%, var(--bz-glaz));
}

.epci-zone:hover path,
.epci-zone:focus-visible path {
  fill: var(--bz-glaz);
}

.epci-zone.is-current path {
  fill: var(--bz-glaz);
  stroke: var(--bz-nuit);
  stroke-width: 1.6px;
}

.epci-zone { outline: none; }
.epci-zone:focus-visible path {
  stroke: var(--bz-nuit);
  stroke-width: 2.4px;
}

.epci-carte .dept-lines {
  fill: none;
  stroke: var(--bz-nuit);
  stroke-width: 2.2px;
  stroke-opacity: 0.55;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

.epci-infobulle {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  max-width: 17rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: var(--bz-nuit);
  color: #fff;
  font-size: 0.85rem;
  line-height: 1.3;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(0, 30, 38, 0.25);
}

.epci-infobulle[hidden] { display: none; }
.epci-infobulle strong { font-family: var(--bz-titre); font-size: 0.95rem; }
.epci-infobulle span { color: rgba(255, 255, 255, 0.75); }

.epci-legende { margin-top: 0.75rem; padding-inline: 0.5rem; }

.epci-legende ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.82rem;
  color: var(--bz-granit);
}

.epci-legende li { display: inline-flex; align-items: center; gap: 0.45rem; }

.epci-pastille {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 4px;
  background: var(--zone, #e3e9ea);
  box-shadow: inset 0 0 0 1px rgba(0, 30, 38, 0.18);
}

.epci-pastille.is-home { background: color-mix(in srgb, var(--dept-22) 50%, var(--bz-glaz)); }

.epci-legende-note { margin: 0.6rem 0 0; font-size: 0.78rem; color: var(--bz-granit); }

/* --- Liste par département -------------------------------------------------- */

.epci-groupe { margin-top: 2.25rem; }

.epci-groupe-titre {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  margin: 0 0 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--zone, var(--bz-encre));
  font-family: var(--bz-titre);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.epci-groupe-num {
  padding: 0.05em 0.45em;
  border-radius: 6px;
  background: var(--zone, var(--bz-sable));
  font-family: var(--bz-donnees);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0;
}

.epci-groupe-compte {
  margin-left: auto;
  font-family: var(--bz-donnees);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bz-granit);
}

.epci-table { width: 100%; border-collapse: collapse; font-size: 0.97rem; }

.epci-table th,
.epci-table td { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--bz-ligne); text-align: left; vertical-align: baseline; }

.epci-table thead th {
  font-family: var(--bz-donnees);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bz-granit);
}

.epci-table tbody th { font-weight: 650; }
.epci-table tbody th a { color: var(--bz-encre); text-decoration: none; border-bottom: 1px solid transparent; }
.epci-table tbody th a:hover,
.epci-table tbody th a:focus-visible { color: var(--bz-glaz-fonce); border-bottom-color: currentColor; }
.epci-table tbody tr:hover { background: rgba(14, 125, 140, 0.05); }
.epci-table tr.is-home th a::after { content: ' ★'; color: var(--bz-glaz); font-size: 0.8em; }

.epci-table .epci-nombre { font-family: var(--bz-donnees); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.epci-table td { color: var(--bz-granit); }
.epci-table td.epci-nombre { color: var(--bz-encre); }

.epci-source { margin: 1.5rem 0 0; max-width: 70ch; font-size: 0.8rem; color: var(--bz-granit); }
.epci-source a { color: inherit; }

/* --- Page d'une intercommunalité -------------------------------------------- */

.epci-haut {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 2rem);
  align-items: start;
  margin-top: 1.5rem;
}

.epci-fiche {
  padding: clamp(1.1rem, 2.5vw, 1.75rem);
  border-radius: 20px;
  background: var(--bz-sable);
}

.epci-fiche-titre {
  margin: 0 0 0.75rem;
  font-family: var(--bz-donnees);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bz-granit);
}

.epci-faits { margin: 0; }
.epci-faits > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.55rem 0; border-top: 1px solid rgba(18, 16, 14, 0.14); }
.epci-faits dt { font-weight: 500; color: var(--bz-granit); }
.epci-faits dd { margin: 0; font-weight: 650; text-align: right; font-variant-numeric: tabular-nums; }

.epci-site { margin: 1rem 0 0; }

.epci-bouton {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  background: var(--bz-nuit);
  color: #fff;
  font-weight: 650;
  text-decoration: none;
}

.epci-bouton:hover,
.epci-bouton:focus-visible { background: var(--bz-glaz-fonce); color: #fff; }

.epci-bouton--ligne { background: transparent; color: var(--bz-encre); box-shadow: inset 0 0 0 1.5px var(--bz-encre); }
.epci-bouton--ligne:hover,
.epci-bouton--ligne:focus-visible { background: var(--bz-encre); color: #fff; }

.epci-communes,
.epci-actus { margin-top: clamp(2rem, 5vw, 3.5rem); }

.epci-communes-note { margin: -0.4rem 0 1rem; font-size: 0.88rem; color: var(--bz-granit); }

.epci-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }

.epci-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bz-sable) 55%, #fff);
  color: var(--bz-encre);
  font-size: 0.93rem;
  line-height: 1.3;
  text-decoration: none;
}

.epci-chip.is-lien {
  background: color-mix(in srgb, var(--bz-glaz) 11%, #fff);
  color: var(--bz-glaz-fonce);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--bz-glaz) 30%, transparent);
}

.epci-chip.is-lien:hover,
.epci-chip.is-lien:focus-visible { background: var(--bz-glaz-fonce); color: #fff; }

.epci-chip-cp { font-family: var(--bz-donnees); font-size: 0.72rem; font-weight: 500; opacity: 0.65; }

.epci-actus-plus { margin: 1.5rem 0 0; }
.epci-retour { margin: 2.5rem 0 0; }
.epci-retour a { color: var(--bz-glaz-fonce); font-weight: 600; text-decoration: none; }
.epci-retour a:hover { text-decoration: underline; }

/* Cartes d'actualité sans la feuille actualites.css (autre gabarit) : grille minimale */
.epci-actus .actus-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr)); gap: 1.25rem; }

/* --- Mobile ------------------------------------------------------------------ */

@media (max-width: 820px) {
  .epci-haut { grid-template-columns: minmax(0, 1fr); }
  .epci-carte { border-radius: 16px; margin-bottom: 1.75rem; }
  .epci-carte--mini { order: -1; }
  .epci-legende ul { gap: 0.3rem 0.9rem; }

  /* Tableau → cartes empilées */
  .epci-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .epci-table,
  .epci-table tbody,
  .epci-table tr,
  .epci-table th,
  .epci-table td { display: block; }
  .epci-table tr { padding: 0.7rem 0; border-bottom: 1px solid var(--bz-ligne); }
  .epci-table th,
  .epci-table td { padding: 0.1rem 0; border: 0; }
  .epci-table tbody th { margin-bottom: 0.25rem; font-size: 1.05rem; }
  .epci-table td { display: inline-block; margin-right: 1rem; font-size: 0.88rem; }
  .epci-table td.epci-nombre { text-align: left; }
  .epci-table td::before { content: attr(data-label) ' : '; color: var(--bz-granit); }
  .epci-groupe-compte { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .epci-zone path { transition: none; }
}
