/* ═══════════════════════════════════════════════════════════════
   Developer Reference — Main Stylesheet
   Design: Dark code-editor aesthetic with green accent (RTL)
   Font: Noto Kufi Arabic + Source Code Pro
═══════════════════════════════════════════════════════════════ */

@charset "UTF-8";

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Colors */
  --clr-bg-0:        #0d0f12;
  --clr-bg-1:        #141720;
  --clr-bg-2:        #1c2030;
  --clr-bg-3:        #252a3a;
  --clr-border:      #2e3448;
  --clr-accent:      #70d700;
  --clr-accent-dim:  #4c9400;
  --clr-accent-glow: rgba(112,215,0,.18);
  --clr-text-1:      #e8eaf0;
  --clr-text-2:      #9aa0b8;
  --clr-text-3:      #5c647e;
  --clr-code-bg:     #111418;
  --clr-code-text:   #a6e22e;
  --clr-fn:          #66d9ef;
  --clr-error:       #ff5555;
  --clr-warn:        #f1c40f;

  /* Layout */
  --sidebar-w:       280px;
  --topbar-h:        60px;
  --radius-sm:       6px;
  --radius-md:       10px;
  --radius-lg:       16px;

  /* Typography */
  --font-body:  'Noto Kufi Arabic', 'Segoe UI', system-ui, sans-serif;
  --font-code:  'Source Code Pro', 'Cascadia Code', 'Fira Code', monospace;

  /* Motion */
  --ease-out:  cubic-bezier(.22,1,.36,1);
  --ease-in:   cubic-bezier(.64,0,.78,0);
  --dur-fast:  150ms;
  --dur-med:   260ms;
  --dur-slow:  400ms;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--clr-bg-0);
  color: var(--clr-text-1);
  line-height: 1.65;
  direction: rtl;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }
a   { color: var(--clr-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--clr-accent);
  outline-offset: 3px;
  border-radius: 3px;
}
button:focus-visible {
  outline: 2px solid var(--clr-accent);
  outline-offset: 2px;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; inset-inline: 0;
  height: var(--topbar-h);
  background: rgba(13,15,18,.92);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--clr-border);
  z-index: 900;
  transition: box-shadow var(--dur-med) var(--ease-out);
}
.topbar.scrolled {
  box-shadow: 0 4px 32px rgba(0,0,0,.5);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1440px;
  margin: auto;
  padding: 0 20px;
}
.topbar-brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--clr-text-1);
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-brand:hover { text-decoration: none; color: var(--clr-accent); }
.brand-accent {
  color: var(--clr-accent);
  font-family: var(--font-code);
  font-size: 1rem;
}

.topbar-spacer { height: var(--topbar-h); }

/* ── Hamburger ─────────────────────────────────────────────── */
.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast);
}
.hamburger:hover { background: var(--clr-bg-3); }
.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--clr-text-1);
  border-radius: 2px;
  transition: transform var(--dur-med) var(--ease-out),
              opacity var(--dur-med);
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 950;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; animation: fadeIn var(--dur-med) var(--ease-out); }

.sidebar {
  position: fixed;
  top: 0;
  inset-inline-end: 0;
  width: var(--sidebar-w);
  height: 100dvh;
  background: var(--clr-bg-1);
  border-inline-start: 1px solid var(--clr-border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);  /* LTR: translateX(100%) = off screen right */
  transition: transform var(--dur-slow) var(--ease-out);
  overflow-y: auto;
  padding-top: 16px;
}
[dir="rtl"] .sidebar { transform: translateX(100%); }
.sidebar.open     { transform: translateX(0); }

.sidebar-close {
  margin: 0 16px 8px;
  padding: 10px 16px;
  background: var(--clr-bg-3);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  color: var(--clr-text-1);
  cursor: pointer;
  font-size: .9rem;
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.sidebar-close:hover { background: var(--clr-error); color: #fff; }

.sidebar-link {
  display: block;
  padding: 13px 20px;
  color: var(--clr-text-2);
  border-radius: 0;
  font-size: .95rem;
  border-bottom: 1px solid var(--clr-border);
  transition: color var(--dur-fast), background var(--dur-fast), padding var(--dur-fast);
}
.sidebar-link:hover {
  color: var(--clr-accent);
  background: var(--clr-accent-glow);
  padding-inline-start: 28px;
  text-decoration: none;
}

/* ── Page Wrapper ────────────────────────────────────────────── */
.page-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ── Hero / Page Header ──────────────────────────────────────── */
.page-hero {
  text-align: center;
  padding: 48px 24px 40px;
  position: relative;
  overflow: hidden;
}
.page-hero::before {
  content: '';
  position: absolute;
  top: -80px; left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 600px;
  background: radial-gradient(circle, var(--clr-accent-glow) 0%, transparent 70%);
  pointer-events: none;
}
.hero-logo {
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 3px solid var(--clr-accent);
  box-shadow: 0 0 40px var(--clr-accent-glow), 0 8px 32px rgba(0,0,0,.5);
  margin: 0 auto 24px;
  object-fit: cover;
  animation: logoIn .6s var(--ease-out) both;
}
.hero-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 900;
  color: var(--clr-text-1);
  line-height: 1.2;
  animation: slideUp .6s var(--ease-out) .1s both;
}
.hero-title span { color: var(--clr-accent); }
.hero-desc {
  color: var(--clr-text-2);
  margin-top: 10px;
  font-size: 1rem;
  animation: slideUp .6s var(--ease-out) .2s both;
}

/* ── Reference Cards (index page) ───────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  margin: 40px 0;
}
.ref-card {
  background: var(--clr-bg-1);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  transition: transform var(--dur-med) var(--ease-out),
              box-shadow var(--dur-med) var(--ease-out),
              border-color var(--dur-med);
  animation: cardIn .5s var(--ease-out) both;
  position: relative;
  overflow: hidden;
}
.ref-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--clr-accent);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--dur-med) var(--ease-out);
}
.ref-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 50px rgba(0,0,0,.5), 0 0 30px var(--clr-accent-glow);
  border-color: var(--clr-accent-dim);
  text-decoration: none;
}
.ref-card:hover::after { transform: scaleX(1); transform-origin: left; }

.ref-card img {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--clr-border);
  transition: border-color var(--dur-med), box-shadow var(--dur-med);
}
.ref-card:hover img {
  border-color: var(--clr-accent);
  box-shadow: 0 0 20px var(--clr-accent-glow);
}
.ref-card-label {
  font-size: .95rem;
  font-weight: 700;
  color: var(--clr-text-1);
  letter-spacing: .01em;
}

/* Stagger animation */
.ref-card:nth-child(1) { animation-delay: .05s; }
.ref-card:nth-child(2) { animation-delay: .10s; }
.ref-card:nth-child(3) { animation-delay: .15s; }
.ref-card:nth-child(4) { animation-delay: .20s; }
.ref-card:nth-child(5) { animation-delay: .25s; }
.ref-card:nth-child(6) { animation-delay: .30s; }

/* ── Search Form ─────────────────────────────────────────────── */
.search-form { margin: 32px 0; }
.search-wrapper {
  display: flex;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
}
.search-input, .search-select {
  background: var(--clr-bg-2);
  border: 1px solid var(--clr-border);
  color: var(--clr-text-1);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: .95rem;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  outline: none;
}
.search-input {
  flex: 1;
  min-width: 200px;
}
.search-input::placeholder { color: var(--clr-text-3); }
.search-input:focus, .search-select:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-glow);
}
.search-select { min-width: 160px; cursor: pointer; }
.search-select option { background: var(--clr-bg-2); }

.search-btn {
  background: var(--clr-accent);
  color: #0d0f12;
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 20px;
  cursor: pointer;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--dur-fast), transform var(--dur-fast), box-shadow var(--dur-fast);
}
.search-btn:hover {
  background: #88ff00;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--clr-accent-glow);
}
.search-btn:active { transform: none; }

/* ── Reference Sections & Tables ─────────────────────────────── */
.ref-section {
  margin-bottom: 48px;
  animation: slideUp .4s var(--ease-out) both;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--clr-border);
}
.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--clr-text-1);
  flex: 1;
}
.section-title::before {
  content: '# ';
  color: var(--clr-accent);
  font-family: var(--font-code);
  font-size: 1rem;
}
.section-badge {
  background: var(--clr-bg-3);
  border: 1px solid var(--clr-border);
  color: var(--clr-text-2);
  font-size: .75rem;
  padding: 2px 10px;
  border-radius: 100px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--clr-border);
}
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.ref-table thead th {
  background: var(--clr-bg-2);
  color: var(--clr-text-2);
  font-weight: 600;
  padding: 12px 16px;
  text-align: start;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--clr-border);
}
.ref-table tbody tr {
  border-bottom: 1px solid var(--clr-border);
  transition: background var(--dur-fast);
}
.ref-table tbody tr:last-child { border-bottom: none; }
.ref-table tbody tr:hover { background: var(--clr-bg-2); }
.ref-table td {
  padding: 12px 16px;
  vertical-align: top;
  color: var(--clr-text-1);
}

.col-name  { width: 20%; min-width: 120px; }
.col-desc  { width: 35%; }
.col-example { width: 45%; }

.fn-name {
  font-family: var(--font-code);
  font-size: .85rem;
  color: var(--clr-fn);
  background: rgba(102,217,239,.08);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(102,217,239,.15);
  word-break: break-all;
}

/* ── Code Block ─────────────────────────────────────────────── */
.code-block-wrap {
  position: relative;
}
.code-block {
  background: var(--clr-code-bg);
  color: var(--clr-code-text);
  font-family: var(--font-code);
  font-size: .8rem;
  line-height: 1.6;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid rgba(166,226,46,.1);
  margin: 0;
}
.copy-btn {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  background: var(--clr-bg-3);
  border: 1px solid var(--clr-border);
  color: var(--clr-text-2);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-fast), background var(--dur-fast), color var(--dur-fast);
  display: flex;
  align-items: center;
}
.code-block-wrap:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: var(--clr-accent); color: #0d0f12; border-color: var(--clr-accent); }
.copy-btn.copied { background: var(--clr-accent); color: #0d0f12; opacity: 1; }

/* ── No Results ─────────────────────────────────────────────── */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--clr-text-3);
}
.no-results svg { width: 64px; height: 64px; opacity: .3; margin: 0 auto 16px; }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--clr-border);
  padding: 24px 20px;
  text-align: center;
  color: var(--clr-text-3);
  font-size: .85rem;
}
.site-footer a { color: var(--clr-accent); }

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--clr-bg-0); }
::-webkit-scrollbar-thumb { background: var(--clr-bg-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--clr-accent-dim); }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes logoIn {
  from { opacity: 0; transform: scale(.8) rotate(-8deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Utilities ───────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.text-accent { color: var(--clr-accent); }
.mt-sm { margin-top: 12px; }
.mt-md { margin-top: 24px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .search-wrapper { flex-direction: column; }
  .search-input, .search-select, .search-btn { width: 100%; }

  .col-example { display: none; }
  .col-name, .col-desc { width: 50%; }

  .cards-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .ref-card { padding: 18px 12px; }
  .ref-card img { width: 60px; height: 60px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ── Color Reference Specific ────────────────────────────────── */
.color-swatch {
  display: inline-block;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.12);
  vertical-align: middle;
  margin-inline-end: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

/* ── Skip Link (Accessibility) ───────────────────────────────── */
.skip-link {
  position: absolute;
  top: -40px; left: 0;
  background: var(--clr-accent);
  color: #0d0f12;
  padding: 8px 16px;
  font-weight: 700;
  z-index: 9999;
  border-radius: 0 0 var(--radius-sm) 0;
  transition: top var(--dur-fast);
}
.skip-link:focus { top: 0; }

/* mobilenav */
/* إعدادات الشريط العلوي الأساسية */
.topbar {
  position: fixed; /* ثبات الشريط في الأعلى */
  top: 0;
  right: 0;
  left: 0;
  background-color: #ffffff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 1000;
  height: 70px; /* ارتفاع ثابت للشريط */
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 100%;
}

.topbar-brand {
  font-size: 1.5em;
  font-weight: bold;
  text-decoration: none;
  color: #333;
}

.brand-accent {
  color: #007bff; /* لون مميز لعلامات الكود */
}

/* تنسيق القائمة الأفقية للشاشات الكبيرة */
.topbar-nav {
  display: flex;
  gap: 20px; /* المسافة بين الروابط */
  align-items: center;
}

.nav-link {
  text-decoration: none;
  color: #495057;
  font-weight: 500;
  transition: color 0.3s ease;
}

.nav-link:hover {
  color: #007bff;
}

/* فاصل للحفاظ على المساحة خلف الشريط الثابت */
.topbar-spacer {
  height: 70px; 
}

/* زر الهواتف مخفي افتراضياً */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
}

.hamburger span {
  display: block;
  width: 25px;
  height: 3px;
  background-color: #333;
  border-radius: 3px;
  transition: all 0.3s ease;
}

@media (max-width: 768px) {
  .hamburger {
      display: flex;
  }

  .topbar-nav {
      position: absolute;
      top: 70px;
      left: 0;
      right: 0;
      background-color: #ffffff;
      flex-direction: column;
      gap: 0;
      box-shadow: 0 10px 15px rgba(0,0,0,0.1); /* زيادة الظل لرؤيتها بوضوح */
      max-height: 0;
      overflow: hidden;
      transition: max-height 0.3s ease-in-out;
      z-index: 9999; /* ضمان ظهورها فوق كل محتوى الصفحة */
  }

  .topbar-nav.active {
      max-height: 500px; /* تم زيادة الارتفاع لضمان استيعاب كل الروابط */
      border-bottom: 2px solid #007bff; /* خط سفلي لتحديد نهاية القائمة */
  }

  .nav-link {
      padding: 15px 20px;
      border-bottom: 1px solid #f1f1f1;
      width: 100%;
      display: block;
      box-sizing: border-box;
  }
}
