/* assets/css/site.css — أنماط الموقع (تُحمَّل دائمًا بعد Tailwind) */
:root {
  --accent: #7c3aed; --radius: 1rem;
  --bg: #f8fafc; --surface: #ffffff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
}
html.dark {
  --bg: #0b1120; --surface: #111a2e; --text: #e5e7eb; --muted: #94a3b8; --line: #26334d;
  color-scheme: dark;
}
* { font-family: 'Cairo', sans-serif; }
html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); }
.container { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }
.text-primary { color: var(--primary); }
.hover-primary:hover { color: var(--primary); }
.bg-primary-soft { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.brand-gradient { background-image: linear-gradient(to right, var(--primary), var(--accent)); }
.gradient-text {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.btn-primary { background: var(--primary); transition: all .3s ease; }
.btn-primary:hover { filter: brightness(.9); transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,.15); }
.btn-outline {
  border: 2px solid var(--primary); color: var(--primary); transition: all .3s ease; background: transparent;
}
.btn-outline:hover { background: var(--primary); color: #fff; transform: translateY(-2px); }
.card-hover { transition: all .3s ease; }
.card-hover:hover { transform: translateY(-5px); box-shadow: 0 20px 25px -5px rgba(0,0,0,.12), 0 10px 10px -5px rgba(0,0,0,.04); }
.navbar-fixed { transition: all .3s ease; }
.navbar-scrolled { background: rgba(255,255,255,.95); backdrop-filter: blur(10px); box-shadow: 0 4px 20px rgba(0,0,0,.05); }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- التنقل: الرابط النشط ---------- */
.nav-link { position: relative; padding: .25rem 0; }
.nav-link::after {
  content: ''; position: absolute; bottom: -4px; right: 0; width: 0; height: 2px;
  background: var(--primary); transition: width .3s ease;
}
.nav-link:hover::after, .nav-link.active::after { width: 100%; }
.nav-link.active { color: var(--primary); }

/* ---------- Preloader / تقدم القراءة / زر الأعلى ---------- */
#preloader {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  background: var(--bg); transition: opacity .4s ease, visibility .4s ease;
  animation: pl-failsafe .4s ease 4s forwards;
}
#preloader.done { opacity: 0; visibility: hidden; }
#preloader .spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid color-mix(in srgb, var(--primary) 20%, transparent); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pl-failsafe { to { opacity: 0; visibility: hidden; } }
#scroll-progress {
  position: fixed; top: 0; right: 0; height: 3px; width: 0; z-index: 60;
  background: linear-gradient(to left, var(--primary), var(--accent)); transition: width .1s linear;
}
#to-top {
  position: fixed; bottom: 1.25rem; left: 1.25rem; z-index: 50; width: 46px; height: 46px; border-radius: 50%;
  color: #fff; background: var(--primary); box-shadow: 0 10px 20px rgba(0,0,0,.2);
  opacity: 0; visibility: hidden; transform: translateY(10px); transition: all .3s ease;
}
#to-top.show { opacity: 1; visibility: visible; transform: none; }
.float-whatsapp {
  position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 50; width: 52px; height: 52px; border-radius: 50%;
  background: #22c55e; color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; box-shadow: 0 10px 20px rgba(34,197,94,.4); transition: transform .3s ease;
}
.float-whatsapp:hover { transform: scale(1.1); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; }
.hero::before, .hero::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(80px); opacity: .35; z-index: 0; pointer-events: none;
}
.hero::before { width: 420px; height: 420px; background: var(--primary); top: -120px; left: -100px; }
.hero::after { width: 380px; height: 380px; background: var(--accent); bottom: -140px; right: -80px; }
.hero > .container { position: relative; z-index: 1; }
.hero-ring {
  padding: 6px; border-radius: 50%;
  background: conic-gradient(from 180deg, var(--primary), var(--accent), var(--primary));
  animation: spin 12s linear infinite;
}
.hero-ring > div { border-radius: 50%; background: var(--bg); padding: 6px; animation: spin 12s linear infinite reverse; }
.hero-ring img { border-radius: 50%; }
.typing-cursor::after { content: '|'; margin-right: 2px; animation: blink 1s steps(1) infinite; color: var(--primary); }
@keyframes blink { 50% { opacity: 0; } }
.float-y { animation: floaty 4s ease-in-out infinite; }
@keyframes floaty { 50% { transform: translateY(-10px); } }

/* ---------- عناصر قسم ---------- */
.section-title { position: relative; display: inline-block; }
.stat-card { text-align: center; padding: 1.5rem 1rem; border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 25px -10px rgba(0,0,0,.15); }
.stat-card .num { font-size: 2.25rem; font-weight: 800; }
.skill-bar { height: 8px; border-radius: 9999px; background: rgba(148,163,184,.25); overflow: hidden; }
.skill-bar > span { display: block; height: 100%; width: 0; border-radius: 9999px; background: linear-gradient(to left, var(--primary), var(--accent)); transition: width 1.2s ease; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-right: 1.75rem; }
.timeline::before { content: ''; position: absolute; top: 6px; bottom: 6px; right: 7px; width: 2px; background: var(--line); }
.timeline-item { position: relative; padding-bottom: 1.75rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; right: -1.75rem; top: 6px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--primary);
}
.timeline-date { display: inline-block; font-size: .8rem; padding: .15rem .75rem; border-radius: 9999px; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }

/* ---------- محتوى المقال ---------- */
.article-content { line-height: 2; font-size: 1.1rem; color: var(--text); overflow-wrap: anywhere; }
.article-content h1, .article-content h2, .article-content h3, .article-content h4 { font-weight: 800; margin: 2rem 0 .75rem; line-height: 1.5; scroll-margin-top: 100px; }
.article-content h2 { font-size: 1.6rem; } .article-content h3 { font-size: 1.3rem; }
.article-content p { margin: 1rem 0; }
.article-content a { color: var(--primary); text-decoration: underline; }
.article-content img { max-width: 100%; height: auto; border-radius: .75rem; margin: 1.25rem auto; display: block; }
.article-content ul, .article-content ol { margin: 1rem 1.5rem; } .article-content ul { list-style: disc; } .article-content ol { list-style: decimal; }
.article-content blockquote { border-right: 4px solid var(--primary); background: color-mix(in srgb, var(--primary) 8%, transparent); padding: .75rem 1.25rem; border-radius: .5rem; margin: 1.25rem 0; }
.article-content pre { background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: .75rem; overflow-x: auto; direction: ltr; text-align: left; margin: 1.25rem 0; }
.article-content code { background: rgba(148,163,184,.2); padding: .1rem .4rem; border-radius: .3rem; font-size: .9em; }
.article-content pre code { background: transparent; padding: 0; }
.article-content table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; display: block; overflow-x: auto; }
.article-content th, .article-content td { border: 1px solid var(--line); padding: .5rem .75rem; }
.article-content iframe, .article-content video { max-width: 100%; border-radius: .75rem; }
#toc a { display: block; padding: .3rem .75rem; border-right: 2px solid var(--line); color: var(--muted); font-size: .95rem; transition: all .2s; }
#toc a:hover, #toc a.active { color: var(--primary); border-right-color: var(--primary); }
#toc a.lvl3 { padding-right: 1.5rem; font-size: .88rem; }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-size: .9rem; color: var(--muted); margin-bottom: 1.5rem; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .sep { font-size: .65rem; opacity: .6; }

/* ---------- Lightbox + مشغل الفيديو ---------- */
.lb-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.92); display: none; align-items: center; justify-content: center; }
.lb-overlay.open { display: flex; animation: fadeIn .25s ease; }
.lb-overlay img { max-width: 94vw; max-height: 86vh; border-radius: .5rem; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lb-btn { position: absolute; color: #fff; background: rgba(255,255,255,.12); width: 46px; height: 46px; border-radius: 50%; font-size: 1.2rem; transition: background .2s; }
.lb-btn:hover { background: rgba(255,255,255,.28); }
.lb-close { top: 1rem; left: 1rem; } .lb-next { left: 1rem; top: 50%; } .lb-prev { right: 1rem; top: 50%; }
.lb-caption { position: absolute; bottom: 1rem; left: 0; right: 0; text-align: center; color: #e5e7eb; padding: 0 1rem; }
.vm-box { width: min(960px, 94vw); aspect-ratio: 16/9; background: #000; border-radius: .75rem; overflow: hidden; }
.vm-box iframe, .vm-box video { width: 100%; height: 100%; border: 0; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.play-badge {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.3); transition: background .3s;
}
.play-badge i { font-size: 3.2rem; color: #fff; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); transition: transform .3s; }
.group:hover .play-badge i { transform: scale(1.15); }

/* ---------- حركات الصفحة ---------- */
main.page-enter, .page-enter { animation: pageIn .5s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- الوضع الليلي: تعويض أصناف Tailwind الشائعة ---------- */
html.dark .bg-white { background-color: var(--surface); }
html.dark .bg-gray-50 { background-color: #0d1424; }
html.dark .bg-gray-100 { background-color: #1b2740; }
html.dark .bg-gray-200 { background-color: #26334d; }
html.dark .text-gray-900, html.dark .text-gray-800 { color: #f3f4f6; }
html.dark .text-gray-700 { color: #d1d5db; }
html.dark .text-gray-600 { color: #aab4c6; }
html.dark .text-gray-500 { color: #8b97ab; }
html.dark .text-gray-400 { color: #74809a; }
html.dark .border-gray-100, html.dark .border-gray-200, html.dark .border-gray-300, html.dark .border-b, html.dark .border-t { border-color: var(--line); }
html.dark .hover\:bg-gray-100:hover { background-color: #1b2740; }
html.dark .navbar-scrolled { background: rgba(17,26,46,.92); }
html.dark input, html.dark textarea, html.dark select { background-color: #0d1424; color: var(--text); border-color: var(--line); }
html.dark .bg-green-100 { background-color: rgba(34,197,94,.15); } html.dark .bg-red-100 { background-color: rgba(239,68,68,.15); }
html.dark .shadow-lg, html.dark .shadow-xl, html.dark .shadow-sm { box-shadow: 0 10px 25px -10px rgba(0,0,0,.6); }

/* ---------- الطباعة (السيرة الذاتية) ---------- */
@media print {
  nav, footer, #preloader, #scroll-progress, #to-top, .float-whatsapp, .no-print { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .sticky { position: static !important; }
  .shadow-lg { box-shadow: none !important; }
}

/* ---------- الوضع LTR (الإنجليزية) ---------- */
html[dir="ltr"] .ml-1 { margin-left: 0; margin-right: .25rem; }
html[dir="ltr"] .ml-2 { margin-left: 0; margin-right: .5rem; }
html[dir="ltr"] .mr-1 { margin-right: 0; margin-left: .25rem; }
html[dir="ltr"] .mr-2 { margin-right: 0; margin-left: .5rem; }
html[dir="ltr"] .border-r-4 { border-right-width: 0; border-left-width: 4px; }
html[dir="ltr"] .md\:text-right { text-align: left; }
html[dir="ltr"] .pr-12 { padding-right: 1rem; padding-left: 3rem; }
html[dir="ltr"] button.right-4 { right: auto; left: 1rem; }
html[dir="ltr"] .fa-arrow-left, html[dir="ltr"] .fa-arrow-right, html[dir="ltr"] .fa-chevron-left, html[dir="ltr"] .fa-chevron-right,
html[dir="ltr"] .fa-paper-plane { transform: scaleX(-1); display: inline-block; }
html[dir="ltr"] .timeline { padding-right: 0; padding-left: 1.75rem; }
html[dir="ltr"] .timeline::before { right: auto; left: 7px; }
html[dir="ltr"] .timeline-item::before { right: auto; left: -1.75rem; }
html[dir="ltr"] .article-content blockquote { border-right: 0; border-left: 4px solid var(--primary); }
html[dir="ltr"] #toc a { border-right: 0; border-left: 2px solid var(--line); }
html[dir="ltr"] #toc a:hover, html[dir="ltr"] #toc a.active { border-left-color: var(--primary); }
html[dir="ltr"] #toc a.lvl3 { padding-right: .75rem; padding-left: 1.5rem; }
html[dir="ltr"] .nav-link::after { right: auto; left: 0; }
html[dir="ltr"] #scroll-progress { right: auto; left: 0; }
html[dir="ltr"] .lb-prev { right: auto; left: 1rem; } html[dir="ltr"] .lb-next { left: auto; right: 1rem; }
html[dir="ltr"] .lb-close { left: auto; right: 1rem; }
