﻿/* 目錄外框 */
#toc-container
{
    width: 100%;
    box-sizing: border-box;
    margin: 25px auto;
    border: 1px solid #e5cda5;
    border-radius: 8px;
    background-color: #fffcf7;
    overflow: hidden;
}

/* 隱藏 Checkbox，保留鍵盤操作功能 */
#toc-toggle-checkbox
{
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

/* 目錄標題列 */
#toc-toggle-label
{
    display: flex;
    align-items: center;
    padding: 15px 20px;
    background-color: #fcf0dc;
    color: #805a2c;
    cursor: pointer;
    user-select: none;
    gap: 10px;
}

/* 目錄標題文字 */
.toc-title
{
    font-size: 25px;
    font-weight: bold;
    margin-right: auto;
}

/* 展開及收合提示文字 */
.toc-status
{
    font-size: 20px;
    color: #a38762;
}

.toc-status::before
{
    content: "展開目錄";
}

#toc-toggle-checkbox:checked + #toc-toggle-label .toc-status::before
{
    content: "收合目錄";
}

/* 右側箭頭 */
.toc-arrow
{
    width: 8px;
    height: 8px;
    border-right: 2px solid #a87b40;
    border-bottom: 2px solid #a87b40;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

#toc-toggle-checkbox:checked + #toc-toggle-label .toc-arrow
{
    transform: rotate(225deg);
}

/* 目錄內容 */
#toc-content
{
    display: none;
    padding: 10px 20px;
}

/* 展開目錄 */
#toc-toggle-checkbox:checked ~ #toc-content
{
    display: block;
}

/* 鍵盤操作提示 */
#toc-toggle-checkbox:focus-visible + #toc-toggle-label
{
    outline: 2px solid #a87b40;
    outline-offset: -2px;
}

/* 目錄清單 */
#toc-content ol
{
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: toc-number;
}

/* 每個目錄項目 */
#toc-content li
{
    counter-increment: toc-number;
    border-bottom: 1px solid #eee3d2;
    margin: 0;
    padding: 0;
}

#toc-content li:last-child
{
    border-bottom: none;
}

/* 目錄超連結 */
#toc-content a
{
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 12px 5px;
    font-size: 20px;
    line-height: 1.6;
    color: #594b38;
    text-decoration: none;
}

/* 自動產生 01、02、03 編號 */
#toc-content a::before
{
    content: counter(toc-number, decimal-leading-zero);
    color: #b58b50;
    font-weight: bold;
}

/* 滑鼠移入效果 */
#toc-content a:hover
{
    background-color: #f9eedc;
    color: #b17b30;
}

/* 手機版調整 */
@media screen and (max-width: 1100px)
{
    #toc-toggle-label
    {
        padding: 12px 15px;
    }

    #toc-content
    {
        padding: 5px 15px;
    }

    .toc-title
    {
        font-size: 30px;
    }
    
    .toc-status
    {
        font-size: 25px;
    }

    #toc-content a
    {
        font-size: 25px;
    }
}