/**
 * Table of Contents (TOC) Styles
 */

/* 目次ボタン（フローティング） */
.toc-toggle {
    position: fixed;
    bottom: 90px;
    /* reCAPTCHA回避のため少し上げる */
    right: 5px;
    /* 右端5px */
    z-index: 1028;
    /* Mobile Nav (1029)より下、CTAより上 */
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #01294D 0%, #0a3d6b 100%);
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;


    /* 初期状態：非表示（navigation.cssの.floating-ctaに合わせる） */
    opacity: 0;
    visibility: hidden;
    transform: translateX(120px);
    /* 右へ隠す */
    transition: transform 0.4s ease, opacity 0.4s ease, visibility 0.4s ease;
}

.toc-toggle i {
    font-size: 20px;
    margin-bottom: 2px;
}

.toc-toggle:hover {
    transform: scale(1.05);
    /* .visible時のhoverはJS制御が必要なため、CSSだけでは難しいが一旦維持 */
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

/* 表示状態 */
.toc-toggle.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    /* 定位置に戻す */
}

.toc-toggle.visible:hover {
    transform: scale(1.05);
}

/* Smart Scrollによる非表示状態（JSロジック変更により.visibleクラス制御になるため不要だが念のため残すか削除） */
.toc-toggle.hidden {
    transform: translateX(120px);
    opacity: 0;
    pointer-events: none;
}

/* 目次ドロワー（スライドメニュー） */
.toc-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 300px;
    height: 100vh;
    background: #fff;
    z-index: 1040;
    /* Header (1030)より上 */
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
    transition: right 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    /* easeOutQuart */
    display: flex;
    flex-direction: column;
    padding-top: 0;
    /* ヘッダーの上に表示するため余白削除 */

}

/* アクティブ状態 */
.toc-drawer.active {
    right: 0;
}

/* ヘッダー部分 */
.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
    background: #f9f9f9;
}

.toc-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #01294D;
}

.toc-close {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0 0.5rem;
}

/* コンテンツ部分 */
.toc-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.toc-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-content li {
    margin-bottom: 0.5rem;
}

.toc-content a {
    text-decoration: none;
    color: #333;
    font-size: 0.95rem;
    display: block;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
    line-height: 1.4;
}

.toc-content a:hover {
    background: #f0f4f8;
    color: #01294D;
}

/* h3レベル（インデント） */
.toc-content ul ul {
    padding-left: 1rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    border-left: 2px solid #eee;
}

.toc-content ul ul a {
    font-size: 0.85rem;
    color: #666;
}

/* オーバーレイ */
.toc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1027;
    /* ドロワーのすぐ下 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.toc-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* モバイルレスポンシブ調整 */
@media screen and (max-width: 768px) {
    .toc-drawer {
        width: 85%;
        max-width: 320px;
    }

    /* 無料相談ボタン(SP)との位置調整（スタック配置） */
    /* .floating-cta が bottom: 80px 程度にあると仮定 */
    .toc-toggle {
        bottom: 240px;
        /* 無料相談ボタン(約230px高)の上 */
        right: 5px;
        /* 右端5px */
        width: 50px;
        height: 50px;
    }

    .toc-toggle span {
        font-size: 9px;
    }

    .toc-toggle i {
        font-size: 18px;
    }

    /* 無料相談ボタンがない場合は下に下げるなどの調整が必要ならJSでクラス付与を検討 */
}