/* « Moi » : bouton d'en-tête + modale (same file in demat_desktop and demat_mobile) */

.moi-ouvrir {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 0.85rem;
  border: 1px solid var(--ligne);
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.moi-ouvrir:hover { background: var(--sable); }
.moi-ouvrir:focus-visible { outline: 2px solid var(--bleu-glaz); outline-offset: 2px; }
.moi-ouvrir svg { flex: none; }

/* A commune is saved: the icon turns blue */
.moi-ouvrir[data-moi-actif] svg { color: var(--bleu-glaz); }

/* --- Modale : centrée (~480px) sur ordinateur, feuille pleine hauteur qui monte du bas sur mobile --- */

.moi {
  --moi-fond: var(--blanc-ecume);
  --moi-encre: var(--hermine, #12100e);
  --moi-glaz: var(--bleu-glaz);
  --moi-glaz-fonce: var(--bleu-glaz-fonce, #0a5f6b);
  position: fixed;
  width: min(30rem, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  padding: 0;
  border: 0;
  border-radius: 22px;
  overflow: hidden auto;
  overscroll-behavior: contain;
  background: var(--moi-fond);
  color: var(--moi-encre);
  box-shadow: 0 30px 80px rgba(0, 30, 38, 0.45);
}

.moi::backdrop { background: rgba(0, 30, 38, 0.62); backdrop-filter: blur(3px); }
.moi[open] { animation: moi-entree 220ms cubic-bezier(.2, .8, .2, 1); }
@keyframes moi-entree { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.moi-fermer {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(251, 250, 247, 0.85);
  color: var(--noir-goemon);
  cursor: pointer;
}

.moi-fermer:hover { background: #fff; }

.moi-fermer:focus-visible,
.moi-bouton:focus-visible,
.moi-bouton-lien:focus-visible,
.moi-teaser:focus-visible,
.moi-ajouter:focus-visible,
.moi-compte-lien:focus-visible { outline: 3px solid var(--moi-glaz); outline-offset: 2px; }

.moi-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--moi-glaz-fonce);
}

.moi-barres { width: 14px; height: 11px; background: linear-gradient(currentColor 0 0) 0 0 / 100% 3px no-repeat, linear-gradient(currentColor 0 0) 0 4px / 62% 3px no-repeat, linear-gradient(currentColor 0 0) 0 8px / 82% 3px no-repeat; }

.moi-grand-titre {
  margin: 0;
  font-family: var(--police-titres); font-synthesis: none; word-spacing: 0.15em;
  font-size: clamp(1.9rem, 6vw, 2.35rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.009em;
}

.moi-grand-titre:focus { outline: none; }

/* Accueil */
.moi-accueil { position: relative; padding: 2rem 1.5rem 1.25rem; }
.moi-accueil .moi-grand-titre { max-width: 13ch; }
.moi-benefice { margin: 0.75rem 0 1.25rem; max-width: 30ch; color: var(--granit); line-height: 1.5; }

.moi-carte { display: block; fill: currentColor; }
.moi-accueil .moi-carte {
  position: absolute;
  top: 1.1rem;
  right: 3.6rem;
  width: 7.5rem;
  color: rgba(14, 125, 140, 0.35);
  pointer-events: none;
}

.moi-carte-ici { fill: var(--moi-glaz); stroke: #fff; stroke-width: 0.8; }
.moi-carte-onde { fill: none; stroke: var(--moi-glaz); stroke-width: 0.8; transform-box: fill-box; transform-origin: center; animation: moi-onde 2.4s ease-out infinite; }
@keyframes moi-onde { from { opacity: 0.9; transform: scale(0.4); } to { opacity: 0; transform: scale(1.8); } }

.moi-bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 52px;
  padding: 0 1.25rem;
  border: 0;
  border-radius: 14px;
  background: var(--moi-glaz);
  color: #fff;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(14, 125, 140, 0.28);
  transition: background 160ms ease, transform 160ms ease;
}

.moi-bouton:hover { background: var(--moi-glaz-fonce); }
.moi-bouton:active { transform: translateY(1px); }
.moi-localiser { width: 100%; }
.moi-localiser:disabled { cursor: progress; }
.moi-onde { opacity: 0.35; transform-origin: 12px 12px; }
.moi-localiser.est-en-cours .moi-onde { animation: moi-cible 1.1s ease-out infinite; }
@keyframes moi-cible { from { opacity: 0.9; transform: scale(0.5); } to { opacity: 0; transform: scale(1.5); } }

.moi-ou { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; color: var(--granit); font-size: 0.88rem; }
.moi-ou::before, .moi-ou::after { content: ""; flex: 1; height: 1px; background: var(--ligne); }

.moi-combo { position: relative; }
.moi-combo-label { display: block; margin-bottom: 0.4rem; font-weight: 650; }
.moi-combo-champ { position: relative; }
.moi-combo-champ svg { position: absolute; top: 50%; left: 0.95rem; transform: translateY(-50%); color: var(--granit); pointer-events: none; }

.moi-combo input {
  width: 100%;
  min-height: 52px;
  padding: 0.6rem 1rem 0.6rem 2.8rem;
  border: 1.5px solid var(--ligne);
  border-radius: 14px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: max(1.02rem, 16px); /* iOS does not zoom on focus */
}

.moi-combo input:focus { outline: none; border-color: var(--moi-glaz); box-shadow: 0 0 0 4px rgba(14, 125, 140, 0.16); }
.moi-combo input[aria-expanded="true"] { border-radius: 14px 14px 0 0; }

.moi-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 3;
  max-height: 16rem;
  margin: 0;
  padding: 0.3rem;
  overflow-y: auto;
  list-style: none;
  border: 1.5px solid var(--moi-glaz);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(0, 30, 38, 0.18);
}

.moi-suggestions [role="option"] {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
}

.moi-suggestions [aria-selected="true"] { background: rgba(14, 125, 140, 0.1); color: var(--moi-glaz-fonce); }
.moi-opt-nom { font-weight: 650; }
.moi-opt-cp { font-family: var(--police-donnees, monospace); font-size: 0.85rem; color: var(--granit); }
.moi-opt-vide { color: var(--granit); cursor: default !important; }

.moi-note { margin: 1rem 0 0; display: flex; gap: 0.5rem; font-size: 0.82rem; line-height: 1.45; color: var(--granit); }
.moi-note::before { content: ""; flex: none; width: 14px; height: 14px; margin-top: 2px; background: currentColor; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1 2 3.5v4C2 11 4.6 14.2 8 15c3.4-.8 6-4 6-7.5v-4z'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 1 2 3.5v4C2 11 4.6 14.2 8 15c3.4-.8 6-4 6-7.5v-4z'/%3E%3C/svg%3E") center / contain no-repeat; }

/* Fiche de la commune */
.moi-fiche-entete {
  position: relative;
  min-height: 13rem;
  padding: 4rem 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: var(--blanc-ecume);
  background:
    linear-gradient(180deg, rgba(0, 30, 38, 0.1) 0%, rgba(0, 30, 38, 0.88) 78%),
    var(--moi-image, none) center / cover,
    url("/images/demat_coeur_de_la_bretagne.webp") center / cover,
    var(--noir-goemon);
}

.moi-fiche-entete .moi-eyebrow { color: #9fe0e8; }
.moi-fiche-entete .moi-grand-titre { font-size: clamp(2.2rem, 8vw, 2.9rem); }
.moi-breton { margin: 0.25rem 0 0; font-family: var(--police-titres); font-synthesis: none; word-spacing: 0.15em; font-weight: 400; font-size: 1.15rem; font-style: italic; opacity: 0.85; }
.moi-fiche-dept { position: absolute; right: 1.25rem; bottom: 0.4rem; font-family: var(--police-titres); font-synthesis: none; word-spacing: 0.15em; font-size: 5.5rem; font-weight: 400; line-height: 1; color: rgba(251, 250, 247, 0.16); }
.moi-fiche .moi-carte--mini { position: absolute; top: 1rem; left: 1.25rem; width: 5.5rem; color: rgba(251, 250, 247, 0.45); }

/* Photo credit (Wikimedia Commons licences), under the card photo */
.moi-credit { margin: 0; padding: 0.35rem 1.5rem 0; font-size: 0.75rem; line-height: 1.35; color: var(--granit); text-align: right; }
.moi-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.moi-territoire { margin: 0; padding: 0.9rem 1.5rem 0; font-weight: 600; color: var(--granit); }
.moi-territoire:empty { display: none; }

.moi-teasers { display: grid; gap: 0.6rem; margin: 0; padding: 1rem 1.5rem 0; list-style: none; }

.moi-teaser {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 64px;
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--ligne);
  border-radius: 16px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: border-color 160ms ease, transform 160ms ease;
}

a.moi-teaser:hover { border-color: var(--moi-glaz); transform: translateY(-1px); }
.moi-teaser-n { font-family: var(--police-titre); /* chiffres : Bricolage (espace fine U+202F visible) */ font-size: 1.9rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; color: var(--moi-glaz-fonce); font-variant-numeric: tabular-nums; }
.moi-teaser span:not(.moi-teaser-fleche) { flex: 1; font-weight: 600; line-height: 1.3; }
.moi-teaser-fleche { color: var(--moi-glaz); font-weight: 700; }
.moi-teaser--attente { border-style: dashed; background: linear-gradient(90deg, rgba(14, 125, 140, 0.04), rgba(14, 125, 140, 0.12), rgba(14, 125, 140, 0.04)) 0 0 / 200% 100%; animation: moi-attente 1.2s linear infinite; }
@keyframes moi-attente { to { background-position: -200% 0; } }

.moi-liens-fiche { display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem; margin: 0; padding: 0.9rem 1.5rem 0; list-style: none; }
.moi-liens-fiche a { color: var(--moi-glaz-fonce); font-weight: 650; }

.moi-actions { display: flex; gap: 1.25rem; margin: 0; padding: 0.6rem 1.5rem 0; }

.moi-bouton-lien {
  padding: 0.35rem 0;
  border: 0;
  background: none;
  color: var(--bleu-glaz-fonce, #0a5f6b);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.moi-actions .moi-bouton-lien { color: var(--granit); font-size: 0.92rem; }
.moi-petit { font-size: 0.85rem; padding: 0; }

.moi-statut { margin: 0; padding: 0.75rem 1.5rem 0; font-weight: 600; color: var(--moi-glaz-fonce); }
.moi-statut:empty { display: none; }

/* Compte : une rangée compacte en bas */
.moi-compte {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding: 0.9rem 1.5rem calc(1rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--ligne);
  background: rgba(232, 221, 200, 0.35);
}

.moi-avatar { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--noir-goemon); color: var(--blanc-ecume); font-family: var(--police-titre); font-weight: 800; font-size: 1.1rem; }
.moi-avatar--invite { background: var(--sable); color: var(--noir-goemon); }
.moi-compte-qui { display: grid; min-width: 0; }
.moi-compte-qui form { margin: 0; }
.moi-compte-lien { color: inherit; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.moi-ajouter {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 999px;
  background: var(--noir-goemon);
  color: var(--blanc-ecume);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.moi-ajouter:hover { background: var(--moi-glaz-fonce); color: #fff; }

/* Also used by the /local « Ma commune » card */
.moi-soustitre { margin: 0 0 0.6rem; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--granit); }
.moi-liens { margin: 0; padding: 0; list-style: none; }
.moi-liens a { display: inline-block; padding: 0.35rem 0; color: var(--bleu-glaz-fonce, #0a5f6b); font-weight: 600; }

@media (max-width: 600px) {
  .moi {
    width: 100%;
    max-width: none;
    height: calc(100dvh - env(safe-area-inset-top, 0px) - 0.75rem);
    max-height: none;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    display: none;
    flex-direction: column;
  }

  .moi[open] { display: flex; animation: moi-feuille 280ms cubic-bezier(.2, .8, .2, 1); }
  @keyframes moi-feuille { from { transform: translateY(100%); } }
  .moi > * { flex-shrink: 0; }
  .moi-compte { margin-top: auto; }
  .moi-accueil { padding-top: 2.5rem; }
  .moi-ajouter { padding: 0 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .moi[open], .moi-carte-onde, .moi-localiser.est-en-cours .moi-onde, .moi-teaser--attente { animation: none; }
  .moi-teaser, .moi-bouton { transition: none; }
}

/* Bannière « Filtré autour de … » des pages pré-filtrées */
.moi-filtre {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1rem;
  margin: 0 0 1.25rem;
  padding: 0.7rem 1rem;
  border-left: 4px solid var(--bleu-glaz);
  border-radius: 8px;
  background: rgba(14, 125, 140, 0.08);
}

.moi-filtre p { margin: 0; }
.moi-filtre a, .moi-filtre .moi-bouton-lien { font-weight: 600; }

/* Dark headers: mobile app header, and the desktop header on narrow windows */
.app-entete .moi-ouvrir { margin-left: auto; border-color: rgba(251, 250, 247, 0.3); color: var(--blanc-ecume); }
.app-entete .moi-ouvrir + .app-entete-burger { margin-left: 0; }
.app-entete .moi-ouvrir:hover { background: rgba(251, 250, 247, 0.12); }

@media (max-width: 900px) {
  .entete .moi-ouvrir { order: 0; margin-left: auto; border-color: rgba(251, 250, 247, 0.3); color: var(--blanc-ecume); }
  .entete .moi-ouvrir:hover { background: rgba(251, 250, 247, 0.12); }
  .entete .bascule-nav { margin-left: 0; }
}

@media (max-width: 380px) {
  .moi-ouvrir { padding: 0 0.7rem; }
}

/* /local : « Ma commune » en tête, son département ressort (il est passé premier) */
.moi-local {
  margin: 0 0 1.5rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--rayon, 10px);
  background: var(--noir-goemon);
  color: var(--blanc-ecume);
}

.moi-local .moi-soustitre { color: #7fd0da; margin-bottom: 0.25rem; }
.moi-local-nom { margin: 0; font-family: var(--police-titres); font-synthesis: none; word-spacing: 0.15em; font-weight: 400; font-size: 1.8rem; }
.moi-local .moi-local-nom a, .moi-local .moi-liens a { color: var(--blanc-ecume); }
.moi-local-infos { margin: 0.2rem 0 0.75rem; opacity: 0.85; }
.moi-local-liens { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
.moi-local-page .com-breizh-departements > li:first-child { outline: 3px solid var(--bleu-glaz); outline-offset: 3px; border-radius: var(--rayon, 10px); }

/* Template headings colours win otherwise */
.moi .moi-fiche-entete .moi-grand-titre { color: var(--blanc-ecume); }
.moi .moi-accueil .moi-grand-titre { color: var(--noir-goemon); }
.moi-compte > .moi-compte-lien { flex: none; }
@media (max-width: 420px) { .moi-avatar--invite { display: none; } }
