/* ============================================================
 * Proteo TOC
 * 投稿内の見出しから自動生成される目次のスタイル
 * ============================================================ */

.proteo-toc {
    --proteo-toc-accent: #2596be;
    --proteo-toc-text: #333;
    --proteo-toc-muted: #888;
    --proteo-toc-border: #e3e3e3;
    --proteo-toc-bg: #f9f9f9;
    --proteo-toc-collapsed-max-height: 280px;

    position: relative;
    margin: 24px 0 32px;
    padding: 16px 20px;
    border: 1px solid var(--proteo-toc-border);
    border-radius: 6px;
    background: var(--proteo-toc-bg);
    font-size: 15px;
    line-height: 1.7;
    color: var(--proteo-toc-text);
}

/* スタイル：ボックス（影なしの控えめ版） */
.proteo-toc--style-boxed {
    background: #fff;
    border-color: rgba(0,0,0,0.08);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* スタイル：ミニマル（縦ライン） */
.proteo-toc--style-minimal {
    background: transparent;
    border: none;
    border-left: 4px solid var(--proteo-toc-accent);
    border-radius: 0;
    padding: 8px 0 8px 20px;
}

/* ヘッダー */
.proteo-toc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--proteo-toc-border);
}
.proteo-toc--style-minimal .proteo-toc__header {
    border-bottom: none;
    padding-bottom: 4px;
    margin-bottom: 8px;
}

.proteo-toc__title {
    font-weight: 700;
    font-size: 1.05em;
    color: var(--proteo-toc-text);
}

/* トグルボタン */
.proteo-toc__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    color: var(--proteo-toc-muted);
    transition: background 0.15s ease, color 0.15s ease;
}
.proteo-toc__toggle:hover,
.proteo-toc__toggle:focus {
    background: rgba(0,0,0,0.05);
    color: var(--proteo-toc-text);
    outline: none;
}
.proteo-toc__toggle-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    position: relative;
}
.proteo-toc__toggle-icon::before,
.proteo-toc__toggle-icon::after {
    content: "";
    position: absolute;
    background: currentColor;
    transition: transform 0.2s ease;
}
.proteo-toc__toggle-icon::before {
    /* 横棒 */
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    margin-top: -1px;
}
.proteo-toc__toggle-icon::after {
    /* 縦棒 */
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    margin-left: -1px;
}
.proteo-toc[aria-collapsed="true"] .proteo-toc__toggle-icon::after {
    transform: scaleY(1);
}
.proteo-toc:not([aria-collapsed="true"]) .proteo-toc__toggle-icon::after {
    /* 開いているとき：横棒のみ（−） */
    transform: scaleY(0);
}

/* 本体 */
.proteo-toc__body {
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.2s ease;
}
.proteo-toc[aria-collapsed="true"] .proteo-toc__body {
    max-height: 0 !important;
    opacity: 0;
    margin: 0;
    padding: 0;
}

/* 「もっと見る」折りたたみ状態 */
.proteo-toc__body--collapsible-more.is-collapsed {
    max-height: var(--proteo-toc-collapsed-max-height);
    -webkit-mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
            mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
}
.proteo-toc__body--collapsible-more:not(.is-collapsed) {
    max-height: none;
    -webkit-mask-image: none;
            mask-image: none;
}

/* 「もっと見る」ボタン */
.proteo-toc__more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 12px;
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--proteo-toc-border);
    border-radius: 4px;
    color: var(--proteo-toc-accent);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    font-family: inherit;
}
.proteo-toc__more-btn:hover,
.proteo-toc__more-btn:focus {
    background: var(--proteo-toc-accent);
    color: #fff;
    border-color: var(--proteo-toc-accent);
    outline: none;
}
.proteo-toc__more-btn-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    transition: transform 0.2s ease;
    margin-left: 2px;
}
.proteo-toc__more-btn[aria-expanded="true"] .proteo-toc__more-btn-icon {
    transform: rotate(180deg);
}

/* リスト */
.proteo-toc__list {
    list-style: none;
    padding-left: 0;
    margin: 0;
    counter-reset: proteo-toc-counter;
}
.proteo-toc__list .proteo-toc__list {
    padding-left: 18px;
    margin: 4px 0 8px;
}

.proteo-toc__item {
    margin: 4px 0;
    position: relative;
}
.proteo-toc__item--virtual {
    /* 構造上のみのアイテム（テキストなし） */
    list-style: none;
}

/* リンク */
.proteo-toc__link {
    color: var(--proteo-toc-text);
    text-decoration: none;
    display: inline;
    padding: 2px 0;
    transition: color 0.15s ease;
    word-break: break-word;
}
.proteo-toc__link:hover,
.proteo-toc__link:focus {
    color: var(--proteo-toc-accent);
    text-decoration: underline;
    outline: none;
}
.proteo-toc__link.is-active {
    color: var(--proteo-toc-accent);
    font-weight: 700;
}
.proteo-toc__link.is-active .proteo-toc__num {
    color: var(--proteo-toc-accent);
}

.proteo-toc__num {
    color: var(--proteo-toc-muted);
    font-weight: 700;
    margin-right: 4px;
    font-size: 0.92em;
}

/* H2 / H3 / H4 でフォントの強さを微調整 */
.proteo-toc__item--lv2 > .proteo-toc__link {
    font-weight: 600;
}
.proteo-toc__item--lv3 > .proteo-toc__link {
    font-weight: 400;
    font-size: 0.97em;
}
.proteo-toc__item--lv4 > .proteo-toc__link {
    font-weight: 400;
    font-size: 0.94em;
    color: #555;
}

/* スマホ表示 */
@media (max-width: 768px) {
    .proteo-toc {
        font-size: 14px;
        padding: 14px 16px;
    }
    .proteo-toc__list .proteo-toc__list {
        padding-left: 14px;
    }
}

/* スクロール追従用のスムーズスクロール */
html {
    scroll-behavior: smooth;
}
