/* =========================================================
   Reader UX (Phase 1) — dark mode, font sizing, toolbar, share
   Pulls colour tokens from app.css; only overrides them when
   [data-theme="dark"] is set on <html>.
   ========================================================= */

:root {
    --reader-base-font: 1rem;
    --reader-font-scale: 1;
    --reader-toolbar-bg: rgba(255,255,255,0.95);
    --reader-toolbar-border: rgba(27, 59, 47, 0.12);
    --reader-toolbar-fg: var(--primary);
}

/* === Dark theme palette === */
html[data-theme="dark"] {
    --primary: #0f1b16;
    --primary-dark: #050b08;
    --primary-light: #1e3329;
    --accent: #E6C757;
    --accent-dark: #D4AF37;
    --accent-light: #F0D77A;
    --cream: #14211a;
    --text-dark: #E6E2D6;
    --text-muted: #9aa49d;
    --border: #29382F;
    --reader-toolbar-bg: rgba(20, 33, 26, 0.92);
    --reader-toolbar-border: rgba(212, 175, 55, 0.22);
    --reader-toolbar-fg: var(--accent);
}
html[data-theme="dark"] body { background: var(--cream); color: var(--text-dark); }
html[data-theme="dark"] .blog-card,
html[data-theme="dark"] .article-body,
html[data-theme="dark"] .content-card,
html[data-theme="dark"] .table {
    background: #18261e;
    color: var(--text-dark);
    border-color: var(--border);
}
html[data-theme="dark"] .blog-card h3 a,
html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5 {
    color: var(--accent-light);
}
html[data-theme="dark"] a { color: var(--accent-light); }
html[data-theme="dark"] a:hover { color: var(--accent); }
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .input-group .form-control {
    background: #1f3128;
    color: var(--text-dark);
    border-color: var(--border);
}
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus {
    background: #21372c;
    color: var(--text-dark);
}
html[data-theme="dark"] .alert-info { background: #1c2f3b; color: #c8e4f5; }
html[data-theme="dark"] .alert-success { background: #1d3623; color: #cbe7cf; }
html[data-theme="dark"] .alert-danger { background: #3a1c1c; color: #f3c9c9; }
html[data-theme="dark"] .alert-warning { background: #3a311b; color: #f1dfa6; }
html[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
html[data-theme="dark"] .article-body p { color: var(--text-dark); }
html[data-theme="dark"] .badge.bg-light { background: #2a3b32 !important; color: var(--accent-light) !important; }

/* === Font sizing === */
html[data-font="sm"] { --reader-font-scale: 0.92; }
html[data-font="md"] { --reader-font-scale: 1; }
html[data-font="lg"] { --reader-font-scale: 1.12; }

.article-body,
.article-body p,
.article-body li {
    font-size: calc(1.08rem * var(--reader-font-scale));
    line-height: 1.85;
}
.article-body h2 { font-size: calc(1.7rem * var(--reader-font-scale)); }
.article-body h3 { font-size: calc(1.35rem * var(--reader-font-scale)); }

/* === Reader Toolbar (floating, right side on desktop) === */
.reader-toolbar {
    position: sticky;
    top: 90px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    background: var(--reader-toolbar-bg);
    border: 1px solid var(--reader-toolbar-border);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    width: 52px;
    align-items: center;
}
.reader-toolbar button,
.reader-toolbar a {
    background: transparent;
    border: 0;
    border-radius: 999px;
    width: 36px;
    height: 36px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--reader-toolbar-fg);
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    transition: background 120ms ease, color 120ms ease;
}
.reader-toolbar button:hover,
.reader-toolbar a:hover {
    background: rgba(212, 175, 55, 0.18);
    color: var(--accent-dark);
}
.reader-toolbar button[aria-pressed="true"],
.reader-toolbar button.is-active {
    background: var(--accent);
    color: var(--primary-dark);
}
.reader-toolbar .toolbar-divider {
    width: 24px;
    height: 1px;
    background: var(--reader-toolbar-border);
    margin: 3px 0;
}

/* === Reactions bar === */
.reactions-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}
.reaction-btn {
    background: white;
    border: 1px solid var(--border);
    color: var(--primary);
    border-radius: 999px;
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all .15s ease;
}
html[data-theme="dark"] .reaction-btn { background: #1c2c24; color: var(--accent-light); }
.reaction-btn:hover { border-color: var(--accent); color: var(--accent-dark); }
.reaction-btn.is-active {
    background: var(--accent);
    color: var(--primary-dark);
    border-color: var(--accent-dark);
    font-weight: 700;
}
.reaction-btn .count {
    background: rgba(0,0,0,0.06);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.78rem;
    font-weight: 700;
}
.reaction-btn.is-active .count { background: rgba(0,0,0,0.18); }

/* === Share bar === */
.share-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 1.25rem 0;
    align-items: center;
}
.share-bar .share-label {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-right: 6px;
}
.share-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--cream);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 0;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease;
}
.share-btn:hover { background: var(--accent); color: var(--primary-dark); transform: translateY(-2px); }
.share-btn.copy.copied { background: var(--success); color: white; }

/* === TTS player === */
.tts-player {
    display: none;
    align-items: center;
    gap: 10px;
    background: var(--primary);
    color: var(--cream);
    padding: 0.6rem 1rem;
    border-radius: 999px;
    margin: 1rem 0;
}
.tts-player.is-on { display: inline-flex; }
.tts-player button {
    background: var(--accent);
    color: var(--primary-dark);
    border: 0;
    border-radius: 999px;
    width: 30px;
    height: 30px;
    font-weight: 700;
    cursor: pointer;
}
.tts-player .tts-progress {
    height: 4px;
    background: rgba(255,255,255,0.18);
    flex: 1 1 120px;
    border-radius: 999px;
    overflow: hidden;
}
.tts-player .tts-progress > span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width .25s linear;
}

/* === Mobile: toolbar moves to top fixed pill === */
@media (max-width: 991px) {
    .reader-toolbar {
        flex-direction: row;
        position: fixed;
        bottom: 12px;
        right: 12px;
        top: auto;
        width: auto;
        border-radius: 999px;
    }
    .reader-toolbar .toolbar-divider {
        width: 1px;
        height: 24px;
        margin: 0 3px;
    }
}

/* === RTL prep (Phase 4) === */
html[dir="rtl"] .reader-toolbar { right: auto; left: 12px; }

/* =====================================================
   Phase 2 — Engagement (tag chips, comments)
   ===================================================== */
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    background: #f3eedb;
    border: 1px solid var(--border);
    color: var(--primary);
    font-size: 0.82rem;
    text-decoration: none;
    transition: all .15s ease;
}
.tag-chip:hover { background: var(--accent); color: var(--primary-dark); border-color: var(--accent-dark); }
html[data-theme="dark"] .tag-chip { background: #1e3329; color: var(--accent-light); border-color: var(--border); }
html[data-theme="dark"] .tag-chip:hover { background: var(--accent); color: var(--primary-dark); }

/* Tag landing hero */
.tag-hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--cream);
    padding: 3rem 0 2.5rem;
    text-align: center;
}
.tag-hero h1 { color: var(--cream); font-size: clamp(1.6rem, 4vw, 2.4rem); margin-bottom: .25rem; }
.tag-hero .tag-meta { color: rgba(248,245,238,0.75); font-size: 0.9rem; }
.tag-hero .tag-meta a { color: var(--accent); margin-left: 8px; }

/* Comments */
.comments-section .comments-list { margin-bottom: 1rem; }
.comment {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border);
}
.comment:last-child { border-bottom: 0; }
.comment-avatar img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent);
}
.comment-body { flex: 1; }
.comment-meta { font-size: 0.88rem; color: var(--primary); }
.comment-meta .text-muted { font-weight: 400; }
.comment-text { margin: 4px 0 6px; white-space: pre-wrap; color: var(--text-dark); }
html[data-theme="dark"] .comment-text { color: var(--text-dark); }

.comment-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.comment-actions button {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 999px;
    cursor: pointer;
}
.comment-actions button:hover { background: rgba(212, 175, 55, 0.15); color: var(--primary); }
.cmt-react-btn .count { font-weight: 700; margin-left: 2px; }
.cmt-react-btn.is-active { color: var(--accent-dark); }

.comment-children {
    margin-left: 18px;
    padding-left: 14px;
    border-left: 2px solid var(--border);
    margin-top: 8px;
}
.cmt-reply-slot:not(:empty) {
    margin-top: 10px;
    padding: 12px;
    background: rgba(212, 175, 55, 0.06);
    border-radius: 6px;
}

.comment-form textarea { resize: vertical; }

/* ===========================
   Phase 3 — Search & Discovery
   =========================== */
.search-suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    z-index: 1080;
    max-height: 420px;
    overflow-y: auto;
    text-align: left;
}
.search-suggestions[hidden] { display: none; }
.search-suggestions .group-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    padding: 8px 14px 4px;
}
.search-suggestions a {
    display: block;
    padding: 8px 14px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    border-top: 1px solid transparent;
}
.search-suggestions a:hover,
.search-suggestions a.is-active {
    background: rgba(212, 175, 55, 0.12);
    color: var(--primary);
}
.search-suggestions a .date {
    float: right;
    color: var(--text-muted);
    font-size: 12px;
}
.trending-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.trending-chip {
    display: inline-block;
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    transition: all .15s ease;
}
.trending-chip:hover {
    background: var(--primary);
    color: #111;
    border-color: var(--primary);
}


 
 