/* static/css/style.css
 * 小說閱讀網站樣式 — 仿紙質書籍暖色調設計
 */

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Noto Serif TC', 'Songti SC', 'STSong', serif;
    line-height: 1.9;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* === 主題色 === */
.theme-sepia {
    --bg: #f5f0e8;
    --bg-card: #ede7db;
    --text: #3d3529;
    --text-secondary: #8a7e6b;
    --accent: #b8860b;
    --border: #d4cbb8;
    --nav-bg: rgba(245, 240, 232, 0.95);
    --hover: #e8e0d0;
}

.theme-light {
    --bg: #ffffff;
    --bg-card: #f8f8f8;
    --text: #2c2c2c;
    --text-secondary: #888;
    --accent: #4a90d9;
    --border: #e0e0e0;
    --nav-bg: rgba(255, 255, 255, 0.95);
    --hover: #f0f0f0;
}

.theme-dark {
    --bg: #1a1a2e;
    --bg-card: #242440;
    --text: #c8c4b8;
    --text-secondary: #7a7670;
    --accent: #d4a853;
    --border: #3a3a50;
    --nav-bg: rgba(26, 26, 46, 0.95);
    --hover: #2e2e48;
}

.theme-green {
    --bg: #c7edcc;
    --bg-card: #b8e0be;
    --text: #2d4a32;
    --text-secondary: #5a7d5e;
    --accent: #3a7d44;
    --border: #a0c9a5;
    --nav-bg: rgba(199, 237, 204, 0.95);
    --hover: #b0d9b5;
}

body {
    background-color: var(--bg);
    color: var(--text);
}

/* === 容器 === */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* === 首頁 === */
.site-header {
    text-align: center;
    padding: 3rem 0 2rem;
}

.site-title {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--accent);
}

.site-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    letter-spacing: 0.15em;
}

/* === 小說卡片 === */
.novel-grid {
    display: grid;
    gap: 1.5rem;
    padding: 1rem 0;
}

.novel-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s;
}

.novel-card:hover {
    background: var(--hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.novel-card-icon { font-size: 3rem; }

.novel-card-title {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.novel-card-author { color: var(--text-secondary); font-size: 0.95rem; }
.novel-card-meta { color: var(--text-secondary); font-size: 0.85rem; margin-top: 0.2rem; }

/* === 麵包屑 === */
.breadcrumb {
    padding: 1rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.breadcrumb a { color: var(--accent); }
.breadcrumb a:hover { text-decoration: underline; }

/* === 小說詳情頁 === */
.novel-header {
    text-align: center;
    padding: 2rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.novel-icon { font-size: 4rem; margin-bottom: 1rem; }

.novel-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.novel-author { color: var(--text-secondary); font-size: 1rem; }
.novel-meta { color: var(--text-secondary); font-size: 0.9rem; margin-top: 0.3rem; }

.btn-continue {
    display: inline-block;
    margin-top: 1.5rem;
    padding: 0.7rem 2rem;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: opacity 0.2s;
}

.btn-continue:hover { opacity: 0.85; }

/* === 章節目錄 === */
.section-title {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    letter-spacing: 0.1em;
}

.chapter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.chapter-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.chapter-item:hover { background: var(--hover); }

.chapter-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.chapter-title { font-size: 0.95rem; }

/* === 閱讀頁面 === */
.reader-page .container { max-width: 100%; padding: 0; }

.reader-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.2rem;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.nav-back {
    color: var(--accent);
    font-size: 0.9rem;
    white-space: nowrap;
}

.nav-title {
    flex: 1;
    text-align: center;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 1rem;
    font-size: 0.85rem;
}

.nav-settings {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0.2rem;
}

/* === 設定面板 === */
.settings-panel {
    position: fixed;
    top: 44px;
    right: 1rem;
    z-index: 200;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.2rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: all 0.2s;
    min-width: 220px;
}

.settings-panel.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.settings-group {
    margin-bottom: 1rem;
}

.settings-group:last-child { margin-bottom: 0; }

.settings-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-size {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: background 0.15s;
}

.btn-size:hover { background: var(--hover); }

#fontSizeDisplay {
    width: 30px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-theme {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--bg);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-theme.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.btn-theme:hover { transform: scale(1.1); }

/* === 正文 === */
.reader-content {
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
    font-size: 18px;
}

.chapter-header {
    text-align: center;
    padding: 1.5rem 0 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.chapter-header h1 {
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.5;
}

.chapter-body {
    text-align: justify;
    letter-spacing: 0.02em;
}

.chapter-body p {
    text-indent: 2em;
    margin-bottom: 0.8em;
    line-height: 1.9;
}

/* === 底部章節導航 === */
.chapter-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 700px;
    margin: 0 auto;
    padding: 1.5rem;
    border-top: 1px solid var(--border);
}

.chapter-nav a, .chapter-nav span {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.nav-prev, .nav-next {
    color: var(--accent);
}

.nav-prev:hover, .nav-next:hover {
    background: var(--hover);
}

.nav-toc {
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.nav-toc:hover { background: var(--hover); }

.disabled {
    color: var(--border);
    cursor: default;
}

/* === 章節側邊欄 === */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.sidebar-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background: var(--bg);
    border-right: 1px solid var(--border);
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

.sidebar-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    transition: background 0.15s;
}

.sidebar-close:hover {
    background: var(--hover);
}

.sidebar-chapters {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.sidebar-chapter-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.65rem 1.2rem;
    font-size: 0.88rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    transition: background 0.12s;
}

.sidebar-chapter-item:hover {
    background: var(--hover);
}

.sidebar-chapter-item.active {
    background: var(--hover);
    color: var(--accent);
    font-weight: 600;
}

.sidebar-ch-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-secondary);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.sidebar-chapter-item.active .sidebar-ch-num {
    background: var(--accent);
    color: #fff;
}

.sidebar-ch-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-chapter-item.read .sidebar-ch-num {
    background: var(--accent);
    color: #fff;
    font-size: 0.65rem;
}

.sidebar-chapter-item.read {
    color: var(--text-secondary);
}

/* === 進度條 === */
.progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--border);
    z-index: 100;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.3s;
}

/* === Footer === */
.site-footer {
    text-align: center;
    padding: 3rem 0 2rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
}

/* === 錯誤頁 === */
.error-page {
    text-align: center;
    padding-top: 5rem;
}

.error-page h1 { font-size: 2rem; margin-bottom: 1rem; }
.error-page p { color: var(--text-secondary); margin-bottom: 2rem; }

/* === 空狀態 === */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem;
    font-size: 1.1rem;
}

/* === RWD === */
@media (max-width: 640px) {
    .container { padding: 1rem; }
    .site-title { font-size: 2rem; }
    .novel-card { padding: 1rem 1.2rem; gap: 1rem; }
    .novel-card-icon { font-size: 2rem; }
    .novel-card-title { font-size: 1.2rem; }
    .reader-content { padding: 1.5rem 1rem 2.5rem; }
    .chapter-header h1 { font-size: 1.3rem; }
    .chapter-nav { padding: 1rem; }
    .chapter-nav a, .chapter-nav span { padding: 0.5rem 0.8rem; font-size: 0.85rem; }
}
