/**
 * Reading Experience Optimization
 * - 优化故事内容排版
 * - 阅读设置面板样式
 * - 沉浸模式样式
 * - 响应式优化
 */

/* ============================================================
   1. 故事内容排版优化
   ============================================================ */

.story-content {
    /* 排版基础 */
    max-width: 740px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    
    /* 字体 */
    font-family: 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', serif;
    font-size: 18px;
    line-height: 1.8;
    letter-spacing: 0.02em;
    
    /* 颜色 */
    color: #1f2937;
    background: #fff;
    
    /* 性能 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 段落 */
.story-content p {
    margin-bottom: 1.5em;
    text-indent: 2em;  /* 首行缩进 */
    text-align: justify;  /* 两端对齐 */
}

/* 标题 */
.story-content h1,
.story-content h2,
.story-content h3,
.story-content h4 {
    font-family: 'Noto Serif SC', 'Source Han Serif SC', serif;
    font-weight: 700;
    line-height: 1.4;
    margin-top: 2em;
    margin-bottom: 1em;
    color: #111827;
}

.story-content h2 {
    font-size: 1.5em;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5em;
}

.story-content h3 {
    font-size: 1.25em;
}

/* 引用 */
.story-content blockquote {
    margin: 1.5em 0;
    padding: 1em 1.5em;
    border-left: 4px solid #6366f1;
    background: #f9fafb;
    border-radius: 0 8px 8px 0;
    color: #4b5563;
    font-style: italic;
}

/* 代码 */
.story-content code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: #f3f4f6;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

.story-content pre {
    background: #1f2937;
    color: #e5e7eb;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1.5em 0;
}

.story-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* 分隔线 */
.story-content hr {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, #e5e7eb, transparent);
    margin: 3em auto;
    max-width: 200px;
}

/* 图片 */
.story-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5em auto;
    display: block;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* 链接 */
.story-content a {
    color: #4f46e5;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.story-content a:hover {
    border-bottom-color: #4f46e5;
}

/* ============================================================
   2. 阅读设置面板样式
   ============================================================ */

#reading-settings-panel {
    font-family: -apple-system, BlinkMacSystemFont, 'Noto Sans SC', sans-serif;
}

#reading-settings-panel h3 {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
}

.setting-group label {
    font-size: 14px;
    color: #374151;
}

.setting-btn {
    padding: 8px 16px;
    border: 2px solid #e5e7eb;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    color: #374151;
}

.setting-btn:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: #eef2ff;
}

.setting-btn.active {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
}

#font-size-display {
    font-size: 16px;
    font-weight: 600;
    color: #6366f1;
    min-width: 50px;
    text-align: center;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(99,102,241,0.3);
}

/* ============================================================
   3. 沉浸模式样式
   ============================================================ */

body.immersive-mode {
    padding-top: 0 !important;
}

body.immersive-mode .navbar,
body.immersive-mode .footer,
body.immersive-mode .breadcrumb,
body.immersive-mode .story-header,
body.immersive-mode .story-actions,
body.immersive-mode .action-bar,
body.immersive-mode .comment-form,
body.immersive-mode .comment-list {
    display: none !important;
}

body.immersive-mode .story-content {
    max-width: 800px;
    padding-top: 4rem;
}

/* ============================================================
   4. 阅读进度条优化
   ============================================================ */

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 9999;
}

.reading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #a78bfa);
    width: 0%;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(99,102,241,0.5);
}

/* ============================================================
   5. 章节导航优化
   ============================================================ */

.chapter-navigation {
    max-width: 740px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: #f9fafb;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chapter-navigation a {
    padding: 10px 20px;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    text-decoration: none;
    color: #374151;
    font-weight: 500;
    transition: all 0.2s;
}

.chapter-navigation a:hover {
    border-color: #6366f1;
    color: #6366f1;
    background: #eef2ff;
}

.chapter-navigation .chapter-info {
    text-align: center;
    font-weight: 600;
    color: #111827;
}

/* ============================================================
   6. 响应式优化
   ============================================================ */

@media (max-width: 768px) {
    .story-content {
        font-size: 16px;
        line-height: 1.7;
        padding: 1.5rem 1rem;
    }
    
    .story-content p {
        text-indent: 1.5em;
    }
    
    #reading-settings-panel {
        width: 100%;
        right: -100%;
    }
    
    .chapter-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .chapter-navigation .chapter-info {
        order: -1;
    }
}

@media (max-width: 480px) {
    .story-content {
        font-size: 15px;
        padding: 1rem 0.75rem;
    }
}

/* ============================================================
   7. 打印优化
   ============================================================ */

@media print {
    .navbar,
    .footer,
    .story-actions,
    .action-bar,
    .comment-form,
    .comment-list,
    .reading-progress,
    #reading-settings-panel,
    .chapter-navigation {
        display: none !important;
    }
    
    .story-content {
        max-width: 100%;
        font-size: 12pt;
        line-height: 1.6;
        color: #000;
    }
}

/* ============================================================
   8. 主题支持（配合 JS 切换）
   ============================================================ */

/* 护眼模式 */
body.theme-sepia .story-content {
    background: #f5e6c8;
    color: #5c4a1e;
}

body.theme-sepia .story-content a {
    color: #8b6914;
}

/* 暗色模式 */
body.theme-dark {
    background: #1a1a2e;
    color: #e0e0e0;
}

body.theme-dark .story-content {
    background: #1a1a2e;
    color: #e0e0e0;
}

body.theme-dark .story-content h1,
body.theme-dark .story-content h2,
body.theme-dark .story-content h3 {
    color: #f0f0f0;
}

body.theme-dark .story-content a {
    color: #6c63ff;
}

body.theme-dark .story-content blockquote {
    background: #2a2a4e;
    color: #b0b0b0;
}

/* ============================================================
   9. 动画
   ============================================================ */

/* 阅读设置面板滑入 */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

#reading-settings-panel.open {
    animation: slideInRight 0.3s ease;
}

/* 按钮悬停效果 */
.setting-btn {
    position: relative;
    overflow: hidden;
}

.setting-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(99,102,241,0.2);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.setting-btn:active::after {
    width: 200px;
    height: 200px;
}

/* ============================================================
   10. 辅助功能
   ============================================================ */

/* 高对比度模式 */
@media (prefers-contrast: high) {
    .story-content {
        color: #000;
        background: #fff;
    }
    
    .story-content a {
        color: #0000ee;
        text-decoration: underline;
    }
}

/* 减少动画 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* 焦点样式（无障碍） */
.setting-btn:focus-visible,
story-content a:focus-visible {
    outline: 3px solid #6366f1;
    outline-offset: 2px;
}
