/* 章节目录页样式 - Win11 风格 */

/* 目录容器 */
.catalog-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

/* 分段导航 */
.section-box-inner {
    padding: 12px !important;
}

.section-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 6px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.section-list li a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    background: rgba(0,0,0,0.03);
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 13px;
    transition: background 0.15s, color 0.15s;
    min-height: 36px;
}

.section-list li a:hover {
    background: var(--primary-bg-light);
    color: var(--primary);
}

.section-list li.cur a {
    background: var(--primary);
    color: #fff;
}

/* 章节网格 */
.chapter-grid {
    padding: 0;
    margin: 0;
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.chapter-grid li {
    border-bottom: 1px solid var(--border-light);
}

.chapter-grid li:nth-child(odd) {
    border-right: 1px solid var(--border-light);
}

/* 去除最后一行底部边框 */
.chapter-grid li:nth-last-child(-n+2):nth-child(odd),
.chapter-grid li:nth-last-child(-n+2):nth-child(even) {
    border-bottom: none;
}

/* 单个章节时 */
.chapter-grid li:only-child {
    border-right: none;
}

/* 奇数个最后一项 */
.chapter-grid li:last-child:nth-child(odd) {
    border-right: none;
}

/* 章节链接 */
.chapter-link, .disabled-chapter {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s;
    min-height: 44px;
    font-size: 14px;
    line-height: 1.4;
}

.chapter-link:hover {
    background: var(--primary-bg-light);
    color: var(--primary);
}

.chapter-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chapter-link .chapter-name {
    font-weight: 500;
}

/* 锁定章节 */
.disabled-chapter {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.disabled-chapter::after {
    content: '\1F512';
    margin-left: auto;
    font-size: 12px;
    flex-shrink: 0;
}

.login-required {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: 8px;
}

/* 阅读记录标记 */
.reading-record-item {
    background: var(--primary-bg-light) !important;
}

.reading-record-item .chapter-link {
    color: var(--primary);
    font-weight: 600;
}

.read-marker {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
    flex-shrink: 0;
    white-space: nowrap;
}

.read-marker svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
    .catalog-container {
        padding: 0 12px;
    }

    .section-list {
        grid-template-columns: repeat(auto-fit, minmax(55px, 1fr));
        gap: 4px;
    }

    .section-list li a {
        padding: 6px 4px;
        font-size: 12px;
        min-height: 32px;
    }

    .chapter-link, .disabled-chapter {
        padding: 10px 12px;
        min-height: 40px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .section-list {
        grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
        gap: 3px;
    }

    .section-list li a {
        padding: 5px 3px;
        font-size: 12px;
        min-height: 28px;
    }

    .chapter-link, .disabled-chapter {
        padding: 9px 10px;
        min-height: 38px;
        font-size: 13px;
    }

    .login-required {
        font-size: 10px;
    }
}

/* 触摸设备 */
@media (hover: none) and (pointer: coarse) {
    .chapter-link:hover {
        background: transparent;
        color: var(--text-primary);
    }

    .chapter-link:active {
        background: var(--primary-bg-light);
    }

    .section-list li a:active {
        background: var(--primary) !important;
        color: #fff !important;
    }
}

/* 安全区域 */
@supports(padding: max(0px)) {
    .catalog-container {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: env(safe-area-inset-bottom);
    }
}
