/* Public article page chrome: theme-aware backdrop, reading progress and the
   reading rail (theme toggle, share, contents, back-to-top). */

.article-page {
    background: #f8fafc;
    min-height: 60vh;
    padding-bottom: 3rem;
    transition: background-color .2s ease;
}

.article-page[data-theme='dark'] {
    background: #0c131d;
}

@media (prefers-color-scheme: dark) {
    .article-page:not([data-theme='light']) {
        background: #0c131d;
    }
}

/* ---- Reading progress ---------------------------------------------------- */
.article-progress {
    position: fixed;
    inset: 0 0 auto;
    height: 3px;
    z-index: 1045;
    pointer-events: none;
}

.article-progress-fill {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #7c3aed);
    transition: width .1s linear;
}

/* ---- Reading rail -------------------------------------------------------- */
/* Hide by default; show only on very wide screens */
.article-rail {
    display: none;
}

/* ---- Wide screens: the rail floats beside the article column ------------- */
@media (min-width: 1600px) {
    .article-rail {
        display: flex;
        position: fixed;
        top: 50%;
        right: 1.25rem;
        transform: translateY(-50%);
        flex-direction: column;
        align-items: flex-start;
        gap: .75rem;
        max-width: none;
        margin: 0;
        padding: 0;
        z-index: 1025;
    }

    .article-rail-group {
        flex-direction: column;
    }

    .article-rail-toc {
        max-height: 42vh;
        overflow-y: auto;
        padding-left: 0;
        border-left: 0;
    }
}

.article-rail-group {
    display: flex;
    align-items: center;
    gap: .4rem;
}

.article-rail-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    background: rgba(255, 255, 255, .85);
    color: #0f172a;
    font-size: .95rem;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: color .18s ease, border-color .18s ease, background-color .18s ease, transform .18s ease;
}

.article-rail-btn:hover {
    color: #2563eb;
    border-color: #2563eb;
    background: #fff;
    transform: translateY(-1px);
}

.article-rail-btn.is-copied {
    color: #fff;
    border-color: #10b981;
    background: #10b981;
}

.article-rail-top {
    display: none;
}

.article-rail-top.is-visible {
    display: inline-flex;
}

.article-rail-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #64748b;
}

.article-rail-toc {
    display: flex;
    flex-direction: column;
    gap: .1rem;
    padding-left: .9rem;
    border-left: 1px solid #e2e8f0;
}

.article-rail-toc-link {
    max-width: 11rem;
    padding: .15rem 0;
    color: #64748b;
    font-size: .82rem;
    line-height: 1.35;
    text-decoration: none;
}

.article-rail-toc-link:hover,
.article-rail-toc-link.is-active {
    color: #2563eb;
}

.article-rail-toc-link.is-active {
    font-weight: 600;
}

/* ---- Theme toggle -------------------------------------------------------- */
.article-theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    border: 1px solid #cbd5e1;
    background: rgba(255, 255, 255, .8);
    color: #0f172a;
    border-radius: 999px;
    padding: .4rem .9rem;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}

/* ---- Dark theme ---------------------------------------------------------- */
.article-page[data-theme='dark'] .article-theme-toggle,
.article-page[data-theme='dark'] .article-rail-btn {
    background: rgba(255, 255, 255, .08);
    color: #e5e7eb;
    border-color: #334155;
}

.article-page[data-theme='dark'] .article-rail-label,
.article-page[data-theme='dark'] .article-rail-toc-link {
    color: #94a3b8;
}

.article-page[data-theme='dark'] .article-rail-toc {
    border-left-color: #1e293b;
}
