/* ------------------------------------------------------------
 * Portail LAPIQ — couleurs tirées du logo
 *   Marine  #0b1c48   Rouge  #d21f30   Blanc
 * ------------------------------------------------------------ */
:root {
  --marine: #0b1c48;
  --marine-2: #16306e;
  --rouge: #d21f30;
  --rouge-fonce: #a8121f;
  --fond: #f3f5f9;
  --surface: #ffffff;
  --texte: #0f1a33;
  --doux: #55607a;
  --bordure: #dde2ec;
  --accent: var(--rouge);
  --lien: var(--marine);
  --ombre: 0 1px 2px rgba(11,28,72,.06), 0 6px 18px rgba(11,28,72,.08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #070f26;
    --surface: #0f1c3f;
    --texte: #eef1f8;
    --doux: #a4adc4;
    --bordure: #243563;
    --lien: #9db4ff;
    --ombre: 0 1px 2px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
  line-height: 1.5;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
main, .pied { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* ---------- En-tête : bande marine + liseré rouge (comme l'anneau du logo) ---------- */
.entete {
  background: var(--marine);
  color: #fff;
  padding-top: env(safe-area-inset-top);
  border-bottom: 4px solid var(--rouge);
  box-shadow: 0 3px 0 #fff, 0 6px 0 var(--marine);
  margin-bottom: 6px;
}
.entete-int {
  max-width: 960px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.marque { display: flex; gap: 12px; align-items: center; min-width: 0; }
.marque img { width: 56px; height: 56px; border-radius: 50%; background: #fff; flex: none; }
.marque h1 { margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: .06em; font-style: italic; }
.marque p { margin: 0; color: #c9d2ea; font-size: .9rem; }
.btn-icone {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  border: 2px solid rgba(255,255,255,.6); background: transparent; color: #fff;
  display: grid; place-items: center; cursor: pointer;
}
.btn-icone:hover { background: rgba(255,255,255,.12); }
.btn-icone svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ---------- Accueil ---------- */
.accueil { margin: 24px 0 16px; }
.accueil h2 { margin: 0 0 4px; font-size: 1.6rem; color: var(--texte); }
.accueil p { margin: 0; color: var(--doux); }

/* ---------- Services ---------- */
.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.carte {
  background: var(--surface); border: 1px solid var(--bordure); border-radius: 16px;
  border-top: 4px solid var(--couleur);
  box-shadow: var(--ombre); overflow: hidden; display: flex; flex-direction: column;
}
.carte-principal {
  display: flex; gap: 14px; align-items: center; padding: 18px;
  text-decoration: none; color: inherit; flex: 1;
}
.carte-principal:hover .carte-nom, .carte-principal:focus-visible .carte-nom { text-decoration: underline; }
.carte-principal:focus-visible { outline: 3px solid var(--rouge); outline-offset: -3px; }
.pastille {
  flex: none; width: 52px; height: 52px; border-radius: 50%;
  background: var(--couleur); color: #fff; display: grid; place-items: center;
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--couleur);
}
.pastille svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pastille-logo { flex: none; width: 58px; height: 58px; border-radius: 50%; background: #fff; }
.carte-nom { margin: 0; font-size: 1.1rem; }
.carte-desc { margin: 2px 0 0; color: var(--doux); font-size: .92rem; }
.sous-liens { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 16px 90px; margin: 0; list-style: none; }
.sous-liens a {
  display: inline-block; padding: 6px 12px; border-radius: 999px; font-size: .85rem;
  border: 1px solid var(--bordure); color: var(--texte); text-decoration: none;
}
.sous-liens a:hover { border-color: var(--rouge); color: var(--rouge); }

/* ---------- Aide ---------- */
.aide {
  margin: 28px 0; padding: 18px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--bordure); border-left: 5px solid var(--marine);
}
@media (prefers-color-scheme: dark) { .aide { border-left-color: var(--rouge); } }
.aide h3 { margin: 0 0 8px; font-size: 1rem; }
.aide ul { margin: 0; padding-left: 20px; color: var(--doux); }
.aide a { color: var(--lien); }

/* ---------- Boutons ---------- */
.btn-installer, dialog button {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 10px 18px; cursor: pointer;
  background: var(--rouge); color: #fff;
}
.btn-installer:hover, dialog button:hover { background: var(--rouge-fonce); }
.btn-installer { display: block; margin: 0 auto 24px; }
dialog button.secondaire { background: transparent; color: var(--texte); border: 1px solid var(--bordure); }

.pied { color: var(--doux); font-size: .82rem; text-align: center; padding-bottom: 24px; }
.pied p { margin: 4px 0; }
#nom-complet { font-weight: 700; color: var(--texte); text-transform: uppercase; letter-spacing: .06em; font-size: .75rem; }

/* ---------- Dialogues ---------- */
dialog {
  border: 1px solid var(--bordure); border-radius: 16px; background: var(--surface); color: var(--texte);
  width: min(420px, calc(100vw - 32px)); padding: 20px;
  max-height: calc(100dvh - 32px); overflow: auto;
}
dialog::backdrop { background: rgba(11,28,72,.55); }
dialog h2 { margin: 0 0 12px; }
dialog label { display: block; margin-top: 12px; font-size: .9rem; font-weight: 600; }
dialog input {
  width: 100%; margin-top: 4px; padding: 10px; font: inherit; border-radius: 8px;
  border: 1px solid var(--bordure); background: var(--fond); color: var(--texte);
}
dialog input:focus { outline: 2px solid var(--marine-2); border-color: transparent; }
.note { font-size: .8rem; color: var(--doux); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.actions.centre { justify-content: center; }
fieldset { border: 1px solid var(--bordure); border-radius: 12px; margin: 16px 0 0; padding: 4px 12px 12px; }
legend { font-weight: 700; padding: 0 4px; }
.photo-ligne { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.photo-ligne input { flex: 1; min-width: 0; }
#apercu-photo { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; }
.erreur { color: var(--rouge); font-size: .82rem; margin: 4px 0 0; }
@media (prefers-color-scheme: dark) { .erreur { color: #ff8a95; } }

/* ---------- Carte de membre (modèle officiel LAPIQ) ---------- */
#zone-carte { margin-bottom: 20px; }
.carte-recherche {
  max-width: 520px; padding: 18px 18px 14px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--bordure); box-shadow: var(--ombre);
}
.carte-recherche h3 { margin: 0 0 6px; font-size: 1.05rem; }
.carte-recherche > p { margin: 0 0 12px; color: var(--doux); }
.carte-recherche label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 6px; }
.recherche-ligne { display: flex; gap: 8px; flex-wrap: wrap; }
.recherche-ligne input {
  flex: 1; min-width: 12rem; font: inherit; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--bordure); background: var(--fond); color: var(--texte);
}
.recherche-ligne input:focus { outline: 2px solid var(--marine-2); border-color: transparent; }
.recherche-ligne button, .exemples-demo button {
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 10px 16px;
  background: var(--rouge); color: #fff; cursor: pointer;
}
.recherche-ligne button:hover, .exemples-demo button:hover { background: var(--rouge-fonce); }
.recherche-ligne button:disabled { opacity: .7; cursor: progress; }
.exemples-demo { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.exemples-demo button {
  background: transparent; color: var(--texte); border: 1px solid var(--bordure);
  font-weight: 600; font-size: .82rem; text-align: left;
}
.exemples-demo button:hover { border-color: var(--rouge); color: var(--rouge); background: transparent; }
.note-exemple {
  max-width: 560px; margin: 10px 0 0; font-size: .82rem; color: var(--doux);
}
.btn-retirer {
  display: inline-block; margin-top: 8px; padding: 0; border: 0; background: none;
  color: var(--doux); text-decoration: underline; cursor: pointer; font: inherit; font-size: .85rem;
}
.btn-retirer:hover { color: var(--rouge); }

/* Vue plein écran : recto + verso */
dialog.plein-ecran { width: min(620px, calc(100vw - 16px)); padding: 12px; }
#carte-grande { display: grid; gap: 12px; }
#carte-grande .cm { cursor: default; box-shadow: none; }

@media (max-width: 480px) {
  .sous-liens { padding-left: 18px; }
  .marque h1 { font-size: 1.25rem; }
}


/* Mode sombre : faire ressortir les éléments marine sur fond marine */
@media (prefers-color-scheme: dark) {
  .carte { border-top-color: color-mix(in srgb, var(--couleur) 55%, #ffffff); }
  .pastille { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px #ffffff; }
}

/* ---------- Bandeaux, actions du bas, messages ---------- */
.bandeau {
  max-width: 960px; margin: 10px auto 0; padding: 10px 16px; border-radius: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: .92rem; font-weight: 600;
}
@media (max-width: 992px) { .bandeau { margin: 10px 16px 0; } }
.bandeau-info { background: #fff3cd; color: #5c4400; }
.bandeau-maj { background: var(--marine); color: #fff; }
.bandeau-maj button {
  font: inherit; border: 0; border-radius: 8px; padding: 6px 14px; cursor: pointer;
  background: var(--rouge); color: #fff;
}
.actions-bas { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 0 0 24px; }
.actions-bas .btn-installer { margin: 0; }
.btn-secondaire {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 8px 18px; cursor: pointer;
  background: transparent; color: var(--texte); border: 2px solid var(--bordure);
}
.btn-secondaire:hover { border-color: var(--marine-2); }
dialog button.lien-danger {
  background: transparent; color: var(--rouge); padding: 10px 4px; margin-right: auto;
  font-weight: 600; text-decoration: underline;
}
dialog button.lien-danger:hover { background: transparent; color: var(--rouge-fonce); }
.etapes { padding-left: 22px; }
.etapes li { margin: 8px 0; }
.ico-ios { width: 20px; height: 20px; vertical-align: -4px; fill: none; stroke: #0a84ff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--marine); color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  font-size: .9rem; z-index: 10; overflow-wrap: anywhere;
}

/* ---------- Renouvellement, aide, pied de page ---------- */
.btn-renouveler {
  display: inline-flex; align-items: center; margin: 12px 0 0 10px; padding: 10px 16px; border-radius: 10px;
  background: var(--rouge); color: #fff; text-decoration: none; font-weight: 700; font-size: .92rem;
}
.btn-renouveler:hover { background: var(--rouge-fonce); }
.liens-aide { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 12px 0 0; }
.liens-aide a, .pied a { color: var(--lien); font-weight: 600; }
.reseaux { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px !important; }
.reseaux a {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--bordure);
  text-decoration: none; color: var(--texte); font-weight: 600;
}
.reseaux a:hover { border-color: var(--rouge); color: var(--rouge); }

/* ---------- Carte : proportions et typographie du modèle ---------- */
.cm {
  --cm-marine: #2d314b; --cm-rouge: #da3441; --cm-gris: #c8cbd6; --cm-encre: #f4f5f8;
  --cm-serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --cm-sans: "Source Sans 3", "Source Sans Pro", system-ui, sans-serif;
  --cm-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  position: relative; display: block; width: 100%; max-width: 560px;
  aspect-ratio: 856 / 540; container-type: inline-size; overflow: hidden;
  border: 0; border-radius: 0; padding: 0; margin: 0;
  background: var(--cm-marine); color: #fff; text-align: left; font: inherit; cursor: pointer;
  box-shadow: 0 10px 26px rgba(20,24,48,.35);
}
.cm-or {
  --cm-marine: #1a1714; --cm-rouge: #c69259; --cm-gris: #d4c0a0; --cm-encre: #f7f3ec;
  background: #1a1714; color: #f7f3ec;
}
.cm-or .cm-bande { color: #1a1714; }
.cm:focus-visible { outline: 3px solid var(--rouge); outline-offset: 3px; }
.cm p { margin: 0; }
.cm-recto::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2.51%; background: var(--cm-rouge); }
.cm-logo { position: absolute; left: 5.5%; top: 20.4%; width: 27.7%; height: auto; background: none; border-radius: 0; }
.cm-droite { position: absolute; left: 36.6%; right: 4.4%; top: 6.5%; }
.cm-surtitre { font-family: var(--cm-sans); font-weight: 600; color: var(--cm-rouge); font-size: 2.2cqw; letter-spacing: .18em; text-transform: uppercase; }
.cm-org { font-family: var(--cm-serif); font-weight: 700; font-size: 6.5cqw; line-height: 1; margin-top: 1.5cqw !important; }
.cm-assoc { font-family: var(--cm-sans); color: var(--cm-gris); font-size: 2.35cqw; line-height: 1.25; margin-top: 1.1cqw !important; }
.cm-filet { border: 0; border-top: .2cqw solid var(--cm-rouge); margin: 2.4cqw 0 0; }
.cm-recto .cm-nom {
  position: absolute; left: 36.6%; right: 4.4%; bottom: 31.4%;
  font-family: var(--cm-serif); font-weight: 600; font-size: 4.7cqw; line-height: 1.08;
  margin: 0 !important; overflow-wrap: anywhere;
}
.cm-nom-moyen { font-size: 3.9cqw !important; }
.cm-nom-long { font-size: 3.45cqw !important; line-height: 1.05 !important; }
.cm-no {
  position: absolute; left: 36.6%; right: 4.4%; bottom: 21.8%;
  font-family: var(--cm-mono); font-weight: 500; font-size: 3.15cqw; color: var(--cm-encre); margin: 0 !important;
}
.cm-no-lib { font-family: var(--cm-sans); font-weight: 600; font-size: .62em; color: var(--cm-gris); margin-right: .35em; }
.cm-bande {
  position: absolute; left: 0; right: 0; bottom: 0; height: 12.96%; z-index: 1;
  background: var(--cm-rouge); color: #fff; font-family: var(--cm-sans);
  display: flex; align-items: center; justify-content: space-between; padding: 0 4.4% 0 5.84%;
  font-size: 2.35cqw;
}
.cm-cat { font-weight: 600; }
/* Verso */
.cm-verso::after { content: ""; position: absolute; right: 0; top: 0; bottom: 12.96%; width: 2.51%; background: var(--cm-rouge); }
.cm-tete { position: absolute; left: 4.9%; top: 6.5%; right: 6.4%; display: flex; align-items: center; gap: 3cqw; }
.cm-logo-petit { width: 16cqw; height: auto; background: none; border-radius: 0; flex: none; }
.cm-verso .cm-org { font-size: 4.35cqw; margin: 0 !important; line-height: 1; }
.cm-verso .cm-assoc { font-size: 2.2cqw; margin-top: .7cqw !important; }
.cm-verso > .cm-filet { position: absolute; left: 4.9%; right: 6.4%; top: 34.5%; margin: 0; }
.cm-corps { position: absolute; left: 4.9%; right: 6.4%; top: 38.5%; bottom: 14%; }
.cm-texte { font-family: var(--cm-sans); font-size: 2.45cqw; line-height: 1.32; color: var(--cm-encre); max-width: 68%; }
.cm-atteste { margin-bottom: .5cqw !important; }
.cm-atteste::after { content: ""; display: block; width: 9.3cqw; margin-top: .9cqw; border-top: .18cqw solid var(--cm-rouge); }
.cm-adr1 sup { font-size: .62em; }
.cm-adr1 { font-weight: 600; color: #fff; margin-top: .4cqw !important; }
.cm-or .cm-adr1, .cm-or .cm-site, .cm-or .cm-org { color: var(--cm-encre); }
.cm-adr2 { color: var(--cm-gris); }
.cm-site { font-weight: 600; font-size: 1.15em; margin-top: .9cqw !important; color: #fff; }
.cm-qr { position: absolute; right: 6.2%; bottom: 20.6%; width: 21.2cqw; background: #fff; border-radius: 1.1cqw; padding: 1.15cqw; line-height: 0; }
.cm-qr svg { width: 100%; height: auto; display: block; }
.cm-devise { justify-content: center; padding: 0 3%; font-size: 2.35cqw; }
/* État sous la carte */
.cm-etat { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.cm-aide { color: var(--doux); font-size: .85rem; }
.statut {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: #e3f4e9; color: #17663a;
}
.statut.bientot { background: #fff3cd; color: #7a5200; }
.statut.expiree { background: var(--rouge); color: #fff; }
.statut.vie { background: #f3e6d4; color: #5c4318; }
