/* ===== الألوان والخطوط العامة ===== */
:root {
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --brand-dark: #3730a3;
  --sky: #0ea5e9;
  --ink: #0f172a;
  --text: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --soft: #eef2ff;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  overflow-x: hidden;
  font-family: 'Tajawal', 'Plus Jakarta Sans', Tahoma, sans-serif;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(rgba(99, 102, 241, 0.05) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.ltr { direction: ltr; text-align: left; }

/* ===== الترويسة ===== */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; justify-content: space-between; height: 76px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand-2), var(--sky));
  display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0;
}
.brand-name { font-weight: 800; font-size: 16px; line-height: 1.3; white-space: nowrap; }
.brand-sub { white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--sky); font-weight: 500; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a {
  color: var(--text); font-weight: 500; font-size: 15px;
  padding: 8px 10px; border-radius: 10px; white-space: nowrap;
}
.nav a:hover { background: var(--soft); color: var(--brand); text-decoration: none; }
.nav a.active { background: var(--soft); color: var(--brand); font-weight: 700; }
.header-tools { display: flex; align-items: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 12px; font-weight: 700; font-size: 15px;
  border: 1px solid transparent; cursor: pointer; font-family: inherit; transition: all .2s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 8px 20px rgba(79, 70, 229, .2); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-light { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-light:hover { background: var(--bg); }
.btn-small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; cursor: pointer; }

@media (max-width: 1280px) {
  .menu-btn { display: inline-flex; }
  .nav {
    display: none; position: absolute; top: 76px; inset-inline: 0;
    flex-direction: column; align-items: stretch; background: #fff;
    border-bottom: 1px solid var(--line); padding: 10px 20px 16px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, .08);
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px; font-size: 16px; }
  .header-contact { display: none; }
}

/* ===== العناوين والأقسام ===== */
.page-head { padding-block: 40px 32px; text-align: center; }
.page-head h1 { font-size: 36px; color: var(--ink); margin: 0 0 10px; font-weight: 800; line-height: 1.3; }
.page-head p { color: var(--muted); max-width: 720px; margin: 0 auto; font-size: 17px; }
.section { padding-block: 48px; }
.section-white { background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-title { font-size: 26px; color: var(--ink); font-weight: 800; margin: 0 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title a { font-size: 15px; font-weight: 700; }

/* ===== الواجهة الرئيسية ===== */
.hero { padding-block: 36px 28px; }
.hero-grid { display: grid; grid-template-columns: 7fr 5fr; gap: 48px; align-items: center; }
.hero-grid > *, .grid > * { min-width: 0; }
.badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 14px; border-radius: 999px;
  background: var(--soft); color: var(--brand); font-size: 13px; font-weight: 700;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
.hero h1 { font-size: 42px; line-height: 1.3; color: var(--ink); margin: 18px 0; font-weight: 800; }
.hero h1 .grad { display: block; background: linear-gradient(90deg, var(--brand-2), var(--sky)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 18px; color: #475569; max-width: 640px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.photo-frame {
  width: 320px; max-width: 100%; aspect-ratio: 1; margin: 0 auto; border-radius: 50%; padding: 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, .12), rgba(14, 165, 233, .2));
  box-shadow: 0 25px 50px rgba(15, 23, 42, .12);
}
.photo-inner { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; background: #e2e8f0; position: relative; display: flex; align-items: center; justify-content: center; }
.photo-inner img { width: 100%; height: 100%; object-fit: cover; }
.photo-inner .no-photo { color: var(--muted); font-size: 14px; text-align: center; padding: 20px; }
.photo-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.photo-caption { display: inline-block; padding: 6px 16px; border-radius: 999px; background: #0f172a; color: #fff; font-size: 13px; font-weight: 800; letter-spacing: 1px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-align: center; }
.stat:hover { border-color: var(--brand-2); text-decoration: none; }
.stat .num { font-size: 34px; font-weight: 800; color: var(--brand); line-height: 1.2; }
.stat .lbl { color: var(--muted); font-weight: 500; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; text-align: center; }
  .hero h1 { font-size: 34px; }
  .hero p { margin: 0 auto; }
  .hero-actions { justify-content: center; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ===== البطاقات والشبكات ===== */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } .grid-4.books { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; display: flex; flex-direction: column; gap: 10px; transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: var(--brand-2); box-shadow: 0 10px 25px rgba(15, 23, 42, .06); }
.card h3 { margin: 0; font-size: 17px; color: var(--ink); line-height: 1.5; font-weight: 700; }
.card .meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); font-weight: 700; }
.card .foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--soft); color: var(--brand); font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 7px; }
.subject { color: var(--sky); font-size: 14px; font-weight: 600; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; background: var(--soft); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icon-btn:hover { background: var(--brand); color: #fff; text-decoration: none; }
.row { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }

/* ===== أدوات البحث والفلترة ===== */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; align-items: center; }
.search {
  flex: 1; min-width: 240px; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line);
  font-family: inherit; font-size: 16px; background: #fff;
}
.search:focus { outline: 2px solid var(--brand-2); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff;
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--text); cursor: pointer;
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.count-note { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.empty { text-align: center; color: var(--muted); padding: 40px; background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ===== الكتب ===== */
.book { display: block; color: #fff; transition: transform .25s; }
.book:hover { transform: translateY(-6px); text-decoration: none; }
.book-cover {
  aspect-ratio: 3 / 4; border-radius: var(--radius); padding: 18px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 12px 24px rgba(15, 23, 42, .15);
}
.book-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.book-cover .layer { position: relative; z-index: 1; }
.book-cover .top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; opacity: .9; }
.book-cover h3 { font-size: 17px; font-weight: 800; line-height: 1.5; margin: 0; text-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.book-cover .bottom { border-top: 1px solid rgba(255, 255, 255, .3); padding-top: 10px; font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.book-cover.has-img .layer { display: none; }

/* ===== الفيديو ===== */
.video {
  border-radius: var(--radius); overflow: hidden; position: relative; aspect-ratio: 16 / 9;
  background: #0f172a center / cover no-repeat; display: flex; align-items: center; justify-content: center; color: #fff;
}
.video:hover { text-decoration: none; }
.video::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0, 0, 0, .85), rgba(0, 0, 0, .1)); }
.video .play { width: 60px; height: 60px; border-radius: 50%; background: #dc2626; display: flex; align-items: center; justify-content: center; z-index: 1; transition: transform .2s; }
.video:hover .play { transform: scale(1.1); }
.video .vtitle { position: absolute; bottom: 0; inset-inline: 0; padding: 14px; z-index: 1; font-weight: 700; font-size: 15px; line-height: 1.5; }

/* ===== المقالات ===== */
.post { display: flex; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; color: var(--text); }
.post:hover { text-decoration: none; border-color: var(--brand-2); }
.post .date { width: 64px; height: 64px; border-radius: 12px; background: var(--soft); color: var(--brand); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; font-weight: 800; font-size: 13px; line-height: 1.3; text-align: center; }
.post .date small { font-weight: 500; color: var(--muted); font-size: 11px; }
.post h3 { margin: 0 0 4px; font-size: 16px; color: var(--ink); }
.post p { margin: 0; font-size: 14px; color: var(--muted); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.panel h2 { margin: 0 0 16px; font-size: 20px; color: var(--ink); padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ===== عن الأستاذ ===== */
.about-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 32px; align-items: start; }
@media (max-width: 900px) { .about-grid { grid-template-columns: 1fr; } }
.profile-links { display: flex; flex-wrap: wrap; gap: 10px; }
.placeholder { color: #b45309; background: #fffbeb; border: 1px dashed #f59e0b; border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.list-clean { margin: 0; padding-inline-start: 20px; }

/* ===== التواصل ===== */
.contact-box { background: linear-gradient(135deg, var(--brand-dark), #0f172a); color: #fff; border-radius: 24px; padding: 40px; max-width: 820px; margin: 0 auto; }
.contact-box h2 { margin: 0 0 6px; font-size: 26px; }
.contact-box p { color: #c7d2fe; margin: 0 0 24px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .full { grid-column: 1 / -1; }
.form input, .form textarea {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .1); color: #fff; font-family: inherit; font-size: 15px;
}
.form input::placeholder, .form textarea::placeholder { color: rgba(255, 255, 255, .65); }
.form button { justify-self: center; background: var(--sky); color: #fff; }
.form-msg { grid-column: 1 / -1; text-align: center; font-weight: 700; min-height: 24px; }
@media (max-width: 640px) { .form { grid-template-columns: 1fr; } .contact-box { padding: 26px; } }

/* ===== التذييل ===== */
.site-footer { background: #0f172a; color: #94a3b8; padding: 32px 0; margin-top: 48px; font-size: 14px; }
.footer-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.site-footer a { color: #cbd5e1; }
.visits { display: inline-flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .06); padding: 6px 12px; border-radius: 10px; }
.loading { text-align: center; color: var(--muted); padding: 30px; }

@media (max-width: 640px) {
  .brand-sub { display: none; }
  .brand-name { font-size: 13px; white-space: normal; max-width: 150px; display: inline-block; }
  .brand-logo { width: 36px; height: 36px; }
  .header-row { height: 64px; }
  .nav { top: 64px; }
  .page-head h1 { font-size: 28px; }
}

/* ===== مسار الصفحة ===== */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 18px; font-size: 15px; color: var(--muted); }
.crumbs a { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; background: var(--soft); padding: 5px 12px; border-radius: 999px; }
.crumbs a:hover { text-decoration: none; background: var(--brand); color: #fff; }
.crumbs .sep { color: #94a3b8; }
.crumbs span:last-child { color: var(--ink); font-weight: 600; }
.foot-links { display: inline-flex; gap: 16px; flex-wrap: wrap; }

/* ===== أيقونات الصفحات في الرئيسية ===== */
.section-tight { padding-block: 8px 48px; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 22px; color: var(--text);
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.tile:hover { text-decoration: none; transform: translateY(-4px); border-color: var(--brand-2); box-shadow: 0 16px 30px rgba(79, 70, 229, .12); }
.tile-icon {
  width: 60px; height: 60px; border-radius: 16px; display: flex; align-items: center; justify-content: center;
  color: #fff; background: linear-gradient(135deg, var(--brand-2), var(--sky));
  box-shadow: 0 8px 18px rgba(79, 70, 229, .25);
}
.tile:nth-child(2) .tile-icon { background: linear-gradient(135deg, #2563eb, #10b981); }
.tile:nth-child(3) .tile-icon { background: linear-gradient(135deg, #7c3aed, #d946ef); }
.tile:nth-child(4) .tile-icon { background: linear-gradient(135deg, #dc2626, #f97316); }
.tile:nth-child(5) .tile-icon { background: linear-gradient(135deg, #0891b2, #3b82f6); }
.tile:nth-child(6) .tile-icon { background: linear-gradient(135deg, #059669, #14b8a6); }
.tile:nth-child(7) .tile-icon { background: linear-gradient(135deg, #b45309, #f59e0b); }
.tile:nth-child(8) .tile-icon { background: linear-gradient(135deg, #be185d, #f472b6); }
.tile:nth-child(9) .tile-icon { background: linear-gradient(135deg, #1e293b, #475569); }
.tile-text b { display: block; font-size: 19px; color: var(--ink); margin-bottom: 2px; }
.tile-text small { display: block; font-size: 14px; color: var(--muted); line-height: 1.6; }
.tile-count { position: absolute; top: 18px; inset-inline-end: 18px; font-size: 22px; font-weight: 800; color: var(--brand); }
@media (max-width: 1000px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) {
  .tile { padding: 16px; gap: 10px; }
  .tile-icon { width: 48px; height: 48px; border-radius: 13px; }
  .tile-text b { font-size: 16px; }
  .tile-text small { display: none; }
  .tile-count { font-size: 17px; top: 14px; inset-inline-end: 14px; }
}

/* ===== بطاقات الأخبار ===== */
.post .thumb { width: 88px; height: 72px; border-radius: 12px; flex-shrink: 0; background: var(--soft) center / cover no-repeat; }
.minis { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.mini { font-size: 12px; font-weight: 700; background: var(--soft); color: var(--brand); border-radius: 6px; padding: 1px 8px; }
.small-date { font-size: 12px !important; margin-top: 4px !important; }

/* ===== صفحة الخبر الكاملة ===== */
.post-full { max-width: 820px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 22px; padding: clamp(22px, 4vw, 44px); }
.post-full h1 { font-size: clamp(26px, 4vw, 36px); color: var(--ink); line-height: 1.35; margin: 6px 0 14px; }
.post-kind { color: var(--sky); font-weight: 700; margin: 0; }
.post-full .lead { font-size: 19px; color: #475569; }
.post-body p { font-size: 17px; margin: 0 0 14px; }
.post-h { font-size: 20px; color: var(--ink); margin: 28px 0 14px; }
.embed { position: relative; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: #0f172a; margin-top: 20px; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 12px; display: block; background: var(--soft); }
@media (max-width: 600px) { .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.file-row { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; font-weight: 600; }
.file-row:hover { background: var(--soft); text-decoration: none; }
@media (max-width: 900px) {
  .hero-grid > :last-child { order: -1; }
  .photo-frame { width: 170px; padding: 8px; }
  .photo-caption, .photo-inner .no-photo { display: none !important; }
  .hero h1 { font-size: 30px; margin: 12px 0; }
  .hero p { font-size: 16px; }
}

/* ===== نصوص بلغتين: يظهر المناسب حسب لغة الموقع ===== */
html[lang="ar"] .only-en, html[lang="en"] .only-ar { display: none; }
.bio-h { font-size: 17px; color: var(--brand); margin: 6px 0 8px; }
.bio-h ~ .bio-h { margin-top: 18px; }
.list-clean li { margin-bottom: 6px; }
