/**
 * Custom Joli TOC Styles - Yandex Zen Style
 * Плавающее мини-меню навигации слева
 */

/* Скрываем стандартный блок TOC в контенте (но не fallback - он уже скрыт инлайн-стилем) */
.wpj-jtoc.wpj-jtoc--main:not(.mosseo-fallback-toc) {
  display: none !important;
}

/* Создаём кастомный плавающий TOC */
.wpj-jtoc-floating-custom {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 8px 12px 0px;
  background: transparent;
}

/* Контейнер для точек/полосок */
.wpj-jtoc-floating-custom .toc-dots {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 0 10px 10px 0;
  box-shadow: 2px 2px 16px rgba(0, 0, 0, 0.12);
  transition: all 0.3s ease;
  position: relative;
}

/* Каждая точка/полоска */
.wpj-jtoc-floating-custom .toc-dot {
  width: 4px;
  height: 20px;
  background: #d1d5db;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}

.wpj-jtoc-floating-custom .toc-dot:hover {
  background: #3b82f6;
  width: 6px;
  transform: scaleY(1.1);
}

.wpj-jtoc-floating-custom .toc-dot.active {
  background: #3b82f6;
  height: 28px;
}

/* Прочитанные разделы */
.wpj-jtoc-floating-custom .toc-dot.read {
  background: #10b981;
}

/* Выпадающее меню */
.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;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Мобильная версия - тоже слева вертикально */
@media (max-width: 1200px) {
  .wpj-jtoc-floating-custom {
    padding: 8px 6px;
  }

  .wpj-jtoc-floating-custom .toc-dots {
    padding: 10px 6px;
  }

  .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 5px;
    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;
}

