/* ==========================================================================
   المصحف الشريف - الطراز التراثي المذهب المستوحى من مجمع الملك فهد
   ========================================================================== */

:root {
  --bg-paper: #FBF7EE;
  --bg-paper-dark: #F5EEDC;
  --text-ayah: #14221C;
  --gold-accent: #C5A059;
  --gold-deep: #9A7730;
  --green-emerald: #164032;
  --green-border: #1F4D3E;
  --ayah-num-color: #A37A2C;
  --frame-shadow: rgba(80, 50, 10, 0.08);
}

/* الوضع الليلي المريح للعينين مع الحفاظ على فخامة التذهيب */
body.dark {
  --bg-paper: #18191A;
  --bg-paper-dark: #121314;
  --text-ayah: #EBE7DD;
  --gold-accent: #D4AF37;
  --gold-deep: #E6C665;
  --green-emerald: #234E3E;
  --green-border: #2D634E;
  --ayah-num-color: #E2BC55;
  --frame-shadow: rgba(0, 0, 0, 0.5);
}

body {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #EFE8D8;
  color: var(--text-ayah);
  user-select: text;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark {
  background-color: #0E0F10;
}

/* خط القرآن الكريم المصحفي */
.font-quran {
  font-family: 'Amiri Quran', 'Amiri', serif;
  font-feature-settings: "cv01", "cv02", "ss01";
}

.font-amiri {
  font-family: 'Amiri', serif;
}

/* شريط التنقل العلوي */
.top-nav {
  background: #F7F1E1;
  border-bottom: 2px solid var(--gold-accent);
}

body.dark .top-nav {
  background: #1B1C1E;
  border-bottom-color: #8C6F2A;
}

.nav-btn {
  background: rgba(197, 160, 89, 0.15);
  color: #1F3F34;
  border: 1px solid rgba(197, 160, 89, 0.35);
  transition: all 0.2s ease;
}

body.dark .nav-btn {
  background: rgba(212, 175, 55, 0.1);
  color: #F0E3C2;
  border-color: rgba(212, 175, 55, 0.3);
}

.nav-btn:hover {
  background: rgba(197, 160, 89, 0.28);
}

/* ==========================================================================
   ورقة المصحف الشريف والإطار الذهبي المحيط
   ========================================================================== */

.mushaf-sheet {
  background-color: var(--bg-paper);
  background-image: radial-gradient(#d6c9af 0.75px, transparent 0.75px), radial-gradient(#d6c9af 0.75px, var(--bg-paper) 0.75px);
  background-size: 30px 30px;
  background-position: 0 0, 15px 15px;
  border-radius: 12px;
  box-shadow: 0 10px 30px var(--frame-shadow), 0 1px 3px rgba(0,0,0,0.06);
  border: 4px solid #DFCEAA;
  padding: 8px;
}

body.dark .mushaf-sheet {
  background-image: radial-gradient(#2c2d30 0.75px, transparent 0.75px), radial-gradient(#2c2d30 0.75px, var(--bg-paper) 0.75px);
  border-color: #383120;
}

.mushaf-inner-frame {
  position: relative;
  border: 2px solid var(--gold-accent);
  outline: 1px solid #164032;
  outline-offset: 4px;
  border-radius: 6px;
  background: var(--bg-paper);
  min-height: 520px;
}

body.dark .mushaf-inner-frame {
  outline-color: #635022;
}

/* زخارف أركان الإطار الإسلامي */
.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.corner::before,
.corner::after {
  content: '';
  position: absolute;
  background-color: var(--gold-accent);
}

.corner-tl { top: 2px; right: 2px; }
.corner-tl::before { top: 0; right: 0; width: 14px; height: 3px; }
.corner-tl::after { top: 0; right: 0; width: 3px; height: 14px; }

.corner-tr { top: 2px; left: 2px; }
.corner-tr::before { top: 0; left: 0; width: 14px; height: 3px; }
.corner-tr::after { top: 0; left: 0; width: 3px; height: 14px; }

.corner-bl { bottom: 2px; right: 2px; }
.corner-bl::before { bottom: 0; right: 0; width: 14px; height: 3px; }
.corner-bl::after { bottom: 0; right: 0; width: 3px; height: 14px; }

.corner-br { bottom: 2px; left: 2px; }
.corner-br::before { bottom: 0; left: 0; width: 14px; height: 3px; }
.corner-br::after { bottom: 0; left: 0; width: 3px; height: 14px; }

/* ==========================================================================
   ترويسة السورة الشريفة (الزخرفة الإسلامية الملكية)
   ========================================================================== */

.surah-header-cartouche {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1rem 0;
}

.cartouche-frame {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #164032 0%, #1e5241 50%, #164032 100%);
  border: 3px solid var(--gold-accent);
  border-radius: 8px;
  padding: 6px 24px;
  box-shadow: 0 4px 12px rgba(22, 64, 50, 0.25), inset 0 0 10px rgba(0,0,0,0.3);
  position: relative;
  min-width: 220px;
}

body.dark .cartouche-frame {
  background: linear-gradient(135deg, #0f241c 0%, #16362a 50%, #0f241c 100%);
  border-color: #d4af37;
}

.cartouche-title {
  color: #F8F3E6;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  letter-spacing: 0.5px;
}

.cartouche-deco {
  display: inline-block;
  width: 14px;
  height: 14px;
  background-color: var(--gold-accent);
  transform: rotate(45deg);
  margin: 0 8px;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

/* ==========================================================================
   علامة ونجم نهاية الآية القرآنية المرقمة (Ayah End Marker)
   ========================================================================== */

.ayah-span {
  position: relative;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 3px;
  transition: background-color 0.2s ease;
  word-spacing: 2px;
}

.ayah-span:hover {
  background-color: rgba(197, 160, 89, 0.18);
}

.ayah-span.active-recitation {
  background-color: rgba(22, 64, 50, 0.15);
  outline: 1px dashed var(--gold-accent);
}

body.dark .ayah-span.active-recitation {
  background-color: rgba(212, 175, 55, 0.2);
}

.ayah-span.is-bookmarked {
  border-bottom: 2px solid #C5A059;
}

.ayah-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 4px;
  font-family: 'Amiri', serif;
  font-size: 0.72em;
  font-weight: bold;
  color: var(--ayah-num-color);
  user-select: none;
  vertical-align: middle;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="44" fill="none" stroke="%23C5A059" stroke-width="6"/><circle cx="50" cy="50" r="38" fill="none" stroke="%23164032" stroke-width="2"/><polygon points="50,2 62,38 98,50 62,62 50,98 38,62 2,50 38,38" fill="none" stroke="%23C5A059" stroke-width="2"/></svg>');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  width: 1.8em;
  height: 1.8em;
  padding-top: 1px;
}

/* مشغل الصوت الثابت */
.audio-dock {
  background-color: rgba(247, 241, 225, 0.94);
  border-color: rgba(197, 160, 89, 0.5);
}

body.dark .audio-dock {
  background-color: rgba(22, 23, 24, 0.94);
  border-color: rgba(212, 175, 55, 0.3);
}

.audio-seek-bar {
  accent-color: #164032;
  background: #DCD0BA;
}

body.dark .audio-seek-bar {
  accent-color: #C5A059;
  background: #3A3528;
}

/* شريط تصفية الفهرس */
.filter-tab {
  background: rgba(197, 160, 89, 0.15);
  color: #36443C;
  transition: all 0.2s ease;
}

.filter-tab.active {
  background: #164032;
  color: #FAF5E8;
}

body.dark .filter-tab {
  color: #DDD2BA;
}

body.dark .filter-tab.active {
  background: #C5A059;
  color: #161718;
}

/* منع ارتداد السحب في الهواتف */
html, body {
  overscroll-behavior-y: contain;
}

/* تنسيق شريط التمرير */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #C5A05988;
  border-radius: 3px;
}