/* ==========================================================================
   Word Cloud Reader - Mobile Reading View Stylesheet
   WeChat Read / Apple Books Inspired Typography & Touch Experience
   ========================================================================== */

#view-reader {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: background-color 0.25s ease, color 0.25s ease;
}

#view-reader.active {
    display: block;
}

/* Reading Progress Bar (Ultra Slim) */
.reading-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 2.5px;
    background: linear-gradient(90deg, #3b82f6, #6366f1);
    width: 0%;
    z-index: 120;
    transition: width 0.1s linear;
}

/* Reader Navigation Bar (Auto-hiding, Frosted Glass) */
.reader-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 52px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s ease;
}

.reader-nav.nav-hidden {
    transform: translateY(-100%);
}

.nav-btn-back {
    display: flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    color: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    min-height: 44px;
}

.nav-title-box {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 0 8px;
}

.nav-doc-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.nav-progress-percent {
    font-size: 0.68rem;
    opacity: 0.6;
    font-weight: 500;
}

.nav-actions-right {
    display: flex;
    align-items: center;
    gap: 2px;
}

.nav-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    transition: background 0.15s;
}

.nav-icon-btn:hover, .nav-icon-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

/* 4 Reading Themes */
#reader-wrapper {
    min-height: 100vh;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* Theme 1: 极简白 (White) */
#reader-wrapper[data-theme="light"] {
    background-color: #f8fafc;
    color: #1e293b;
}
#reader-wrapper[data-theme="light"] .reader-nav {
    background: rgba(255, 255, 255, 0.9);
    border-bottom-color: #e2e8f0;
}
#reader-wrapper[data-theme="light"] .fluid-content-card {
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

/* Theme 2: 羊皮纸护眼暖黄 (Warm Sepia) - The gold standard for mobile reading */
#reader-wrapper[data-theme="sepia"] {
    background-color: #f6f1e7;
    color: #3b2d1d;
}
#reader-wrapper[data-theme="sepia"] .reader-nav {
    background: rgba(246, 241, 231, 0.92);
    border-bottom-color: #e6ded1;
}
#reader-wrapper[data-theme="sepia"] .fluid-content-card {
    background: #fbf8f2;
    box-shadow: 0 4px 20px rgba(74, 52, 28, 0.04);
    border: 1px solid #ede4d6;
}

/* Theme 3: 雅灰冷色 (Slate Mist) */
#reader-wrapper[data-theme="gray"] {
    background-color: #eef1f5;
    color: #1e293b;
}
#reader-wrapper[data-theme="gray"] .reader-nav {
    background: rgba(238, 241, 245, 0.92);
    border-bottom-color: #cbd5e1;
}
#reader-wrapper[data-theme="gray"] .fluid-content-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

/* Theme 4: 暗黑夜间 (Dark OLED) */
#reader-wrapper[data-theme="dark"] {
    background-color: #141416;
    color: #e2e8f0;
}
#reader-wrapper[data-theme="dark"] .reader-nav {
    background: rgba(20, 20, 22, 0.92);
    border-bottom-color: #27272a;
}
#reader-wrapper[data-theme="dark"] .nav-icon-btn:hover,
#reader-wrapper[data-theme="dark"] .nav-icon-btn:active {
    background: rgba(255, 255, 255, 0.08);
}
#reader-wrapper[data-theme="dark"] .fluid-content-card {
    background: #1c1c20;
    border: 1px solid #27272a;
}
#reader-wrapper[data-theme="dark"] table,
#reader-wrapper[data-theme="dark"] th,
#reader-wrapper[data-theme="dark"] td {
    border-color: #3f3f46 !important;
}
#reader-wrapper[data-theme="dark"] th {
    background: rgba(255, 255, 255, 0.05) !important;
}

/* Content Container */
.reader-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 16px 14px calc(60px + env(safe-area-inset-bottom));
}

/* Fluid Article Typography (Chinese Mobile Optimized) */
.fluid-content-card {
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    font-size: 17px;
    line-height: 1.85;
    transition: font-size 0.15s ease, line-height 0.15s ease;
}

.fluid-article-content {
    text-align: justify;
    text-justify: inter-ideograph;
    word-break: break-word;
    letter-spacing: 0.01em;
}

.fluid-article-content p {
    margin-bottom: 1.2em;
}

.fluid-article-content h1,
.fluid-article-content h2,
.fluid-article-content h3,
.fluid-article-content h4 {
    font-weight: 700;
    line-height: 1.35;
    margin-top: 1.8em;
    margin-bottom: 0.6em;
    color: inherit;
}

.fluid-article-content h1 {
    font-size: 1.55em;
    padding-bottom: 0.35em;
    border-bottom: 2px solid rgba(125, 125, 125, 0.12);
}

.fluid-article-content h2 {
    font-size: 1.32em;
    padding-left: 10px;
    border-left: 3px solid var(--primary);
}

.fluid-article-content h3 {
    font-size: 1.15em;
}

.fluid-article-content ul,
.fluid-article-content ol {
    padding-left: 1.5em;
    margin-bottom: 1.2em;
}

.fluid-article-content li {
    margin-bottom: 0.4em;
}

.fluid-article-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 18px auto;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Table Responsive Horizontal Scroll */
.table-scroll-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(125, 125, 125, 0.2);
}

.fluid-article-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88em;
    line-height: 1.5;
}

.fluid-article-content th,
.fluid-article-content td {
    border: 1px solid rgba(125, 125, 125, 0.2);
    padding: 9px 12px;
    text-align: left;
}

.fluid-article-content th {
    background: rgba(125, 125, 125, 0.06);
    font-weight: 600;
}

/* Original Page Mode (Docx-Preview) */
#docx-render-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: auto;
    padding-top: 10px;
}

.docx-wrapper {
    background: transparent !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.docx-wrapper > section.docx {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08) !important;
    margin-bottom: 20px !important;
    border-radius: 6px;
    max-width: 100% !important;
}

/* Floating Zoom Bar for Preview Mode */
.floating-zoom-bar {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-pill);
    padding: 6px 14px;
    display: none;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 105;
    color: #ffffff;
}

.zoom-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
}

.zoom-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.zoom-label {
    font-size: 0.82rem;
    font-weight: 600;
    min-width: 44px;
    text-align: center;
}

.zoom-fit-btn {
    font-size: 0.76rem;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
}

/* WeChat Read Style Reading Settings Bottom Sheet */
.settings-sheet-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    display: flex;
    align-items: flex-end;
}

.settings-sheet-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.settings-sheet {
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-modal);
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
    padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
}

.settings-sheet-backdrop.open .settings-sheet {
    transform: translateY(0);
}

.sheet-drag-handle {
    width: 36px;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin: 0 auto 16px;
}

.setting-row {
    margin-bottom: 20px;
}

.setting-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

/* Mode Switcher Segmented Control */
.segmented-control {
    display: flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: var(--radius-md);
    gap: 3px;
}

.segment-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.segment-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Theme Picker Grid */
.theme-picker-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.theme-card-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 4px;
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    cursor: pointer;
    background: #f8fafc;
    transition: all 0.15s ease;
}

.theme-card-btn.active {
    border-color: var(--primary);
    background: #eff6ff;
}

.theme-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.theme-circle.t-white { background: #ffffff; border: 1px solid #e2e8f0; }
.theme-circle.t-sepia { background: #f6f1e7; border: 1px solid #e6ded1; }
.theme-circle.t-gray  { background: #eef1f5; border: 1px solid #cbd5e1; }
.theme-circle.t-dark  { background: #141416; }

.theme-name {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Font Size & Line Spacing Sliders */
.stepper-control {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: var(--radius-md);
    padding: 4px;
    justify-content: space-between;
}

.stepper-btn {
    background: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 7px 18px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.stepper-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stepper-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: all 0.15s ease;
}

.stepper-dot.active {
    background: var(--primary);
    transform: scale(1.4);
}

/* Outline (TOC) Drawer */
.toc-drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.toc-drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.toc-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 85vw;
    background: #ffffff;
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.15);
    z-index: 155;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

.toc-drawer-backdrop.open .toc-drawer {
    transform: translateX(0);
}

.toc-drawer-header {
    height: 52px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toc-drawer-title {
    font-size: 1rem;
    font-weight: 700;
}

.toc-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px;
    -webkit-overflow-scrolling: touch;
}

.toc-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.4;
    transition: all 0.12s ease;
}

.toc-item:hover, .toc-item:active {
    background: #f1f5f9;
    color: var(--text-primary);
}

.toc-item.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

.toc-item.level-2 { padding-left: 22px; font-size: 0.84rem; }
.toc-item.level-3 { padding-left: 36px; font-size: 0.8rem; }

/* Loading & Feedback */
.reader-spinner-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 22px 28px;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-modal);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 160;
    font-size: 0.9rem;
    font-weight: 600;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile Screen Specific Tweaks */
@media (max-width: 640px) {
    .reader-container {
        padding: 10px 8px calc(60px + env(safe-area-inset-bottom));
    }
    .fluid-content-card {
        padding: 22px 16px;
        border-radius: var(--radius-lg);
        font-size: 16px;
    }
    .nav-doc-title {
        max-width: 170px;
    }
}
