/* مدونة طالب علم — التصميم الحديث
   لتغيير الألوان: عدّل المتغيرات في :root فقط */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d2321;
  --muted: #66706c;
  --line: #e7e4dc;
  --accent: #0f5e4a;        /* اللون الأساسي (أخضر زيتي) */
  --accent-soft: #e5f0ec;
  --gold: #a8832f;
  --research: #2f4f8a;
  --letters: #8a4a2f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .04), 0 8px 24px rgba(20, 30, 25, .06);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --maxw: 1120px;
  --readw: 720px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111614; --surface: #171e1b; --text: #e8ece9; --muted: #9aa5a0;
    --line: #26302c; --accent: #5cc3a1; --accent-soft: #1b2b25; --gold: #d4b062;
    --research: #8fb0ea; --letters: #e2a283;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 17px; line-height: 1.85;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 4px; }
img { max-width: 100%; height: auto; display: block; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.skip { position: absolute; right: -9999px; }
.skip:focus { right: 12px; top: 12px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* الرأس */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-size: 22px; font-weight: 700;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 18px; font-weight: 700; }
.brand-text small { font-size: 12.5px; color: var(--muted); }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: var(--text); padding: 6px 12px; border-radius: 999px; font-size: 15px; font-weight: 500;
}
.nav a:hover { background: var(--accent-soft); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .nav a[aria-current="page"] { color: #0c1411; } }
.nav-search { display: inline-flex; align-items: center; gap: 6px; }
.nav-toggle { display: none; background: none; border: 0; padding: 10px; cursor: pointer; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--text); margin: 5px 0; border-radius: 2px; }
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav {
    display: none; position: absolute; inset-inline: 0; top: 68px; flex-direction: column; align-items: stretch;
    background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 16px 16px; box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .nav a { padding: 10px 14px; border-radius: 10px; }
}

main { min-height: 60vh; padding-bottom: 64px; }

/* الواجهة */
.hero { text-align: center; padding: 64px 0 40px; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); margin: 0; font-weight: 700; letter-spacing: 0; }
.hero-tag { color: var(--gold); font-size: 18px; margin: 6px 0 28px; }
.hero-search { display: flex; max-width: 520px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px; box-shadow: var(--shadow); }
.hero-search input { flex: 1; border: 0; background: transparent; padding: 10px 18px; font: inherit; color: var(--text); outline: none; min-width: 0; }
.hero-search button, .btn {
  border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 600; padding: 8px 22px; border-radius: 999px; cursor: pointer;
}
@media (prefers-color-scheme: dark) { .hero-search button, .btn { color: #0c1411; } }

.home-section { margin-top: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 24px; }
.more { font-size: 15px; font-weight: 500; }

/* البطاقات */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-cover img { aspect-ratio: 16/9; object-fit: cover; width: 100%; }
.card-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { margin: 0; font-size: 19px; line-height: 1.55; }
.card h3 a { color: var(--text); }
.card p { margin: 0; color: var(--muted); font-size: 15.5px; line-height: 1.75; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 14px; }
.badge { font-size: 12.5px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge-research { color: var(--research); background: color-mix(in srgb, var(--research) 12%, transparent); }
.badge-letters { color: var(--letters); background: color-mix(in srgb, var(--letters) 12%, transparent); }
.pdf-flag { font-size: 11px; font-weight: 700; border: 1px solid currentColor; padding: 0 6px; border-radius: 5px; color: #b3261e; }
.tags { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: auto; padding-top: 6px; font-size: 14px; }
.tags a { color: var(--muted); }
.tags a:hover { color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chips a {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  padding: 6px 14px; border-radius: 999px; font-size: 15px;
}
.chips a span { color: var(--muted); font-size: 13px; margin-inline-start: 4px; }
.chips a:hover { border-color: var(--accent); text-decoration: none; }
.chips-lg a { font-size: 17px; padding: 8px 18px; }

/* رؤوس الصفحات */
.page-head { padding: 40px 0 20px; }
.page-head h1 { margin: 0; font-size: clamp(28px, 4.5vw, 38px); }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }

/* صفحة المقال */
.post { max-width: var(--readw); margin: 0 auto; }
.post-head { padding: 40px 0 12px; }
.post-head h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.45; margin: 8px 0 10px; }
.lead { font-size: 19px; color: var(--muted); margin: 0 0 14px; }
.post-cover { margin: 18px 0; }
.post-cover img { border-radius: var(--radius); width: 100%; }
.prose { font-size: 18.5px; line-height: 2; }
.prose h2 { font-size: 26px; margin: 2em 0 .5em; line-height: 1.5; }
.prose h3 { font-size: 21px; margin: 1.6em 0 .4em; }
.prose p { margin: 0 0 1.1em; }
.prose blockquote {
  margin: 1.5em 0; padding: 14px 20px; background: var(--accent-soft);
  border-inline-start: 4px solid var(--accent); border-radius: 8px;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose img { border-radius: 10px; margin: 1.2em auto; }
.prose ul, .prose ol { padding-inline-start: 1.4em; }
.prose li { margin: .25em 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 16px; margin: 1.2em 0; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 12px; text-align: right; }
.prose th { background: var(--accent-soft); }
.prose code { background: var(--accent-soft); padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.prose a { text-decoration: underline; text-underline-offset: 4px; }

.attachment {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 28px 0; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: #b3261e;
}
.attachment div { flex: 1; display: flex; flex-direction: column; color: var(--text); line-height: 1.5; }
.attachment small { color: var(--muted); }
.btn-ghost { background: transparent; color: var(--accent) !important; border: 1px solid var(--accent); }
.btn:hover { text-decoration: none; opacity: .92; }
.post-tags { border-top: 1px solid var(--line); margin-top: 32px; padding-top: 16px; }

.pager { max-width: var(--readw); margin: 36px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pager a { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; color: var(--text); display: flex; flex-direction: column; line-height: 1.6; }
.pager a small { color: var(--muted); }
.pager .next { text-align: left; }
.pager a:hover { border-color: var(--accent); text-decoration: none; }

.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 36px; }
.pagination a { padding: 6px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.pagination a[aria-current="page"] { background: var(--accent); color: #fff; border-color: var(--accent); }

.empty { color: var(--muted); text-align: center; padding: 40px 0; }
.empty.big { padding: 100px 0; }

/* البحث (Pagefind) */
.search-box {
  --pagefind-ui-primary: var(--accent);
  --pagefind-ui-text: var(--text);
  --pagefind-ui-background: var(--surface);
  --pagefind-ui-border: var(--line);
  --pagefind-ui-tag: var(--accent-soft);
  --pagefind-ui-border-radius: 12px;
  --pagefind-ui-font: var(--font);
  max-width: 900px;
}
.search-box fieldset, .search-box .pagefind-ui__filter-panel { border: 0; }
.search-box .pagefind-ui__result-title { font-size: 19px; }
.search-box .pagefind-ui__search-input { direction: rtl; }
.search-box mark { background: #ffe9a8; color: inherit; border-radius: 3px; }

/* التذييل */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0; text-align: center; font-size: 15px; }
.site-footer p { margin: 4px 0; }

@media (max-width: 600px) {
  body { font-size: 16.5px; }
  .hero { padding: 40px 0 24px; }
  .prose { font-size: 17.5px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: right; }
}
@media print {
  .site-header, .site-footer, .pager, .attachment, .post-tags { display: none; }
  body { background: #fff; color: #000; }
}
