/* ─────────────────────────────────────────────────────────────
   للمونتاج - Design Tokens & Global Utilities
   ───────────────────────────────────────────────────────────── */

html { background: #0D0316; color-scheme: dark; }
html[data-theme="light"] { background: #FAF7FC; color-scheme: light; }
html[data-theme="dark"] { background: #0D0316; color-scheme: dark; }

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { margin: 0; }

/* ── Brand Purple Scale ── */
:root {
  --purple-50:  #FBF4FE;
  --purple-100: #F3E2FB;
  --purple-200: #E6C2F5;
  --purple-300: #D196EC;
  --purple-400: #B85FDF;
  --purple-500: #9B30C8;
  --purple-600: #7E1FAA;
  --purple-700: #5E1485;
  --purple-800: #3D0B5A;
  --purple-900: #1F0530;
  --purple-950: #110319;

  /* Brand gradient */
  --gradient-brand: linear-gradient(135deg, #4E0F65 0%, #8B2BAA 50%, #C44FE0 100%);
  --gradient-soft:  linear-gradient(135deg, #F8EBFC 0%, #F0DAF8 100%);
  --gradient-dark:  linear-gradient(180deg, #110319 0%, #1A0728 100%);

  /* Light surfaces */
  --bg:        #FAF7FC;
  --surface:   #FFFFFF;
  --surface-2: #F5F0F8;
  --surface-3: #ECE3F1;
  --border:    #E5D8EC;
  --border-2:  #D3BFDF;
  --ink:       #170424;
  --ink-2:     #3A1F4C;
  --muted:     #6E5878;
  --muted-2:   #9986A4;

  /* Status */
  --success: #2D9D78;
  --warning: #D48C1A;
  --danger:  #C8344B;
  --info:    #3B6BD9;

  /* Typography */
  --font-arabic: "IBM Plex Sans Arabic", "Segoe UI", system-ui, sans-serif;
  --font-mono:   "IBM Plex Mono", "JetBrains Mono", ui-monospace, monospace;

  --fs-display: 88px;
  --fs-h1: 56px;
  --fs-h2: 40px;
  --fs-h3: 28px;
  --fs-h4: 22px;
  --fs-body: 17px;
  --fs-small: 14px;
  --fs-xs: 12px;

  /* Radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(31,5,48,.06), 0 1px 1px rgba(31,5,48,.04);
  --shadow-md:  0 8px 24px -8px rgba(94,20,133,.18), 0 2px 6px rgba(31,5,48,.06);
  --shadow-lg:  0 24px 48px -12px rgba(94,20,133,.25), 0 4px 12px rgba(31,5,48,.08);
  --shadow-glow: 0 0 0 1px rgba(155,48,200,.15), 0 16px 40px -8px rgba(155,48,200,.35);
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --bg:        #0D0316;
  --surface:   #170728;
  --surface-2: #20102F;
  --surface-3: #2B1840;
  --border:    #321E48;
  --border-2:  #432A5E;
  --ink:       #F6EDFB;
  --ink-2:     #D8C7E4;
  --muted:     #A290B0;
  --muted-2:   #7A6889;
  --gradient-soft: linear-gradient(135deg, #2B1240 0%, #1A0728 100%);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 8px 24px -8px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.3);
  --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.6);
  --shadow-glow: 0 0 0 1px rgba(184,95,223,.25), 0 16px 40px -8px rgba(184,95,223,.5);
}

/* ── Card style variants ── */
[data-card="flat"]     .card { box-shadow: none !important; border: 1px solid transparent !important; background: var(--surface-2) !important; }
[data-card="bordered"] .card { box-shadow: none !important; border: 1px solid var(--border) !important; }
[data-card="shadowed"] .card { box-shadow: var(--shadow-md) !important; border: 1px solid transparent !important; }

/* ── Base ── */
body {
  font-family: var(--font-arabic);
  direction: rtl;
  background: var(--bg);
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: 1.6;
  font-feature-settings: "kern","liga";
}
p  { margin: 0; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
button { font-family: inherit; cursor: pointer; }
a  { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ── Utilities ── */
.gradient-text {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.gradient-bg { background: var(--gradient-brand); color: white; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--purple-100);
  color: var(--purple-700);
  font-size: var(--fs-xs);
  font-weight: 500;
}
[data-theme="dark"] .chip { background: rgba(184,95,223,.15); color: var(--purple-200); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: var(--fs-small);
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
  transition: all 160ms ease;
  cursor: pointer;
}
.btn-primary   { background: var(--gradient-brand); color: white; box-shadow: var(--shadow-glow); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-ghost     { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn-sm  { padding: 6px 12px; font-size: var(--fs-xs); border-radius: 10px; }
.btn-lg  { padding: 14px 22px; font-size: var(--fs-body); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

/* Scrollbar */
.thin-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.thin-scroll::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
.thin-scroll::-webkit-scrollbar-track { background: transparent; }

/* ── Top Bar ── */
:root { --topbar-h: 40px; }
.header-topbar {
  background: #1A0630;
  border-bottom: 1px solid rgba(255,255,255,.07);
  position: sticky;
  top: 0;
  z-index: 101;
  height: var(--topbar-h);
}
[data-theme=”light”] .header-topbar { background: #2B0A45; }
:root { --logo-area: 156px; }
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 36px;
  height: 100%;
  gap: 16px;
}
/* Pages + social centered as a group */
.topbar-pages {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
}
.topbar-pages a {
  font-size: 15px;
  color: rgba(255,255,255,.82);
  padding: 4px 13px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 400;
  transition: color .14s, background .14s;
}
.topbar-pages a:hover { color: #fff; background: rgba(255,255,255,.1); }
/* Social icons */
.topbar-social {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar-social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: rgba(255,255,255,.6);
  transition: color .14s, background .14s;
}
.topbar-social a:hover { color: #fff; background: rgba(255,255,255,.1); }
/* logo-full gets same fixed width as the spacer */
.logo-full { flex: 0 0 var(--logo-area); min-width: 0; overflow: hidden; }

/* ── Shared Header ── */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: var(--topbar-h); z-index: 100;
}
/* When topbar is absent, header sticks to top */
body:not(:has(.header-topbar)) .site-header { top: 0; }
.site-header nav { display: flex; gap: 28px; font-size: 15px; color: var(--ink-2); }
.site-header nav a { transition: color 120ms; }
.site-header nav a:hover { color: var(--ink); }
.site-header nav a.active { font-weight: 600; color: var(--ink); }
.header-actions { display: flex; align-items: center; gap: 10px; }

/* ── Shared Footer ── */
.site-footer {
  padding: 48px 56px 36px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.site-footer .footer-grid {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 40px;
}
.site-footer .footer-bottom {
  margin-top: 36px; padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between;
  color: var(--muted); font-size: 13px;
}
.footer-col h5 { font-size: 14px; margin-bottom: 12px; }
.footer-col ul { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 14px; }

/* ── Logo ── */
.logo-full {
  display: inline-flex; align-items: center; gap: 10px;
  direction: rtl; text-decoration: none;
}
.logo-text {
  font-family: var(--font-arabic);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: -0.02em;
  line-height: 1;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ── Article Card ── */
.article-card { display: flex; flex-direction: column; gap: 14px; cursor: pointer; }
.article-card:hover .article-cover { transform: scale(1.02); }
.article-cover {
  border-radius: 18px; position: relative; overflow: hidden;
  transition: transform 220ms ease;
}
.article-cover .cover-cat {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,.92); color: var(--purple-700);
  font-size: 12px; font-weight: 500;
  padding: 4px 10px; border-radius: 999px;
}
.article-cover .cover-shine {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(255,255,255,.18), transparent 55%);
}
.article-meta { display: flex; gap: 10px; color: var(--muted); font-size: 13px; }
.article-author { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.author-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gradient-brand); flex-shrink: 0;
}


.hero {
  padding: 64px 56px 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 1.1fr);
  gap: 56px;
  align-items: center;
}
.hero-headline { font-size: 72px; line-height: 1.08; margin-bottom: 24px; }
.hero-sub { font-size: 19px; color: var(--muted); line-height: 1.8; max-width: 560px; }
.hero-ctas, .header-actions, .author-actions { display: flex; gap: 10px; align-items: center; }
.hero-stats { display: flex; gap: 28px; margin-top: 34px; color: var(--muted); font-size: 14px; }
.hero-stats b { color: var(--ink); font-size: 22px; display: block; }
.hero-featured {
  min-height: 460px;
  border-radius: 28px;
  background: var(--gradient-brand);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.hero-featured::before {
  content: "";
  position: absolute;
  inset: 30px 30px auto;
  height: 6px;
  background: rgba(255,255,255,.35);
  border-radius: 3px;
}
.hero-featured img, .article-cover img, .article-cover-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-featured img { position: absolute; inset: 0; opacity: .72; mix-blend-mode: screen; }
.featured-body { position: absolute; right: 28px; left: 28px; bottom: 28px; color: #fff; z-index: 1; }
.featured-label { font-size: 13px; opacity: .85; }
.featured-title { font-size: 32px; margin-top: 8px; line-height: 1.35; }
.featured-meta { margin-top: 12px; font-size: 13px; opacity: .9; }
.categories, .latest, .archive-hero, .filter-bar, .tabs-bar, .archive-grid, .pagination {
  padding-inline: 56px;
}
.categories { padding-block: 24px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.categories .label { color: var(--muted); font-size: 14px; margin-left: 8px; }
.chip-active { background: var(--gradient-brand) !important; color: #fff !important; }
.latest { padding-block: 32px 56px; }
.section-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; }
.section-title { font-size: 36px; }
.see-all, .text-link { color: var(--purple-600); font-weight: 600; }
.articles-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 28px; }
.col-stack { display: flex; flex-direction: column; gap: 24px; }
.newsletter-card { padding: 24px; background: var(--gradient-soft) !important; }
.newsletter-card h4 { font-size: 20px; margin-top: 12px; }
.newsletter-card p, .muted { color: var(--muted); }
.newsletter-row { display: flex; gap: 8px; margin-top: 16px; }
.newsletter-row input, .filter-input, .form-grid input, .form-grid textarea, .form-grid select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
.archive-hero { padding-block: 56px 32px; }
.archive-hero h1 { font-size: 64px; margin-top: 14px; line-height: 1.1; }
.archive-hero p { font-size: 18px; color: var(--muted); margin-top: 12px; max-width: 680px; }
.filter-bar { display: flex; gap: 14px; align-items: center; padding-bottom: 18px; }
.search-box { flex: 1; display: flex; gap: 10px; align-items: center; padding: 10px 14px; }
.search-box input { border: 0; background: transparent; outline: 0; flex: 1; }
.tabs-bar { border-bottom: 1px solid var(--border); padding-top: 10px; }
.tabs { display: flex; gap: 24px; overflow-x: auto; }
.tab { padding: 0 0 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--purple-600); }
.archive-grid { padding-block: 40px 56px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.pagination { padding-bottom: 64px; display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.page-btn { min-width: 36px; padding: 7px 11px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.page-btn.active { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.article-cover-hero { height: 420px; background: var(--gradient-brand); position: relative; overflow: hidden; }
.article-cover-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 35%, rgba(0,0,0,.58)); }
.cover-content { position: absolute; z-index: 1; right: 56px; left: 56px; bottom: 36px; color: #fff; }
.cover-chips { display: flex; gap: 10px; margin-bottom: 14px; }
.cover-chip-solid { background: rgba(255,255,255,.92); color: var(--purple-700); }
.cover-chip-ghost { background: rgba(255,255,255,.15); color: #fff; }
.article-layout { display: grid; grid-template-columns: 230px minmax(0, 760px) 240px; gap: 40px; padding: 40px 56px 64px; max-width: 1440px; margin: 0 auto; }
.toc-sidebar, .right-rail { position: sticky; top: 96px; align-self: start; }
.toc-label { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.toc-list { display: flex; flex-direction: column; gap: 10px; border-inline-end: 2px solid var(--border); padding-inline-end: 14px; }
.toc-item { font-size: 14px; color: var(--ink-2); }
.toc-item.active { color: var(--purple-600); font-weight: 600; }
.author-bar { display: flex; align-items: center; gap: 14px; padding-bottom: 24px; border-bottom: 1px solid var(--border); margin-bottom: 32px; }
.author-avatar-lg { width: 44px; height: 44px; border-radius: 50%; background: var(--gradient-brand); flex-shrink: 0; }
.author-info { flex: 1; }
.author-name { font-size: 15px; font-weight: 600; }
.author-meta { font-size: 13px; color: var(--muted); }
.article-body { max-width: 760px; }
.article-body p { font-size: 17px; line-height: 1.95; margin-bottom: 20px; }
.article-body > p:first-of-type { font-size: 21px; color: var(--ink-2); }
.article-body h2 { font-size: 32px; margin: 40px 0 14px; }
.article-body blockquote { border-inline-start: 4px solid var(--purple-500); padding: 12px 22px; margin: 28px 0; background: var(--gradient-soft); border-radius: 0 14px 14px 0; }
.article-body pre { direction: ltr; text-align: left; overflow: auto; background: var(--purple-900); color: #F3E2FB; padding: 20px; border-radius: 12px; }
.article-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }
.right-rail { display: flex; flex-direction: column; gap: 18px; }
.rail-card { padding: 18px; }
.related-item { display: flex; gap: 10px; margin-top: 12px; }
.related-thumb { width: 48px; height: 48px; border-radius: 10px; background: var(--gradient-brand); flex-shrink: 0; }
.related-title { font-size: 13px; font-weight: 600; line-height: 1.45; }
.admin-page, .setup-page { min-height: 100vh; }
.setup-page { display: grid; place-items: center; padding: 24px; }
.setup-card { width: min(720px, 100%); padding: 28px; }
.setup-card h1 { font-size: 34px; margin-bottom: 16px; }
.form-grid { display: grid; gap: 14px; margin-top: 18px; }
.form-grid label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.alert { padding: 12px 14px; border-radius: 10px; background: rgba(200,52,75,.12); color: var(--danger); margin: 10px 0; }
.admin-shell-lite { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.admin-sidebar-lite { background: var(--surface); border-inline-start: 1px solid var(--border); padding: 20px; }
.admin-nav-lite { display: grid; gap: 8px; margin-top: 24px; }
.admin-nav-lite a { padding: 10px 12px; border-radius: 10px; color: var(--ink-2); }
.admin-nav-lite a.active, .admin-nav-lite a:hover { background: var(--purple-100); color: var(--purple-700); }
.admin-main-lite { padding: 28px; overflow: auto; }
.admin-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; }
.admin-table { width: 100%; border-collapse: collapse; overflow: hidden; }
.admin-table th, .admin-table td { padding: 12px; border-bottom: 1px solid var(--border); text-align: right; font-size: 14px; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.editor-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.editor-main-card, .editor-side-card { padding: 18px; }
.content-editor { min-height: 380px; font-family: var(--font-arabic); line-height: 1.8; }

@media (max-width: 1100px) {
  .site-header { padding: 18px 22px; gap: 14px; }
  .hero, .articles-grid, .article-layout, .admin-shell-lite, .editor-grid { grid-template-columns: 1fr; }
  .hero, .categories, .latest, .archive-hero, .filter-bar, .tabs-bar, .archive-grid, .pagination, .article-layout { padding-inline: 22px; }
  .archive-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toc-sidebar { display: none; }
  .right-rail { position: static; }
}
@media (max-width: 700px) {
  .hero-headline, .archive-hero h1 { font-size: clamp(28px,7vw,42px); }
  .cover-content h1 { font-size: 28px !important; }
  .archive-grid { grid-template-columns: 1fr; }
  .filter-bar, .section-header { align-items: stretch; flex-direction: column; }
  .site-footer .footer-grid { grid-template-columns: 1fr; }
  .site-footer .footer-bottom { flex-direction: column; gap: 8px; }
  .hero-featured { min-height: 300px; }
}

/* Dynamic frontend glue: keep PHP templates visually aligned with the static back design. */
html { scroll-behavior: smooth; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }

.site-header {
  padding: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.header-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
  padding: 12px 36px;
}
.logo-mark { width: 40px; height: 40px; flex-shrink: 0; }
.header-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  gap: 2px;
  font-size: 14px;
  color: var(--ink-2);
  overflow: visible;
}
.header-nav a:hover, .header-nav a.active { color: var(--ink); font-weight: 600; }
.header-nav > a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  white-space: nowrap;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  transition: background 140ms, color 140ms;
}
.header-nav > a:hover { background: var(--surface-2); color: var(--ink); font-weight: normal; }
.header-nav > a.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
/* Hide icons in the top nav bar — only show in dropdown menus */
.header-nav > a .nav-icon,
.header-nav > .nav-dropdown > .nav-link .nav-icon { display: none; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  border-bottom: none;
  white-space: nowrap;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background 140ms, color 140ms;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { color: var(--purple-500); background: rgba(155,48,200,.08); }
[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .header-nav > a:hover { background: var(--surface-3); }
[data-theme="dark"] .nav-link.active { background: rgba(184,95,223,.12); color: var(--purple-300); }
.nav-icon { display: inline-flex; align-items: center; color: currentColor; }
.nav-caret { opacity: .6; transition: transform .2s; flex-shrink: 0; }
.nav-dropdown { position: relative; }
.nav-dropdown:hover > .nav-link .nav-caret,
.nav-dropdown:focus-within > .nav-link .nav-caret { transform: rotate(180deg); }
.nav-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .15s, transform .15s, visibility .15s;
  z-index: 200;
}
.nav-dropdown:hover .nav-menu,
.nav-dropdown:focus-within .nav-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.nav-menu a {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  white-space: nowrap;
  font-size: 13.5px;
}
.nav-menu a:hover,
.nav-menu a.active {
  color: var(--purple-600);
  background: var(--surface-2);
  font-weight: 500;
}
[data-theme="dark"] .nav-menu a:hover,
[data-theme="dark"] .nav-menu a.active { color: var(--purple-300); background: var(--surface-3); }
.nav-menu .nav-icon { display: inline-flex; }
.nav-menu .nav-menu-child { padding-right: 28px; font-size: 12.5px; opacity: .85; }
/* ── Logo from settings ── */
.logo-img {
  height: 38px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
  display: block;
}

/* ── Mobile Nav Drawer ── */
.nav-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s;
}
.nav-drawer-overlay.open { opacity: 1; pointer-events: auto; }
.nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: var(--surface);
  z-index: 9999;
  transform: translateX(110%);
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -8px 0 40px rgba(0,0,0,.25);
}
.nav-drawer.open { transform: translateX(0); }
.nav-drawer-head {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
  min-height: 56px;
}
.nav-drawer-close {
  position: absolute;
  left: 12px;
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  transition: background .14s;
}
.nav-drawer-close:hover { background: var(--surface-2); }
.nav-drawer-logo-img {
  height: 32px;
  width: auto;
  max-width: 130px;
  object-fit: contain;
}
.nav-drawer-logo-text {
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
}
.nav-drawer-body { flex: 1; overflow-y: auto; }
.nav-drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 20px;
  color: var(--ink);
  font-size: 15.5px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  transition: background .14s;
  text-decoration: none;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  cursor: pointer;
  font-family: inherit;
  text-align: right;
}
.nav-drawer-item:hover { background: var(--surface-2); }
.nav-drawer-item-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(155,48,200,.08);
  border-radius: var(--r-sm);
  color: var(--purple-500);
  flex-shrink: 0;
  order: -1; /* icon on the right in RTL (first in source = rightmost in RTL) */
}
[data-theme="dark"] .nav-drawer-item-icon { background: rgba(184,95,223,.12); }
.nav-drawer-label { flex: 1; }
.nav-drawer-caret { color: var(--muted); transition: transform .2s; flex-shrink: 0; }
.nav-drawer-toggle[aria-expanded="true"] .nav-drawer-caret { transform: rotate(180deg); }
.nav-drawer-children {
  display: none;
  flex-direction: column;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.nav-drawer-children.open { display: flex; }
.nav-drawer-child {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 20px 11px 20px;
  padding-right: 54px;
  font-size: 14px;
  color: var(--ink-2);
  border-bottom: 1px solid var(--border);
  transition: background .14s, color .14s;
}
.nav-drawer-child:last-child { border-bottom: none; }
.nav-drawer-child:hover { background: var(--surface-3); color: var(--purple-600); }
[data-theme="dark"] .nav-drawer-child:hover { color: var(--purple-300); }

.menu-toggle {
  display: none;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 6px;
}

.article-cover { aspect-ratio: 16 / 10; background: var(--gradient-brand); }
.article-cover[style*="height"] { aspect-ratio: auto; }
.article-card:hover { transform: translateY(-2px); transition: transform 180ms ease; }
.article-card:hover .article-cover img { transform: scale(1.035); }
.article-cover img { transition: transform 220ms ease; }
.article-cover .cover-cat, .cover-cat {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,.92);
  color: var(--purple-700);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
}
.cover-shine {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(255,255,255,.18), transparent 55%);
  pointer-events: none;
}
.articles-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.author-avatar,
.author-avatar-lg {
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
}
.author-avatar img,
.author-avatar-lg img,
.related-thumb img { width: 100%; height: 100%; object-fit: cover; }

.home-feature-grid { grid-template-columns: 1.4fr 1fr 1fr; }
.home-large-card .article-cover { height: 360px !important; aspect-ratio: auto; }
.compact-newsletter { display: block; color: var(--ink); }

.filter-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; width: 100%; }
.filter-search { flex: 1; min-width: 240px; position: relative; }
.filter-search form { width: 100%; }
.filter-search .si { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filter-search input {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  outline: none;
}
.filter-sort select { min-width: 150px; }
.tab-btn {
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
}
.tab-btn.active,
.tab-btn:hover { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.archive-filter { padding-bottom: 18px; }
.archive-sort {
  min-width: 210px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
.archive-grid {
  padding: 40px 56px 56px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
}
.archive-grid .article-cover {
  height: 220px !important;
  aspect-ratio: auto;
}
.archive-grid .article-card h3 {
  font-size: 22px !important;
  line-height: 1.3 !important;
}
.archive-grid .article-card p {
  font-size: 15px !important;
}
.archive-results {
  padding-inline: 56px;
  margin: 22px 0 0;
}
.archive-tags {
  margin: 0 56px 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.archive-tags h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}
.pagination { margin-top: 48px; padding-inline: 0; }
.page-link {
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
}
.page-link.active { background: var(--gradient-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-glow); }
.page-link.disabled { opacity: .45; pointer-events: none; }
.search-results-count { color: var(--muted); margin-bottom: 22px; }

.tags-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}
.tag-chip:hover { background: var(--purple-100); color: var(--purple-700); }
.tag-count { font-size: 11px; color: var(--muted-2); }

.article-body :where(p, div) {
  font-size: 17px;
  line-height: 1.95;
  margin-bottom: 20px;
}
.article-body h2 { font-size: 32px; margin: 40px 0 14px; }
.article-body h3 { font-size: 24px; margin: 32px 0 12px; }
.article-body ul,
.article-body ol { padding-right: 24px; margin-bottom: 20px; }
.article-body ul li { list-style: disc; }
.article-body ol li { list-style: decimal; }
.article-body li { margin-bottom: 8px; }
.article-body blockquote {
  border-inline-start: 4px solid var(--purple-500);
  padding: 12px 22px;
  margin: 28px 0;
  background: var(--gradient-soft);
  border-radius: 0 14px 14px 0;
}
.article-body pre {
  direction: ltr;
  text-align: left;
  overflow: auto;
  background: var(--purple-900);
  color: #F3E2FB;
  padding: 20px;
  border-radius: 12px;
}
.article-body code { font-family: var(--font-mono); }
.article-body img,
.article-body iframe,
.article-body video {
  max-width: 100%;
  border-radius: 16px;
  margin: 28px auto;
}
.article-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }

.share-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
}
.like-btn.liked { border-color: var(--purple-400); color: var(--purple-600); }

.author-box,
.comments-section,
.comment-form {
  margin-top: 32px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.author-box { display: flex; gap: 16px; align-items: flex-start; }
.author-box-avatar,
.comment-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.author-box-avatar img { width: 100%; height: 100%; object-fit: cover; }
.author-box-name { font-weight: 700; margin-bottom: 4px; }
.author-box-bio,
.comment-date,
.comment-text { color: var(--muted); font-size: 14px; }
.comments-list { display: grid; gap: 14px; margin-top: 18px; }
.comment-item { display: flex; gap: 12px; }
.comment-author { font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: grid; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 13px; color: var(--ink-2); }
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
.no-results { text-align: center; padding: 56px 20px; color: var(--muted); }
.no-results .icon { font-size: 42px; margin-bottom: 12px; }
.scroll-top-btn.visible { display: flex !important; }

.brand-page { max-width: 1280px; margin: 0 auto; padding: 64px 56px; }
.brand-section { padding: 64px 0; border-bottom: 1px solid var(--border); }
.brand-section:last-child { border-bottom: 0; }
.brand-section-title {
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 20px;
}
.swatch-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.swatch {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 10px;
}
.swatch-color { height: 72px; border-radius: 12px; margin-bottom: 10px; }
.swatch-name { font-family: var(--font-mono); color: var(--ink-2); line-height: 1.45; }
.font-sample { font-size: clamp(44px, 8vw, 96px); font-weight: 700; line-height: 1; }

@media (max-width: 1100px) {
  /* header stays in ONE row — no wrapping */
  .header-inner { padding: 18px 22px; }
  .articles-grid,
  .archive-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-feature-grid { grid-template-columns: 1fr 1fr; }
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .toc-sidebar { display: none; }
  .right-rail { position: static; }
  .swatch-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  /* ── Header mobile ── */
  :root { --topbar-h: 36px; }
  .header-topbar { height: var(--topbar-h); }
  .topbar-pages a { font-size: 13px; padding: 3px 9px; }
  .topbar-social { gap: 2px; }
  .site-header .header-inner { padding: 12px 16px; flex-wrap: nowrap; }
  .header-nav { display: none !important; }
  .menu-toggle { display: flex !important; align-items: center; justify-content: center; }
  .header-actions .btn-primary { display: none; }
  .header-actions .btn-ghost:not([data-theme-toggle]):not([aria-label="بحث"]) { display: none; }
  .logo-text { font-size: 18px; }
  .logo-img { height: 32px; }

  /* ── Grids ── */
  .articles-grid,
  .archive-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .home-feature-grid { grid-template-columns: 1fr !important; gap: 16px; }

  /* ── Home cards ── */
  .hero { padding: 32px 20px 20px; grid-template-columns: 1fr; gap: 24px; }
  .hero-headline { font-size: clamp(28px, 7vw, 42px); }
  .hero-featured { height: 300px; border-radius: 18px; }
  .hero-featured .featured-title { font-size: 22px; }
  .categories { padding: 14px 20px; }
  .latest { padding: 24px 20px 40px; }
  .section-title { font-size: 26px; }
  /* Force home large card thumbnail = 220px on mobile */
  .home-large-card .article-cover { height: 220px !important; }

  /* ── Article page ── */
  .toc-sidebar { display: none !important; }
  .right-rail { display: none; }
  .article-layout { grid-template-columns: 1fr; padding: 20px 16px 40px; }
  .article-hero-overlay { padding: 20px 16px; }
  .author-bar { flex-wrap: wrap; gap: 10px; }

  /* ── Archive / filter ── */
  .filter-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .archive-results { padding-inline: 20px; }
  .archive-tags { margin: 0 20px 40px; }
  .form-row { grid-template-columns: 1fr; }

  /* ── Footer ── */
  .site-footer { padding: 36px 20px 24px; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
  .brand-page { padding: 40px 20px; }
  .brand-section { padding: 40px 0; }
  .swatch-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .articles-grid,
  .archive-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; gap: 8px; text-align: center; }
}
