/**
 * Lunafitch Novel Theme - reader.css
 * Dedicated stylesheet for the Dual-Toolbar Immersive Reader Engine
 */

/* ==========================================================================
   1. Reading Progress Bar
   ========================================================================== */
.reader-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #d4af37, #fef08a);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.7);
    z-index: 1100;
    transition: width 0.1s ease;
}

/* ==========================================================================
   2. Sticky Top Navigation Bar
   ========================================================================== */
.reader-top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(9, 10, 16, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.reader-top-navbar.is-hidden {
    transform: translateY(-100%);
}

.reader-topbar-inner {
    max-width: var(--container-max);
    height: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.reader-btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    transition: all 0.2s;
    flex-shrink: 0;
}

.reader-btn-back:hover {
    color: var(--text-primary);
    border-color: var(--accent-gold);
}

.reader-title-block {
    text-align: center;
    flex: 1;
    min-width: 0;
    padding: 0 10px;
}

.reader-novel-name {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reader-chapter-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    line-height: 1.2;
}

.reader-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.reader-dropdown-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.reader-select-chapter {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 28px 6px 12px;
    cursor: pointer;
    max-width: 180px;
    outline: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reader-select-chapter:focus {
    border-color: var(--accent-gold);
}

.select-chevron {
    position: absolute;
    right: 10px;
    pointer-events: none;
    color: var(--text-muted);
}

.reader-btn-home {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.reader-btn-home:hover {
    color: var(--text-primary);
    border-color: var(--accent-gold);
}

/* ==========================================================================
   3. Reading Canvas Main Container
   ========================================================================== */
.reader-page-wrapper {
    padding-top: 72px;
    padding-bottom: 90px;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

.reader-container {
    max-width: var(--reader-max);
    margin: 0 auto;
    padding: 40px 24px 80px;
    border-radius: var(--radius-md);
    transition: background-color 0.3s, color 0.3s;
}

/* Fonts */
.reader-container.font-serif {
    font-family: var(--font-serif);
}

.reader-container.font-sans {
    font-family: var(--font-sans);
}

/* Themes */
/* 1. Warm Sepia */
body.theme-sepia {
    background-color: #1a1714 !important;
}
.reader-container.theme-sepia {
    background-color: #23201d;
    color: #e8dec8;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}
.theme-sepia .reader-top-navbar {
    background: rgba(26, 23, 20, 0.96);
}

/* 2. Cosmic Dark (Default) */
body.theme-dark {
    background-color: #090a10 !important;
}
.reader-container.theme-dark {
    background-color: #0e1019;
    color: #cbd5e1;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
}
.theme-dark .reader-top-navbar {
    background: rgba(9, 10, 16, 0.96);
}

/* 3. OLED True Black */
body.theme-oled {
    background-color: #000000 !important;
}
.reader-container.theme-oled {
    background-color: #050505;
    color: #d1d5db;
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.theme-oled .reader-top-navbar {
    background: rgba(0, 0, 0, 0.98);
}

/* 4. Soft White (Mode Terang) */
body.theme-light {
    background-color: #f1f0ea !important;
}
.reader-container.theme-light {
    background-color: #ffffff;
    color: #1f2937;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}
.theme-light .reader-top-navbar {
    background: rgba(255, 255, 255, 0.96);
    border-bottom-color: rgba(0, 0, 0, 0.1);
}
.theme-light .reader-chapter-title {
    color: #111827;
}
.theme-light .reader-btn-back,
.theme-light .reader-btn-home,
.theme-light .reader-select-chapter {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #374151;
}

/* Chapter Heading */
.chapter-content-header {
    margin-bottom: 36px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.theme-light .chapter-content-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

.chapter-series-badge a {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.chapter-heading {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 12px;
}

.chapter-meta-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    opacity: 0.7;
}

/* Narrative Body */
.chapter-body-text {
    font-size: 18px;
    line-height: 1.9;
    letter-spacing: 0.01em;
}

.chapter-body-text p {
    margin-bottom: 1.6em;
    text-align: justify;
    text-justify: inter-word;
}

/* End-of-Chapter Actions */
.chapter-end-nav {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-light .chapter-end-nav {
    border-top-color: rgba(0, 0, 0, 0.08);
}

.end-nav-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-nav-chapter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: inherit;
    transition: all 0.2s;
}

.btn-nav-chapter:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.btn-nav-chapter.primary {
    background: var(--accent-gold);
    color: #000;
    font-weight: 700;
    border-color: var(--accent-gold);
}

.btn-nav-chapter.primary:hover {
    background: var(--accent-gold-hover);
    transform: translateY(-2px);
}

.btn-nav-chapter.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==========================================================================
   4. Floating Action Toolbar (Bottom FAB)
   ========================================================================== */
.reader-floating-toolbar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.reader-floating-toolbar.is-hidden {
    transform: translate(-50%, 120px);
}

.reader-fab-dock {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(14, 16, 25, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
    padding: 6px 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7), 0 0 20px rgba(212, 175, 55, 0.15);
}

.fab-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.fab-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.fab-btn.primary {
    background: var(--accent-gold);
    color: #000;
}

.fab-btn.primary:hover {
    background: var(--accent-gold-hover);
    transform: scale(1.05);
}

.fab-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==========================================================================
   5. Settings Popover Panel
   ========================================================================== */
.reader-settings-popover {
    position: fixed;
    bottom: 84px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: 90%;
    max-width: 360px;
    background: rgba(14, 16, 25, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.reader-settings-popover.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.popover-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.popover-close-btn {
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}

.popover-section {
    margin-bottom: 18px;
}

.popover-label-row,
.popover-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.popover-val-badge {
    color: var(--accent-gold);
    font-weight: 700;
}

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

.theme-choice-btn {
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.theme-choice-btn.sepia { background: #23201d; color: #e8dec8; }
.theme-choice-btn.dark { background: #090a10; color: #cbd5e1; }
.theme-choice-btn.oled { background: #000000; color: #ffffff; }
.theme-choice-btn.light { background: #fbfaf8; color: #18181b; }

.theme-choice-btn.active {
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.4);
}

/* Font picker */
.font-picker-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.font-choice-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.font-choice-btn.active {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

/* Size controls */
.size-controls-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.size-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.font-slider {
    flex: 1;
    accent-color: var(--accent-gold);
}

/* Line Height */
.line-height-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.lh-choice-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.lh-choice-btn.active {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

/* ==========================================================================
   6. Table of Contents Drawer Modal
   ========================================================================== */
.reader-toc-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 100%;
    max-width: 380px;
    height: 100vh;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.8);
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.reader-toc-drawer.open {
    left: 0;
}

.toc-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.toc-header-title h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.toc-count {
    font-size: 11px;
    color: var(--accent-gold);
}

.toc-close-btn {
    font-size: 24px;
    color: var(--text-muted);
}

.toc-search-wrap {
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
}

.toc-search-wrap input {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.toc-search-wrap input:focus {
    border-color: var(--accent-gold);
}

.toc-chapter-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toc-item-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    transition: all 0.2s;
    text-decoration: none;
}

.toc-item-link:hover {
    border-color: var(--accent-gold);
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.toc-item-link.current {
    border-color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.12);
    color: var(--accent-gold);
    font-weight: 700;
}

.toc-item-num {
    font-weight: 700;
    color: var(--accent-gold);
    font-size: 11px;
}

.toc-item-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-active-badge {
    background: var(--accent-gold);
    color: #000;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 2px;
}

.reader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1040;
}

/* ==========================================================================
   7. Mobile Reader Overrides
   ========================================================================== */
@media (max-width: 600px) {
    .reader-btn-back .back-text {
        display: none;
    }
    .reader-topbar-inner {
        padding: 0 12px;
    }
    .reader-select-chapter {
        max-width: 120px;
    }
    .reader-container {
        padding: 24px 16px 60px;
    }
    .chapter-body-text {
        font-size: 16px;
    }
    .reader-floating-toolbar {
        bottom: 16px;
    }
}
