/* Améliorations propres au site Next.js (absentes de WordPress), chargées après le CSS d'origine.
   Elles ne changent ni les contenus ni les URLs. Voir components/ArticleEnhancements.tsx.
   --adm-header-h : hauteur de l'en-tête fixe, tenue à jour par le JavaScript. */

:root {
  --adm-header-h: 77px;
  --adm-btt-bottom: 24px;
  --adm-dark: #0a2935;
  --adm-red: #bc2624;
  --adm-border: #d3dce8;
}

/* Logo de l'en-tête à la taille de aidiagme.com : 235 px de large au plus sur tablette et ordinateur
   (sur mobile, la largeur fixée par Bricks est déjà la même que sur aidiagme.com) */
@media (min-width: 768px) {
  #brx-header #brxe-b94694 .bricks-site-logo {
    max-width: 235px;
  }
}

/* Ancres (#…) : le titre visé s'arrête sous l'en-tête fixe au lieu d'être caché dessous */
html {
  scroll-padding-top: calc(var(--adm-header-h) + 16px);
}
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ---------- Articles ---------- */

/* Sommaire fixe dans la colonne de gauche (ordinateur) : il suit la lecture et défile
   lui-même s'il est plus haut que l'écran */
@media (min-width: 992px) {
  .single-post .ba-web-design-servicedetail_inner-sidebar-content {
    position: sticky;
    top: calc(var(--adm-header-h) + 20px);
    max-height: calc(100vh - var(--adm-header-h) - 40px);
  }
  .single-post .ba-web-design-servicedetail_inner-sidebar-content .brxe-post-toc {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--adm-border) transparent;
    padding-right: 6px;
  }
}
.single-post .brxe-post-toc .toc-link.is-active-link {
  color: var(--adm-red);
}

/* Sommaire repliable en haut de l'article (tablette et mobile, où la colonne est masquée) */
.adm-toc-mobile {
  display: none;
  margin: 0 0 24px;
  border: 1px solid var(--adm-border);
  border-radius: 12px;
  background: #fff;
}
@media (max-width: 991px) {
  .adm-toc-mobile {
    display: block;
  }
}
.adm-toc-mobile > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 700;
  color: var(--adm-dark);
  list-style: none;
}
.adm-toc-mobile > summary::-webkit-details-marker {
  display: none;
}
.adm-toc-mobile > summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-3px);
  transition: transform 0.2s ease;
}
.adm-toc-mobile[open] > summary::after {
  transform: rotate(-135deg) translateY(-1px);
}
.adm-toc-mobile nav {
  padding: 0 18px 14px;
  border-top: 1px solid var(--adm-border);
}
.adm-toc-mobile ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.adm-toc-mobile ul ul {
  padding-left: 16px;
}
.adm-toc-mobile li {
  margin: 0;
}
.adm-toc-mobile a {
  display: block;
  padding: 7px 0;
  color: var(--adm-dark);
  text-decoration: none;
  line-height: 1.4;
  font-size: 15px;
}
.adm-toc-mobile ul ul a {
  font-size: 14px;
  opacity: 0.85;
}

/* Liens soulignés dans le texte de l'article (repérables sans se fier à la couleur) */
.single-post .brxe-post-content :is(p, li, td, th, blockquote, figcaption) a:not(.wp-block-button__link) {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
.single-post .brxe-post-content :is(p, li, td, th, blockquote, figcaption) a:not(.wp-block-button__link):hover {
  text-decoration-thickness: 2px;
}

/* Tableau plus large que l'écran : il défile horizontalement au lieu d'élargir la page */
.adm-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Barre de progression de lecture, sous l'en-tête */
.adm-reading-progress {
  position: fixed;
  top: var(--adm-header-h);
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 997;
  pointer-events: none;
}
.adm-reading-progress > span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--adm-red);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* Bouton « retour en haut », au-dessus de l'encart du bas de page */
.adm-back-to-top {
  position: fixed;
  right: 20px;
  bottom: var(--adm-btt-bottom);
  z-index: 997;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--adm-dark);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(10, 41, 53, 0.25);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s, bottom 0.2s ease;
}
.adm-back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}
.adm-back-to-top:hover {
  background: var(--adm-red);
}
.adm-back-to-top:focus-visible {
  outline: 3px solid var(--adm-red);
  outline-offset: 3px;
}
@media (max-width: 478px) {
  .adm-back-to-top {
    right: 14px;
    width: 42px;
    height: 42px;
  }
}

/* Encart fixe du bas des articles : croix de fermeture sur mobile (ArticleEnhancements.tsx) */
.adm-cta-close {
  display: none;
}
@media (max-width: 767px) {
  .adm-cta-close {
    position: absolute;
    top: -14px;
    right: 12px;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: var(--adm-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(10, 41, 53, 0.35);
  }
  /* Zone de toucher de 46 px autour de la croix */
  .adm-cta-close::before {
    content: "";
    position: absolute;
    inset: -8px;
  }
  .adm-cta-close:focus-visible {
    outline: 3px solid var(--adm-red);
    outline-offset: 2px;
  }
  .adm-cta-closed #brxe-9e9bb2 {
    display: none !important;
  }
}
