/* ============================================
   Analyzing Islam
   Reader page — dedicated reading experience
   Black background, white text, serif display headers.
   ============================================ */

.reader-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ===== Table of Contents (sticky sidebar) ===== */
.reader-toc {
  position: sticky;
  top: 72px;
  align-self: start;
  height: calc(100vh - 90px);
  overflow-y: auto;
  padding: 32px 24px 32px 0;
  border-right: 1px solid var(--border);
  font-size: 13px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
}

.reader-toc::-webkit-scrollbar { width: 6px; }
.reader-toc::-webkit-scrollbar-thumb { background: var(--border-hover); }
.reader-toc::-webkit-scrollbar-track { background: transparent; }

.reader-toc-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  margin-bottom: 16px;
  font-weight: 600;
  padding: 0 8px;
}

.reader-toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.reader-toc li {
  margin: 0;
}

.reader-toc a {
  color: var(--text-muted);
  text-decoration: none;
  display: flex;
  gap: 10px;
  padding: 5px 10px;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  border-left: 2px solid transparent;
}

.reader-toc a:hover {
  color: var(--text);
  background: var(--panel);
  border-left-color: var(--border-hover);
  text-decoration: none;
}

.reader-toc a.active {
  color: var(--text);
  background: var(--panel);
  border-left-color: var(--accent);
}

.reader-toc .toc-num {
  flex: 0 0 24px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  color: var(--text-dim);
  text-align: right;
  font-weight: 600;
}

.reader-toc .toc-name {
  flex: 1;
  font-family: var(--serif);
  font-style: italic;
}

/* ===== Main reading column ===== */
.reader-main {
  padding: 40px 0 80px 48px;
  max-width: 720px;
}

.reader-hero {
  padding: 40px 0 56px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 56px;
}

.reader-meta {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 16px;
}

.reader-hero h1 {
  font-family: var(--serif);
  font-size: clamp(56px, 7vw, 84px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  margin: 0 0 24px;
  color: var(--text);
}

.reader-intro {
  font-size: 15px;
  color: var(--text-muted);
  margin: 0 0 28px;
  max-width: 560px;
  line-height: 1.65;
}

.reader-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===== Sūrah block ===== */
.surah {
  margin-bottom: 96px;
  scroll-margin-top: 80px;
}

.surah-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.surah-number {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 8px;
}

.surah h2 {
  font-family: var(--serif);
  font-size: clamp(36px, 4.5vw, 52px);
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.surah-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 500;
}

.surah-bismillah {
  font-family: var(--serif);
  font-style: italic;
  color: var(--accent);
  font-size: 17px;
  letter-spacing: 0.01em;
  margin-top: 18px;
  padding: 0;
}

/* ===== Verses ===== */
.verses {
  list-style: none;
  padding: 0;
  margin: 0;
}

.verses li {
  display: grid;
  grid-template-columns: 36px 1fr;
  column-gap: 20px;
  row-gap: 10px;
  padding: 10px 0;
  margin: 0;
  line-height: 1.8;
  scroll-margin-top: 80px;
  border: none;
  background: transparent;
}

.verses li:target {
  background: rgba(122, 162, 247, 0.08);
  padding-left: 12px;
  border-left: 2px solid var(--accent);
  margin-left: -14px;
}

.verse-number {
  grid-column: 1;
  grid-row: 1 / span 2;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  padding-top: 6px;
  text-align: right;
  user-select: none;
  letter-spacing: 0.04em;
}

.verse-text {
  grid-column: 2;
  grid-row: 1;
  color: var(--text);
  font-size: 16px;
  font-family: var(--sans);
  line-height: 1.8;
}

.verse-arabic {
  grid-column: 2;
  grid-row: 2;
  direction: rtl;
  text-align: right;
  font-family: "Amiri", "Scheherazade New", "Noto Naskh Arabic", serif;
  font-size: 21px;
  line-height: 2.1;
  color: var(--text-dim);
}

.reader-footer {
  margin-top: 80px;
  padding: 32px 0 0;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.7;
}

.reader-footer p { margin: 0; }

/* ==========================================================
   Hadith reader — different structure from the Quran.
   ========================================================== */

.hadith-book {
  margin-bottom: 96px;
  scroll-margin-top: 80px;
}

.hadith-book-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.hadith-book-number {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 8px;
}

.hadith-book h2 {
  font-family: var(--serif);
  font-size: clamp(32px, 4vw, 44px);
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text);
  line-height: 1.15;
}

.hadith-book-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 500;
}

.hadith-book-arabic {
  font-family: "Amiri", "Scheherazade New", "Noto Naskh Arabic", "Traditional Arabic", "Simplified Arabic", serif;
  font-size: 28px;
  color: var(--accent);
  margin: 6px 0 14px;
  line-height: 1.3;
  direction: rtl;
  unicode-bidi: isolate;
}

.hadith-book-body {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.hadith {
  border-top: 1px solid var(--border);
  padding-top: 24px;
  scroll-margin-top: 80px;
}

.hadith:first-child {
  border-top: none;
  padding-top: 0;
}

.hadith-header {
  margin-bottom: 12px;
}

.hadith-ref {
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hadith-body {
  color: var(--text);
  font-size: 16px;
  line-height: 1.8;
}

.hadith-narrator {
  font-family: var(--serif);
  font-style: italic;
  color: var(--accent);
  font-size: 15px;
  margin-bottom: 12px;
  letter-spacing: 0.01em;
}

.hadith-body p {
  margin: 0 0 12px;
  color: var(--text);
}

.hadith-body p:last-child {
  margin-bottom: 0;
}

/* Arabic text rendered under the English translation — muted, RTL, spacious. */
.hadith-body p.hadith-arabic {
  direction: rtl;
  text-align: right;
  font-family: "Amiri", "Scheherazade New", "Noto Naskh Arabic", serif;
  font-size: 19px;
  line-height: 2.1;
  color: var(--text-dim);
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.hadith:target {
  background: rgba(122, 162, 247, 0.05);
  margin-left: -16px;
  padding-left: 16px;
  border-left: 2px solid var(--accent);
}

/* ==========================================================
   PDF-embed reader — for sources where OCR quality makes
   native HTML rendering unusable (Abu Dawud, Tirmidhi, Nasa'i,
   Ibn Majah — all scanned Darussalam editions).
   ========================================================== */

.pdf-reader-layout {
  max-width: 1600px;
  margin: 0 auto;
  padding: 32px 32px 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 72px);
}

.pdf-reader-header {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
}

.pdf-reader-meta {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 10px;
}

.pdf-reader-header h1 {
  font-family: var(--serif);
  font-size: clamp(30px, 4vw, 44px);
  margin: 0;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.pdf-reader-header p {
  color: var(--text-muted);
  margin: 8px 0 0;
  font-size: 14px;
  max-width: 560px;
}

.pdf-reader-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.pdf-reader-frame {
  flex: 1;
  border: 1px solid var(--border);
  background: #2b2b2b;
  width: 100%;
  min-height: 1100px;
  margin-bottom: 32px;
}

.pdf-reader-note {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.pdf-reader-note strong {
  color: var(--text);
}

/* Mobile fallback: large button shown instead of the iframe. */
.pdf-reader-mobile-open {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  min-height: 260px;
  padding: 48px 24px;
  margin-bottom: 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}

.pdf-reader-mobile-open:hover,
.pdf-reader-mobile-open:active {
  background: #1a1a1a;
  border-color: var(--accent);
  text-decoration: none;
  color: var(--text);
}

.pdf-reader-mobile-open-icon {
  font-size: 48px;
  line-height: 1;
}

.pdf-reader-mobile-open-label {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}

.pdf-reader-mobile-open-hint {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 420px;
  line-height: 1.5;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .reader-layout {
    grid-template-columns: 1fr;
    padding: 0 20px;
  }
  .reader-toc {
    position: static;
    height: auto;
    max-height: 280px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    /* Horizontal padding here absorbs the negative margin-left used by
       .toc-section labels on external-source readers; without it, "INFANCY
       GOSPEL OF JAMES" and similar section labels would clip off the
       left edge on phones. */
    padding: 20px 16px;
    overflow-x: hidden;
  }
  .reader-main {
    padding: 24px 0 60px;
  }
  .reader-hero h1 {
    font-size: clamp(40px, 11vw, 64px);
  }
  .surah h2 {
    font-size: clamp(28px, 7vw, 40px);
  }
}
