/* Hadith Library — matches Masjid site theme */

html {
  font-size: 16px;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

body.hadith-page {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text-dark);
}

.hadith-shell {
  max-width: 900px;
  margin: 0 auto;
  min-height: calc(100vh - var(--nav-h, 60px));
}

.screen {
  display: none;
  flex-direction: column;
  min-height: calc(100vh - var(--nav-h, 60px));
  animation: hadith-fade-in .25s ease;
}
.screen.active { display: flex; }

@keyframes hadith-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Hero ── */
.hadith-hero {
  position: relative;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 55%, var(--primary-light) 100%);
  padding: 48px 24px 56px;
  overflow: hidden;
  text-align: center;
}
.hero-pattern {
  position: absolute;
  inset: 0;
  opacity: .08;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-inner { position: relative; z-index: 1; }
.hero-badge {
  display: inline-block;
  background: rgba(201, 168, 76, .25);
  border: 1px solid rgba(201, 168, 76, .45);
  color: var(--gold-light);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 14px;
}
.hero-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 700;
  color: #fff;
  margin-bottom: 10px;
  line-height: 1.2;
}
.hero-sub {
  color: rgba(255,255,255,.82);
  font-size: .95rem;
  max-width: 480px;
  margin: 0 auto 22px;
  line-height: 1.55;
}
.hero-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.hero-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--gold);
  color: var(--primary-dark);
  border: none;
  border-radius: var(--r-md);
  padding: 10px 20px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.hero-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.hero-btn-outline {
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1.5px solid rgba(255,255,255,.35);
  box-shadow: none;
}
.hero-btn-outline:hover { background: rgba(255,255,255,.2); }

/* ── Section head ── */
.section-head {
  padding: 28px 20px 8px;
  text-align: center;
}
.section-head h2 {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  color: var(--primary);
  margin-bottom: 4px;
}
.section-head p {
  font-size: .85rem;
  color: var(--text-mid);
}

/* ── Books grid ── */
.books-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 12px 16px 32px;
}
@media (min-width: 600px) {
  .books-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 16px 24px 40px; }
}

.book-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 16px 18px;
  cursor: pointer;
  text-align: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  animation: book-in .4s ease both;
  font-family: inherit;
  width: 100%;
}
@keyframes book-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.book-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--book-grad, linear-gradient(90deg, var(--primary), var(--gold)));
}
.book-card-glow {
  position: absolute;
  top: -40px; right: -40px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--book-grad, var(--primary));
  opacity: .06;
  pointer-events: none;
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--gold);
}
.book-icon { font-size: 2rem; margin-bottom: 8px; }
.book-arabic {
  font-family: 'Amiri', serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.5;
  margin-bottom: 8px;
}
.book-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 0 auto 10px;
  width: 50%;
}
.book-english {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-mid);
  line-height: 1.35;
  margin-bottom: 12px;
}
.book-cta {
  font-size: .72rem;
  font-weight: 600;
  color: var(--gold-dark);
  letter-spacing: .02em;
}
.book-cta span { margin-left: 2px; }

/* ── Breadcrumb nav (replaces inner appbar) ── */
.hadith-bc-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
}
.bc-back {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--primary);
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: inherit;
  transition: background .15s;
}
.bc-back:hover { background: rgba(45,90,61,.08); }
.hadith-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
  font-size: .75rem;
}
.bc-tools {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.bc-tool {
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.bc-tool:hover { background: rgba(45,90,61,.08); }
.bc-tool[hidden] { display: none; }

.bc-sep { color: var(--text-light); margin: 0 2px; }
.bc-link {
  background: none;
  border: none;
  color: var(--primary-light);
  cursor: pointer;
  font-size: inherit;
  font-family: inherit;
  padding: 2px 4px;
  border-radius: 4px;
}
.bc-link:hover { color: var(--gold-dark); text-decoration: underline; }
.bc-current {
  color: var(--text-mid);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

/* ── Book page head (chapters screen) ── */
.book-page-head {
  padding: 20px 20px 4px;
  text-align: center;
}
.book-page-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--primary);
}
.book-page-arabic {
  font-family: 'Amiri', serif;
  font-size: 1.1rem;
  color: var(--text-mid);
  margin-top: 4px;
}

.bm-clear-link {
  display: block;
  margin: 12px 16px 0;
  padding: 0;
  background: none;
  border: none;
  color: #c62828;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: right;
  font-family: inherit;
}
.bm-clear-link:hover { text-decoration: underline; }

/* ── Stats bar ── */
.stats-bar {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  background: var(--card);
}
.stat-pill {
  flex: 1;
  text-align: center;
  background: rgba(45,90,61,.08);
  border: 1px solid rgba(45,90,61,.15);
  border-radius: var(--r-md);
  padding: 8px 12px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--primary);
}
.stat-pill-gold {
  background: rgba(201,168,76,.12);
  border-color: rgba(201,168,76,.3);
  color: var(--gold-dark);
}

/* ── Scroll body ── */
.scroll-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 24px;
}

/* ── Chapter list ── */
.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chapter-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 14px;
  cursor: pointer;
  text-align: right;
  direction: rtl;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .15s;
  font-family: inherit;
}
.chapter-item:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-md);
  transform: translateX(-3px);
}
.chapter-num {
  min-width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  direction: ltr;
}
.chapter-body { flex: 1; min-width: 0; }
.chapter-name {
  font-family: 'Noto Nastaliq Urdu', serif;
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--text-dark);
}
.chapter-sub {
  font-family: 'Amiri', serif;
  font-size: .85rem;
  color: var(--text-mid);
  margin-top: 2px;
  direction: rtl;
}
.chapter-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  direction: ltr;
}
.chapter-count {
  background: rgba(201,168,76,.15);
  color: var(--gold-dark);
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
}
.chapter-arrow {
  color: var(--text-light);
  font-size: 1.2rem;
}

/* ── Chapter header (hadith list) ── */
.chapter-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  padding: 18px 20px;
  color: #fff;
  text-align: center;
  flex-shrink: 0;
}
.ch-hdr-title {
  font-family: 'Noto Nastaliq Urdu', serif;
  font-size: 1.25rem;
  line-height: 1.7;
  direction: rtl;
}
.ch-hdr-arabic {
  font-family: 'Amiri', serif;
  font-size: 1rem;
  opacity: .85;
  margin-top: 4px;
  direction: rtl;
}
.ch-hdr-count {
  font-size: .75rem;
  opacity: .7;
  margin-top: 8px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ── Hadith list items ── */
.hadith-list { display: flex; flex-direction: column; gap: 8px; }
.h-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.h-list-item:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-sm);
}
.h-num-box {
  min-width: 40px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  font-weight: 700;
  font-size: .82rem;
  text-align: center;
  flex-shrink: 0;
}
.h-list-info { flex: 1; min-width: 0; }
.h-list-no {
  font-size: .72rem;
  font-weight: 600;
  color: var(--gold-dark);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.h-list-preview {
  font-family: 'Noto Nastaliq Urdu', serif;
  font-size: .95rem;
  line-height: 1.6;
  color: var(--text-dark);
  margin-top: 3px;
  direction: rtl;
  text-align: right;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.h-list-arrow {
  color: var(--text-light);
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ── Detail ── */
.detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  cursor: pointer;
  color: var(--primary);
  font-size: .82rem;
  font-weight: 600;
  font-family: inherit;
  transition: background .15s, border-color .15s;
}
.action-btn:hover {
  background: rgba(45,90,61,.06);
  border-color: var(--primary-light);
}
.action-ico { font-size: 1rem; }
.h-num-pill {
  margin-left: auto;
  background: var(--gold);
  color: var(--primary-dark);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: .78rem;
  font-weight: 700;
}

.hadith-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.h-meta-block {
  padding: 14px 18px;
  background: rgba(201,168,76,.06);
  border-bottom: 1px solid var(--border);
}
.h-meta-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gold-dark);
}
.h-meta-text {
  font-size: .88rem;
  color: var(--text-mid);
  margin-top: 4px;
  line-height: 1.5;
}
.h-meta-urdu {
  font-family: 'Noto Nastaliq Urdu', serif;
  font-size: 1rem;
  direction: rtl;
  text-align: right;
  color: var(--text-dark);
}
.h-lang-label {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--primary-light);
  margin-bottom: 8px;
}
.h-arabic-sec {
  background: rgba(45,90,61,.04);
  padding: 20px 18px;
  direction: rtl;
}
.h-arabic-text {
  font-family: 'Amiri', serif;
  font-size: 1.45rem;
  line-height: 2;
  color: var(--text-dark);
  text-align: right;
}
.h-sep, .h-sep2 { height: 1px; background: var(--border); }
.h-urdu-sec { padding: 18px; direction: rtl; }
.h-urdu-text {
  font-family: 'Noto Nastaliq Urdu', serif;
  font-size: 1.15rem;
  line-height: 2;
  color: var(--text-dark);
  text-align: right;
}
.h-en-sec { padding: 18px; direction: ltr; }
.h-en-text {
  font-size: .92rem;
  line-height: 1.75;
  color: var(--text-mid);
}

.info-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.info-chip {
  background: rgba(45,90,61,.08);
  border: 1px solid rgba(45,90,61,.2);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: .78rem;
  color: var(--primary);
  font-weight: 500;
}

/* ── Search ── */
.search-wrap { padding: 14px 16px; flex-shrink: 0; }
.search-inner { position: relative; }
.search-input {
  width: 100%;
  padding: 12px 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  font-size: .92rem;
  outline: none;
  background: var(--card);
  color: var(--text-dark);
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s;
}
.search-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(45,90,61,.1);
}
.s-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
  opacity: .5;
}
.s-clear {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-mid);
  padding: 4px;
}
.search-hint {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-mid);
}
.search-hint-icon { font-size: 2.5rem; opacity: .3; margin-bottom: 12px; }
.search-hint p { font-size: .88rem; }
.s-results-header {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-mid);
  padding: 4px 0 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.s-result-item {
  display: block;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: right;
  direction: rtl;
  transition: border-color .15s;
  font-family: inherit;
}
.s-result-item:hover { border-color: var(--gold); }
.s-r-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  direction: ltr;
}
.s-r-num {
  background: var(--primary);
  color: #fff;
  padding: 3px 10px;
  font-size: .72rem;
  font-weight: 700;
  border-radius: 10px;
}
.s-r-ch {
  font-size: .72rem;
  color: var(--text-mid);
  font-weight: 500;
  max-width: 60%;
  text-align: right;
  direction: rtl;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.s-r-text {
  font-family: 'Noto Nastaliq Urdu', serif;
  font-size: .95rem;
  line-height: 1.65;
  color: var(--text-dark);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.s-more {
  text-align: center;
  font-size: .78rem;
  color: var(--text-light);
  padding: 12px;
}

/* ── Bookmarks ── */
.bm-item {
  display: block;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: right;
  direction: rtl;
  transition: border-color .15s;
  font-family: inherit;
}
.bm-item:hover { border-color: var(--gold); }
.bm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  direction: ltr;
}
.bm-num {
  background: var(--gold);
  color: var(--primary-dark);
  padding: 3px 10px;
  font-size: .72rem;
  font-weight: 700;
  border-radius: 10px;
}
.bm-del {
  color: #e53935;
  font-size: .9rem;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}
.bm-del:hover { background: rgba(229,57,53,.1); }
.bm-book {
  font-size: .75rem;
  color: var(--primary-light);
  font-weight: 600;
  margin-bottom: 5px;
  direction: ltr;
  text-align: left;
}
.bm-text {
  font-family: 'Noto Nastaliq Urdu', serif;
  font-size: .95rem;
  line-height: 1.65;
  color: var(--text-dark);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Loading / empty / error ── */
.loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px 24px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(45,90,61,.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: hadith-spin .75s linear infinite;
}
@keyframes hadith-spin { to { transform: rotate(360deg); } }
.loading p { font-size: .92rem; color: var(--text-mid); font-weight: 500; }
.loading-hint { font-size: .78rem; color: var(--text-light); }

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 24px;
  text-align: center;
}
.empty-ico { font-size: 3rem; opacity: .25; }
.empty-t { font-size: 1rem; font-weight: 600; color: var(--text-mid); }
.empty-s { font-size: .82rem; color: var(--text-light); }

.error-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 24px;
  text-align: center;
}
.error-box .ico { font-size: 3rem; }
.error-box h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: #c62828;
}
.error-box p {
  font-size: .82rem;
  color: var(--text-mid);
  line-height: 1.6;
  max-width: 400px;
  word-break: break-word;
}
.retry-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  padding: 10px 28px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  margin-top: 4px;
  transition: background .15s;
}
.retry-btn:hover { background: var(--primary-light); }

/* ── Snackbar ── */
#snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--primary-dark);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--r-md);
  font-size: .85rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transition: transform .3s ease;
  z-index: 9999;
  white-space: nowrap;
  border-left: 3px solid var(--gold);
}
#snackbar.show { transform: translateX(-50%) translateY(0); }

/* ── Dark mode ── */
body.dark-mode.hadith-page .hadith-bc-wrap,
body.dark-mode.hadith-page .hadith-card,
body.dark-mode.hadith-page .book-card,
body.dark-mode.hadith-page .chapter-item,
body.dark-mode.hadith-page .h-list-item,
body.dark-mode.hadith-page .s-result-item,
body.dark-mode.hadith-page .bm-item {
  background: var(--card);
  border-color: var(--border);
}
body.dark-mode.hadith-page .hadith-bc-wrap { background: var(--bg); }
body.dark-mode.hadith-page .hero-btn-outline { border-color: rgba(255,255,255,.25); }
body.dark-mode.hadith-page .search-input { background: var(--card); border-color: var(--border); }
body.dark-mode.hadith-page .h-arabic-sec { background: rgba(45,90,61,.12); }
body.dark-mode.hadith-page .h-meta-block { background: rgba(201,168,76,.08); }
