/* ==========================================================
   📚 Table des matières (TOC)
   ========================================================== */

/* ----- Layout général ----- */
.page-with-toc {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
}

/* ----- Bloc TOC ----- */
#page-toc {
  position: sticky;
  top: 6rem;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  flex-shrink: 0;
  width: 260px;
  padding: 1.2rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Pour un scroll agréable dans le menu */
#page-toc::-webkit-scrollbar {
  width: 6px;
}

#page-toc::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

#page-toc::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* ----- Liste ----- */
#page-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ----- Liens ----- */
#page-toc a {
  display: block;
  padding: 0.4rem 0.6rem;
  color: #333;
  text-decoration: none;
  border-left: 3px solid transparent;
  border-radius: 4px;
  transition: all 0.2s ease;
  line-height: 1.4;
}

#page-toc a:hover {
  background: #f5f8fa;
  color: #0066cc;
}

/* ----- Lien actif ----- */
#page-toc a.active {
  background: #e8f2ff;
  border-color: #0077ff;
  color: #0077ff;
  font-weight: 600;
}

/* ----- Hiérarchie ----- */
#page-toc li.h1 a {
  font-size: 1rem;
  margin-top: 0.6rem;
}

#page-toc li.h2 a {
  font-size: 0.9rem;
  margin-left: 1.2rem;
  color: #555;
}

/* ----- Contenu principal ----- */
.page-content {
  flex: 1;
  min-width: 0;
}

/* ==========================================================
   📱 Responsive
   ========================================================== */

@media (max-width: 900px) {
  .page-with-toc {
    flex-direction: column;
  }

  #page-toc {
    position: relative;
    top: 0;
    width: 100%;
    max-height: none;
    border: none;
    box-shadow: none;
    padding: 0;
    background: none;
  }

  /* Bouton sommaire */
  #toc-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0077ff;
    color: #fff;
    padding: 0.8rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    margin-bottom: 0.6rem;
  }

  #toc-toggle::after {
    content: "▾";
    font-size: 1rem;
    transition: transform 0.2s;
  }

  #toc-toggle.open::after {
    transform: rotate(180deg);
  }

  #page-toc ul {
    display: none;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.6rem;
    margin-top: 0.4rem;
  }

  #page-toc.open ul {
    display: block;
  }

  #page-toc a {
    padding: 0.5rem 0.8rem;
    border-radius: 4px;
  }
}



















/* ==========================================================
   📱 TOC MOBILE — propre, centré, 100% largeur
   ========================================================== */

#page-toc-mobile {
  position: sticky;
  top: 5em;
  left: 0;
  width: 100%;
  z-index: 100;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  display: none;
  /* caché sur desktop */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;


}

@media (max-width: 770px) {
  #page-toc-mobile {
    top: 6.5em;
  }
}


/* ---- Barre d’en-tête du sommaire ---- */
#toc-mobile-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.9rem 1.2rem;
  box-sizing: border-box;
  font-weight: 600;
  color: #222;
  cursor: pointer;
}

#toc-current-title {
  flex: 1;
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 1rem;
}

/* ---- Bouton flèche ---- */
#toc-toggle {
  background: none;
  border: none;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#toc-toggle svg {
  width: 18px;
  height: 18px;
  fill: #333;
  transition: transform 0.25s ease;
}

#page-toc-mobile.open #toc-toggle svg {
  transform: rotate(180deg);
}

/* ---- Liste déroulante ---- */
#toc-mobile-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
  border-top: 1px solid #eee;
  background: #fff;
  box-sizing: border-box;
  width: 100%;
}

#page-toc-mobile.open #toc-mobile-list {
  display: block;
  animation: fadeIn 0.2s ease;
}

#toc-mobile-list li {
  border-bottom: 1px solid #f3f3f3;
}

#toc-mobile-list a {
  display: block;
  padding: 0.9rem 1.2rem;
  text-decoration: none;
  color: #333;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

#toc-mobile-list a:hover {
  background: #f7f9fc;
}

#toc-mobile-list a.active {
  color: #0077ff;
  border-color: #0077ff;
  background: #eef7ff;
}

/* ---- Animation ---- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  #page-toc {
    display: none;
  }

  #page-toc-mobile {
    display: block;
  }
}



@media (max-width: 900px) {

  .page-content h1,
  .page-content h2 {
    scroll-margin-top: 90px;
    /* espace sous la barre mobile */
  }
}