﻿/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
a{
    text-decoration:none;
    color:darkgreen;
}
html, body {
    width: 100%;
    height: 100%;   
    background: #f9f3e7;
    font-family: 'Georgia', 'Times New Roman', '宋体', 'Songti SC', serif;
}
.navBack{
    line-height:25px;
    height:25px;
    padding-left:20px;
    float:left;
    border-bottom:solid 1px #dacbbc;
}
.reader {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;    
}

/* ============================================================
       阅读区域 — 使用 CSS Columns 分页
       ============================================================ */
.page-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f9f3e7;
    touch-action: none;
    user-select: none;
    transition: background-color 0.3s ease;
}

/* 
      关键：使用 CSS Multi-column Layout 实现分页
      - column-width 设为一个超大值（比容器宽），保证每个 column 占满容器宽度
      - column-gap 设置为容器宽度，使 column 之间有足够间隙，
        滑动时不会看到相邻列的内容
      - height: 100% 固定高度，内容会自动分成多个 column
      - column-fill: auto 保证内容按顺序填充 column
      - 用一个 wrapper 承载所有 column，通过 transform 水平位移实现翻页
    */
.columns-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;   
    /* 关键属性 */
    column-width: 9999px; /* 比任何容器都宽，强制每个 column 占满容器宽度 */
    column-gap: 16px; /* column 之间无间隙，靠 translateX 位移 */
    column-fill: auto; /* 按顺序填满 column */
    height: 100%;   
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    /* 内边距设在 wrapper 上，这样每个 column 共享相同 padding */
    padding: 5px 16px;
    /* 保证内容在 padding 内 */
    box-sizing: border-box;
}

/* 内容容器：存放实际的 HTML 文本 */
.columns-content {
    /* 让内容填充到 column 中 */
    height: 100%;
    width: 100%;
    font-size: 1.15rem;
    line-height: 1.8;
    color: #3f3a32;
    word-break: break-word;
    transition: font-size 0.2s ease, color 0.3s ease;
}

    /* 文本样式 */
    .columns-content p {
        margin-bottom: 1.2em;
        text-indent: 2em;
        margin-top: 0;
    }

    .columns-content h1,
    .columns-content h2,
    .columns-content h3 {
        margin: 1em 0 0.8em;
        text-indent: 0;
        font-weight: 600;
    }

    .columns-content img {
        max-width: 100%;
        height: auto;
        display: block;
        margin: 1em auto;
    }

    .columns-content blockquote {
        margin: 1em 0;
        padding: 0.5em 1em;
        border-left: 3px solid #dacbbc;
        color: #6b5a48;
        font-style: italic;
    }

/* 隐藏原生滚动条 */
.page-container::-webkit-scrollbar {
    display: none;
}

.page-container {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* ============================================================
       章节标题浮层
       ============================================================ */
.chapter-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 18px 24px 12px;
    font-size: 0.85rem;
    letter-spacing: 1px;
    color: #9b7e5c;
    z-index: 51;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    text-shadow: 0 1px 2px rgba(152 127 64 / 80%);
    transition: color 0.3s ease;
}
/* ============================================================
       加载提示
       ============================================================ */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(249, 243, 231, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    color: #6b5a48;
    gap: 16px;
    font-size: 0.95rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

    .loading-overlay.show {
        opacity: 1;
        visibility: visible;
    }

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #dacbbc;
    border-top-color: #8b7a66;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-message {
    color: #b34a3a;
    font-size: 0.9rem;
    text-align: center;
    padding: 0 20px;
    line-height: 1.5;
}

/* ============================================================
       底部控制栏
       ============================================================ */
.bottom-bar {
    display: flex;
    background: #f2e9da;
    border-top: 1px solid #dacbbc;
    padding: 10px 20px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    z-index: 10;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

    .bottom-bar .nav-btn {
        background: #f9f3e7;
        border: 1px solid #c7b5a0;
        padding: 10px 22px;
        border-radius: 40px;
        font-size: 0.9rem;
        color: #5d4b38;
        font-weight: 500;
        letter-spacing: 0.5px;
        transition: background 0.15s, transform 0.1s;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 4px;
        font-family: inherit;
    }

        .bottom-bar .nav-btn:active {
            background: #e6d9c8;
            transform: scale(0.96);
        }

        .bottom-bar .nav-btn:disabled {
            opacity: 0.35;
            pointer-events: none;
            filter: grayscale(0.3);
        }

    .bottom-bar .page-indicator {
        font-variant-numeric: tabular-nums;
        background: #e6d9c8;
        padding: 6px 18px;
        border-radius: 30px;
        font-size: 0.9rem;
        color: #5b4a37;
        letter-spacing: 0.5px;
        white-space: nowrap;
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .bottom-bar .menu-btn {
        background: #f9f3e7;
        border: 1px solid #c7b5a0;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.15s, transform 0.1s;
        font-size: 1.2rem;
        color: #5d4b38;
        flex-shrink: 0;
        font-family: inherit;
    }

        .bottom-bar .menu-btn:active {
            background: #e6d9c8;
            transform: scale(0.94);
        }
/* ============================================================
       菜单面板
       ============================================================ */
.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

    .menu-overlay.show {
        opacity: 1;
        visibility: visible;
    }

.menu-card {
    width: 88%;
    max-width: 380px;
    background: #f9f3e7;
    border-radius: 24px;
    padding: 24px 20px 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    color: #3f3a32;
    transform: scale(0.92);
    transition: transform 0.25s ease, background-color 0.3s ease, color 0.3s ease;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(180, 155, 125, 0.2);
}

.menu-overlay.show .menu-card {
    transform: scale(1);
}

.menu-section {
    margin-bottom: 20px;
}

    .menu-section:last-child {
        margin-bottom: 0;
    }

.menu-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #aa9b8a;
    margin-bottom: 12px;
    font-weight: 600;
}

.font-size-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.font-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid #dacbbc;
    background: #f2e9da;
    color: #5d4b38;
    font-size: 1.4rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.1s;
    user-select: none;
    line-height: 1;
    font-family: inherit;
}

    .font-btn:active {
        background: #e6d9c8;
        transform: scale(0.94);
    }

.font-size-value {
    font-size: 0.95rem;
    color: #6b5a48;
    flex: 1;
    text-align: center;
    font-weight: 500;
}

.bg-options {
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.bg-swatch {
    flex: 1;
    height: 50px;
    border-radius: 14px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.1s;
    position: relative;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.06);
}

    .bg-swatch:active {
        transform: scale(0.95);
    }

    .bg-swatch.active {
        border-color: #8b7a66;
        box-shadow: 0 0 0 2px rgba(139, 122, 102, 0.3);
    }

    .bg-swatch[data-bg="paper"] {
        background: #f9f3e7;
    }

    .bg-swatch[data-bg="white"] {
        background: #ffffff;
    }

    .bg-swatch[data-bg="sepia"] {
        background: #f0e6d2;
    }

    .bg-swatch[data-bg="green"] {
        background: #e8f0e4;
    }

    .bg-swatch[data-bg="night"] {
        background: #2a2a2a;
    }

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.toggle-label {
    font-size: 0.95rem;
    color: #5d4b38;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    width: 56px;
    height: 30px;
    border-radius: 30px;
    background: #dacbbc;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
    flex-shrink: 0;
}

    .toggle-switch::after {
        content: '';
        position: absolute;
        top: 3px;
        left: 3px;
        width: 24px;
        height: 24px;
        border-radius: 50%;
        background: #fff;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
        transition: transform 0.3s;
    }

    .toggle-switch.on {
        background: #6b8c6b;
    }

        .toggle-switch.on::after {
            transform: translateX(26px);
        }

.catalog-list {
    max-height: 180px;
    overflow-y: auto;
    border-radius: 12px;
    background: #f2e9da;
    padding: 4px;
    scrollbar-width: thin;
}

.catalog-item {
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #5d4b38;
    transition: background 0.15s;
}

    .catalog-item:hover {
        background: #e6d9c8;
    }

    .catalog-item.active {
        background: #dacbbc;
        font-weight: 600;
        color: #3f3a32;
    }

.menu-close {
    margin-top: 4px;
    padding: 14px;
    text-align: center;
    font-size: 0.95rem;
    color: #9b7e5c;
    cursor: pointer;
    border-top: 1px solid #e2d3be;
    font-weight: 500;
    transition: color 0.15s;
}

    .menu-close:active {
        color: #6b5a48;
    }

/* ============================================================
       夜间模式
       ============================================================ */
body.night-mode {
    background: #1a1a1a;
}

    body.night-mode .reader {
        background: #1a1a1a;
    }

    body.night-mode .page-container {
        background: #1e1e1e;
    }

    body.night-mode .columns-content {
        color: #c8c3ba;
    }

        body.night-mode .columns-content blockquote {
            border-left-color: #555;
            color: #a89f94;
        }

    body.night-mode .chapter-header {
        color: #7a7065;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    }

    body.night-mode .bottom-bar {
        background: #2a2a2a;
        border-top-color: #3a3a3a;
    }

        body.night-mode .bottom-bar .nav-btn {
            background: #333;
            border-color: #444;
            color: #c8c3ba;
        }

            body.night-mode .bottom-bar .nav-btn:active {
                background: #3d3d3d;
            }

        body.night-mode .bottom-bar .page-indicator {
            background: #333;
            color: #c8c3ba;
            box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
        }

        body.night-mode .bottom-bar .menu-btn {
            background: #333;
            border-color: #444;
            color: #c8c3ba;
        }

            body.night-mode .bottom-bar .menu-btn:active {
                background: #3d3d3d;
            }

    body.night-mode .menu-card {
        background: #2a2a2a;
        color: #c8c3ba;
        border-color: rgba(255, 255, 255, 0.06);
    }

    body.night-mode .menu-section-title {
        color: #6b635a;
    }

    body.night-mode .font-btn {
        background: #333;
        border-color: #444;
        color: #c8c3ba;
    }

        body.night-mode .font-btn:active {
            background: #3d3d3d;
        }

    body.night-mode .font-size-value {
        color: #a89f94;
    }

    body.night-mode .bg-swatch.active {
        border-color: #888;
    }

    body.night-mode .toggle-label {
        color: #c8c3ba;
    }

    body.night-mode .catalog-list {
        background: #333;
    }

    body.night-mode .catalog-item {
        color: #c8c3ba;
    }

        body.night-mode .catalog-item:hover {
            background: #3d3d3d;
        }

        body.night-mode .catalog-item.active {
            background: #444;
            color: #eee;
        }

    body.night-mode .menu-close {
        color: #7a7065;
        border-top-color: #3a3a3a;
    }

    body.night-mode .loading-overlay {
        background: rgba(30, 30, 30, 0.9);
        color: #a89f94;
    }

    body.night-mode .loading-spinner {
        border-color: #444;
        border-top-color: #888;
    }

    body.night-mode .error-message {
        color: #d88a7a;
    }

.swipe-hint {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.15);
    color: #8b7a66;
    font-size: 0.7rem;
    padding: 4px 10px;
    border-radius: 20px;
    pointer-events: none;
    z-index: 6;
    opacity: 0.5;
    transition: opacity 0.4s ease;
}

@media (min-width: 501px) {
    .swipe-hint {
        display: none;
    }
}
@media (max-width: 501px) {  
    .bottom-bar .nav-btn {
        font-size:0.7em
    }
}

@media (max-height: 600px) {
    .columns-wrapper {
        padding: 50px 20px 30px;
    }

    .columns-content {
        font-size: 1rem;
        line-height: 1.7;
    }

    .menu-card {
        padding: 18px 16px;
    }

    .catalog-list {
        max-height: 120px;
    }

    .bottom-bar {
        padding: 8px 16px;
    }

        .bottom-bar .nav-btn {
            padding: 8px 16px;
            font-size: 0.85rem;
        }
}
