/* =============================================================================
   RGE2 — Socle
   Design tokens, reset, typographie, container et grille.
   Aucune dépendance externe.
   ============================================================================= */

/* ── Couleurs de marque ───────────────────────────────────────────
   Ce bloc est écrasé par le Customizer (injecté après cette feuille). */
:root {
  --color-primary:   #1A3A5C;
  --color-secondary: #4A7C59;
  --color-accent:    #E8A020;
  --color-bg:        #F5F5F5;
  --color-text:      #333333;
}

:root {
  /* ── Neutres ── */
  --color-white:   #ffffff;
  --color-surface: #ffffff;
  --color-border:  #e2e6ea;
  --color-muted:   #545a60;
  --color-dark:    #102235;

  /* ── Dérivées ──
     La 1re déclaration sert de repli, la 2e s'applique dès que color-mix()
     est supporté et suit alors les couleurs du Customizer. */
  --color-primary-soft: rgba(26, 58, 92, .06);
  --color-primary-soft: color-mix(in srgb, var(--color-primary) 6%, #fff);
  --color-primary-tint: rgba(26, 58, 92, .12);
  --color-primary-tint: color-mix(in srgb, var(--color-primary) 12%, #fff);
  --color-primary-dark: #142e49;
  --color-primary-dark: color-mix(in srgb, var(--color-primary) 82%, #000);

  --color-secondary-soft: rgba(74, 124, 89, .08);
  --color-secondary-soft: color-mix(in srgb, var(--color-secondary) 9%, #fff);
  --color-secondary-dark: #3c6549;
  --color-secondary-dark: color-mix(in srgb, var(--color-secondary) 82%, #000);

  --color-accent-soft: rgba(232, 160, 32, .1);
  --color-accent-soft: color-mix(in srgb, var(--color-accent) 12%, #fff);
  --color-accent-dark: #c2851a;
  --color-accent-dark: color-mix(in srgb, var(--color-accent) 85%, #000);

  --color-text-soft: #5c6268;
  --color-text-soft: color-mix(in srgb, var(--color-text) 78%, #fff);

  /* ── États ── */
  --color-success: #2e7d4f;
  --color-warning: #b56a00;
  --color-danger:  #b3261e;

  /* ── Typographie ── */
  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Source Code Pro', SFMono-Regular, monospace;

  --text-xs:   .78rem;
  --text-sm:   .875rem;
  --text-base: 1rem;
  --text-md:   1.0625rem;
  --text-lg:   clamp(1.09rem, 1.02rem + .35vw, 1.22rem);
  --text-xl:   clamp(1.2rem, 1.1rem + .5vw, 1.4rem);
  --text-2xl:  clamp(1.35rem, 1.2rem + .75vw, 1.65rem);
  --text-3xl:  clamp(1.6rem, 1.35rem + 1.15vw, 2.1rem);
  --text-4xl:  clamp(1.9rem, 1.5rem + 1.85vw, 2.8rem);

  --leading-tight: 1.2;
  --leading-snug:  1.35;
  --leading-base:  1.6;
  --leading-loose: 1.8;

  /* ── Espacement ── */
  --space-1:  .25rem;
  --space-2:  .5rem;
  --space-3:  .75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-7:  2rem;
  --space-8:  2.5rem;
  --space-10: 3rem;
  --space-12: 4rem;
  --space-16: 5.5rem;

  /* Rythme vertical des sections, resserré sur mobile */
  --section-gap: clamp(2.75rem, 2rem + 3vw, 5rem);

  /* ── Layout ── */
  --container-width:  1160px;
  --container-narrow: 820px;
  --gutter: clamp(1rem, .6rem + 1.6vw, 1.75rem);
  --header-height: 72px;

  /* ── Formes ── */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(16, 34, 53, .06), 0 1px 3px rgba(16, 34, 53, .05);
  --shadow:    0 2px 4px rgba(16, 34, 53, .04), 0 6px 16px rgba(16, 34, 53, .07);
  --shadow-md: 0 4px 8px rgba(16, 34, 53, .05), 0 12px 28px rgba(16, 34, 53, .09);
  --shadow-lg: 0 8px 16px rgba(16, 34, 53, .06), 0 24px 48px rgba(16, 34, 53, .12);

  --transition:    .18s ease;
  --transition-md: .3s cubic-bezier(.2, .7, .3, 1);
}

/* ═════════════════════════════════════════════════════════════════
   RESET
   ═════════════════════════════════════════════════════════════════ */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1.5rem);
}

body {
  margin: 0;
  font-family: var(--font-base);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  line-height: var(--leading-snug);
  color: var(--color-primary);
  text-wrap: balance;
}

p, ul, ol, dl, figure, blockquote, pre, table { margin: 0; }

ul, ol { padding-left: 1.35rem; }

img, svg, video, canvas, iframe {
  display: block;
  max-width: 100%;
}
img, video { height: auto; }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--color-accent); }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

fieldset {
  margin: 0;
  padding: 0;
  border: none;
  min-width: 0;
}
legend { padding: 0; }

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-7) 0;
}

table { border-collapse: collapse; }

address { font-style: normal; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═════════════════════════════════════════════════════════════════
   ACCESSIBILITÉ
   ═════════════════════════════════════════════════════════════════ */
.skip-to-content {
  position: absolute;
  top: 0;
  left: -9999px;
  z-index: 9999;
  padding: .7rem 1.4rem;
  background: var(--color-primary);
  color: var(--color-white);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: 0 0 var(--radius) 0;
}
.skip-to-content:focus {
  left: 0;
  color: var(--color-white);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.screen-reader-text,
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.screen-reader-text:focus {
  position: static !important;
  width: auto;
  height: auto;
  clip: auto;
  white-space: normal;
}

/* ═════════════════════════════════════════════════════════════════
   LAYOUT
   ═════════════════════════════════════════════════════════════════ */
.container {
  width: 100%;
  max-width: var(--container-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow { max-width: var(--container-narrow); }
.container--wide   { max-width: 1360px; }

.site-main {
  display: block;
  min-height: 40vh;
}

/* Rythme vertical par défaut du contenu d'une page */
.page-shell {
  padding-block: var(--space-8) var(--section-gap);
}

/* Article + colonne latérale */
.page-layout {
  display: grid;
  gap: var(--space-8);
  align-items: start;
}
@media (min-width: 992px) {
  .page-layout--with-aside {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: var(--space-10);
  }
}

/* L'aside précède le contenu dans le DOM pour rester utile sur mobile,
   puis repasse à droite sur les grands écrans. */
.page-layout__content { min-width: 0; }
.page-layout__aside { min-width: 0; }
@media (min-width: 992px) {
  .page-layout__content { order: 1; }
  .page-layout__aside {
    order: 2;
    position: sticky;
    top: calc(var(--header-height) + 1.5rem);
    max-height: calc(100vh - var(--header-height) - 3rem);
    overflow-y: auto;
  }
}

/* ── Grille fluide ────────────────────────────────────────────────
   <div class="rge-grid" data-cols="3">…</div> */
.rge-grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
}
.rge-grid--tight { gap: var(--space-4); }

@media (min-width: 600px) {
  .rge-grid[data-cols="2"],
  .rge-grid[data-cols="3"],
  .rge-grid[data-cols="4"] { --cols: 2; }
}
@media (min-width: 992px) {
  .rge-grid[data-cols="3"] { --cols: 3; }
  .rge-grid[data-cols="4"] { --cols: 4; }
}

/* Grille auto-ajustée pour les listes de cartes de largeur libre */
.rge-autogrid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
}

/* ── Sections ─────────────────────────────────────────────────── */
.section {
  padding-block: var(--section-gap);
}
.section--tight { padding-block: var(--space-8); }
.section--alt   { background: var(--color-white); }
.section--soft  { background: var(--color-primary-soft); }
.section--dark  { background: var(--color-primary); color: rgba(255, 255, 255, .85); }
.section--dark :is(h1, h2, h3, h4) { color: var(--color-white); }

.section__header {
  max-width: 720px;
  margin-bottom: var(--space-8);
}
.section__header--center {
  margin-inline: auto;
  text-align: center;
}
.section__eyebrow {
  display: inline-block;
  margin-bottom: var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--color-secondary);
}
.section__title {
  font-size: var(--text-3xl);
  font-weight: 800;
  letter-spacing: -.02em;
}
.section__lead {
  margin-top: var(--space-3);
  font-size: var(--text-lg);
  color: var(--color-text-soft);
  line-height: var(--leading-loose);
}
.section--dark .section__lead { color: rgba(255, 255, 255, .75); }
.section--dark .section__eyebrow { color: var(--color-accent); }

/* ── Utilitaires ──────────────────────────────────────────────── */
.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-7); }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}
.cluster--center { justify-content: center; }

.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-section { margin-bottom: var(--section-gap); }
.mt-section { margin-top: var(--section-gap); }

.text-center { text-align: center; }
.text-muted  { color: var(--color-muted); }
.text-lead   { font-size: var(--text-lg); color: var(--color-text-soft); }

.is-hidden { display: none !important; }

/* ── Indicateur de chargement ─────────────────────────────────── */
.rge-spinner {
  display: inline-block;
  width: 1.05rem;
  height: 1.05rem;
  border: 2px solid var(--color-primary-tint);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: rge-spin .7s linear infinite;
  vertical-align: -.2em;
}
@keyframes rge-spin { to { transform: rotate(360deg); } }

.rge-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.is-busy { opacity: .45; transition: opacity var(--transition); }
