@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400;1,700&family=Readex+Pro:wght@300;400;500;600;700&display=swap');

:root {
  --font-sans: 'Readex Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Amiri', serif;
  
  --bg-page: #f9f8f4;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-subtle: #f3f0e8;
  --bg-header: rgba(249, 248, 244, 0.94);
  
  --text-primary: #1c2430;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  
  --border-color: #e5e0d3;
  --border-subtle: #eeebe3;
  
  --accent: #1e3a8a;
  --accent-light: #e0e7ff;
  --accent-hover: #172554;
  --gold: #b45309;
  --gold-light: #fef3c7;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --article-font-size: 1.25rem;
  --article-line-height: 2.1;
}

[data-theme="dark"] {
  --bg-page: #0d121c;
  --bg-surface: #151d2d;
  --bg-card: #151d2d;
  --bg-subtle: #1c273c;
  --bg-header: rgba(13, 18, 28, 0.94);
  
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  
  --border-color: #26334a;
  --border-subtle: #1e2a3d;
  
  --accent: #3b82f6;
  --accent-light: #1e293b;
  --accent-hover: #60a5fa;
  --gold: #f59e0b;
  --gold-light: #2c2214;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-family: var(--font-sans);
  direction: rtl;
  text-align: right;
  scroll-behavior: smooth;
  background-color: var(--bg-page);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}
body { min-height: 100vh; display: flex; flex-direction: column; line-height: 1.6; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }
.container-reading { max-width: 860px; margin: 0 auto; padding: 0 1.25rem; }

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}
.nav-wrapper { display: flex; align-items: center; justify-content: space-between; height: 4.75rem; }
.brand-area { display: flex; align-items: center; gap: 0.9rem; text-decoration: none; color: inherit; }
.brand-logo-badge {
  width: 2.85rem; height: 2.85rem; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), #111827);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: 1.5rem; font-weight: bold;
  border: 1.5px solid var(--gold); box-shadow: var(--shadow-sm);
}
.brand-text h1, .brand-text .title { font-size: 1.3rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.brand-text .subtitle { font-size: 0.76rem; color: var(--gold); font-weight: 600; margin-top: 2px; }

.nav-menu { display: flex; align-items: center; gap: 1.25rem; list-style: none; }
.nav-link {
  font-size: 0.92rem; font-weight: 500; color: var(--text-secondary);
  text-decoration: none; padding: 0.45rem 0.65rem; border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}
.nav-link:hover, .nav-link.active { color: var(--accent); background: var(--bg-subtle); }

.nav-actions { display: flex; align-items: center; gap: 0.65rem; }
.icon-btn {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  color: var(--text-secondary); width: 2.5rem; height: 2.5rem;
  border-radius: var(--radius-full); display: flex; align-items: center;
  justify-content: center; cursor: pointer; transition: all 0.2s ease; font-size: 1.05rem;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.mobile-menu-btn { display: none; }

.hero-section {
  padding: 3.5rem 0 2.5rem;
  background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--bg-page) 100%);
  border-bottom: 1px solid var(--border-subtle);
}

.hero-content-wrap {
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
}

.hero-main-col {
  text-align: center;
}

@media (min-width: 860px) {
  .hero-content-wrap {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    text-align: right;
    gap: 3.5rem;
  }
  .hero-main-col {
    flex: 1;
    text-align: right;
  }
  .hero-main-col .hero-desc {
    margin: 0 0 2rem 0;
  }
  .hero-main-col .hero-cta-btns {
    justify-content: flex-start !important;
  }
}

/* صورة الباحث في دائرة مذهبة على يسار أعلى الواجهة */
.hero-scholar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.scholar-avatar-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  padding: 4px;
  background: linear-gradient(135deg, #f59e0b, #d97706, #fbbf24, #b45309);
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.45), 0 8px 22px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.scholar-avatar-circle:hover {
  transform: scale(1.06);
  box-shadow: 0 0 35px rgba(245, 158, 11, 0.65), 0 12px 28px rgba(0, 0, 0, 0.35);
}

.scholar-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg-page);
  display: block;
}

.scholar-avatar-caption {
  text-align: center;
}

.scholar-avatar-name {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 0.15rem;
  white-space: nowrap;
}

.scholar-avatar-sub {
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 600;
  margin-top: 2px;
}
.hero-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--gold-light); color: var(--gold);
  padding: 0.35rem 1.1rem; border-radius: var(--radius-full);
  font-size: 0.85rem; font-weight: 600; margin-bottom: 1.25rem;
  border: 1px solid rgba(180, 83, 9, 0.2);
}
.hero-title {
  font-family: var(--font-serif); font-size: 2.6rem; font-weight: 700;
  color: var(--text-primary); line-height: 1.35; margin-bottom: 1rem;
}
.hero-desc {
  font-size: 1.15rem; color: var(--text-secondary); line-height: 1.8;
  max-width: 780px; margin: 0 auto 2rem;
}

.hero-stats {
  display: flex; justify-content: center; gap: 2.5rem; margin-top: 1.75rem;
  padding-top: 1.75rem; border-top: 1px dashed var(--border-color); flex-wrap: wrap;
}
.stat-item { text-align: center; }
.stat-num { font-size: 1.9rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.2rem; }

.section-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin: 3rem 0 1.5rem; padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border-color);
}
.section-title {
  font-family: var(--font-serif); font-size: 1.75rem; font-weight: 700;
  color: var(--text-primary); position: relative;
}
.section-title::after {
  content: ''; position: absolute; bottom: -0.85rem; right: 0;
  width: 60px; height: 3px; background: var(--gold); border-radius: 2px;
}
.section-link { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.95rem; }
.section-link:hover { text-decoration: underline; }

.category-pills { display: flex; gap: 0.6rem; overflow-x: auto; padding: 0.5rem 0 1.25rem; scrollbar-width: thin; }
.pill-btn {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  color: var(--text-secondary); padding: 0.45rem 1rem; border-radius: var(--radius-full);
  font-size: 0.88rem; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: all 0.2s ease; text-decoration: none;
}
.pill-btn:hover, .pill-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.posts-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.75rem; margin: 1.5rem 0 3rem;
}
.post-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); overflow: hidden; display: flex;
  flex-direction: column; text-decoration: none; color: inherit;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  box-shadow: var(--shadow-sm);
}
.post-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--accent); }

.card-img-wrapper { position: relative; width: 100%; height: 190px; background: var(--bg-subtle); overflow: hidden; }
.card-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.post-card:hover .card-img { transform: scale(1.04); }

.card-placeholder-img {
  width: 100%; height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--bg-subtle), var(--border-color));
  color: var(--gold); font-family: var(--font-serif); padding: 1rem; text-align: center;
}
.card-content { padding: 1.35rem; display: flex; flex-direction: column; flex-grow: 1; }
.card-meta { display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.card-category { background: var(--accent-light); color: var(--accent); padding: 0.2rem 0.65rem; border-radius: var(--radius-full); font-weight: 600; font-size: 0.78rem; }
.card-title {
  font-family: var(--font-serif); font-size: 1.25rem; font-weight: 700;
  color: var(--text-primary); line-height: 1.45; margin-bottom: 0.65rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-snippet {
  font-size: 0.92rem; color: var(--text-secondary); line-height: 1.7;
  margin-bottom: 1rem; display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden; flex-grow: 1;
}
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 0.85rem; border-top: 1px solid var(--border-subtle);
  font-size: 0.82rem; color: var(--text-muted);
}
.read-more-link { color: var(--accent); font-weight: 600; display: inline-flex; align-items: center; gap: 0.35rem; }

/* Reading Toolbar & Article Page */
.reading-toolbar {
  position: sticky; top: 4.75rem; z-index: 40;
  background: var(--bg-surface); border-bottom: 1px solid var(--border-color);
  padding: 0.65rem 0; margin-bottom: 2rem;
}
.toolbar-wrapper { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.65rem; }
.toolbar-tools { display: flex; align-items: center; gap: 0.5rem; }
.btn-tool {
  background: var(--bg-subtle); border: 1px solid var(--border-color);
  color: var(--text-primary); padding: 0.35rem 0.75rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 500; cursor: pointer; display: inline-flex;
  align-items: center; gap: 0.4rem; transition: all 0.2s ease;
}
.btn-tool:hover { background: var(--border-color); }

.article-header { margin: 1.5rem 0 2rem; border-bottom: 1px solid var(--border-color); padding-bottom: 1.5rem; }
.article-breadcrumb { display: flex; align-items: center; gap: 0.5rem; font-size: 0.88rem; color: var(--text-muted); margin-bottom: 0.85rem; }
.article-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.article-breadcrumb a:hover { color: var(--accent); }
.article-main-title {
  font-family: var(--font-serif); font-size: 2.25rem; font-weight: 700;
  color: var(--text-primary); line-height: 1.4; margin-bottom: 1.25rem;
}
.article-meta-bar { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; font-size: 0.9rem; color: var(--text-muted); }
.author-chip { display: inline-flex; align-items: center; gap: 0.6rem; font-weight: 600; color: var(--text-primary); }
.author-avatar-sm {
  width: 2.25rem; height: 2.25rem; border-radius: var(--radius-full);
  background: var(--accent); color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: bold; font-family: var(--font-serif);
}

.article-body {
  font-family: var(--font-serif);
  font-size: var(--article-font-size);
  line-height: var(--article-line-height);
  color: var(--text-primary);
}
.article-body.font-sans-mode { font-family: var(--font-sans); }
.article-body p { margin-bottom: 1.65rem; text-align: justify; }
.article-body h2, .article-body h3, .article-body h4 {
  font-family: var(--font-sans); color: var(--text-primary);
  margin-top: 2.25rem; margin-bottom: 1rem; line-height: 1.4;
}
.article-body h2 { font-size: 1.55rem; border-right: 4px solid var(--accent); padding-right: 0.75rem; }
.article-body h3 { font-size: 1.3rem; color: var(--gold); }
.article-body blockquote {
  margin: 1.85rem 0; padding: 1.15rem 1.5rem; background: var(--bg-subtle);
  border-right: 4px solid var(--gold); border-radius: var(--radius-sm);
  color: var(--text-secondary); font-style: italic;
}
.article-body img { max-width: 100%; height: auto; border-radius: var(--radius-md); margin: 1.5rem auto; display: block; box-shadow: var(--shadow-sm); }
.article-body iframe { max-width: 100%; border-radius: var(--radius-md); margin: 1.5rem auto; display: block; }
.article-body .media-container { margin: 1.75rem 0; text-align: center; }

#progress-bar { position: fixed; top: 0; right: 0; height: 3.5px; background: var(--gold); width: 0%; z-index: 100; transition: width 0.1s ease; }

.author-box {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 1.75rem; margin: 3rem 0 2rem;
  display: flex; gap: 1.25rem; align-items: center;
}
.author-box-avatar {
  width: 4.5rem; height: 4.5rem; border-radius: var(--radius-full);
  background: var(--accent); color: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 1.8rem; font-family: var(--font-serif); flex-shrink: 0;
}

.citation-box {
  background: var(--bg-subtle); border: 1px dashed var(--border-color);
  border-radius: var(--radius-md); padding: 1.25rem; margin: 2rem 0;
}
.citation-box-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.65rem; font-weight: 600; font-size: 0.88rem; }
.citation-text { font-family: monospace; font-size: 0.82rem; background: var(--bg-surface); padding: 0.75rem; border-radius: var(--radius-sm); direction: rtl; text-align: right; line-height: 1.6; border: 1px solid var(--border-color); }

.post-nav-box {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 2.5rem 0;
}
.post-nav-card {
  padding: 1rem 1.25rem; background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); text-decoration: none; color: inherit;
  transition: all 0.2s ease;
}
.post-nav-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.post-nav-label { font-size: 0.75rem; color: var(--gold); font-weight: 600; margin-bottom: 0.25rem; }
.post-nav-title { font-size: 0.92rem; font-weight: 600; color: var(--text-primary); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Modal Search */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.65);
  z-index: 100; display: none; align-items: flex-start; justify-content: center;
  padding-top: 10vh; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal-card {
  background: var(--bg-surface); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); width: 90%; max-width: 650px;
  box-shadow: var(--shadow-lg); overflow: hidden; max-height: 80vh;
  display: flex; flex-direction: column;
}
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 0.75rem; }
.modal-search-input { flex-grow: 1; border: none; background: transparent; font-size: 1.1rem; font-family: var(--font-sans); color: var(--text-primary); outline: none; }
.search-results-list { padding: 0.75rem; overflow-y: auto; flex-grow: 1; list-style: none; }
.search-result-item { padding: 0.75rem 1rem; border-radius: var(--radius-md); margin-bottom: 0.4rem; display: block; text-decoration: none; color: inherit; transition: background 0.15s ease; }
.search-result-item:hover { background: var(--bg-subtle); }
.search-result-title { font-weight: 600; color: var(--accent); margin-bottom: 0.25rem; }
.search-result-snippet { font-size: 0.82rem; color: var(--text-muted); }

.site-footer { margin-top: auto; background: var(--bg-surface); border-top: 1px solid var(--border-color); padding: 3rem 0 2rem; }
.footer-content { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1.5rem; }
.footer-links { display: flex; gap: 1.5rem; list-style: none; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; }
.footer-links a:hover { color: var(--accent); }

@media print {
  body { background: #fff !important; color: #000 !important; }
  .site-header, .site-footer, .reading-toolbar, .btn-tool, .modal-overlay, #progress-bar, .mobile-menu-btn, .post-nav-box { display: none !important; }
  .article-body { font-size: 12pt !important; line-height: 1.6 !important; }
  .container-reading { max-width: 100% !important; padding: 0 !important; }
}

@media (max-width: 768px) {
  .nav-menu { display: none; }
  .mobile-menu-btn { display: flex; }
  .hero-title { font-size: 1.85rem; }
  .article-main-title { font-size: 1.6rem; }
  .posts-grid { grid-template-columns: 1fr; }
  .post-nav-box { grid-template-columns: 1fr; }
  .mobile-nav { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; }
  .mobile-nav.open { display: block; }
  .mobile-nav-panel { position: absolute; top:0; right:0; width:75%; height:100%; background:var(--bg-surface); padding:2rem 1.5rem; display:flex; flex-direction:column; gap:1rem; }
}

/* ==========================================
   Library Window & Book Card Styling
   ========================================== */
.library-window {
  background: var(--bg-surface);
  border: 2px solid var(--gold);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  margin: 3.5rem auto;
  box-shadow: 0 10px 25px rgba(180, 83, 9, 0.08);
  position: relative;
}
.library-window-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--gold);
  color: #fff;
  padding: 0.4rem 1.25rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
}
.book-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.book-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--gold);
}
.book-cover-wrap {
  background: var(--bg-subtle);
  padding: 1.5rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
}
.book-cover-img {
  max-height: 240px;
  width: auto;
  border-radius: 6px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
  transition: transform 0.3s ease;
}
.book-card:hover .book-cover-img {
  transform: scale(1.04);
}
.btn-download-direct {
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: #fff !important;
  font-weight: 700;
  text-decoration: none;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(180, 83, 9, 0.25);
  font-size: 0.88rem;
}
.btn-download-direct:hover {
  background: linear-gradient(135deg, #92400e, var(--gold));
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(180, 83, 9, 0.35);
}

