/* ---------------------------------------------------------------------------
   Linguistic Miracle reading pages: /read, /read/<surah>, /read/<surah>/<ayah>.
   They wear the main reader's clothes - its nav bar, its gold verse box, its
   commentary card - with Linguistic Miracle as the only commentary. Whatever
   reader.css already gets right (fonts, footnotes, Quill formatting) is left
   to reader.css; this file only adds what these pages have of their own.
   --------------------------------------------------------------------------- */

/* Full container width, the same as the nav bar above it and the reader
   itself - a narrower column here left the bar stranded over empty margins.
   Without .section's 8rem of air at the top, too. */
.lm-page {
    padding-top: var(--space-md);
    padding-bottom: 4rem;
}

.lm-kicker {
    font-family: var(--font-mono, monospace);
    font-size: 0.72rem;
    font-weight: 400;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-primary);
    margin: 0 0 0.75rem;
}

.lm-block {
    margin-bottom: 3rem;
}

/* --- Page header -------------------------------------------------------- */

.lm-hero {
    padding: 1.5rem 0 2rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 2.25rem;
}

.lm-hero h1 {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.15;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
}

.lm-hero-ar {
    font-family: 'Amiri', serif;
    color: var(--accent-primary);
    font-size: 0.8em;
    margin-left: 0.4rem;
    white-space: nowrap;
}

.lm-lede {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.7;
    max-width: 62ch;
    margin: 0;
}

.lm-lede a,
.lm-stats a {
    color: var(--accent-primary);
}

.lm-stats {
    margin: 1rem 0 0;
    font-family: var(--font-mono, monospace);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- The reader's nav bar, on these pages ------------------------------- */

.lm-nav-btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* The first and last verse: the arrow stays put, greyed out. */
.reader-nav .btn-icon.is-disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.3;
    pointer-events: none;
}

.reader-nav-center #current-ref {
    font-size: 0.95rem;
}

/* The go-to-verse picker, sitting where the reader's verse dropdown sits. */
.lm-picker {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.lm-picker .verse-select {
    max-width: 11rem;
    color-scheme: dark;
}

.lm-picker .lm-picker-surah {
    max-width: 13rem;
}

/* With scripts on, picking a verse navigates straight away. */
.js .lm-picker button {
    display: none;
}

/* --- The verse, in the reader's gold box -------------------------------- */

/* reader.css styles #verse-box plainly; the reader itself adds the gold
   inline. These pages have no script to do that, so it lives here. */
.lm-page #verse-box,
.lm-verse-box {
    text-align: center;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
    border: 1px solid rgba(212, 168, 83, 0.3);
    border-top: 2px solid rgba(212, 168, 83, 0.6);
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(212, 168, 83, 0.08);
}

.lm-page #verse-box p:last-child,
.lm-verse-box p:last-child {
    margin-bottom: 0;
}

/* --- Index: recently added ---------------------------------------------- */

.lm-recent {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 0.75rem;
}

.lm-recent-item {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 0.85rem;
    align-items: center;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    text-decoration: none;
    transition: border-color 150ms ease, background 150ms ease;
}

.lm-recent-item:hover {
    border-color: var(--border-active);
    background: var(--accent-glow);
}

.lm-recent-ref {
    grid-row: span 2;
    font-family: var(--font-mono, monospace);
    font-size: 0.95rem;
    color: var(--accent-primary);
}

.lm-recent-name {
    color: var(--text-primary);
}

.lm-recent-date {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* --- Index: surahs ------------------------------------------------------ */

.lm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
}

.lm-surah {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    text-decoration: none;
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}

.lm-surah:hover {
    border-color: var(--border-active);
    background: var(--accent-glow);
    transform: translateY(-1px);
}

.lm-surah-num {
    flex: none;
    width: 2.4rem;
    height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    font-family: var(--font-mono, monospace);
    font-size: 0.85rem;
    color: var(--accent-primary);
}

.lm-surah-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.lm-surah-name {
    color: var(--text-primary);
    font-weight: 600;
}

.lm-surah-meaning {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.lm-surah-count {
    margin-top: 0.3rem;
    font-family: var(--font-mono, monospace);
    font-size: 0.72rem;
    color: var(--text-muted);
}

.lm-surah-count.is-complete {
    color: var(--accent-primary);
}

.lm-surah-ar {
    flex: none;
    font-family: 'Amiri', serif;
    font-size: 1.35rem;
    color: var(--accent-primary);
}

/* --- Surah page: verse strip -------------------------------------------- */

/* One scrolling row that sticks to the top while you read, so any verse is
   a tap away even deep into a long surah. */
.lm-jump {
    position: sticky;
    /* clears the reader nav bar above it */
    top: 80px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow-x: auto;
    scrollbar-width: none;
    margin: 0 0 1rem;
    padding: 0.7rem 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-subtle);
}

.lm-jump::-webkit-scrollbar {
    height: 0;
}

.lm-jump-label {
    flex: none;
    margin-right: 0.4rem;
    font-family: var(--font-mono, monospace);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.lm-jump a {
    flex: none;
    min-width: 2rem;
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    text-align: center;
    font-family: var(--font-mono, monospace);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.lm-jump a:hover,
.lm-jump a.is-current {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-glow);
}

/* --- Surah page: verses ------------------------------------------------- */

.lm-verse {
    padding: 1rem 0 2.5rem;
    /* clear the nav bar and the verse strip when jumping to a verse */
    scroll-margin-top: 8.5rem;
}

.lm-verse:target {
    animation: lm-arrive 2.4s ease-out;
}

@keyframes lm-arrive {
    from { background: var(--accent-glow); }
    to { background: transparent; }
}

.lm-verse-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.1rem;
}

.lm-verse-num {
    font-family: var(--font-mono, monospace);
    font-size: 0.8rem;
    color: var(--accent-primary);
    text-decoration: none;
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    padding: 0.15rem 0.65rem;
}

.lm-verse-open {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
}

.lm-verse-open:hover {
    color: var(--accent-primary);
}

.lm-verse-ar {
    font-family: 'Amiri', serif;
    font-size: 1.8rem;
    line-height: 2;
    direction: rtl;
    color: #ffffff;
    word-spacing: 0.1em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin: 0 0 1rem;
}

.lm-verse-en {
    font-family: 'Crimson Pro', serif;
    font-size: 1.2rem;
    font-style: italic;
    color: rgba(212, 168, 83, 0.85);
    line-height: 1.6;
    margin: 0;
}

/* The commentary: the reader's gold rule down the left, the Author Studio's
   heading scale. Size and family come from .tafsir-content in reader.css, so
   a verse reads identically here, in the reader and in the Studio. */
.lm-commentary {
    max-height: none;
    overflow: visible;
    padding-left: 0.75rem;
    border-left: 2px solid var(--accent-primary);
    line-height: 1.8;
    color: var(--text-primary);
}

.lm-commentary h1 { font-family: var(--font-heading); font-size: 1.9rem; line-height: 1.25; margin: 1.4rem 0 0.6rem; color: var(--accent-primary); }
.lm-commentary h2 { font-family: var(--font-heading); font-size: 1.55rem; line-height: 1.3; margin: 1.3rem 0 0.5rem; color: var(--accent-primary); }
.lm-commentary h3 { font-family: var(--font-heading); font-size: 1.3rem; line-height: 1.35; margin: 1.15rem 0 0.45rem; }
.lm-commentary h4 { font-size: 1.05rem; margin: 1rem 0 0.4rem; text-transform: uppercase; letter-spacing: 0.06em; }
.lm-commentary p { margin: 0 0 0.9rem; }
.lm-commentary img { max-width: 100%; height: auto; border-radius: 4px; }
.lm-commentary blockquote {
    border-left: 3px solid var(--accent-muted);
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: var(--text-secondary);
}

/* --- Surah page: previous / next ---------------------------------------- */

.lm-pager {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 2.5rem;
}

.lm-pager-link {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    transition: border-color 150ms ease, background 150ms ease;
}

.lm-pager-link span {
    font-family: var(--font-mono, monospace);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.lm-pager-link:hover {
    border-color: var(--border-active);
    background: var(--accent-glow);
}

.lm-pager-next {
    margin-left: auto;
    text-align: right;
}

@media (max-width: 640px) {
    .lm-hero h1 { font-size: 1.9rem; }
    .lm-hero-ar { display: block; margin: 0.3rem 0 0; }
    .lm-surah-ar { font-size: 1.15rem; }
    .lm-verse { padding: 0.75rem 0 1.75rem; }
}

.lm-empty {
    padding: 1.25rem 1.4rem;
    border: 1px dashed var(--border-subtle);
    border-radius: 10px;
    color: var(--text-secondary);
}

.lm-empty p {
    margin: 0 0 0.5rem;
}

.lm-empty p:last-child {
    margin-bottom: 0;
}

.lm-empty a {
    color: var(--accent-primary);
}

.lm-share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    padding: 1.5rem 0 0.5rem;
}

.lm-share-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--accent-primary);
    border-radius: 999px;
    background: transparent;
    color: var(--accent-primary);
    font-family: inherit;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
}

.lm-share-btn:hover {
    background: var(--accent-glow);
}

.lm-share-btn.is-done {
    background: var(--accent-primary);
    color: #10131a;
}

.lm-share-link {
    margin-left: 0.25rem;
    font-size: 0.88rem;
    color: var(--text-muted);
    text-decoration: none;
}

.lm-share-link:hover {
    color: var(--accent-primary);
}

/* --- Small screens ------------------------------------------------------ */

@media (max-width: 768px) {
    /* The nav bar wraps here, so its height is no longer fixed: pin the verse
       strip to the page instead of to a guess at how tall the bar is. */
    .lm-jump {
        position: static;
    }

    .lm-verse {
        scroll-margin-top: 1rem;
    }

    .lm-nav-btn {
        padding: 0.4rem 0.6rem !important;
        font-size: 0.75rem !important;
    }

    .reader-nav-center #current-ref {
        font-size: 0.8rem !important;
    }

    .lm-picker {
        gap: 0.3rem;
    }

    .lm-picker .verse-select,
    .lm-picker .lm-picker-surah {
        max-width: 40vw;
        font-size: 0.75rem;
        padding: 0.3rem 1.6rem 0.3rem 0.5rem;
    }

    .lm-page #verse-box,
    .lm-verse-box {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .lm-verse-ar {
        font-size: 1.4rem;
        line-height: 1.8;
        margin-bottom: 0.75rem;
    }

    .lm-verse-en {
        font-size: 1rem;
    }
}

/* Same on the reading pages: a line written in Arabic reads right-to-left. */
.lm-commentary p,
.lm-commentary li,
.lm-commentary h1,
.lm-commentary h2,
.lm-commentary h3,
.lm-commentary h4,
.lm-commentary blockquote {
    unicode-bidi: plaintext;
    text-align: start;
}

.lm-commentary .ql-align-left { text-align: left; }
.lm-commentary .ql-align-center { text-align: center; }
.lm-commentary .ql-align-right { text-align: right; }
.lm-commentary .ql-align-justify { text-align: justify; }
.lm-commentary .ql-direction-rtl { unicode-bidi: embed; }
