/* =============================================
   READER VIEW
   ============================================= */
.reader-page { display: flex; min-height: 100vh; }
.reader {
    margin-left: 240px;
    flex: 1;
    max-width: 900px;
    padding: 11rem 4rem 6rem;   /* large top padding clears the fixed controls bar */
}

/* ---------- Fixed TTS controls bar ---------- */
.reader__controls {
    position: fixed;
    top: 0;
    left: 240px;
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    background: rgba(18, 6, 30, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.reader__controls .btn--ghost { font-size: 0.8rem; padding: 0.5rem 1.2rem; }
.reader__controls .btn.is-disabled { opacity: 0.4; pointer-events: none; }

/* Row of the three buttons, centred */
.reader__buttons {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;             /* allow buttons to wrap if tight */
}

/* ---------- TTS status / standby message ---------- */
.tts-status {
    display: none;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 0.9rem;
    color: var(--accent-soft);
    text-align: center;
    white-space: normal;         /* allow wrapping to fit the area */
    max-width: 100%;             /* constrain to the controls width */
    width: 100%;
    padding: 0 0.25rem;
}
.tts-status.is-visible { display: inline-block; }
.tts-status .spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 0.5rem;
    border: 2px solid rgba(255,61,158,0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Header ---------- */
.reader__header { margin-bottom: 3rem; }
.reader__num {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--accent);
    font-size: 1rem;
    letter-spacing: 0.3em;
}
.reader__header h1 {
    font-family: var(--font-serif);
    font-size: 3rem;
    font-weight: 400;
    margin: 0.4rem 0 0.8rem;
}
.reader__teaser { color: var(--text-muted); font-style: italic; font-size: 1.05rem; }

/* ---------- Body ---------- */
.reader__body { border-top: 1px solid var(--line); padding-top: 2rem; }
.chapter { margin-bottom: 3rem; }
.chapter__title {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 400;
    color: var(--accent-soft);
    margin-bottom: 1.2rem;
    letter-spacing: 0.03em;
}
.reader__body p {
    margin-bottom: 1.4rem;
    font-size: 1.12rem;
    color: var(--text);
    transition: background 0.3s, color 0.3s;
    border-radius: 6px;
    padding: 0.2rem 0.4rem;
}
.reader__body p.is-reading {
    background: rgba(255,61,158,0.1);
    color: var(--accent-soft);
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
}

/* ---------- Chapter reveal ---------- */
.chapter {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.chapter.is-visible { opacity: 1; transform: none; }

/* ---------- Sidebar footer (signout, visitors, copyright) ---------- */
.sidebar__footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    margin-top: 1rem;
}
.sidebar__signout {
    display: inline-block;
    padding: 0.45rem 1.4rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 40px;
    transition: all 0.3s;
    text-align: center;
}
.sidebar__signout:hover { color: var(--danger); border-color: var(--danger); }
.sidebar__visitors {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
}
.sidebar__visitors:hover { color: var(--accent-soft); }
.sidebar__copyright {
    margin-top: 0.4rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- Foot ---------- */
.reader__foot { margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--line); text-align: center; }
.reader__end {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
}

/* =============================================
   RESPONSIVE — Mobile / narrow screens
   ============================================= */
@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        width: 180px;
        height: 100vh;
        flex-direction: column;
        justify-content: space-between;
        padding: 1rem 0.8rem;
        border-right: 1px solid var(--line);
        overflow-y: auto;
    }
    .sidebar__brand {
        font-size: 1rem;
        margin-bottom: 1rem;
        text-align: center;
        white-space: normal;
    }
    .sidebar__nav {
        flex-direction: column;
        gap: 0.3rem;
        flex: 1;
    }
    .sidebar__link {
        white-space: nowrap;
        flex-wrap: nowrap;
        font-size: 0.8rem;
        padding: 0.5rem 0.3rem;
    }
    .sidebar__num { margin-right: 0.3rem; }
    .sidebar__footer { margin-top: 0.4rem; }

    /* Reader content offset by the fixed sidebar */
    .reader {
        margin-left: 180px;
        padding: 13rem 1.25rem 4rem;   /* extra top padding clears the fixed controls */
    }

    /* Controls fixed, centred, stacked */
    .reader__controls {
        position: fixed;
        top: 0;
        left: 180px;
        right: 0;
        align-items: center;
        text-align: center;
    }
    .reader__controls .btn--ghost { width: auto; }
    .reader__header h1 { font-size: 2.2rem; }
}
