/* ===== Base ===== */
.wstoc * { box-sizing: border-box; }
.wstoc a { text-decoration: none; color: inherit; }
.wstoc .wstoc-icon { width: 14px; height: 14px; display: inline-block; fill: currentColor; }

/* ===== Visibilité desktop/mobile ===== */
.wstoc--rail { display:block; }
@media (max-width: 767px){ .wstoc--rail { display:none; } }

.wstoc--mobile { display:none; }
@media (max-width: 767px){ .wstoc--mobile { display:block; margin: 0 0 16px; } }

/* ===== Rail (desktop) ===== */
.wstoc--rail {
  position: relative;
  padding-left: 18px;
  font-size: 14px;
  color: #2a2a2a;
}
.wstoc--rail .wstoc__title {
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: .2px;
}
.wstoc--rail .wstoc__inner {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow: auto;
  padding-right: 8px;
}

/* piste progression */
.wstoc--rail .wstoc__progress {
  position: absolute;
  left: 0;
  width: 4px;
  background: #f0f2f5;
  border-radius: 3px;
}
.wstoc--rail .wstoc__progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  width: 4px;
  height: 0%;
  background: #1e88e5;
  border-radius: 3px;
  transition: none;
}

/* ===== Listes communes ===== */
.wstoc__list, .wstoc__sublist { list-style: none; margin: 0; padding: 0; }
.wstoc__item { margin: 0; }

/* Rail: espacement + séparateurs (gap un peu réduit) */
.wstoc--rail .wstoc__summary,
.wstoc--rail .wstoc__line,
.wstoc--rail .wstoc__details > summary {
  display: flex;
  align-items: center;
  gap: 10px;                 /* gap rail un peu réduit */
  padding: 14px 0;
  border-top: 1px solid #eceff3;
}
.wstoc--rail .wstoc__item:first-child .wstoc__summary,
.wstoc--rail .wstoc__item:first-child .wstoc__line,
.wstoc--rail .wstoc__item:first-child .wstoc__details > summary {
  border-top: 0;
}

.wstoc__sublist {
  margin: 8px 0 12px 24px;
  padding: 0;
}
.wstoc__item--h3 {
  padding: 10px 0;
  border-top: 1px solid #f2f4f7;
}
.wstoc__item--h3:first-child { border-top: 0; }

.wstoc__item--h3 .wstoc__link { font-weight: 400; }
.wstoc__link { color: #2a2a2a; }
.wstoc__link:hover { text-decoration: underline; }
.wstoc__icon,
.wstoc__leaf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9aa4b2;
}
.wstoc__details > summary::-webkit-details-marker { display: none; }
.wstoc__details > summary { list-style: none; cursor: pointer; }
.wstoc__details > summary .wstoc__icon .wstoc-icon-arrow {
  transform: rotate(0deg);
  transition: transform .14s ease;
}
.wstoc__details > summary .wstoc__icon {
  width: 22px; height: 22px;
  border-radius: 6px;
}
.wstoc__details[open] > summary .wstoc__icon .wstoc-icon-arrow { transform: rotate(-90deg); }
.wstoc__details[open] > summary .wstoc__icon {
  background: rgba(30,136,229,.08);
  color: #1e88e5;
}
.wstoc__link.is-active { color: #1e88e5; font-weight: 600; }
.wstoc__icon.is-active,
.wstoc__leaf.is-active { color: #1e88e5; }

/* ===== Mobile accordion ===== */
.wstoc--mobile .wstocm__root{
  position: static;                /* <details> non-sticky par défaut */
  border: 1px solid #eceff3;
  border-radius: 10px;
  background: #fff;
}
.wstoc--mobile.is-stuck .wstocm__root { position: sticky; }

.wstoc--mobile .wstocm__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-weight: 600;
  cursor: pointer;
}
.wstoc--mobile .wstocm__summary .wstocm__chev .wstoc-icon-arrow {
  transform: rotate(0deg);
  transition: transform .14s ease;
}
.wstoc--mobile .wstocm__root[open] .wstocm__summary .wstoc-icon-arrow { transform: rotate(-90deg); }

.wstoc--mobile .wstocm__list { list-style: none; margin: 0; padding: 8px 14px 14px; }
.wstoc--mobile .wstocm__item { margin: 0; }

/* === MOBILE: H2 avec/sans enfants — même espacement et séparateurs que desktop === */
.wstoc--mobile .wstocm__list > .wstocm__item--h2 > .wstocm__line,
.wstoc--mobile .wstocm__list > .wstocm__item--h2 > details.wstocm__details > summary {
  display: flex;
  align-items: center;
  gap: 4px;                 /* écart réduit */
  padding: 6px 0;           /* air vertical */
  border-top: 1px solid #eceff3;
}
.wstoc--mobile .wstocm__list > .wstocm__item--h2:first-child > .wstocm__line,
.wstoc--mobile .wstocm__list > .wstocm__item--h2:first-child > details.wstocm__details > summary {
  border-top: 0;
}

/* Chevrons H2 */
.wstoc--mobile .wstocm__details > summary .wstoc-icon-arrow {
  transform: rotate(0deg);
  transition: transform .14s ease;
}
.wstoc--mobile .wstocm__details[open] > summary .wstoc-icon-arrow { transform: rotate(-90deg); }

/* H3 mobile */
.wstoc--mobile .wstocm__sublist {
  list-style: none;
  margin: 6px 0 8px 24px;
  padding: 0;
}
.wstoc--mobile .wstocm__item--h3 {
  padding: 10px 0;
  border-top: 1px solid #f2f4f7;
}
.wstoc--mobile .wstocm__item--h3:first-child { border-top: 0; }
.wstoc--mobile .wstocm__link { color: #2a2a2a; }
.wstoc--mobile .wstocm__link:hover { text-decoration: underline; }

/* Supprimer les chevrons natifs */
.wstoc--mobile .wstocm__root > summary::-webkit-details-marker,
.wstoc--mobile .wstocm__details > summary::-webkit-details-marker { display: none; }
.wstoc--mobile .wstocm__root > summary,
.wstoc--mobile .wstocm__details > summary { list-style: none; }
@supports selector(summary::marker) {
  .wstoc--mobile .wstocm__root > summary::marker,
  .wstoc--mobile .wstocm__details > summary::marker { content: ""; }
}

/* Mince quand scrolled + replié */
.wstoc--mobile.is-thin .wstocm__root:not([open]) .wstocm__summary {
  padding: 8px 12px;
  font-size: 0.95rem;
}
.wstoc--mobile.is-thin .wstocm__summary .wstocm__chev .wstoc-icon-arrow { width: 12px; height: 12px; }

/* Scrollbar fine (ouvert) */
.wstoc--mobile .wstocm__root[open] {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.25) transparent;
}
.wstoc--mobile .wstocm__root[open]::-webkit-scrollbar { width: 6px; }
.wstoc--mobile .wstocm__root[open]::-webkit-scrollbar-track { background: transparent; }
.wstoc--mobile .wstocm__root[open]::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,.25);
  border-radius: 3px;
  transition: background-color .2s ease;
}
.wstoc--mobile .wstocm__root[open]::-webkit-scrollbar-thumb:hover { background-color: rgba(0,0,0,.4); }

/* Bouton "Afficher plus" (rail) */
.wstoc__show-more {
  all: unset !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  cursor: pointer !important;
  font: inherit !important;
  color: inherit !important;
  line-height: 1.4 !important;
  width: 100% !important;
  padding: 8px 0 !important;
}
.wstoc__show-more-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.wstoc__show-more:hover,
.wstoc__show-more:focus,
.wstoc__show-more:active {
  background: none !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  text-decoration: none !important;
}

/* Rail: overflow interne quand “Afficher plus” */
.wstoc__list--collapsed { overflow: hidden !important; }
.wstoc__list--expanded  { overflow-y: auto !important; overflow-x: hidden !important; }
.wstoc__list--expanded {
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.25) transparent;
}
.wstoc__list--expanded::-webkit-scrollbar { width: 6px; }
.wstoc__list--expanded::-webkit-scrollbar-track { background: transparent; }
.wstoc__list--expanded::-webkit-scrollbar-thumb {
  background-color: rgba(0,0,0,0.25);
  border-radius: 3px;
  transition: background-color 0.2s ease;
}
.wstoc__list--expanded::-webkit-scrollbar-thumb:hover { background-color: rgba(0,0,0,0.4); }

/* ===== Mobile sticky max-height & scrollbar ===== */
@media (max-width: 767px){
  .wstoc--mobile { position: relative; }
  .wstoc--mobile.is-stuck{
    position: sticky;
    top: var(--wstocm-offset, 12px);
    z-index: 30;
  }

  /* Quand sticky + beaucoup de contenu : limite la hauteur et scroll interne */
  .wstoc--mobile.is-stuck .wstocm__root{
    max-height: calc(100vh - var(--wstocm-offset, 12px) - 12px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(0,0,0,.25) transparent;
  }
  .wstoc--mobile.is-stuck .wstocm__root::-webkit-scrollbar{ width:6px; }
  .wstoc--mobile.is-stuck .wstocm__root::-webkit-scrollbar-track{ background:transparent; }
  .wstoc--mobile.is-stuck .wstocm__root::-webkit-scrollbar-thumb{
    background-color: rgba(0,0,0,.25);
    border-radius: 3px;
    transition: background-color .2s ease;
  }
  .wstoc--mobile.is-stuck .wstocm__root::-webkit-scrollbar-thumb:hover{
    background-color: rgba(0,0,0,.4);
  }
}

/* Barre de progression horizontale sur mobile TOC - pleine largeur, au-dessus de tout */
.wstoc--mobile .wstocm__summary {
  position: relative; /* ancrage pour le ::before */
  overflow: visible;  /* pour que la barre dépasse si besoin */
}

.wstoc--mobile .wstocm__summary::before {
  content: "";
  position: absolute;
  top: 0; /* collé bord top */
  left: 0;
  width: var(--wstocm-progress, 0%);
  height: 4px; /* épaisseur plus visible */
  background-color: #1e88e5;
  z-index: 2; /* passe au-dessus du texte et de l'icône */
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  transition: width 0.15s ease-out;
}


.wstoc--mobile.is-stuck .wstocm__root:not([open]) .wstocm__summary::before {
  opacity: 1;
}


