/**
 * Tabla de contenido (sycsl_toc).
 * Colores ajustables por web desde su tema:
 *   .toc { --toc-acento: #049ec5; }
 */
.toc,
.toc-hoja,
.toc-burbuja {
  --toc-acento: #049ec5;
  --toc-texto: #131313;
  --toc-borde: #e3e6ea;
  --toc-suave: #f6f7f8;
}

/* En la home el tema aplica `.path-frontpage #main section { margin-top: -100px }`
   a cualquier <section>: aquí no debe aplicarse. */
.path-frontpage #main section.toc {
  margin-top: 8px;
}

/* El índice lateral antiguo ya no se usa. */
#anchormenu {
  display: none !important;
}

/* Que el título no quede tapado por la cabecera fija al saltar. */
h2[id],
h3[id] {
  scroll-margin-top: 90px;
}

.toc {
  box-sizing: border-box;
  margin: 8px 0 28px;
  border: 1px solid var(--toc-borde);
  border-radius: 10px;
  background: #fff;
  color: var(--toc-texto);
  font-size: 15px;
  line-height: 1.4;
}

.toc__cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  margin: 0;
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.toc__cabecera:focus-visible {
  outline: 2px solid var(--toc-acento);
  outline-offset: 2px;
}

.toc__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

/* Icono ☰ dibujado con CSS (sin fuentes de iconos). */
.toc__title::before {
  content: "";
  width: 14px;
  height: 10px;
  flex: 0 0 auto;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 50% / 100% 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 100% / 100% 2px no-repeat;
}

.toc__toggle {
  color: var(--toc-acento);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

@media (hover: hover) and (pointer: fine) {
  .toc__cabecera:hover .toc__toggle {
    text-decoration: underline;
  }
}

.toc__content {
  padding: 0 18px 16px;
}

.toc__content[hidden] {
  display: none;
}

/* Listas numeradas 1. / 3.1. como Legalbet. */
.toc .toc__lista,
.toc-hoja .toc__lista {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
}

.toc .toc__lista > li,
.toc-hoja .toc__lista > li {
  margin: 0;
  padding: 0;
  counter-increment: toc;
}

.toc .toc__lista .toc__lista,
.toc-hoja .toc__lista .toc__lista {
  margin: 2px 0 4px;
  padding-left: 22px;
}

.toc a.toc__content-link--show-number,
.toc-hoja a.toc__content-link--show-number {
  display: block;
  padding: 5px 0;
  color: var(--toc-texto);
  font-weight: 400;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.toc a.toc__content-link--show-number::before,
.toc-hoja a.toc__content-link--show-number::before {
  content: counters(toc, ".") ". ";
  font-weight: 700;
}

.toc .toc__lista .toc__lista a.toc__content-link--show-number {
  font-size: 14px;
}

@media (hover: hover) and (pointer: fine) {
  .toc a.toc__content-link--show-number:hover,
  .toc-hoja a.toc__content-link--show-number:hover {
    color: var(--toc-acento);
  }
}

.toc__content-link--show-number:focus-visible {
  outline: 2px solid var(--toc-acento);
  outline-offset: 1px;
}

/* Panel "Contenido" en móvil. */
.toc-hoja {
  position: fixed;
  inset: 0;
  /* Modal: por encima de cabecera, aviso de cookies y recomendador. */
  z-index: 2147483000;
}

.toc-hoja[hidden] {
  display: none;
}

.toc-hoja__fondo {
  position: absolute;
  inset: 0;
  background: rgba(19, 19, 19, .45);
}

.toc-hoja__panel {
  position: absolute;
  inset: 16px 12px;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  border-radius: 14px;
  background: #fff;
  color: var(--toc-texto);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
  animation: toc-entrar .18s ease-out;
}

@keyframes toc-entrar {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.toc-hoja__cab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--toc-borde);
}

.toc-hoja__titulo {
  font-size: 20px;
  font-weight: 700;
}

.toc-hoja__cerrar {
  width: 40px;
  height: 40px;
  margin: -8px -8px -8px 0;
  border: 0;
  background: none;
  color: #6b6b6b;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.toc-hoja__cuerpo {
  flex: 1 1 auto;
  padding: 10px 16px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  font-size: 15px;
  line-height: 1.4;
}

.toc-hoja__cuerpo a.toc__content-link--show-number {
  padding: 8px 0;
}

html.toc-hoja-abierta,
html.toc-hoja-abierta body {
  overflow: hidden;
}

/* Burbuja flotante (móvil), mismo sitio que la anterior. */
.toc-burbuja {
  display: none;
}

@media (max-width: 767.98px) {
  .toc-burbuja:not([hidden]) {
    position: fixed;
    right: 12px;
    bottom: 80px;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #333;
    color: #fff;
    box-shadow: 0 0 5px #0dcaf0;
    cursor: pointer;
  }

  .toc__cabecera {
    padding: 12px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toc-hoja__panel {
    animation: none;
  }
}
