/*
 * /local pages (départements, département, commune, intercommunalité) — editorial hero, stats band,
 * sticky "Sur cette page" nav. Markup: html/layouts/demat/local.php. Same file in both demat templates.
 */

.loc {
  --loc-sable-clair: #f3ede1;
  --loc-glaz-clair: #7fd0da;
}

/* ---------- Hero ---------- */

.loc-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  grid-template-areas:
    "texte image"
    "stats stats";
  margin: 0.5rem 0 clamp(2rem, 1.5rem + 2vw, 3rem);
  border-radius: calc(var(--rayon, 10px) * 1.6);
  overflow: hidden;
  background: var(--noir-goemon, #001e26);
  color: var(--blanc-ecume, #fbfaf7);
}

.loc-hero-texte {
  grid-area: texte;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.9rem;
  min-width: 0;
  container-type: inline-size;
  padding: clamp(1.5rem, 1rem + 3vw, 3.5rem) clamp(1.25rem, 0.75rem + 3vw, 3.5rem) clamp(1.5rem, 1rem + 2vw, 2.5rem);
}

.loc-surtitre {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  margin: 0;
  font-family: var(--police-donnees, monospace);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--loc-glaz-clair);
}

.loc-surtitre a { color: inherit; text-decoration: none; }
.loc-surtitre a:hover, .loc-surtitre a:focus-visible { text-decoration: underline; text-underline-offset: 0.2em; }

/* The three-bar E of the Demat logo */
.loc-barres {
  flex: none;
  width: 1.6rem;
  height: 0.9rem;
  background:
    linear-gradient(currentColor 0 0) 0 0 / 100% 3px no-repeat,
    linear-gradient(currentColor 0 0) 0 50% / 72% 3px no-repeat,
    linear-gradient(currentColor 0 0) 0 100% / 100% 3px no-repeat;
}

.loc-titre {
  margin: 0;
  font-family: var(--police-titres); font-synthesis: none; word-spacing: 0.15em; font-weight: 400;
  color: inherit;
  overflow-wrap: break-word;
  hyphens: manual;
}

.loc-titre-nom { font-family: var(--police-titres); font-synthesis: none; word-spacing: 0.15em;
  display: block;
  /* capped by the text column width so a 12-letter word (« Départements ») never breaks */
  font-size: min(clamp(2.9rem, 1.4rem + 6.2vw, 7rem), 15cqi);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: -0.011em;
  font-variation-settings: "wdth" 85;
}

.loc-titre--long .loc-titre-nom { font-size: min(clamp(2.2rem, 1.2rem + 4vw, 4.8rem), 12cqi); line-height: 0.98; }

.loc-titre-suite {
  display: block;
  font-family: var(--police-titre); /* sous-titre : reste en Bricolage */
  word-spacing: normal;
  margin-top: 0.75rem;
  max-width: 34ch;
  font-size: clamp(1rem, 0.9rem + 0.5vw, 1.3rem);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0;
  color: rgba(251, 250, 247, 0.78);
}

.loc-breton {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.75rem;
  margin: 0.25rem 0 0;
}

.loc-breton-label {
  font-family: var(--police-donnees, monospace);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(251, 250, 247, 0.65);
}

.loc-breton-nom {
  font-family: var(--police-titres); font-synthesis: none; word-spacing: 0.15em;
  font-size: clamp(1.6rem, 1.1rem + 2.2vw, 2.9rem);
  font-weight: 400;
  font-style: italic;
  line-height: 1;
  letter-spacing: -0.006em;
  color: var(--sable, #e8ddc8);
}

.loc-lede {
  margin: 0.25rem 0 0;
  max-width: 52ch;
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
  line-height: 1.55;
  color: rgba(251, 250, 247, 0.85);
}

.loc-hero-image {
  grid-area: image;
  position: relative;
  min-height: 100%;
}

.loc-hero-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Lets the dark text panel bleed into the photo */
.loc-hero-image::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--noir-goemon, #001e26) 0%, rgba(0, 30, 38, 0) 35%);
}

/* Photo credit (Wikimedia Commons licences require it), over the bottom-right corner of the photo */
.loc-credit {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 1;
  max-width: 100%;
  margin: 0;
  padding: 0.3rem 0.6rem;
  background: rgba(0, 30, 38, 0.72);
  color: #fbfaf7;
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: right;
}

.loc-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.loc-credit a:hover, .loc-credit a:focus-visible { color: #fff; text-decoration-thickness: 2px; }

/* ---------- Stats band ---------- */

.loc-stats {
  grid-area: stats;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  margin: 0;
  border-top: 1px solid rgba(251, 250, 247, 0.16);
}

.loc-stats > div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: 0.35rem;
  min-width: 0;
  padding: 1.1rem clamp(1.25rem, 0.75rem + 2vw, 2rem) 1.3rem;
  border-left: 1px solid rgba(251, 250, 247, 0.16);
}

.loc-stats > div:first-child { border-left: 0; }

.loc-stats dt {
  font-family: var(--police-donnees, monospace);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--loc-glaz-clair);
}

.loc-stats dd {
  margin: 0;
  font-family: var(--police-titre); /* chiffres : Bricolage (espace fine U+202F visible) */
  font-size: clamp(1.25rem, 1rem + 0.9vw, 1.9rem);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* ---------- Sticky in-page nav ---------- */

.loc-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: calc(-1 * clamp(1.25rem, 1rem + 1vw, 2rem)) 0 2rem;
  background: var(--blanc-ecume, #fbfaf7);
  border-bottom: 1px solid var(--ligne, rgba(18, 16, 14, 0.12));
}

body:has(.entete--fixe) .loc-nav { top: 72px; }
/* demat_mobile: under the fixed app header */
body:has(.app-entete) .loc-nav { top: var(--entete-totale, 56px); }
body:has(.app-entete) .loc [id] { scroll-margin-top: calc(var(--entete-totale, 56px) + 4rem); }

.loc-nav ul {
  display: flex;
  gap: 0.25rem;
  margin: 0;
  padding: 0.5rem 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}

.loc-nav ul::-webkit-scrollbar { display: none; }

.loc-nav a {
  display: block;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  color: var(--noir-goemon, #001e26);
  text-decoration: none;
}

.loc-nav a:hover, .loc-nav a:focus-visible { background: var(--sable, #e8ddc8); }

.loc [id] { scroll-margin-top: 5rem; }
body:has(.entete--fixe) .loc [id] { scroll-margin-top: 9.5rem; }

@media (prefers-reduced-motion: no-preference) {
  html:has(.loc-nav) { scroll-behavior: smooth; }
}

/* ---------- Bigger section titles, more air ---------- */

.loc .epci-h2,
.loc .commune-section > h2 { font-family: var(--police-titres); font-synthesis: none; word-spacing: 0.15em; font-weight: 400;
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.008em;
}

.loc .commune-section,
.loc .com-breizh-epci:not(.com-breizh-epci--item),
.loc .epci-actus,
.loc .epci-communes { margin-top: clamp(2.5rem, 2rem + 3vw, 4.5rem); }

/* /local: the hero's stats band already gives these totals */
.loc-hero--region ~ .com-breizh-totaux { display: none; }

/* The fiche in the commune grid is no longer the first thing under the H1: give it the sable card look */
.loc .commune-fiche-carte { background: var(--loc-sable-clair); border-color: transparent; }

/* ---------- Narrow screens ---------- */

@media (max-width: 59.99em) {
  .loc-hero {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "image" "texte" "stats";
    margin-top: 0;
  }

  .loc-hero-image { aspect-ratio: 16 / 9; min-height: 0; }
  .loc-hero-image::after { background: linear-gradient(0deg, var(--noir-goemon, #001e26) 0%, rgba(0, 30, 38, 0) 45%); }
  .loc-credit { top: 0; bottom: auto; }
  .loc-hero-texte { padding-top: 0.5rem; margin-top: -2.5rem; position: relative; }

  .loc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .loc-stats > div { border-left: 0; border-top: 1px solid rgba(251, 250, 247, 0.16); padding: 0.9rem 1.25rem 1rem; }
  .loc-stats > div:nth-child(even) { border-left: 1px solid rgba(251, 250, 247, 0.16); }
  .loc-stats > div:nth-child(-n+2) { border-top: 0; }
  .loc-stats > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* /local/<dept>: full-bleed hero (heros_immersif) inside the component wrapper, whose breizh.css section margin would win */
.com-breizh-localites > .heros-local { margin-top: -2rem; }
.heros-local .loc-breton { margin: -0.25rem 0 1rem; }
