/* ==========================================================================
   Reader — a post read page by page (inc/reader/template-tags.php)
   Loaded on a reader post only. It adds as little as possible: the page reads
   like an article (.entry-content.prose), fields are the site's .search-form,
   buttons are the site's .header-lang-btn, separators are main.css's
   #f0f0f0 lines. No boxes.
   ========================================================================== */

.reader {
    padding-bottom: 2.5rem;
}

.reader-intro + .reader {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #f0f0f0;
}

/* one row: details · «الملف الأصلي» · «تابع القراءة» */
.reader-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    margin-bottom: 1.25rem;
    font-size: 0.9375rem;
    color: #666;
}

.reader-meta:empty {
    display: none;
}

/* ---------- recording: the player itself, stuck under the header while reading ---------- */

.reader-media {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem 1rem;
    margin-bottom: 1.25rem;
    padding: 0.5rem 0;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}

.reader-media.is-video {
    position: static;
    border-bottom: 0;
}

.reader-player {
    flex: 1 1 18rem;
    width: 100%;
    height: 2.5rem;
}

.reader-media.is-video .flavor-media,
.reader-media .flavor-audio {
    flex-basis: 100%;
    margin: 0;
}

.reader-media.is-video .reader-player {
    height: 100%;
}

.reader-follow {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    color: #666;
    white-space: nowrap;
    cursor: pointer;
}

.reader-follow input {
    accent-color: #111;
}

.reader .header-lang-btn {
    padding: 0.25rem 0.625rem;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
}

.reader-resume:not([hidden]) {
    display: inline-flex;
    gap: 0.5rem;
}

/* ---------- the page counter: "n / total", n typed to go there ---------- */

.reader-jump {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: #666;
}

.reader-jump-input {
    width: 2.75em;
    padding: 0 0.125rem;
    font: inherit;
    color: #111;
    text-align: center;
    background: transparent;
    border: 0;
    border-bottom: 1px dashed #bbb;
    -moz-appearance: textfield;
    appearance: textfield;
}

.reader-jump-input::-webkit-outer-spin-button,
.reader-jump-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.reader-jump-input:hover,
.reader-jump-input:focus {
    border-bottom-color: #111;
    outline: none;
}

.reader-pagehead .reader-jump {
    margin-inline-start: auto;
}

/* ---------- a page ---------- */

.reader-page {
    scroll-margin-top: 5rem;
}

.reader-page + .reader-page {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid #f0f0f0;
}

.reader-pagehead {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: #666;
}

.reader-label {
    color: #111;
    font-weight: 700;
}

.reader-body {
    display: grid;
    gap: 2rem;
}

.reader-page.has-original .reader-body {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
}

.reader-text :is(h2, h3, h4, li[id]) {
    scroll-margin-top: 5rem;
}

.reader-text mark,
.reader-hit mark {
    background: #fff1b8;
    color: inherit;
    border-radius: 0.125rem;
    padding: 0 0.1em;
}

.reader-original {
    position: sticky;
    top: 1rem;
    margin: 0;
}

.reader-original img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid #eee;
    border-radius: 0.375rem;
}

.reader-original figcaption {
    margin-top: 0.375rem;
    font-size: 0.875rem;
    color: #666;
    text-align: center;
}

/* a moment in the recording */
.reader-time {
    display: inline-block;
    margin: 0 0.125rem;
    padding: 0 0.375rem;
    font: inherit;
    font-size: 0.75em;
    line-height: 1.6;
    direction: ltr;
    color: #666;
    background: none;
    border: 1px solid #ddd;
    border-radius: 0.375rem;
    cursor: pointer;
    vertical-align: 0.1em;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.reader-time:hover {
    color: #111;
    border-color: #111;
}

.reader-time.is-static {
    cursor: default;
}

.reader-time.is-current {
    color: #fff;
    background: #111;
    border-color: #111;
}

/* footnotes */
.reader-fnref a {
    padding-inline: 0.125rem;
    text-decoration: none;
}

.reader-footnotes {
    margin-top: 1.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f0f0f0;
    font-size: 0.9em;
    color: #444;
}

.reader-footnotes ol {
    padding-inline-start: 1.25rem;
}

.reader-fnback {
    text-decoration: none;
}

/* ---------- page navigation ---------- */

.reader-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.25rem;
    border-top: 1px solid #f0f0f0;
}

/* ---------- search results ---------- */

.reader-results-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.reader-count {
    font-size: 0.9375rem;
    font-weight: 400;
    color: #666;
}

.reader-hit {
    display: flex;
    gap: 1rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid #f0f0f0;
    line-height: 1.9;
}

.reader-hit:hover b {
    text-decoration: underline;
}

.reader-hit b {
    flex: none;
    min-width: 4rem;
}

.reader-back {
    margin-top: 1.25rem;
}

.reader-notice {
    margin: 0 0 1.25rem;
}

/* ---------- small screens ---------- */

@media (max-width: 720px) {
    .reader-page.has-original .reader-body {
        grid-template-columns: 1fr;
    }

    .reader-original {
        position: static;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reader-time {
        transition: none;
    }
}

/* ---------- print: the text only ---------- */

@media print {
    .site-header, .top-bar, .site-footer, .back-to-top,
    .reader-media, .reader-nav, .reader-resume, .reader-jump,
    .post-nav, .post-related, .entry-footer {
        display: none !important;
    }

    .reader-time {
        border: 0;
    }
}
