/**
 * Custom Joli TOC Styles - Yandex Zen Style
 * Плавающее мини-меню навигации слева
 */

/* Скрываем стандартный блок TOC в контенте (но не fallback - он уже скрыт инлайн-стилем) */
.wpj-jtoc.wpj-jtoc--main:not(.mosseo-fallback-toc) {
  display: none !important;
}

/* Создаём кастомный плавающий TOC (+30%) */
.wpj-jtoc-floating-custom {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 10px 16px 0px;
  background: transparent;
}

/* Контейнер для точек/полосок (+30%) */
.wpj-jtoc-floating-custom .toc-dots {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 10px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 0 13px 13px 0;
  box-shadow: 2px 2px 20px rgba(0, 0, 0, 0.12);
  transition: all 0.3s ease;
  position: relative;
}

/* Каждая точка/полоска (+45%) */
.wpj-jtoc-floating-custom .toc-dot {
  width: 7px;
  height: 29px;
  background: #d1d5db;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}

.wpj-jtoc-floating-custom .toc-dot:hover {
  background: #3b82f6;
  width: 9px;
  transform: scaleY(1.1);
}

.wpj-jtoc-floating-custom .toc-dot.active {
  background: #3b82f6;
  height: 41px;
}

/* Прочитанные разделы */
.wpj-jtoc-floating-custom .toc-dot.read {
  background: #10b981;
}

/* Разные размеры точек по уровню заголовка (+45%) */
.wpj-jtoc-floating-custom .toc-dot.toc-dot--h1 {
  height: 35px;
  width: 7px;
}

.wpj-jtoc-floating-custom .toc-dot.toc-dot--h2 {
  height: 26px;
  width: 7px;
}

.wpj-jtoc-floating-custom .toc-dot.toc-dot--h3 {
  height: 17px;
  width: 4px;
  margin-left: 3px;
}

.wpj-jtoc-floating-custom .toc-dot.toc-dot--h1.active {
  height: 46px;
}

.wpj-jtoc-floating-custom .toc-dot.toc-dot--h2.active {
  height: 35px;
}

.wpj-jtoc-floating-custom .toc-dot.toc-dot--h3.active {
  height: 23px;
}

/* Выпадающее меню */
.wpj-jtoc-floating-custom .toc-dropdown {
  position: absolute;
  left: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  padding: 0;
  min-width: 300px;
  max-width: 380px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  transform: translateY(-50%) translateX(-10px);
}

/* Показываем дропдаун только через класс is-open (контролируется JS) */
.wpj-jtoc-floating-custom.is-open .toc-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}

/* Заголовок дропдауна */
.wpj-jtoc-floating-custom .toc-dropdown-header {
  padding: 14px 18px 12px;
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #f3f4f6;
}

/* Список заголовков */
.wpj-jtoc-floating-custom .toc-dropdown-list {
  list-style: none;
  margin: 0;
  padding: 8px 0 12px;
  max-height: 55vh;
  overflow-y: auto;
}

.wpj-jtoc-floating-custom .toc-dropdown-list::-webkit-scrollbar {
  width: 5px;
}

.wpj-jtoc-floating-custom .toc-dropdown-list::-webkit-scrollbar-track {
  background: transparent;
}

.wpj-jtoc-floating-custom .toc-dropdown-list::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 3px;
}

.wpj-jtoc-floating-custom .toc-dropdown-list::-webkit-scrollbar-thumb:hover {
  background: #d1d5db;
}

/* Элемент списка */
.wpj-jtoc-floating-custom .toc-dropdown-item {
  margin: 0;
  padding: 0;
}

.wpj-jtoc-floating-custom .toc-dropdown-item a {
  display: flex;
  align-items: center;
  padding: 12px 18px;
  color: #4b5563;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.45;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  cursor: pointer;
}

.wpj-jtoc-floating-custom .toc-dropdown-item a:hover {
  background: #f9fafb;
  color: #3b82f6;
  border-left-color: #3b82f6;
}

.wpj-jtoc-floating-custom .toc-dropdown-item.active a {
  background: #eff6ff;
  color: #2563eb;
  border-left-color: #3b82f6;
  font-weight: 500;
}

/* Номер пункта */
.wpj-jtoc-floating-custom .toc-dropdown-item .toc-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  background: #f3f4f6;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin-right: 14px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.wpj-jtoc-floating-custom .toc-dropdown-item a:hover .toc-num {
  background: #dbeafe;
  color: #3b82f6;
}

.wpj-jtoc-floating-custom .toc-dropdown-item.active .toc-num {
  background: #3b82f6;
  color: #ffffff;
}

/* Текст заголовка */
.wpj-jtoc-floating-custom .toc-dropdown-item .toc-text {
  flex: 1;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* === Иерархическая структура dropdown === */

/* Вложенные списки */
.wpj-jtoc-floating-custom .toc-dropdown-sublist {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0;
}

/* Уровни заголовков в dropdown */
.wpj-jtoc-floating-custom .toc-dropdown-item--h1 > a {
  font-weight: 600;
  font-size: 15px;
  color: #1f2937;
  padding-left: 18px;
}

.wpj-jtoc-floating-custom .toc-dropdown-item--h1 > a::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 6px;
  background: #6b7280;
  border-radius: 50%;
  margin-right: 12px;
  flex-shrink: 0;
}

.wpj-jtoc-floating-custom .toc-dropdown-item--h1.active > a::before,
.wpj-jtoc-floating-custom .toc-dropdown-item--h1.read > a::before {
  background: #10b981;
}

.wpj-jtoc-floating-custom .toc-dropdown-item--h2 > a {
  font-weight: 500;
  font-size: 14px;
  padding-left: 32px;
}

.wpj-jtoc-floating-custom .toc-dropdown-item--h2 > a::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  background: #9ca3af;
  border-radius: 50%;
  margin-right: 10px;
  flex-shrink: 0;
}

.wpj-jtoc-floating-custom .toc-dropdown-item--h2.active > a::before,
.wpj-jtoc-floating-custom .toc-dropdown-item--h2.read > a::before {
  background: #10b981;
}

.wpj-jtoc-floating-custom .toc-dropdown-item--h3 > a {
  font-weight: 400;
  font-size: 13px;
  padding-left: 48px;
  color: #6b7280;
}

.wpj-jtoc-floating-custom .toc-dropdown-item--h3 > a::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  background: #d1d5db;
  border-radius: 50%;
  margin-right: 8px;
  flex-shrink: 0;
}

.wpj-jtoc-floating-custom .toc-dropdown-item--h3.active > a::before,
.wpj-jtoc-floating-custom .toc-dropdown-item--h3.read > a::before {
  background: #10b981;
}

/* Прочитанные элементы в dropdown */
.wpj-jtoc-floating-custom .toc-dropdown-item.read > a {
  color: #10b981;
}

.wpj-jtoc-floating-custom .toc-dropdown-item.read > a .toc-text {
  opacity: 0.85;
}

/* Активный элемент */
.wpj-jtoc-floating-custom .toc-dropdown-item.active > a {
  background: #eff6ff;
  color: #2563eb;
  border-left-color: #3b82f6;
}

/* Мобильная версия - тоже слева вертикально */
@media (max-width: 1200px) {
  .wpj-jtoc-floating-custom {
    padding: 8px 0px;
  }

  .wpj-jtoc-floating-custom .toc-dots {
    padding: 10px 8px;
  }

  .wpj-jtoc-floating-custom .toc-dot {
    height: 16px;
  }

  .wpj-jtoc-floating-custom .toc-dot.active {
    height: 22px;
  }

  .wpj-jtoc-floating-custom .toc-dropdown {
    max-width: calc(100vw - 60px);
    min-width: 260px;
  }
}

/* Маленькие экраны */
@media (max-width: 576px) {
  .wpj-jtoc-floating-custom .toc-dots {
    padding: 8px 8px;
    gap: 5px;
  }

  .wpj-jtoc-floating-custom .toc-dot {
    width: 3px;
    height: 14px;
  }

  .wpj-jtoc-floating-custom .toc-dot.active {
    height: 18px;
  }

  .wpj-jtoc-floating-custom .toc-dropdown {
    min-width: 240px;
    max-width: calc(100vw - 50px);
  }

  .wpj-jtoc-floating-custom .toc-dropdown-item a {
    padding: 10px 14px;
    font-size: 13px;
  }

  .wpj-jtoc-floating-custom .toc-dropdown-item .toc-num {
    min-width: 22px;
    height: 22px;
    font-size: 11px;
    margin-right: 10px;
  }
}

/* Анимация появления виджета */
@keyframes tocFadeIn {
  from {
    opacity: 0;
    transform: translateY(-50%) translateX(-15px);
  }
  to {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
  }
}

.wpj-jtoc-floating-custom {
  animation: tocFadeIn 0.6s ease 0.8s both;
}


/* === Компактный режим при большом количестве заголовков (>10) === */
.wpj-jtoc-floating-custom.has-many-headings .toc-dots {
  gap: 4px;
}

.wpj-jtoc-floating-custom.has-many-headings .toc-dot {
  height: 14px;
}

.wpj-jtoc-floating-custom.has-many-headings .toc-dot.active {
  height: 20px;
}

.wpj-jtoc-floating-custom.has-many-headings .toc-dot.toc-dot--h1 {
  height: 18px;
}

.wpj-jtoc-floating-custom.has-many-headings .toc-dot.toc-dot--h2 {
  height: 10px;
}

.wpj-jtoc-floating-custom.has-many-headings .toc-dot.toc-dot--h3 {
  height: 7px;
}

.wpj-jtoc-floating-custom.has-many-headings .toc-dot.toc-dot--h1.active {
  height: 24px;
}

.wpj-jtoc-floating-custom.has-many-headings .toc-dot.toc-dot--h2.active {
  height: 16px;
}

.wpj-jtoc-floating-custom.has-many-headings .toc-dot.toc-dot--h3.active {
  height: 12px;
}

