/* ========================================
   Kokensha TOC (Table of Contents) Styles
   サイトのトンマナに合わせたシンプルなデザイン
   ======================================== */

.kokensha-toc {
  background: #fff;
  margin: 32px 0;
  padding: 24px;
}

.kokensha-toc__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.kokensha-toc__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #333;
}

.kokensha-toc__toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}

.kokensha-toc__toggle:hover {
  opacity: 0.7;
}

.kokensha-toc__toggle-icon {
  display: block;
  width: 12px;
  height: 12px;
  transition: transform 0.3s;
  transform: rotate(-90deg);
}

.kokensha-toc.is-collapsed .kokensha-toc__toggle-icon {
  transform: rotate(0deg);
}

.kokensha-toc__nav {
  transition: max-height 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

.kokensha-toc.is-collapsed .kokensha-toc__nav {
  max-height: 0 !important;
  opacity: 0;
}

.kokensha-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: h2-counter;
}

.kokensha-toc__list--nested {
  margin-left: 24px;
  margin-top: 8px;
  counter-reset: h3-counter;
}

.kokensha-toc__item--level2 {
  margin: 8px 0;
  counter-increment: h2-counter;
  display: flex;
  align-items: flex-start;
}

.kokensha-toc__item--level2::before {
  content: counter(h2-counter) ". ";
  color: #666;
  margin-right: 6px;
  flex-shrink: 0;
}

.kokensha-toc__item--level3 {
  margin: 8px 0;
  counter-increment: h3-counter;
  display: flex;
  align-items: flex-start;
}

.kokensha-toc__item--level3::before {
  content: counter(h3-counter) ". ";
  color: #666;
  margin-right: 6px;
  flex-shrink: 0;
}

.kokensha-toc__item--level4 {
  margin: 8px 0;
  display: flex;
  align-items: flex-start;
}

.kokensha-toc__link {
  color: #181b39 !important;
  text-decoration: none !important;
  display: inline-block;
  line-height: 1.6;
  transition: opacity 0.3s;
  outline: none !important;
  box-shadow: none !important;
}

.kokensha-toc__link:hover {
  opacity: 0.7;
}

.kokensha-toc__link:focus,
.kokensha-toc__link:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.kokensha-toc__link.is-active {
  font-weight: 600;
}

/* レベル別スタイル */
.kokensha-toc__item--level2 .kokensha-toc__link {
  font-size: 16px;
  font-weight: 700;
}

.kokensha-toc__item--level3 .kokensha-toc__link {
  font-size: 15px;
}

.kokensha-toc__item--level4 .kokensha-toc__link {
  font-size: 14px;
}

/* スムーススクロール用のアンカーオフセット */
.c-article__content h2[id],
.c-article__content h3[id],
.c-article__content h4[id] {
  scroll-margin-top: 100px;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
  .kokensha-toc {
    margin: 24px 0;
    padding: 16px;
  }

  .kokensha-toc__title {
    font-size: 16px;
  }

  .kokensha-toc__list--nested {
    margin-left: 16px;
  }

  .kokensha-toc__item--level2 .kokensha-toc__link {
    font-size: 15px;
  }

  .kokensha-toc__item--level3 .kokensha-toc__link {
    font-size: 14px;
  }

  .kokensha-toc__item--level4 .kokensha-toc__link {
    font-size: 13px;
  }
}
