/* =========================================================================
   Portail des référents de quartier — thème « Lavande & pierre »
   Provence moderne : pierre claire, lavande / bleu des volets, terre douce.
   Accessibilité RGAA (contrastes AA clair + sombre), thème clair/sombre,
   mobile-first, polices auto-hébergées (souverain / CSP-clean).
   ========================================================================= */

/* --- Polices auto-hébergées (woff2 locaux) --- */
@font-face { font-family: "Inter"; src: url("../fonts/inter-400.da03732a27e1.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-600.2ede57db1a3a.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-700.8ca0a5155296.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("../fonts/fraunces-400.15ccd91d7a8f.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("../fonts/fraunces-600.b8dca52ca5f9.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

/* --- Palette : clair (par défaut) --- */
:root {
  --bg: #f5f3fa;
  --surface: #ffffff;
  --fg: #2a2730;
  --muted: #615d70;
  --border: #e4e0ee;
  --accent: #595c88;          /* lavande / bleu des volets — liens, focus, primaire */
  --accent-hover: #484a70;
  --accent-contrast: #ffffff; /* texte sur boutons accent */
  --terracotta: #b98a6a;      /* terre douce — décor, survols, pictos */
  --gold: #c9a227;            /* or doux — touches décoratives */
  --danger: #b00020;
  --card-bg: var(--surface);
  --shadow: 0 1px 2px rgba(40, 35, 60, .06), 0 6px 20px rgba(40, 35, 60, .07);
  --radius: 14px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1822; --surface: #232030; --fg: #e9e6f0; --muted: #a8a3b8;
    --border: #353143; --accent: #9aa0d8; --accent-hover: #b3b8e6;
    --accent-contrast: #16131f; --terracotta: #c9a98a; --gold: #d9c06a;
    --danger: #ff8a9b; --shadow: 0 2px 12px rgba(0, 0, 0, .45);
  }
}
/* Choix explicite (compte / sélecteur) — prioritaire sur la préférence système */
html[data-theme="clair"] {
  --bg: #f5f3fa; --surface: #ffffff; --fg: #2a2730; --muted: #615d70;
  --border: #e4e0ee; --accent: #595c88; --accent-hover: #484a70;
  --accent-contrast: #ffffff; --terracotta: #b98a6a; --gold: #c9a227;
  --danger: #b00020; --shadow: 0 1px 2px rgba(40,35,60,.06), 0 6px 20px rgba(40,35,60,.07);
}
html[data-theme="sombre"] {
  --bg: #1a1822; --surface: #232030; --fg: #e9e6f0; --muted: #a8a3b8;
  --border: #353143; --accent: #9aa0d8; --accent-hover: #b3b8e6;
  --accent-contrast: #16131f; --terracotta: #c9a98a; --gold: #d9c06a;
  --danger: #ff8a9b; --shadow: 0 2px 12px rgba(0,0,0,.45);
}

/* --- Base --- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.65;
  background: var(--bg);
  color: var(--fg);
  /* Bascule clair/sombre en douceur (annulée si mouvement réduit, voir fin de fichier) */
  transition: background-color .25s ease, color .25s ease;
}
.site-header, .site-footer, .card, .referent-card, .flash, .formset,
select, input, textarea, button, .button {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.2; color: var(--fg); }
h1 { font-size: clamp(1.8rem, 1.2rem + 2.6vw, 2.7rem); margin: 0 0 .6rem; letter-spacing: -.01em; }
h2 { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.7rem); margin: 1.8rem 0 .7rem; }
h3 { font-size: 1.2rem; margin: 1.2rem 0 .4rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-underline-offset: .15em; }
a:hover { color: var(--accent-hover); }
.muted { color: var(--muted); font-size: .95rem; }
img { max-width: 100%; height: auto; }

/* --- Accessibilité : focus visible + lien d'évitement --- */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent);
  color: var(--accent-contrast); padding: .6rem 1rem; z-index: 100; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* --- En-tête --- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem 1.25rem; flex-wrap: wrap; padding: .8rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  /* fine bande sun/terre en haut, clin d'œil provençal */
  border-top: 4px solid transparent;
  border-image: linear-gradient(90deg, var(--accent), var(--gold), var(--terracotta)) 1;
}
.brand a { font-family: var(--serif); font-weight: 600; font-size: 1.15rem; text-decoration: none; color: var(--fg); }
.site-nav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.site-nav a { text-decoration: none; color: var(--fg); font-weight: 500; padding: .2rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.header-tools { display: flex; align-items: center; gap: .6rem; }

/* Sélecteur de langue : liste déroulante + bouton « Changer », compact et en ligne */
.lang-form { display: flex; align-items: center; gap: .35rem; }
.lang-form select { padding: .3rem .45rem; font-size: .85rem; }
.lang-form button { padding: .35rem .6rem; font-size: .85rem; }

.theme-toggle {
  font-size: 1.05rem; background: var(--bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 999px; padding: .35rem .6rem; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); }

select, input, textarea {
  font: inherit; color: var(--fg); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: .5rem .6rem;
}
select { padding: .4rem .6rem; }

/* --- Contenu --- */
.site-main { max-width: 920px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }

/* --- Fil d'Ariane --- */
.breadcrumb { max-width: 920px; margin: 0 auto; padding: .7rem 1.25rem 0; font-size: .9rem; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: 0; }
.breadcrumb li + li::before { content: "›"; margin-right: .4rem; color: var(--muted); }
.breadcrumb a { text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--muted); }

/* --- Accueil : héros + bannière (blason net + texte réel, adapté aux 2 thèmes) --- */
.hero { margin-bottom: 1.5rem; }
.hero-banniere {
  display: flex; align-items: center; gap: 1.15rem;
  padding: 1rem 1.4rem; margin-bottom: 1.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.hero-blason {
  flex: 0 0 auto; width: 68px; height: auto; /* < taille native : reste net */
  filter: drop-shadow(0 1px 2px rgba(40, 35, 60, .25));
}
.hero-commune { display: flex; flex-direction: column; line-height: 1.3; }
.hero-commune-de { font-size: .95rem; color: var(--muted); }
.hero-commune-nom {
  font-family: var(--serif); font-weight: 600; letter-spacing: -.01em;
  font-size: clamp(1.35rem, 1rem + 2vw, 2rem); color: var(--accent);
}
.hero-commune-region { font-size: .9rem; color: var(--muted); }
.hero h1 { margin-top: 0; }
.hero > p:first-of-type, .hero p.lead { font-size: 1.12rem; }
.cta { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.25rem 0; }

/* --- Boutons --- */
button, .button {
  display: inline-block; background: var(--accent); color: var(--accent-contrast);
  border: 0; border-radius: 999px; padding: .6rem 1.25rem; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
button:hover, .button:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow); }
button:active, .button:active { transform: translateY(0); box-shadow: none; }
button:disabled, button[aria-disabled="true"], .button[aria-disabled="true"] {
  opacity: .55; cursor: not-allowed;
}
button:disabled:hover { background: var(--accent); transform: none; box-shadow: none; }
input:disabled, select:disabled, textarea:disabled {
  background: var(--bg); color: var(--muted); cursor: not-allowed;
}
a.button { line-height: 1.4; }

/* --- Cartes & sections --- */
.cards-section { margin-top: 2rem; }
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card, .referent-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.card h2 { margin-top: 0; font-size: 1.15rem; }
.actu-home-list { list-style: none; padding: 0; }
.actu-home-list li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.actu-home-list li:last-child { border-bottom: 0; }

/* --- Page de quartier --- */
.quartier-carte img { border-radius: var(--radius); box-shadow: var(--shadow); }
.referents { list-style: none; padding: 0; display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.referent-photo {
  width: 96px; height: 96px; object-fit: cover; /* carré fixe : pas de décalage de mise en page */
  border-radius: 50%; box-shadow: var(--shadow);
}
.referent-nom { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; margin: .4rem 0 .2rem; }
.referent-contact a { font-weight: 600; }
.actualite { border-top: 1px solid var(--border); padding-top: 1.1rem; margin-top: 1.25rem; }
.actu-meta { color: var(--muted); font-size: .9rem; }
.actu-pj, .actu-liens { margin: .5rem 0; }
.pagination { display: flex; gap: 1rem; align-items: center; margin-top: 1.25rem; }

/* --- Messages flash --- */
.flash-messages { list-style: none; padding: 0; margin: 0 0 1.25rem; }
.flash {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .7rem 1rem; border-radius: 10px; border: 1px solid var(--border);
  border-left-width: 4px; background: var(--surface); margin-bottom: .5rem;
}
.flash.success {
  border-left-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.flash.error {
  border-left-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}
.flash-icone { flex: 0 0 auto; margin-top: .3rem; color: var(--accent); }
.flash.error .flash-icone { color: var(--danger); }

/* --- Formulaires --- */
.contact-form, .auth-form, .traitement-form, .quartier-select-form,
.actualite-form, .sondage-form, .profil-form { max-width: 640px; }
.field { display: flex; flex-direction: column; gap: .3rem; margin: 0 0 1.1rem; }
.field > label { font-weight: 600; }
.consent-field label { font-weight: 400; display: flex; gap: .5rem; align-items: flex-start; }
.field input, .field select, .field textarea { width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field .help { color: var(--muted); font-size: .9rem; }
.field-error, .form-errors { color: var(--danger); font-size: .95rem; }
.field-error { font-weight: 600; }
.form-errors {
  border: 1px solid var(--danger); border-left-width: 4px; border-radius: 10px;
  padding: .7rem 1rem; margin: 0 0 1.1rem;
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}
.has-error input, .has-error select, .has-error textarea {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 5%, var(--surface));
}
.req { color: var(--accent); font-weight: 700; }  /* indicateur requis : contraste AA (RGAA) */
.rgpd-mention {
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: .9rem 1.1rem; margin: 1.1rem 0; font-size: .92rem;
}
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* --- Bouton secondaire --- */
button.bouton-secondaire, .button.bouton-secondaire {
  background: var(--surface); color: var(--accent); border: 1px solid var(--accent);
}
button.bouton-secondaire:hover, .button.bouton-secondaire:hover {
  background: var(--bg); color: var(--accent-hover); border-color: var(--accent-hover);
}

/* --- Aperçu Markdown (rendu côté serveur) --- */
.apercu-markdown {
  border: 1px dashed var(--accent); border-radius: var(--radius);
  padding: 1rem 1.2rem; margin: 0 0 1.5rem; background: var(--surface);
  max-width: 640px;
}
.apercu-markdown h2 { margin-top: 0; font-size: 1.15rem; }

/* --- Éditeur Markdown (barre d'outils maison) --- */
.md-toolbar { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .4rem; }
.md-btn { background: var(--bg); color: var(--fg); border: 1px solid var(--border);
  border-radius: 8px; padding: .3rem .65rem; font-size: .9rem; cursor: pointer; }
.md-btn:hover { border-color: var(--accent); }

/* --- Formsets --- */
.formset { border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem; margin: 1.25rem 0; background: var(--surface); }
.formset legend { font-family: var(--serif); font-weight: 600; padding: 0 .4rem; }
.formset-row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: end;
  padding: .6rem 0; border-bottom: 1px dashed var(--border); }
.question-row { flex-direction: column; align-items: stretch; }

/* --- Tables back-office --- */
/* Conteneur défilant accessible : région nommée, atteignable au clavier (RGAA) */
.table-scroll { overflow-x: auto; margin-bottom: 1rem; }
.table-scroll:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.messages-table { width: 100%; border-collapse: collapse; }
.messages-table th, .messages-table td { text-align: left; padding: .6rem .65rem; border-bottom: 1px solid var(--border); }
.messages-table th { font-family: var(--serif); white-space: nowrap; }
@media (max-width: 640px) {
  .messages-table th, .messages-table td { padding: .45rem .5rem; font-size: .95rem; }
}
.ligne-nouveau { background: color-mix(in srgb, var(--accent) 6%, transparent); }
/* Filtres de la boîte de réception : en ligne sur desktop, empilés sur mobile */
.filtres-messages { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; margin-bottom: 1.25rem; }
.filtres-messages .field { margin: 0; flex: 1 1 180px; min-width: 180px; }
.filtres-messages button { flex: 0 0 auto; }
.message-detail dt { font-weight: 600; margin-top: .7rem; color: var(--muted); }
.message-detail dd { margin: 0 0 .3rem; }

/* --- Sondages --- */
.sondages-liste { line-height: 2; }
.vote-form .question { border: 1px solid var(--border); border-radius: 12px; padding: .7rem 1.1rem; margin: 1rem 0; background: var(--surface); }
.vote-form .question legend { font-family: var(--serif); font-weight: 600; }
.vote-form .option { display: block; padding: .3rem 0; cursor: pointer; }
.resultats-liste { list-style: none; padding: 0; }
.resultats-liste li { display: grid; grid-template-columns: 1fr 2fr auto; gap: .7rem; align-items: center; margin: .4rem 0; }
.res-barre { width: 100%; height: .95rem; display: block; }
.res-barre-fond { fill: var(--border); }
.res-barre-part { fill: var(--accent); }
.res-valeur { color: var(--muted); font-variant-numeric: tabular-nums; }

/* --- Espace référent : tableau de bord --- */
.indicateurs {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.indicateurs li {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow);
}
.indicateurs a { text-decoration: none; color: var(--fg); }
.indicateurs a strong {
  display: block; font-family: var(--serif); font-size: 2rem; line-height: 1.15;
  color: var(--accent);
}
.indicateurs a:hover { color: var(--accent); text-decoration: underline; }
.badge {
  display: inline-block; background: var(--accent); color: var(--accent-contrast);
  border-radius: 999px; padding: .05rem .6rem; font-size: .82rem; font-weight: 600;
  margin-top: .35rem;
}
.liste-resume { list-style: none; padding: 0; margin: 0; }
.liste-resume li { padding: .55rem .1rem; border-bottom: 1px solid var(--border); }
.liste-resume li:last-child { border-bottom: 0; }
.espace-nav { margin-top: 2rem; }
.espace-nav ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .6rem; }
.espace-nav a {
  display: inline-block; background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: 999px; padding: .45rem 1.05rem;
  text-decoration: none; font-weight: 600;
}
.espace-nav a:hover { border-color: var(--accent); color: var(--accent); }
.espace-nav .icone { vertical-align: -.22em; margin-right: .35rem; color: var(--accent); }

/* --- Pictogrammes & états vides --- */
.icone { vertical-align: -.2em; }
.etat-vide {
  text-align: center; padding: 2.2rem 1rem; margin: 1rem 0;
  border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted);
}
.etat-vide .icone { display: block; margin: 0 auto .6rem; color: var(--terracotta); }
.etat-vide p { margin: 0; }

/* --- Accueil : étapes « Comment ça marche » --- */
.etapes {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.etape {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.etape-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-contrast);
  font-family: var(--serif); font-weight: 600;
}
.etape h3 { margin: .6rem 0 .3rem; font-size: 1.1rem; }
.etape p { margin: 0; font-size: .95rem; color: var(--muted); }
.logout-form { margin-top: 2rem; }
.logout-form button { background: var(--surface); color: var(--fg); border: 1px solid var(--border); }
.logout-form button:hover { background: var(--surface); border-color: var(--danger); color: var(--danger); transform: none; box-shadow: none; }

/* --- Pages éditoriales --- */
.page-statique { max-width: 720px; }
.page-statique h2 { font-size: 1.3rem; }

/* --- Pied de page --- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 1.5rem 1.25rem; text-align: center; margin-top: 2rem; }
.site-footer nav { display: flex; gap: 1.25rem; justify-content: center; flex-wrap: wrap; margin-bottom: .5rem; }
.site-footer .motif { color: var(--accent); opacity: .7; margin-bottom: .4rem; }

/* --- Mouvement réduit (préférence d'accessibilité) --- */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
