/* ========================================
   Reading Page
   ======================================== */

.surah-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.surah-dropdown {
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  min-width: 200px;
}

.surah-title {
  text-align: center;
  font-size: 36px;
  line-height: 1.6;
  margin-bottom: 4px;
}

.surah-meta {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.bismillah {
  text-align: center;
  font-family: var(--arabic-font);
  font-size: var(--arabic-size);
  line-height: 2;
  padding: 24px;
  color: var(--text-primary);
}

/* Ayah container */
.ayah-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.ayah-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.ayah-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Word-by-word grid */
.wbw-container {
  display: flex;
  flex-wrap: wrap;
  direction: rtl;
  gap: 8px;
  justify-content: center;
}

.wbw-word {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s ease;
  min-width: 60px;
}

.wbw-word:hover {
  background: var(--bg-accent);
}

.wbw-word.active {
  background: var(--accent-light);
  outline: 2px solid var(--accent);
}

.wbw-arabic {
  font-family: var(--arabic-font);
  font-size: var(--arabic-size);
  line-height: 1.6;
  color: var(--text-primary);
}

.wbw-translit {
  font-size: 10px;
  color: var(--accent);
  text-align: center;
  direction: ltr;
  max-width: 120px;
  line-height: 1.3;
  font-style: italic;
  opacity: 0.85;
}

.wbw-meaning {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  direction: ltr;
  max-width: 120px;
  line-height: 1.3;
}


.translit-hidden .wbw-translit {
  display: none;
}

/* Word detail panel — mobile: slides up from bottom */
.word-detail-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-card);
  border-top: 2px solid var(--accent);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  z-index: 100;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  will-change: transform;
}

.word-detail-panel.open {
  transform: translateY(0);
}

.close-btn {
  position: absolute;
  top: 12px;
  inset-inline-end: 16px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
}

.close-btn:hover {
  color: var(--text-primary);
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-arabic {
  font-family: var(--arabic-font);
  font-size: 32px;
  color: var(--text-primary);
}

.detail-meaning {
  font-size: 16px;
  color: var(--text-secondary);
}

/* Audio button next to ayah number */
.ayah-block .audio-btn {
  width: 26px;
  height: 26px;
  font-size: 10px;
  margin-inline-start: 4px;
}

.detail-root {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--accent-light, var(--bg-highlight));
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.detail-root__label {
  font-weight: 500;
}

.detail-root__arabic {
  font-family: var(--arabic-font, 'Amiri', serif);
  font-size: 20px;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
  direction: rtl;
}

.detail-root__arabic:hover {
  text-decoration: underline;
}

.detail-root__stats {
  font-size: 12px;
  color: var(--text-muted);
}

.detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.detail-info-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-accent);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  margin-inline-start: auto;
  transition: all 0.15s ease;
}

.detail-info-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.detail-grammar {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

.detail-occurrences {
  margin-top: 16px;
}

.detail-occurrences h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.occ-verse {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}

.occ-ref {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.occ-text {
  font-family: var(--arabic-font);
  font-size: 18px;
  direction: rtl;
  line-height: 1.8;
}

.occ-translation {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Desktop: side panel with content shift */
@media (min-width: 768px) {
  .word-detail-panel {
    left: auto;
    width: 400px;
    top: 56px; /* below sticky nav */
    bottom: 0;
    max-height: none;
    border-top: none;
    border-inline-start: 2px solid var(--accent);
    transform: translateX(100%);
  }

  [dir="rtl"] .word-detail-panel {
    left: 0;
    right: auto;
    transform: translateX(-100%);
  }

  .word-detail-panel.open {
    transform: translateX(0);
  }

  /* Shift main content when panel is open */
  #read-app.panel-open {
    margin-inline-end: 400px;
    transition: margin 0.3s ease;
  }

  .wbw-word {
    padding: 10px 14px;
  }
}

@media (max-width: 640px) {
  .wbw-word {
    padding: 6px 8px;
    min-width: 50px;
  }

  .wbw-arabic {
    font-size: 20px;
  }

  .wbw-meaning {
    font-size: 10px;
  }
}

/* RTL support for reading page */
[dir="rtl"] .surah-meta,
[dir="rtl"] .surah-title {
  font-family: var(--urdu-font), var(--arabic-font), serif;
}

[dir="rtl"] .wbw-meaning {
  font-family: var(--urdu-font), serif;
  direction: rtl;
  line-height: 1.6;
}

[dir="rtl"] .detail-meaning,
[dir="rtl"] .detail-grammar,
[dir="rtl"] .occ-translation {
  font-family: var(--urdu-font), serif;
  direction: rtl;
  text-align: right;
  line-height: 2;
}

[dir="rtl"] .detail-header {
  flex-direction: row-reverse;
}

.audio-btn--detail {
  opacity: 1 !important;
  pointer-events: auto !important;
  display: inline-flex !important;
  flex-shrink: 0;
  margin-left: -8px;
}

[dir="rtl"] .surah-nav {
  flex-direction: row-reverse;
}
