/* ========================================
   Theme Styles
======================================== */

/* Light Theme (Default) */
.reader-body[data-theme="light"] {
    --background: #F8F4E6;
    --card-bg: #FFFFFF;
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --border-color: #E0D5C7;
    background: #F8F4E6;
    color: #2C3E50;
}

/* Dark Theme */
.reader-body[data-theme="dark"] {
    --background: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
    background: #1a1a1a;
    color: #e0e0e0;
}

.reader-body[data-theme="dark"] .reader-header {
    background: #2d2d2d;
}

.reader-body[data-theme="dark"] .table-of-contents {
    background: #2d2d2d;
}

.reader-body[data-theme="dark"] .settings-panel {
    background: #2d2d2d !important;
}

.reader-body[data-theme="dark"] .setting-group {
    background: #3d3d3d !important;
}

.reader-body[data-theme="dark"] .chapter-body {
    background: #2d2d2d;
    color: #e0e0e0;
}

/* Sepia Theme */
.reader-body[data-theme="sepia"] {
    --background: #F4E8D0;
    --card-bg: #FFF9ED;
    --text-primary: #5C4033;
    --text-secondary: #8B7355;
    --border-color: #D6C4A1;
    background: #F4E8D0;
    color: #5C4033;
}

.reader-body[data-theme="sepia"] .reader-header {
    background: #5C4033;
}

.reader-body[data-theme="sepia"] .table-of-contents {
    background: #FFF9ED;
}

.reader-body[data-theme="sepia"] .settings-panel {
    background: #FFF9ED !important;
}

.reader-body[data-theme="sepia"] .setting-group {
    background: #FFFDF8 !important;
}

.reader-body[data-theme="sepia"] .chapter-body {
    background: #FFF9ED;
    color: #5C4033;
}

/* Dekoboko Modern Theme - 凸凹万博専用テーマ */
.reader-body[data-theme="dekoboko"] {
    --background: #FAF9F7;
    --card-bg: #FFFFFF;
    --text-primary: #2D3748;
    --text-secondary: #4A5568;
    --border-color: #E2E8F0;
    --primary-color: #4C51BF;  /* インディゴ（凸を表現） */
    --secondary-color: #ED8936;  /* コーラル（凹を表現） */
    --accent-color: #48BB78;  /* グリーン（調和） */
    background: linear-gradient(135deg, #FAF9F7 0%, #F7F3FF 100%);
    color: #2D3748;
}

.reader-body[data-theme="dekoboko"] .reader-header {
    background: linear-gradient(135deg, #4C51BF, #667EEA);
    box-shadow: 0 4px 20px rgba(76, 81, 191, 0.15);
}

.reader-body[data-theme="dekoboko"] .table-of-contents {
    background: #FFFFFF;
    border: 1px solid rgba(76, 81, 191, 0.1);
}

.reader-body[data-theme="dekoboko"] .settings-panel {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(76, 81, 191, 0.1);
}

.reader-body[data-theme="dekoboko"] .setting-group {
    background: rgba(247, 243, 255, 0.5) !important;
    border: 1px solid rgba(76, 81, 191, 0.05);
}

.reader-body[data-theme="dekoboko"] .chapter-body {
    background: #FFFFFF;
    color: #2D3748;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    padding: 2.5rem;
}

.reader-body[data-theme="dekoboko"] .chapter-title {
    color: #4C51BF;
    border-bottom: 3px solid linear-gradient(90deg, #4C51BF, #ED8936);
    position: relative;
}

.reader-body[data-theme="dekoboko"] .chapter-title::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #4C51BF 0%, #ED8936 50%, #48BB78 100%);
}

.reader-body[data-theme="dekoboko"] .chapter-intro {
    background: linear-gradient(135deg, rgba(76, 81, 191, 0.05), rgba(237, 137, 54, 0.05));
    border-left: 4px solid #4C51BF;
    padding: 1rem 1.5rem;
    border-radius: 5px;
}

.reader-body[data-theme="dekoboko"] a {
    color: #4C51BF;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.reader-body[data-theme="dekoboko"] a:hover {
    color: #ED8936;
    border-bottom-color: #ED8936;
}

.reader-body[data-theme="dekoboko"] .quick-nav {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(76, 81, 191, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.reader-body[data-theme="dekoboko"] .quick-nav-button:hover {
    background: linear-gradient(135deg, rgba(76, 81, 191, 0.1), rgba(237, 137, 54, 0.1));
    color: #4C51BF;
}

.reader-body[data-theme="dekoboko"] ::selection {
    background: rgba(76, 81, 191, 0.2);
    color: #2D3748;
}

/* Font Size Variations */
.reader-body[data-font-size="small"] .chapter-body {
    font-size: 0.95rem;
}

.reader-body[data-font-size="small"] .chapter-intro {
    font-size: 0.9rem;
}

.reader-body[data-font-size="medium"] .chapter-body {
    font-size: 1.125rem;
}

.reader-body[data-font-size="medium"] .chapter-intro {
    font-size: 1.05rem;
}

.reader-body[data-font-size="large"] .chapter-body {
    font-size: 1.25rem;
}

.reader-body[data-font-size="large"] .chapter-intro {
    font-size: 1.15rem;
}

.reader-body[data-font-size="xlarge"] .chapter-body {
    font-size: 1.5rem;
}

.reader-body[data-font-size="xlarge"] .chapter-intro {
    font-size: 1.35rem;
}

/* Line Height Variations */
.reader-body[data-line-height="narrow"] .chapter-body,
.reader-body[data-line-height="narrow"] .chapter-intro {
    line-height: 1.5;
}

.reader-body[data-line-height="normal"] .chapter-body,
.reader-body[data-line-height="normal"] .chapter-intro {
    line-height: 1.9;
}

.reader-body[data-line-height="wide"] .chapter-body,
.reader-body[data-line-height="wide"] .chapter-intro {
    line-height: 2.2;
}

/* Font Family Variations */
.reader-body[data-font-family="gothic"] .chapter-body,
.reader-body[data-font-family="gothic"] .chapter-intro {
    font-family: 'Noto Sans JP', sans-serif;
}

.reader-body[data-font-family="mincho"] .chapter-body,
.reader-body[data-font-family="mincho"] .chapter-intro {
    font-family: 'Noto Serif JP', serif;
}

/* ========================================
   Dark Theme
======================================== */

.reader-body[data-theme="dark"] {
    background: #1a1a1a;
    color: #e0e0e0;
}

.reader-body[data-theme="dark"]::before {
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.02) 2px,
            rgba(255, 255, 255, 0.02) 4px
        );
}

.reader-body[data-theme="dark"] .reader-header {
    background: #2C3E50;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.reader-body[data-theme="dark"] .book-title,
.reader-body[data-theme="dark"] .chapter-title {
    color: #e0e0e0;
}

.reader-body[data-theme="dark"] .current-chapter {
    color: #a0a0a0;
}

.reader-body[data-theme="dark"] .menu-toggle span,
.reader-body[data-theme="dark"] .settings-toggle {
    background: #e0e0e0;
    color: #e0e0e0;
}

.reader-body[data-theme="dark"] .back-link {
    color: #E74C3C;
    border-color: #E74C3C;
}

.reader-body[data-theme="dark"] .back-link:hover {
    background: #E74C3C;
    color: white;
}

.reader-body[data-theme="dark"] .progress-bar {
    background: #3a3a3a;
}

.reader-body[data-theme="dark"] .table-of-contents,
.reader-body[data-theme="dark"] .settings-panel {
    background: #2a2a2a;
    border-color: #3a3a3a;
}

.reader-body[data-theme="dark"] .toc-title,
.reader-body[data-theme="dark"] .settings-title {
    border-color: #3a3a3a;
    color: #e0e0e0;
}

.reader-body[data-theme="dark"] .toc-section h3 {
    color: #a0a0a0;
}

.reader-body[data-theme="dark"] .toc-item:hover {
    background: #3a3a3a;
}

.reader-body[data-theme="dark"] .toc-item.active {
    background: #34495E;
    border-color: #34495E;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

.reader-body[data-theme="dark"] .toc-item.active::after {
    background: #E74C3C;
}

.reader-body[data-theme="dark"] .toc-text {
    color: #e0e0e0;
}

.reader-body[data-theme="dark"] .toc-pages {
    color: #808080;
}

.reader-body[data-theme="dark"] .chapter-content {
    background: #2a2a2a;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    border-color: #3a3a3a;
}

.reader-body[data-theme="dark"] .chapter-body {
    color: #e0e0e0;
}

.reader-body[data-theme="dark"] .access-gate {
    background: #1a1a1a;
}

.reader-body[data-theme="dark"] .gate-content p {
    color: #a0a0a0;
}

.reader-body[data-theme="dark"] .access-method {
    background: #2a2a2a;
    border-color: #3a3a3a;
}

.reader-body[data-theme="dark"] .access-method:hover {
    border-color: #E74C3C;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.3);
}

.reader-body[data-theme="dark"] .access-method:hover::after {
    background: #E74C3C;
}

.reader-body[data-theme="dark"] .method-text {
    color: #e0e0e0;
}

.reader-body[data-theme="dark"] .chapter-footer {
    border-color: #3a3a3a;
}

.reader-body[data-theme="dark"] .font-size-btn,
.reader-body[data-theme="dark"] .line-height-btn,
.reader-body[data-theme="dark"] .theme-btn,
.reader-body[data-theme="dark"] .font-btn {
    background: #1a1a1a;
    border-color: #3a3a3a;
    color: #e0e0e0;
}

.reader-body[data-theme="dark"] .font-size-btn:hover,
.reader-body[data-theme="dark"] .line-height-btn:hover,
.reader-body[data-theme="dark"] .theme-btn:hover,
.reader-body[data-theme="dark"] .font-btn:hover {
    border-color: #6bb6ff;
}

.reader-body[data-theme="dark"] .font-size-btn.active,
.reader-body[data-theme="dark"] .line-height-btn.active,
.reader-body[data-theme="dark"] .theme-btn.active,
.reader-body[data-theme="dark"] .font-btn.active {
    background: #34495E;
    border-color: #34495E;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.3);
}

.reader-body[data-theme="dark"] .modal-content {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #E74C3C;
    box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.4);
}

.reader-body[data-theme="dark"] .modal-close {
    color: #a0a0a0;
}

.reader-body[data-theme="dark"] .modal-close:hover {
    background: #3a3a3a;
}

/* ダークテーマでの章末ポイント */
.reader-body[data-theme="dark"] .chapter-points-section {
    background: #2a2a2a;
    border-color: #3a3a3a;
}

.reader-body[data-theme="dark"] .chapter-points {
    color: #a0a0a0 !important;
}

.reader-body[data-theme="dark"] .chapter-points-section ul li {
    color: #d0d0d0;
}

/* ダークテーマでの部タイトル */
.reader-body[data-theme="dark"] .toc-item.part-header {
    background: #2a2a2a;
    border-left-color: #34495E;
    border-top-color: #3a3a3a;
    border-bottom-color: #3a3a3a;
}

.reader-body[data-theme="dark"] .toc-item.part-header:hover {
    background: #3a3a3a;
}

.reader-body[data-theme="dark"] .toc-item.part-header.active {
    background: #34495E;
}

/* ダークテーマでの章の導入文 */
.reader-body[data-theme="dark"] .chapter-intro {
    background: #2a2a2a;
    color: #b0b0b0;
    border-left-color: #E74C3C;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
}

/* ========================================
   Sepia Theme
======================================== */

.reader-body[data-theme="sepia"] {
    background: #F8F4E6;
}

.reader-body[data-theme="sepia"]::before {
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(139, 119, 71, 0.03) 2px,
            rgba(139, 119, 71, 0.03) 4px
        );
}

.reader-body[data-theme="sepia"] .reader-header {
    background: #8B7355;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.reader-body[data-theme="sepia"] .book-title {
    color: #FFF8DC;
}

.reader-body[data-theme="sepia"] .current-chapter {
    color: rgba(255, 248, 220, 0.8);
}

.reader-body[data-theme="sepia"] .menu-toggle span,
.reader-body[data-theme="sepia"] .settings-toggle {
    background: #FFF8DC;
    color: #FFF8DC;
}

.reader-body[data-theme="sepia"] .chapter-content {
    background: #FFF8DC;
    border-color: #D2B48C;
}

.reader-body[data-theme="sepia"] .chapter-body {
    color: #5D4E37;
}

.reader-body[data-theme="sepia"] .table-of-contents,
.reader-body[data-theme="sepia"] .settings-panel {
    background: #FFF8DC;
    border-color: #D2B48C;
}

.reader-body[data-theme="sepia"] .toc-title {
    background: #F8F4E6;
    border-color: #D2B48C;
}

.reader-body[data-theme="sepia"] .toc-item:hover {
    background: #F8F4E6;
    border-color: #D2B48C;
}

.reader-body[data-theme="sepia"] .toc-item.active {
    background: #8B7355;
    color: #FFF8DC;
    border-color: #8B7355;
}

.reader-body[data-theme="sepia"] .toc-item.active::after {
    background: #CD853F;
}

/* ========================================
   Print Styles
======================================== */

@media print {
    .reader-header,
    .table-of-contents,
    .settings-panel,
    .chapter-nav,
    .access-gate {
        display: none !important;
    }
    
    .reader-container {
        margin-top: 0;
    }
    
    .content-area {
        max-width: 100%;
        padding: 0;
    }
    
    .chapter-content {
        box-shadow: none;
        padding: 0;
    }
    
    .chapter-body {
        font-size: 11pt;
        line-height: 1.6;
    }
}