/**
 * 目次（Table of Contents）スタイル
 * PC版：右側フローティング表示
 * スマホ版：ボタンとモーダル表示
 */

/* PC版：右側フローティング目次 */
#toc-container {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
    overflow-y: auto;
    z-index: 1000;
    transition: top 0.3s ease, transform 0.3s ease;
}

#toc-container::-webkit-scrollbar {
    width: 6px;
}

#toc-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#toc-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

#toc-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* CTAセクション */
.toc-cta-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
}

.toc-cta-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.2s ease;
    text-align: center;
}

.toc-cta-button:last-child {
    margin-bottom: 0;
}

.toc-cta-icon {
    font-size: 16px;
    line-height: 1;
}

.toc-cta-text {
    flex: 1;
    text-align: center;
}

.toc-cta-primary {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.3);
}

.toc-cta-primary:hover {
    background: linear-gradient(135deg, #ea580c 0%, #dc2626 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

.toc-cta-secondary {
    background: #1f2937;
    color: white;
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.3);
}

.toc-cta-secondary:hover {
    background: #111827;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(31, 41, 55, 0.4);
}

.toc-cta-tertiary {
    background: #3b82f6;
    color: white;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.toc-cta-tertiary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

#toc-container .toc-title {
    font-size: 16px;
    font-weight: 800;
    color: #1a202c;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.toc-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.toc-label::before {
    content: '📑';
    font-size: 18px;
    line-height: 1;
}

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

.toc-item {
    margin: 0;
    padding: 0;
}

.toc-link {
    display: block;
    padding: 8px 12px;
    color: #4a5568;
    text-decoration: none;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 6px;
    transition: all 0.2s ease;
    word-break: break-word;
}

.toc-link:hover {
    background-color: #f7fafc;
    color: #2d3748;
    transform: translateX(4px);
}

.toc-link.toc-active {
    background-color: #fed7aa;
    color: #c05621;
    font-weight: 700;
    border-left: 3px solid #f97316;
    padding-left: 9px;
}

/* 見出しレベルのインデント */
.toc-level-2 .toc-link {
    padding-left: 12px;
    font-weight: 600;
}

.toc-level-3 .toc-link {
    padding-left: 24px;
    font-size: 13px;
    color: #718096;
}

.toc-level-4 .toc-link {
    padding-left: 36px;
    font-size: 12px;
    color: #a0aec0;
}

.toc-nested {
    margin-top: 4px;
    margin-left: 0;
}

/* スマホ版：ボタン */
#toc-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: #f97316;
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
    cursor: pointer;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
}

#toc-button:hover {
    background: #ea580c;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.5);
}

#toc-button:active {
    transform: scale(0.95);
}

#toc-button svg {
    width: 24px;
    height: 24px;
}

/* スマホ版：モーダル */
#toc-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#toc-modal.toc-modal-open {
    opacity: 1;
    visibility: visible;
}

.toc-modal-content {
    background: white;
    width: 100%;
    max-width: 100%;
    max-height: 80vh;
    border-radius: 20px 20px 0 0;
    padding: 24px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

#toc-modal.toc-modal-open .toc-modal-content {
    transform: translateY(0);
}

.toc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
}

.toc-modal-title {
    font-size: 18px;
    font-weight: 800;
    color: #1a202c;
    margin: 0;
}

.toc-modal-title .toc-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.toc-modal-title .toc-label::before {
    content: '📑';
    font-size: 20px;
    line-height: 1;
}

/* スマホ版CTA */
.toc-cta-mobile {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid #e2e8f0;
}

.toc-cta-mobile .toc-cta-button {
    padding: 12px 16px;
    font-size: 14px;
    margin-bottom: 10px;
}

.toc-cta-mobile .toc-cta-icon {
    font-size: 18px;
}

.toc-close-button {
    background: none;
    border: none;
    font-size: 24px;
    color: #718096;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.toc-close-button:hover {
    background: #f7fafc;
    color: #2d3748;
}

/* スマホ版の目次リスト */
#toc-modal .toc-list {
    padding-left: 0;
}

#toc-modal .toc-link {
    padding: 12px 16px;
    font-size: 15px;
}

#toc-modal .toc-level-2 .toc-link {
    padding-left: 16px;
}

#toc-modal .toc-level-3 .toc-link {
    padding-left: 28px;
}

#toc-modal .toc-level-4 .toc-link {
    padding-left: 40px;
}

/* レスポンシブ：PC版を非表示 */
@media (max-width: 767px) {
    #toc-container {
        display: none;
    }
}

/* レスポンシブ：スマホ版を非表示 */
@media (min-width: 768px) {
    #toc-button,
    #toc-modal {
        display: none;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toc-item {
    animation: fadeIn 0.3s ease forwards;
}

.toc-item:nth-child(1) { animation-delay: 0.05s; }
.toc-item:nth-child(2) { animation-delay: 0.1s; }
.toc-item:nth-child(3) { animation-delay: 0.15s; }
.toc-item:nth-child(4) { animation-delay: 0.2s; }
.toc-item:nth-child(5) { animation-delay: 0.25s; }
.toc-item:nth-child(6) { animation-delay: 0.3s; }
.toc-item:nth-child(7) { animation-delay: 0.35s; }
.toc-item:nth-child(8) { animation-delay: 0.4s; }
.toc-item:nth-child(9) { animation-delay: 0.45s; }
.toc-item:nth-child(10) { animation-delay: 0.5s; }

/* スクロールバーのスタイル（モーダル用） */
.toc-modal-content::-webkit-scrollbar {
    width: 6px;
}

.toc-modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.toc-modal-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.toc-modal-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

