/* =============================================================
   MSC Blog CTA — CTA contextuel articles de blog + articles similaires
   Thème clair MSC (style.css du child theme) : blanc / gris / rouge #E3211B.
   Fallbacks en dur (bug :root dans style.css), valeurs alignées sur la charte.
   ============================================================= */

/* ------------------------------------------------------------
   1. CTA — carte sticky dans sa colonne (Theme Builder)
   Toujours visible, non fermable, pas de position fixed.
   Le décalage `top` est injecté par le plugin (réglage « sticky_top »).
   ------------------------------------------------------------ */
.msc-cta-stick {
  position: sticky;
  top: 100px; /* surchargé par le réglage via wp_add_inline_style */
  z-index: 1; /* sous le header du site — ne JAMAIS utiliser l'option sticky de Divi */
  box-sizing: border-box;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 24px 24px;
  background: var(--msc-white, #ffffff);
  color: var(--msc-dark, #1a1a2e);
  border: 1px solid var(--msc-gray-200, #e8e8ec);
  border-top: 3px solid var(--msc-red, #E3211B); /* signature de marque */
  border-radius: var(--msc-radius, 10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .06);
  font-family: var(--msc-font, 'DM Sans', 'Segoe UI', system-ui, sans-serif);
}

.msc-cta-stick__body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Eyebrow alignée sur le pattern .s-label du site (trait + uppercase rouge) */
.msc-cta-stick__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--msc-red, #E3211B);
}
.msc-cta-stick__brand::before {
  content: "";
  width: 20px;
  height: 1px;
  background: var(--msc-red, #E3211B);
}

.msc-cta-stick__titre {
  font-family: var(--msc-font-display, 'DM Serif Display', Georgia, serif);
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: var(--msc-dark, #1a1a2e);
}

.msc-cta-stick__prix {
  font-size: .95rem;
  font-weight: 600;
  color: var(--msc-gray-600, #5a5a6e);
}

.msc-cta-stick__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 20px;
  background: var(--msc-red, #E3211B);
  color: #fff;
  font-size: .98rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--msc-radius-sm, 6px);
  transition: background .2s ease, transform .2s ease;
}
.msc-cta-stick__btn::after {
  content: "\2192"; /* → */
  font-weight: 400;
  transition: transform .2s ease;
}
.msc-cta-stick__btn:hover {
  background: var(--msc-red-dark, #B81A15);
  color: #fff;
  transform: translateY(-1px);
}
.msc-cta-stick__btn:hover::after {
  transform: translateX(3px);
}
.msc-cta-stick__btn:focus-visible {
  outline: 2px solid var(--msc-red, #E3211B);
  outline-offset: 2px;
}

/* ------------------------------------------------------------
   Intégration Divi — sticky natif sans l'option sticky de Divi.
   L'option Divi élève le z-index du module ET de sa section quand
   l'élément colle → le contenu passe devant le header. Ici, on étire
   simplement la colonne du CTA à la hauteur de l'article : la carte
   (position: sticky ci-dessus) voyage sur tout le défilement.
   Prérequis : le module code [msc_cta] est SEUL dans sa colonne.
   ------------------------------------------------------------ */
@media (min-width: 981px) {
  .et_pb_row:has(.msc-cta-stick) {
    display: flex;
    align-items: stretch; /* la colonne du CTA prend la hauteur de la plus grande colonne */
  }
  .et_pb_column:has(.msc-cta-stick) .et_pb_module:has(.msc-cta-stick),
  .et_pb_column:has(.msc-cta-stick) .et_pb_code_inner {
    height: 100%; /* laisse la carte sticky voyager sur toute la colonne */
  }
}

/* ------------------------------------------------------------
   Mobile / tablette (colonnes empilées) : barre fixe en bas de
   l'écran, compacte, une ligne. Safe-area iOS respectée.
   ------------------------------------------------------------ */
@media (max-width: 980px) {
  .msc-cta-stick {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto !important; /* neutralise le décalage sticky desktop injecté par le réglage */
    z-index: 9000;
    width: 100%;
    margin: 0;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 9px 16px calc(9px + env(safe-area-inset-bottom, 0px));
    border: 0;
    border-top: 2px solid var(--msc-red, #E3211B);
    border-radius: 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, .12);
  }

  /* Texte empilé verticalement : le titre dispose de 2 lignes au lieu
     d'être tronqué sur une seule baseline partagée avec le prix. */
  .msc-cta-stick__body {
    flex: 1 1 auto;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
    min-width: 0;
  }

  /* Pas d'eyebrow ni de gros titre serif : compacité. */
  .msc-cta-stick__brand { display: none; }

  /* Le titre prévaut : il s'enroule sur 2 lignes max plutôt que d'être coupé. */
  .msc-cta-stick__titre {
    font-family: var(--msc-font, 'DM Sans', system-ui, sans-serif);
    font-size: .92rem;
    font-weight: 700;
    line-height: 1.25;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .msc-cta-stick__prix {
    font-size: .8rem;
    line-height: 1.2;
    max-width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Bouton plus fin : moins de hauteur, label sur une seule ligne. */
  .msc-cta-stick__btn {
    flex: 0 0 auto;
    padding: 8px 15px;
    font-size: .85rem;
    line-height: 1.15;
    white-space: nowrap;
  }

  /* Réserve sous le contenu : la barre peut faire ~2 lignes de haut. */
  body:has(.msc-cta-stick) { padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px)); }
}

/* Très petits écrans : on garde titre + bouton fin, le prix saute. */
@media (max-width: 380px) {
  .msc-cta-stick__prix { display: none; }
  .msc-cta-stick__btn { padding: 8px 13px; font-size: .82rem; }
}

/* ------------------------------------------------------------
   2. ARTICLES SIMILAIRES — slider scroll-snap (3 visibles desktop)
   ------------------------------------------------------------ */
.msc-related {
  margin: 3rem 0 1rem;
  font-family: var(--msc-font, 'DM Sans', 'Segoe UI', system-ui, sans-serif);
}

.msc-related__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.5rem;
}

/* Kicker chapter-mark : trait rouge + label uppercase (pattern .s-label) */
.msc-related__kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: .55rem;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--msc-red, #E3211B);
}
.msc-related__kicker::before {
  content: "";
  width: 20px;
  height: 1px;
  background: var(--msc-red, #E3211B);
}

.msc-related__heading {
  font-family: var(--msc-font-display, 'DM Serif Display', Georgia, serif);
  font-size: 1.6rem;
  margin: 0;
  color: var(--msc-dark, #1a1a2e);
}

/* Flèches du slider (le JS les affiche si nécessaire et gère disabled) */
.msc-related__nav {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}
.msc-related__nav[hidden] { display: none; }

.msc-related__arrow {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  background: var(--msc-white, #ffffff);
  border: 1px solid var(--msc-gray-200, #e8e8ec);
  border-radius: 50%;
  color: var(--msc-dark, #1a1a2e);
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease, background .2s ease;
}
.msc-related__arrow:hover {
  border-color: var(--msc-red, #E3211B);
  color: var(--msc-red, #E3211B);
}
.msc-related__arrow:focus-visible {
  outline: 2px solid var(--msc-red, #E3211B);
  outline-offset: 2px;
}
.msc-related__arrow[disabled] {
  opacity: .35;
  cursor: default;
  border-color: var(--msc-gray-200, #e8e8ec);
  color: var(--msc-gray-400, #9e9eab);
}

/* Piste : 3 cartes visibles, défilement horizontal avec snap */
.msc-related__track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 3rem) / 3);
  gap: 1.5rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;       /* Firefox */
  padding: 4px;                /* laisse respirer ombres et focus ring */
  margin: -4px;
}
.msc-related__track::-webkit-scrollbar { display: none; }

.msc-related-card {
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  background: var(--msc-white, #ffffff);
  border: 1px solid var(--msc-gray-200, #e8e8ec);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .25s cubic-bezier(.16, 1, .3, 1),
              box-shadow .25s ease,
              border-color .25s ease;
}
.msc-related-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, .1);
  border-color: var(--msc-gray-300, #d1d1d9);
}
.msc-related-card:focus-visible {
  outline: 2px solid var(--msc-red, #E3211B);
  outline-offset: 2px;
}

/* Conteneur média : clippe le zoom hover, fige le ratio (piste stable) */
.msc-related-card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--msc-gray-100, #f7f7f8);
}

.msc-related-card__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s cubic-bezier(.16, 1, .3, 1);
}
.msc-related-card:hover .msc-related-card__img {
  transform: scale(1.04);
}

/* Placeholder sans vignette : wordmark discret sur fond gris clair */
.msc-related-card__ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0 1rem;
  font-family: var(--msc-font-display, 'DM Serif Display', Georgia, serif);
  font-size: 1.1rem;
  text-align: center;
  color: var(--msc-gray-300, #d1d1d9);
}

.msc-related-card__body {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  padding: 1.1rem 1.2rem 1.3rem;
}

/* La date n'est pas un élément d'action : gris, pas rouge */
.msc-related-card__date {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--msc-gray-600, #5a5a6e);
}

.msc-related-card__title {
  font-family: var(--msc-font-display, 'DM Serif Display', Georgia, serif);
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 0;
  color: var(--msc-dark, #1a1a2e);
}

.msc-related-card__excerpt {
  font-size: .9rem;
  line-height: 1.55;
  color: var(--msc-gray-600, #5a5a6e);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.msc-related-card__more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: .25rem;
  font-size: .88rem;
  font-weight: 700;
  color: var(--msc-red, #E3211B);
}
.msc-related-card__more::after {
  content: "\2192"; /* → */
  font-weight: 400;
  transition: transform .2s ease;
}
.msc-related-card:hover .msc-related-card__more {
  color: var(--msc-red-dark, #B81A15);
}
.msc-related-card:hover .msc-related-card__more::after {
  transform: translateX(4px);
}

@media (prefers-reduced-motion: reduce) {
  .msc-related__track { scroll-behavior: auto; }
  .msc-related-card,
  .msc-related-card__img,
  .msc-related-card__more::after { transition: none; }
}

/* 2 cartes visibles en tablette, 1 + amorce de la suivante en mobile */
@media (max-width: 980px) {
  .msc-related__track { grid-auto-columns: calc((100% - 1.5rem) / 2); }
}
@media (max-width: 640px) {
  .msc-related__track { grid-auto-columns: 86%; }
}
