/* === BLOQUE 4: REPRODUCTOR DE VOZ + INDICE INTERACTIVO PRO (CLS = 0) === */

/* 1. Compensacion de anclas para la cabecera sticky cristalina */
.prose h2,
.prose h3,
.prose h4 {
  scroll-margin-top: 92px !important;
}

/* Ocultar sumarios duplicados heredados de TinyMCE Joomla cuando nuestro TOC interactivo esta activo */
body.esm-toc-ready .prose .mce-toc {
  display: none !important;
}

/* Resaltado sin desplazamiento (box-shadow) del parrafo que se esta narrando */
.prose .esm-tts-active-node {
  background-color: #f0fdfa !important;
  box-shadow: -4px 0 0 #0d9488, 0 0 0 6px #f0fdfa !important;
  border-radius: 6px;
  transition: background-color 0.22s ease, box-shadow 0.22s ease;
}

/* 2. Barra del Reproductor 'Escuchar articulo' */
.esm-audio-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0 0 1.25rem;
  padding: 0.68rem 0.95rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%) !important;
  border: 1px solid #cbd5e1 !important;
  border-left: 4px solid #0d9488 !important;
  border-radius: 14px !important;
  box-shadow: 0 4px 14px -4px rgba(9, 17, 31, 0.06) !important;
}

.esm-audio-bar.is-speaking {
  background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 100%) !important;
  border-color: #5eead4 !important;
  border-left-color: #0b6e66 !important;
}

.esm-audio-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.esm-audio-play-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.45rem !important;
  padding: 0.46rem 0.98rem !important;
  border-radius: 999px !important;
  border: 1px solid #0b6e66 !important;
  background: linear-gradient(180deg, #0d9488 0%, #0b6e66 100%) !important;
  color: #ffffff !important;
  font-size: 0.82rem !important;
  font-weight: 800 !important;
  cursor: pointer !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24), 0 4px 12px -2px rgba(11, 110, 102, 0.35) !important;
  transition: transform 0.15s ease, filter 0.15s ease !important;
}
.esm-audio-play-btn:hover {
  transform: translateY(-1px) !important;
  filter: brightness(1.06) !important;
}
.esm-audio-play-btn svg,
.esm-audio-play-btn span {
  color: #ffffff !important;
  stroke: currentColor;
}

.esm-audio-ctrls {
  display: none;
  align-items: center;
  gap: 0.35rem;
}
.esm-audio-bar.has-started .esm-audio-ctrls {
  display: inline-flex;
}

.esm-audio-ctrl-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  border-radius: 999px !important;
  border: 1px solid #cbd5e1 !important;
  background: #ffffff !important;
  color: #0f172a !important;
  cursor: pointer !important;
  transition: border-color 0.15s ease, background-color 0.15s ease !important;
}
.esm-audio-ctrl-btn:hover {
  border-color: #0d9488 !important;
  background: #f0fdfa !important;
  color: #0b6e66 !important;
}

.esm-audio-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.esm-audio-status {
  font-size: 0.79rem;
  font-weight: 700;
  color: #475569 !important;
}

.esm-audio-speed-btn {
  padding: 0.28rem 0.62rem !important;
  border-radius: 999px !important;
  border: 1px solid #cbd5e1 !important;
  background: #ffffff !important;
  color: #09111f !important;
  font-size: 0.75rem !important;
  font-weight: 800 !important;
  cursor: pointer !important;
}
.esm-audio-speed-btn:hover {
  border-color: #0d9488 !important;
  color: #0b6e66 !important;
}

.esm-audio-track {
  width: 100%;
  height: 4px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  display: none;
  margin-top: 0.15rem;
}
.esm-audio-bar.has-started .esm-audio-track {
  display: block;
}
.esm-audio-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #0d9488 0%, #10b981 100%);
  transition: width 0.25s ease;
}

/* 3. Indice Plegable en Movil / Vista de 1 Columna */
.esm-inline-toc {
  display: none;
  margin: 0 0 1.45rem;
  background: #f8fafc !important;
  border: 1px solid #dbe3ee !important;
  border-radius: 14px !important;
  overflow: hidden;
}
@media (max-width: 1024px) {
  .esm-inline-toc.has-items {
    display: block;
  }
}
.article-layout.single-col .esm-inline-toc.has-items {
  display: block;
}

.esm-inline-toc summary {
  list-style: none;
  cursor: pointer;
  padding: 0.78rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.87rem;
  font-weight: 800;
  color: #09111f !important;
  user-select: none;
}
.esm-inline-toc summary::-webkit-details-marker {
  display: none;
}
.esm-inline-toc-caret {
  transition: transform 0.2s ease;
  color: #0d9488;
}
.esm-inline-toc[open] .esm-inline-toc-caret {
  transform: rotate(180deg);
}

.esm-inline-toc-list {
  margin: 0 !important;
  padding: 0.2rem 1rem 0.9rem !important;
  list-style: none !important;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.esm-inline-toc-list a {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.36rem 0.5rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 650;
  color: #1e293b !important;
  text-decoration: none !important;
}
.esm-inline-toc-list a.is-h3 {
  padding-left: 1.35rem;
  font-size: 0.81rem;
  font-weight: 600;
  color: #475569 !important;
}
.esm-inline-toc-list a:hover,
.esm-inline-toc-list a.is-active {
  background: #ecfdf5 !important;
  color: #0b6e66 !important;
}

/* 4. Barra Lateral Derecha Sticky + Scroll-Spy en Escritorio */
@media (min-width: 1025px) {
  .article-layout > aside {
    position: sticky !important;
    top: 86px !important;
    align-self: start !important;
    max-height: calc(100vh - 104px);
    overflow-y: auto;
    scrollbar-width: thin;
  }
}

.esm-toc-head-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 0.5rem !important;
  margin-bottom: 0.65rem !important;
}

.esm-toc-pct-pill {
  font-size: 0.7rem;
  font-weight: 850;
  padding: 0.12rem 0.48rem;
  border-radius: 999px;
  background: #ecfdf5 !important;
  border: 1px solid #99f6e4 !important;
  color: #0b6e66 !important;
}

.esm-toc-pro-list {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.esm-toc-pro-link {
  display: flex !important;
  align-items: baseline !important;
  gap: 0.48rem !important;
  padding: 0.4rem 0.6rem !important;
  border-radius: 9px !important;
  border-left: 3px solid transparent !important;
  font-size: 0.84rem !important;
  font-weight: 650 !important;
  line-height: 1.32 !important;
  color: #334155 !important;
  text-decoration: none !important;
  transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease !important;
}
.esm-toc-pro-link.is-h3 {
  padding-left: 1.35rem !important;
  font-size: 0.8rem !important;
  font-weight: 550 !important;
  color: #52637a !important;
}
.esm-toc-pro-link:hover {
  background: #f8fafc !important;
  color: #0b6e66 !important;
}
.esm-toc-pro-link.is-active {
  background: #ecfdf5 !important;
  border-left-color: #0d9488 !important;
  color: #09111f !important;
  font-weight: 800 !important;
}
.esm-toc-num {
  font-size: 0.7rem;
  font-weight: 800;
  color: #0d9488 !important;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .esm-audio-meta {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }
}
