﻿/* ── CALiterary Reader — wwwroot/css/AuthorBooks/reader.css ─── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --reader-bg: #faf9f7;
    --reader-text: #2c2c2c;
    --reader-header-bg: #1a1a2e;
    --reader-header-fg: #f0f0f0;
    --reader-accent: #c0392b;
    --reader-header-h: 54px;
    --reader-font: Georgia, 'Times New Roman', serif;
}

html, body {
    height: 100%;
}

    body.reader-shell {
        background: var(--reader-bg);
        color: var(--reader-text);
        font-family: var(--reader-font);
        display: flex;
        flex-direction: column;
        height: 100vh;
        overflow: hidden;
    }

/* ── Header ─────────────────────────────────────────────────── */
.reader-header {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--reader-header-h);
    background: var(--reader-header-bg);
    color: var(--reader-header-fg);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

.reader-back {
    color: var(--reader-header-fg);
    text-decoration: none;
    font-size: .875rem;
    opacity: .75;
    white-space: nowrap;
    flex-shrink: 0;
}

    .reader-back:hover {
        opacity: 1;
    }

.reader-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.reader-title {
    font-size: 1rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-author {
    font-size: .75rem;
    opacity: .6;
}

/* ── Home shell ──────────────────────────────────────────────── */
.reader-main {
    margin-top: var(--reader-header-h);
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 0px;
    padding: 0px;
}

/* ── PDF viewer ──────────────────────────────────────────────── */
.viewer-pdf {
    flex: 1;
    display: flex;
}

.pdf-frame {
    flex: 1;
    width: 100%;
    height: calc(100vh - var(--reader-header-h));
    border: none;
}

/* ── EPUB viewer ─────────────────────────────────────────────── */
.viewer-epub {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#epub-viewport {
    flex: 1;
    overflow: hidden;
}

#epub-viewport iframe {
    width: 100% !important;
    height: 100% !important;
}

/* Rendition theme controls two-column layout; keep defensive iframe-body
   overrides to prevent embedded book styles from constraining width. */
#epub-viewport iframe body {
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.epub-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem 2rem;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.epub-btn {
    background: var(--reader-accent);
    color: #fff;
    border: none;
    padding: .45rem 1.4rem;
    border-radius: 4px;
    font-size: .95rem;
    cursor: pointer;
    transition: opacity .15s;
}

    .epub-btn:hover {
        opacity: .85;
    }

#epub-progress {
    font-size: .85rem;
    color: #666;
}

/* ── DOCX viewer ─────────────────────────────────────────────── */
.viewer-docx {
    flex: 1;
    overflow-y: auto;
    padding: 2.5rem 1rem;
}

.docx-body {
    max-width: 780px;
    margin: 0 auto;
    padding: 2.5rem 3rem;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 12px rgba(0,0,0,.08);
    font-size: 1.05rem;
    line-height: 1.85;
}

    .docx-body h1, .docx-body h2,
    .docx-body h3, .docx-body h4 {
        margin: 1.75rem 0 .75rem;
        line-height: 1.3;
    }

    .docx-body p {
        margin-bottom: 1.1rem;
    }

    .docx-body img {
        max-width: 100%;
        height: auto;
        margin: 1rem 0;
    }

    .docx-body table {
        width: 100%;
        border-collapse: collapse;
        margin: 1.5rem 0;
    }

    .docx-body td, .docx-body th {
        border: 1px solid #ddd;
        padding: .5rem .75rem;
    }

/* ── Shared states ───────────────────────────────────────────── */
.reader-loading {
    text-align: center;
    padding: 4rem 2rem;
    color: #999;
    font-style: italic;
    font-size: 1rem;
}

.reader-unsupported {
    text-align: center;
    padding: 4rem 2rem;
}

.reader-download-btn {
    display: inline-block;
    margin-top: 1rem;
    padding: .6rem 1.8rem;
    background: var(--reader-accent);
    color: #fff;
    border-radius: 4px;
    text-decoration: none;
}

.reader-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fdfdfd;
    border-bottom: 1px solid #ddd;
    padding: 8px 12px;
    height: 44px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    font-family: system-ui, sans-serif;
}

.toolbar-btn {
    background: #f1f3f4;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

    .toolbar-btn:hover {
        background: #e5e7e9;
    }

.toolbar-status {
    font-size: 14px;
    color: #2e7d32;
    font-weight: 600;
}

.reader-tools {
    display: flex;
    gap: .5rem;
    align-items: center;
    margin-left: auto;
}

.reader-header .toolbar-btn {
    background: #f1f3f4;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
}
