/* =========================================================================
   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);
}
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; }
.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 --- */
.hero { margin-bottom: 1.5rem; }
.accueil-banniere {
  width: 100%; border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 1.25rem; display: block;
}
.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); }
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 { max-width: 96px; 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 {
  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); }
.flash.error { border-left-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; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.req { color: var(--terracotta); }
.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; }

/* --- É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 --- */
.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); }
.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; }
.resultats-liste meter { width: 100%; height: 1rem; }
.res-valeur { color: var(--muted); font-variant-numeric: tabular-nums; }

/* --- 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; }
}
