/* ---------------------------------------------------------------------------
   KM Articles Bridge — charte éditoriale des articles générés

   Tous les sélecteurs contiennent une classe km-* : la feuille ne modifie ni
   les pages Divi, ni les articles anciens. Les variables peuvent être
   surchargées depuis le thème enfant sans modifier l'extension.
   --------------------------------------------------------------------------- */

:root {
  --km-bleu-nuit: #123e6b;
  --km-bleu: #1d6fb8;
  --km-bleu-vif: #2f86d1;
  --km-turquoise: #0d827a;
  --km-orange: #c96823;
  --km-vert: #16825d;
  --km-rouge: #bd3542;
  --km-texte: #203247;
  --km-texte-doux: #627487;
  --km-fond: #f5f9fc;
  --km-fond-bleu: #edf6fc;
  --km-fond-turquoise: #eaf8f5;
  --km-fond-orange: #fff4e9;
  --km-bordure: #d6e4ef;
  --km-rayon: 14px;
  --km-ombre: 0 12px 34px rgba(18, 62, 107, 0.09);
}

/* ---------- Rythme général et éléments éditoriaux ---------- */
.km-article {
  color: var(--km-texte);
  line-height: 1.75;
}

.km-article > p {
  margin: 0 0 1.2em;
}

.km-article > h2 {
  position: relative;
  margin: 2.4em 0 0.9em;
  padding: 0 0 0.55em 0.9em;
  color: var(--km-bleu-nuit);
  font-size: clamp(1.55em, 2.7vw, 2.05em);
  line-height: 1.25;
  letter-spacing: -0.018em;
  border-bottom: 1px solid color-mix(in srgb, currentColor 24%, transparent);
}

.km-article > h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.08em;
  bottom: 0.55em;
  width: 5px;
  border-radius: 999px;
  background: currentColor;
}

/* Alternance mesurée : quatre teintes de la charte, jamais de couleurs aléatoires. */
.km-article > h2:nth-of-type(4n + 2) { color: var(--km-turquoise); }
.km-article > h2:nth-of-type(4n + 3) { color: var(--km-orange); }
.km-article > h2:nth-of-type(4n + 4) { color: var(--km-bleu-vif); }

.km-article > h3,
.km-article section > h3 {
  margin: 1.8em 0 0.7em;
  padding-left: 0.75em;
  color: var(--km-bleu);
  font-size: 1.25em;
  line-height: 1.35;
  border-left: 3px solid var(--km-turquoise);
}

.km-article strong {
  color: var(--km-bleu-nuit);
  font-weight: 750;
}

.km-article mark {
  padding: 0.08em 0.28em;
  color: #77390e;
  background: linear-gradient(transparent 18%, #ffe1b9 18%, #ffe1b9 90%, transparent 90%);
  border-radius: 3px;
}

.km-article a:not(.km-cta__bouton) {
  color: var(--km-bleu);
  font-weight: 600;
  text-decoration-color: color-mix(in srgb, var(--km-bleu) 38%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.km-article a:not(.km-cta__bouton):hover,
.km-article a:not(.km-cta__bouton):focus {
  color: var(--km-turquoise);
  text-decoration-color: currentColor;
}

.km-article > ul,
.km-article > ol {
  margin: 1.25em 0 1.7em;
  padding-left: 1.45em;
}

.km-article > ul li,
.km-article > ol li {
  margin: 0.5em 0;
  padding-left: 0.25em;
}

.km-article > ul li::marker { color: var(--km-turquoise); }
.km-article > ol li::marker {
  color: var(--km-orange);
  font-weight: 700;
}

.km-article > blockquote {
  position: relative;
  margin: 2em 0;
  padding: 1.25em 1.5em 1.25em 3.8em;
  color: var(--km-bleu-nuit);
  background: linear-gradient(135deg, var(--km-fond-bleu), #fff);
  border: 1px solid var(--km-bordure);
  border-radius: var(--km-rayon);
  box-shadow: var(--km-ombre);
}

.km-article > blockquote::before {
  content: "“";
  position: absolute;
  left: 0.55em;
  top: 0.05em;
  color: var(--km-bleu);
  font: 700 3.3em/1 Georgia, serif;
  opacity: 0.75;
}

/* ---------- Images ---------- */
.km-image {
  display: table;
  width: auto;
  max-width: 100%;
  margin: 2.2em auto;
  clear: both;
}

.km-image .km-img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(18, 62, 107, 0.12);
}

.km-image .km-legende {
  display: table-caption;
  caption-side: bottom;
  padding: 0.7em 0.75em 0;
  color: var(--km-texte-doux);
  font-size: 0.88em;
  font-style: italic;
  line-height: 1.45;
  text-align: center;
}

.km-image.km-taille-pleine,
.km-image .km-taille-pleine { width: 100%; }
.km-image .km-taille-grande { width: min(1024px, 100%); }
.km-image .km-taille-moyenne { width: min(600px, 100%); }
.km-image .km-taille-petite { width: min(300px, 100%); }

.km-align-centre { margin-right: auto; margin-left: auto; }
.km-align-gauche {
  float: left;
  margin: 0.5em 2em 1.25em 0;
}
.km-align-droite {
  float: right;
  margin: 0.5em 0 1.25em 2em;
}

/* ---------- Encadrés Markdown :::info / :::conseil / :::attention ---------- */
.km-encadre {
  --km-encadre-accent: var(--km-bleu);
  --km-encadre-fond: var(--km-fond-bleu);
  position: relative;
  margin: 2em 0;
  padding: 1.25em 1.5em;
  background: linear-gradient(135deg, var(--km-encadre-fond), #fff);
  border: 1px solid var(--km-bordure);
  border-left: 5px solid var(--km-encadre-accent);
  border-radius: var(--km-rayon);
  box-shadow: var(--km-ombre);
}

.km-encadre > p:first-child { margin-top: 0; }
.km-encadre > p:last-child { margin-bottom: 0; }
.km-encadre strong { color: var(--km-encadre-accent); }

.km-encadre--attention,
.km-encadre--avertissement {
  --km-encadre-accent: var(--km-orange);
  --km-encadre-fond: var(--km-fond-orange);
}

.km-encadre--important,
.km-encadre--danger {
  --km-encadre-accent: var(--km-rouge);
  --km-encadre-fond: #fff0f1;
}

.km-encadre--astuce,
.km-encadre--conseil {
  --km-encadre-accent: var(--km-vert);
  --km-encadre-fond: var(--km-fond-turquoise);
}

/* ---------- Appels à l'action ---------- */
.km-cta {
  position: relative;
  overflow: hidden;
  margin: 2.4em 0;
  padding: 1.6em 1.7em 1.45em;
  background: linear-gradient(135deg, var(--km-bleu-nuit), var(--km-bleu));
  border-radius: calc(var(--km-rayon) + 2px);
  box-shadow: 0 16px 38px rgba(18, 62, 107, 0.2);
}

.km-cta::after {
  content: "";
  position: absolute;
  right: -45px;
  top: -70px;
  width: 180px;
  height: 180px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.km-cta .km-cta__titre {
  position: relative;
  z-index: 1;
  margin: 0 0 0.45em;
  color: #fff;
  font-size: 1.22em;
  line-height: 1.35;
}

.km-cta .km-cta__titre strong { color: inherit; }

.km-cta .km-cta__texte {
  position: relative;
  z-index: 1;
  margin: 0 0 1.05em;
  color: rgba(255, 255, 255, 0.88);
}

.km-cta .km-cta__action {
  position: relative;
  z-index: 1;
  margin: 0;
}

.km-cta .km-cta__bouton {
  display: inline-block;
  padding: 0.78em 1.35em;
  color: var(--km-bleu-nuit);
  background: #fff;
  border: 2px solid #fff;
  border-radius: 999px;
  font-weight: 750;
  line-height: 1.25;
  text-decoration: none;
  transition: transform 0.18s ease, background 0.18s ease;
}

.km-cta .km-cta__bouton:hover,
.km-cta .km-cta__bouton:focus {
  color: #fff;
  background: transparent;
  text-decoration: none;
  transform: translateY(-1px);
}

.km-cta .km-cta__bouton:focus-visible {
  outline: 3px solid #ffd19e;
  outline-offset: 3px;
}

/* ---------- Tableaux ---------- */
.km-tableau {
  max-width: 100%;
  margin: 2em 0;
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--km-bordure);
  border-radius: var(--km-rayon);
  box-shadow: var(--km-ombre);
  -webkit-overflow-scrolling: touch;
}

.km-tableau table {
  width: 100%;
  min-width: 560px;
  margin: 0;
  border: 0;
  border-collapse: collapse;
}

.km-tableau th {
  padding: 0.95em 1em;
  color: #fff;
  background: var(--km-bleu-nuit);
  border: 0;
  font-weight: 700;
  text-align: left;
}

.km-tableau td {
  padding: 0.88em 1em;
  color: var(--km-texte);
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--km-bordure);
}

.km-tableau tbody tr:nth-child(even) td { background: var(--km-fond); }
.km-tableau tbody tr:hover td { background: var(--km-fond-turquoise); }
.km-tableau tbody tr:last-child td { border-bottom: 0; }

/* ---------- FAQ accordéon ---------- */
.km-faq {
  margin: 3em 0 0;
  padding: 2em;
  background: linear-gradient(145deg, #f3f8fd, #eef4fa);
  border-radius: calc(var(--km-rayon) + 6px);
}

.km-faq .km-faq__surtitre,
.km-liens-internes .km-liens-internes__surtitre {
  margin: 0 0 0.35em;
  color: var(--km-orange);
  font-size: 0.78em;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.km-faq > h2,
.km-liens-internes > h2 {
  margin: 0 0 1em;
  padding: 0;
  color: var(--km-bleu-nuit);
  font-size: clamp(1.45em, 2.4vw, 1.9em);
  border: 0;
}

.km-faq .km-faq__liste {
  display: grid;
  gap: 0.75em;
}

.km-faq .km-faq__item {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--km-bordure);
  border-radius: 12px;
  box-shadow: 0 7px 20px rgba(18, 62, 107, 0.06);
}

.km-faq .km-faq__question {
  position: relative;
  padding: 1.05em 3.5em 1.05em 1.2em;
  color: var(--km-bleu-nuit);
  font-weight: 750;
  line-height: 1.4;
  cursor: pointer;
  list-style: none;
}

.km-faq .km-faq__question::-webkit-details-marker { display: none; }

.km-faq .km-faq__question::after {
  content: "+";
  position: absolute;
  right: 1.05em;
  top: 50%;
  display: grid;
  place-items: center;
  width: 1.75em;
  height: 1.75em;
  color: var(--km-orange);
  background: var(--km-fond-orange);
  border-radius: 50%;
  font-size: 1.15em;
  transform: translateY(-50%);
  transition: transform 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.km-faq .km-faq__item[open] {
  border-color: color-mix(in srgb, var(--km-bleu) 55%, var(--km-bordure));
}

.km-faq .km-faq__item[open] .km-faq__question {
  color: var(--km-bleu);
  border-bottom: 1px solid var(--km-bordure);
}

.km-faq .km-faq__item[open] .km-faq__question::after {
  content: "−";
  color: #fff;
  background: var(--km-orange);
  transform: translateY(-50%) rotate(180deg);
}

.km-faq .km-faq__question:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--km-bleu) 35%, transparent);
  outline-offset: -3px;
}

.km-faq .km-faq__reponse {
  padding: 1em 1.2em 1.15em;
  color: var(--km-texte-doux);
}

.km-faq .km-faq__reponse > :first-child { margin-top: 0; }
.km-faq .km-faq__reponse > :last-child { margin-bottom: 0; }

/* Compatibilité avec les articles envoyés avant la version accordéon. */
.km-faq > h3 {
  margin: 1.2em 0 0.4em;
  padding-left: 0.8em;
  color: var(--km-bleu);
  font-size: 1.08em;
  border-left: 3px solid var(--km-orange);
}

.km-faq > h3 + p {
  margin-top: 0;
  padding: 0 0.8em 0.8em;
  color: var(--km-texte-doux);
}

/* ---------- Articles associés ---------- */
.km-liens-internes {
  margin: 2.7em 0 0;
  padding: 1.7em;
  background: #fff;
  border: 1px solid var(--km-bordure);
  border-radius: calc(var(--km-rayon) + 2px);
  box-shadow: var(--km-ombre);
}

.km-liens-internes ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.km-liens-internes li { margin: 0; }

.km-liens-internes li a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 3.4em;
  padding: 0.9em 3em 0.9em 1em;
  color: var(--km-bleu-nuit);
  background: var(--km-fond);
  border: 1px solid transparent;
  border-radius: 10px;
  text-decoration: none;
}

.km-liens-internes li a::after {
  content: "→";
  position: absolute;
  right: 1em;
  color: var(--km-orange);
  font-size: 1.25em;
}

.km-liens-internes li a:hover,
.km-liens-internes li a:focus {
  color: var(--km-bleu);
  background: var(--km-fond-bleu);
  border-color: var(--km-bordure);
}

/* ---------- Sources externes ---------- */
.km-sources {
  margin: 2.3em 0;
  padding: 1.15em 1.35em;
  background: var(--km-fond);
  border-left: 4px solid var(--km-turquoise);
  border-radius: 0 var(--km-rayon) var(--km-rayon) 0;
}

.km-sources > h2 {
  margin: 0 0 0.55em;
  padding: 0;
  color: var(--km-turquoise);
  font-size: 1.15em;
  border: 0;
}

.km-sources ol {
  margin: 0;
  padding-left: 1.3em;
}

.km-sources li {
  margin: 0.35em 0;
  color: var(--km-texte-doux);
}

/* ---------- Petits écrans ---------- */
@media (max-width: 720px) {
  .km-article > h2 {
    margin-top: 2em;
    padding-left: 0.75em;
  }

  .km-align-gauche,
  .km-align-droite {
    float: none;
    margin: 1.8em auto;
  }

  .km-faq {
    padding: 1.25em 1em;
  }

  .km-liens-internes {
    padding: 1.25em 1em;
  }

  .km-liens-internes ul {
    grid-template-columns: 1fr;
  }

  .km-cta {
    padding: 1.35em 1.1em;
    text-align: center;
  }

  .km-cta .km-cta__bouton {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }

  .km-article > blockquote {
    padding: 1.1em 1.1em 1.1em 3em;
  }
}

/* ---------- Impression et accessibilité ---------- */
@media print {
  .km-cta { color: #000; background: none; border: 1px solid #999; box-shadow: none; }
  .km-cta .km-cta__titre,
  .km-cta .km-cta__texte { color: #000; }
  .km-cta .km-cta__bouton { color: #000; border-color: #000; text-decoration: underline; }
  .km-faq .km-faq__item { break-inside: avoid; box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  .km-cta .km-cta__bouton,
  .km-faq .km-faq__question::after {
    transition: none;
  }
}
