/* ============================================
   PAGES PAR DÉFAUT — Normalisation KingComposer
   Appliqué à toutes les pages .page-template-default
   ============================================ */

/* === 1. Neutraliser le débordement du conteneur post-content ===
   Constat : .wp-block-post-content sans max-width → contentWidth: 2252px
   Les styles KC inline définissent width:69.82%/30.17% sur les colonnes
   → on contraint d'abord le conteneur parent */
.page-template-default .wp-block-post-content {
  max-width: 780px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 2rem 1.5rem 3rem !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

/* === 2. Neutraliser TOUS les layouts KC → single column ===
   Les colonnes KC utilisent : kc_col-sm-8, kc_col-sm-10, kc_col-sm-12,
   kc_row, kc-row-container, kc-wrap-columns, kc-col-container
   Les styles inline KC définissent des width% → on force 100% */
.page-template-default .kc_row,
.page-template-default .kc-row-container,
.page-template-default .kc-wrap-columns {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  display: block !important;
  box-sizing: border-box !important;
}

/* Colonnes KC : remise à plat, annulation des widths inline KC */
.page-template-default .kc_column,
.page-template-default .kc-col-container,
.page-template-default [class*="kc_col-sm-"],
.page-template-default [class*="kc_col-md-"] {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  display: block !important;
  box-sizing: border-box !important;
}

/* Annuler les widths% définies dans les <style> inline KC
   (ex: body.kc-css-system .kc-css-XXXXXXX{width: 69.82%}) */
.page-template-default body.kc-css-system [class*="kc-css-"],
body.kc-css-system .page-template-default [class*="kc-css-"] {
  width: 100% !important;
  max-width: 100% !important;
  float: none !important;
}

/* === 3. Masquer H1/H2 KC dupliqués ===
   La bannière TT5 (.wp-block-post-title) affiche déjà le titre de la page.
   Règles :
   - h1.kc_title dans .kc-title-wrap → toujours masqué (duplique la bannière)
   - premier .kc_row ne contenant qu'un .kc-title-wrap avec h2 seul → masqué
     (= row de titre de page KC qui duplique la bannière)
   - les h2.kc_title dans les rows suivants → conservés (titres de section) */
.page-template-default .kc-title-wrap h1,
.page-template-default h1.kc_title {
  display: none !important;
}

/* Masquer le kc-title-wrap ne contenant qu'un h1 */
.page-template-default .kc-title-wrap:has(> h1:only-child) {
  display: none !important;
}

/* Masquer le premier kc_row s'il ne contient QUE un kc-title-wrap sans kc_text_block
   → c'est le row de titre KC qui duplique la bannière TT5 */
.page-template-default .kc_row:first-of-type:not(:has(.kc_text_block)) {
  display: none !important;
}

/* === 4. Titres internes KC (h2, h3, p.kc_title) === */
.page-template-default h2.kc_title,
.page-template-default h3.kc_title,
.page-template-default p.kc_title,
.page-template-default .kc_title:not(h1) {
  font-family: Georgia, serif !important;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  color: #22413a !important;
  margin-top: 2rem !important;
  margin-bottom: 1rem !important;
  padding-bottom: 0.4rem !important;
  border-bottom: 2px solid #eb3e6c !important;
  display: block !important;
  line-height: 1.4 !important;
}

/* kc-title-wrap contenant un h2/h3/p */
.page-template-default .kc-title-wrap:not(:has(> h1:only-child)) {
  margin-bottom: 0.5rem;
}

/* === 5. Annuler font-size aberrante des styles KC inline ===
   KC injecte : .kc-css-XXXXXX p { font-size: 20px; }
   On force la typographie correcte sur tous les paragraphes KC */
.page-template-default .kc_text_block,
.page-template-default .kc_text_block p,
.page-template-default .kc-title-wrap p {
  font-family: Georgia, serif !important;
  font-size: 1rem !important;
  line-height: 1.85 !important;
  color: #333 !important;
  text-align: left !important;
  margin-bottom: 1rem !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
.page-template-default .kc_text_block p:last-child {
  margin-bottom: 0 !important;
}

/* === 6. Annuler background/padding KC inline sur colonnes ===
   KC applique parfois background:#edf2f6 et padding:20px sur les colonnes
   (ex: .kc-css-4089075 { background: #edf2f6; padding: 20px; })
   On laisse ces styles pour les blocs texte mais on recentre */
.page-template-default .kc_column[class*="kc-css-"] {
  background: transparent !important;
  padding: 0 !important;
}
/* Réappliquer un fond léger sur les kc_text_block si KC l'a défini */
.page-template-default .kc_text_block {
  padding: 0 !important;
  margin-bottom: 1.5rem !important;
}

/* === 7. Premier kc_row : encart introduction === */
.page-template-default .kc_row:first-of-type > .kc-row-container > .kc-wrap-columns > .kc_column > .kc-col-container > .kc_text_block,
.page-template-default .kc_row:first-of-type .kc-title-wrap + .kc_text_block {
  background: #f5f5f0 !important;
  border-left: 4px solid #22413a !important;
  padding: 1.25rem 1.5rem !important;
  border-radius: 0 4px 4px 0 !important;
  margin-bottom: 2rem !important;
}

/* === 8. Listes KC → stylisées === */
.page-template-default .kc_text_block ul,
.page-template-default .kc_text_block ol {
  padding-left: 0 !important;
  list-style: none !important;
  margin: 1rem 0 1.5rem !important;
}
.page-template-default .kc_text_block li {
  position: relative !important;
  padding: 0.5rem 0.75rem 0.5rem 1.5rem !important;
  font-family: Georgia, serif !important;
  font-size: 1rem !important;
  line-height: 1.7 !important;
  color: #333 !important;
  border-bottom: 1px solid #f0f0f0 !important;
}
.page-template-default .kc_text_block li::before {
  content: "›" !important;
  position: absolute !important;
  left: 0.25rem !important;
  color: #eb3e6c !important;
  font-weight: 700 !important;
  font-size: 1.1rem !important;
}

/* === 9. Liens KC et contenu === */
.page-template-default .kc_text_block a,
.page-template-default .kc-title-wrap a {
  color: #22413a !important;
  text-decoration: none !important;
  border-bottom: 1px dashed #59716b !important;
  transition: color 0.15s, border-color 0.15s !important;
}
.page-template-default .kc_text_block a:hover,
.page-template-default .kc-title-wrap a:hover {
  color: #eb3e6c !important;
  border-color: #eb3e6c !important;
}

/* === 10. Images KC === */
.page-template-default .kc_text_block img,
.page-template-default .kc-title-wrap img {
  max-width: 100% !important;
  height: auto !important;
  border-radius: 4px !important;
  margin: 1rem 0 !important;
  display: block !important;
}

/* === 11. H3 dans kc_text_block (titres de section sans kc_title) === */
.page-template-default .kc_text_block h2,
.page-template-default .kc_text_block h3,
.page-template-default .kc-title-wrap h2,
.page-template-default .kc-title-wrap h3 {
  font-family: Georgia, serif !important;
  font-size: 1.1rem !important;
  font-weight: 700 !important;
  color: #22413a !important;
  margin-top: 1.5rem !important;
  margin-bottom: 0.75rem !important;
  line-height: 1.4 !important;
}

/* === 12. Supprimer éléments vides KC === */
.page-template-default .kc-title-wrap:empty,
.page-template-default p:empty,
.page-template-default h4:empty {
  display: none !important;
}
/* &nbsp; seuls dans kc-title-wrap */
.page-template-default .kc-title-wrap:has(> div:only-child:empty) {
  display: none !important;
}

/* === 13. Filet décoratif accent sous la bannière === */
.page-template-default main::before {
  content: '';
  display: block;
  width: 50px;
  height: 3px;
  background: #eb3e6c;
  margin: 0 auto 0;
}

/* === 14. Sections KC avec background : garder le fond mais limiter la largeur === */
.page-template-default .kc_row {
  margin-bottom: 0.5rem !important;
}

/* === 15. Responsive === */
@media (max-width: 640px) {
  .page-template-default .wp-block-post-content {
    padding: 1.5rem 1rem 2rem !important;
  }
}
