/* ══════════════════════════════════════════════════════
   BLOG — Dark RTL Arabic Theme
   Font: Lateef (Google Fonts)
   ══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Lateef:wght@200;300;400;500;600;700;800&display=swap');

/* ── CSS VARIABLES ────────────────────────────────────── */
:root {
  /* Dark mode (default) */
  --bg:          #141416;
  --bg2:         #1c1c1f;
  --bg3:         #232326;
  --surface:     #28282c;
  --surface2:    #303034;
  --border:      rgba(255,255,255,.07);
  --border2:     rgba(255,255,255,.12);
  --text:        #e8e8f0;
  --text2:       #9090a8;
  --text3:       #55556a;
  --heading:     #ffffff;
  --accent:      #a855f7;
  --accent2:     #c084fc;
  --accent-bg:   rgba(168,85,247,.12);
  --card-shadow: 0 4px 24px rgba(0,0,0,.4);
  --card-hover:  0 8px 40px rgba(0,0,0,.6);
  --navbar-bg:   rgba(20,20,22,.92);
  --radius:      14px;
  --radius-sm:   8px;
  --font:        'Lateef', serif;
}

/* Light mode */
body.light-mode {
  --bg:          #f5f3ef;
  --bg2:         #edeae4;
  --bg3:         #e4e0d8;
  --surface:     #ffffff;
  --surface2:    #f0ece4;
  --border:      rgba(0,0,0,.08);
  --border2:     rgba(0,0,0,.14);
  --text:        #2a2a2a;
  --text2:       #666666;
  --text3:       #999999;
  --heading:     #111111;
  --card-shadow: 0 4px 24px rgba(0,0,0,.08);
  --card-hover:  0 8px 40px rgba(0,0,0,.14);
  --navbar-bg:   rgba(245,243,239,.95);
}

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

html {
  direction: rtl;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.8;
  min-height: 100vh;
  transition: background .3s ease, color .3s ease;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color .2s;
}

img {
  max-width: 100%;
  display: block;
}

/* ── NAVBAR ───────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 16px;
  z-index: 1000;
  padding: 0 20px;
  pointer-events: none;
}

.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(18,18,22,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border2);
  border-radius: 40px;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
  pointer-events: all;
  transition: background .3s;
}

body.light-mode .navbar-inner {
  background: rgba(255,255,255,.92);
  border-color: var(--border2);
  box-shadow: 0 4px 24px rgba(0,0,0,.1);
}

/* Logo — right side in RTL */
.navbar-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.navbar-logo img {
  height: 36px;
  width: auto;
}

.navbar-logo-text {
  font-family: 'Belanosima', sans-serif;
  font-size: 22px;
  font-weight: 400;
  color: #a855f7;
  letter-spacing: .02em;
}

/* ── HERO SECTION ─────────────────────────────────────── */
.hero {
  width: 100%;
  position: relative;
  overflow: hidden;
  margin-top: -88px;
}

.hero-img {
  width: 100%;
  height: 520px;
  object-fit: cover;
  display: block;
}

.hero-curve {
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  line-height: 0;
}

.hero-curve svg {
  display: block;
  width: 100%;
}

/* Nav links — centered */
.navbar-links {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  list-style: none;
}

.navbar-links li {
  position: relative;
}

.navbar-links a {
  display: block;
  padding: 6px 16px;
  font-size: 17px;
  font-weight: 500;
  color: var(--text2);
  border-radius: 20px;
  transition: all .2s;
  white-space: nowrap;
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--heading);
  background: var(--surface);
}

.navbar-links a.active {
  position: relative;
}

.navbar-links a.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: 16px;
  left: 16px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* Dropdown */
.navbar-links .dropdown {
  position: relative;
}

.navbar-links .dropdown > a {
  display: flex;
  align-items: center;
  gap: 6px;
}

.navbar-links .dropdown > a::before {
  content: '▾';
  font-size: 12px;
  order: -1;
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-width: 180px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  list-style: none;
  z-index: 100;
}

.dropdown:hover .dropdown-menu {
  display: block;
}

.dropdown-menu li a {
  display: block;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 16px;
  color: var(--text2);
}

.dropdown-menu li a:hover {
  background: var(--surface);
  color: var(--heading);
}

/* Right controls — left side in RTL */
.navbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.navbar-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s;
  font-size: 16px;
}

.navbar-btn:hover {
  background: var(--surface2);
  color: var(--heading);
  border-color: var(--border2);
}

/* Search overlay */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(10px);
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.search-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.search-box {
  width: 100%;
  max-width: 600px;
  padding: 0 24px;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 50px;
  padding: 12px 20px;
  gap: 12px;
}

.search-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 20px;
  color: var(--text);
  direction: rtl;
}

.search-input-wrap input::placeholder {
  color: var(--text3);
}

.search-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  transition: color .2s;
}

.search-close:hover { color: var(--text); }

.search-results {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-result-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  cursor: pointer;
  transition: all .15s;
}

.search-result-item:hover {
  border-color: var(--border2);
  background: var(--surface);
}

.search-result-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 4px;
}

.search-result-meta {
  font-size: 14px;
  color: var(--text3);
}

/* ── MAIN CONTAINER ───────────────────────────────────── */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px;
}

main {
  padding-top: 16px;
}

/* ── SECTION TITLES ───────────────────────────────────── */
.section-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 26px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
  order: 1;
}

/* ── FEATURED POSTS — 3 columns ───────────────────────── */
.featured-section {
  padding: 48px 0 40px;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.featured-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: transform .25s ease, box-shadow .25s ease;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.featured-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-hover);
  border-color: var(--border2);
}

.featured-card-img {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  display: block;
}

.featured-card-img-placeholder {
  width: 100%;
  aspect-ratio: 16/10;
  background: var(--surface2);
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 40px;
}

.featured-card-body {
  padding: 18px 20px 20px;
}

.featured-card-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── LATEST POSTS — wide horizontal cards ─────────────── */
.latest-section {
  padding: 8px 0 60px;
}

.latest-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.latest-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  transition: transform .25s ease, box-shadow .25s ease;
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 200px;
  text-decoration: none;
  color: inherit;
}

.latest-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-hover);
  border-color: var(--border2);
}

/* RTL — image on the right */
.latest-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  order: 2;
}

.latest-card-img-placeholder {
  width: 100%;
  height: 100%;
  min-height: 200px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text3);
  font-size: 36px;
  order: 2;
}

.latest-card-body {
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  order: 1;
}

.latest-card-top {}

.category-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text2);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.category-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.latest-card-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.5;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.latest-card-excerpt {
  font-size: 17px;
  color: var(--text2);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 16px;
}

.latest-card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--text3);
}

.latest-card-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ── SINGLE POST PAGE ─────────────────────────────────── */
.post-page {
  max-width: 1280px;
  margin: 40px auto 80px;
  padding: 0 28px;
}

/* The card itself */
.post-card {
  background: #1e1e24;
  border: 1px solid var(--border2);
  border-radius: 20px;
  overflow: visible;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}

body.light-mode .post-card {
  background: #ffffff;
  border-color: var(--border2);
}

/* Cover — flush top, sides, no radius on top corners of card */
.post-cover-wrap {
  position: relative;
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  margin: 0;
}

.post-cover-img {
  width: 100%;
  aspect-ratio: 16/7;
  object-fit: cover;
  display: block;
  border-radius: 20px 20px 0 0;
}

/* Category + tag pills — bottom right */
.post-cover-pills {
  position: absolute;
  bottom: 16px;
  right: 16px;
  top: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  z-index: 3;
}

/* Date + reading time — normal flow, top right below cover */
/* Page is dir=rtl so flex-start = physical right, flex-end = physical left */
.post-top-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-size: 13px;
  color: var(--text2);
  padding: 10px 20px 0 0;
  width: 100%;
}

.post-pill {
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.post-pill.category {
  background: rgba(168,85,247,.85);
  color: #fff;
}

.post-pill.tag {
  background: rgba(0,0,0,.55);
  color: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.2);
}

/* Author — centered, half over cover, half below */
.post-author {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: -55px;
  margin-bottom: 20px;
  position: relative;
  z-index: 2;
  padding: 0 32px;
}

.post-author-avatar {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #1e1e24;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

body.light-mode .post-author-avatar {
  border-color: #ffffff;
}

.post-author-avatar-placeholder {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--surface2);
  border: 3px solid #1e1e24;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--text3);
  margin-top: -55px;
}

.post-author-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--heading);
}

.post-author-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--text3);
}

/* Card content area */
.post-card-body {
  padding: 0 36px 36px;
}

/* Post content */
.post-title {
  font-size: 36px;
  font-weight: 800;
  color: var(--heading);
  line-height: 1.4;
  margin-bottom: 24px;
  text-align: right;
}

.post-content {
  font-size: 20px;
  line-height: 1.9;
  color: var(--text);
  text-align: right;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  color: var(--heading);
  margin: 32px 0 14px;
  font-weight: 700;
  line-height: 1.4;
}

.post-content h2 { font-size: 28px; }
.post-content h3 { font-size: 24px; }
.post-content p  { margin-bottom: 20px; }

.post-content a {
  color: var(--accent2);
  border-bottom: 1px solid rgba(168,85,247,.3);
  transition: border-color .2s;
}

.post-content a:hover { border-color: var(--accent); }

.post-content ul,
.post-content ol {
  margin: 0 20px 20px 0;
}

.post-content li { margin-bottom: 6px; }

.post-content blockquote {
  border-right: 4px solid var(--accent);
  margin: 28px 0;
  padding: 14px 20px;
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text2);
  font-style: italic;
}

.post-content img {
  border-radius: var(--radius-sm);
  margin: 20px 0;
  max-width: 100%;
}

/* ── TERMINAL CODE BLOCKS ─────────────────────────────── */
.post-content pre {
  margin: 28px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  direction: ltr;
  text-align: left;
}

.code-block-wrap {
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 28px 0;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  direction: ltr;
}

.code-block-header {
  background: #2d2d30;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.code-block-dots {
  display: flex;
  gap: 6px;
}

.code-block-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot-red    { background: #ff5f57; }
.dot-yellow { background: #febc2e; }
.dot-green  { background: #28c840; }

.code-block-lang {
  font-size: 12px;
  color: #888;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  letter-spacing: .05em;
}

.code-block-copy {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 4px;
  color: #aaa;
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all .15s;
  font-family: sans-serif;
}

.code-block-copy:hover { background: rgba(255,255,255,.15); color: #fff; }
.code-block-copy.copied { color: #28c840; border-color: #28c840; }

.code-block-body {
  background: #1e1e1e;
  padding: 18px 20px;
  overflow-x: auto;
}

.code-block-body code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.7;
  color: #d4d4d4;
}

/* Inline code */
.post-content code:not(pre code) {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: .85em;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  color: var(--accent2);
  direction: ltr;
  display: inline-block;
}

/* ── FOOTER ───────────────────────────────────────────── */
.footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 48px 0 28px;
  margin-top: 60px;
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.footer-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-links a {
  color: var(--text2);
  font-size: 16px;
  transition: color .2s;
}

.footer-links a:hover { color: var(--accent2); }

.footer-bottom {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 28px 0;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text3);
}

/* ── UTILITIES ────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
  font-size: 18px;
}

.no-posts {
  text-align: center;
  padding: 80px 20px;
  color: var(--text3);
}

.no-posts-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 16px;
  opacity: .3;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 40px;
}

.page-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  transition: all .15s;
  font-family: var(--font);
}

.page-btn:hover,
.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 900px) {
  .featured-grid {
    grid-template-columns: 1fr 1fr;
  }
  .featured-grid .featured-card:last-child {
    display: none;
  }
  .latest-card {
    grid-template-columns: 220px 1fr;
  }
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .navbar-links { display: none; }
  .featured-grid { grid-template-columns: 1fr; }
  .latest-card {
    grid-template-columns: 1fr;
  }
  .latest-card-img,
  .latest-card-img-placeholder {
    height: 200px;
    order: 1;
  }
  .latest-card-body { order: 2; }
  .post-title { font-size: 28px; }
  .post-content { font-size: 18px; }
  .footer-inner { grid-template-columns: 1fr; }
}
