/*
Theme Name: Maharah Blog
Theme URI: https://maharahconsult.sa
Author: Maharah Consult
Author URI: https://maharahconsult.sa
Description: قالب مدونة احترافي لشركة مهارة للمحاماة والاستشارات - تصميم عصري متوافق مع هوية المهرة
Version: 2.0.0
Requires at least: 5.8
Tested up to: 6.6
Requires PHP: 7.4
Text Domain: maharah-blog
Tags: blog, rtl-language-support, featured-images, translation-ready, right-to-left
*/

/* ====== Maharah Blog - Professional Design ====== */

/* CSS Variables - Maharah Brand Colors */
:root {
  /* Brand Colors */
  --maharah-forest: #0D493E;
  --maharah-forest-alt: #0C4A3F;
  --maharah-sage: #E7EDEC;
  --maharah-gold: #BB9A70;
  --maharah-gold-hover: #a88760;
  --maharah-ivory: #FFF6EE;

  /* Text Colors */
  --text-primary: var(--maharah-forest);
  --text-secondary: rgba(13, 73, 62, 0.7);
  --text-muted: rgba(13, 73, 62, 0.5);

  /* Background Colors */
  --bg-primary: var(--maharah-sage);
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(13, 73, 62, 0.03);
  --bg-white: #ffffff;

  /* Accent Colors */
  --accent-primary: var(--maharah-gold);
  --accent-hover: var(--maharah-gold-hover);
  --border-color: rgba(13, 73, 62, 0.1);
  --border-hover: rgba(187, 154, 112, 0.3);
  --shadow-sm: 0 1px 6px rgba(13, 73, 62, 0.04);
  --shadow-md: 0 4px 12px rgba(13, 73, 62, 0.08);
  --shadow-lg: 0 10px 40px rgba(13, 73, 62, 0.12);
}

/* ====== Global Reset & Typography ====== */
html[lang="ar"] {
  direction: rtl;
  text-align: right;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Jannat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-primary);
  background: var(--bg-primary);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

a {
  color: var(--text-primary);
  text-decoration: none;
  transition: all 0.3s ease;
}

/* ====== Container ====== */
.container {
  width: min(1400px, 92%);
  margin-inline: auto;
  padding: 0 1rem;
}

/* ====== Header ====== */
.site-header {
  background: linear-gradient(135deg, var(--maharah-forest) 0%, var(--maharah-gold) 100%);
  border-bottom: none;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 9999;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
  height: 80px;
  width: 100%;
}

.site-header.sticky,
.site-header.fixed,
body.scrolled .site-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
}

.site-header .wrap {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px;
  padding: 0 !important;
  height: 80px !important;
  flex-direction: row !important;
  text-align: right !important;
}

.site-header .wrap.header-stack {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px;
  padding: 0 !important;
  height: 80px !important;
  text-align: right !important;
}

.branding {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  order: 1 !important;
  flex: 0 0 auto !important;
}

.main-nav {
  order: 2 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 1 !important;
}

.header-spacer {
  order: 3 !important;
  flex: 0 0 auto !important;
}

.brand-logo {
  display: block;
  height: 50px !important;
  width: auto;
  max-width: 120px;
  filter: brightness(0) invert(1);
  transition: transform 0.3s ease;
}

.brand-logo:hover {
  transform: scale(1.05);
}

/* ====== Navigation ====== */
.main-nav ul,
.footer-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.main-nav ul {
  justify-content: center;
  flex: 0 0 auto;
  margin: 0 auto;
}

.main-nav a,
.footer-nav a {
  color: #ffffff;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.main-nav a::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--maharah-gold);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.main-nav a:hover {
  background: rgba(255, 255, 255, 0.2);
}

.main-nav a:hover::before {
  transform: scaleX(1);
}

/* ====== Headings ====== */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  line-height: 1.4;
  margin: 0 0 16px;
  font-weight: 700;
}

h1 {
  font-size: 2.5rem;
  background: linear-gradient(135deg, var(--maharah-forest) 0%, var(--maharah-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 1.8rem;
}

h3 {
  font-size: 1.4rem;
}

/* ====== Hero Section ====== */
.blog-hero {
  width: 100%;
  background: linear-gradient(135deg, var(--maharah-ivory) 0%, var(--maharah-sage) 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 120px 0 40px 0;
  text-align: center;
  margin-top: 0;
}

.blog-hero .hero-img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

/* ====== Posts Grid ====== */
.posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin: 40px 0;
}

@media (min-width: 768px) {
  .posts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .posts-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ====== Post Card ====== */
.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  backdrop-filter: blur(10px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.post-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-lg);
  background: var(--bg-card-hover);
}

.post-thumb {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, var(--maharah-sage) 0%, var(--maharah-ivory) 100%);
  transition: transform 0.5s ease;
}

.post-card:hover .post-thumb {
  transform: scale(1.1);
}

.post-thumb-container {
  overflow: hidden;
  position: relative;
}

.post-thumb-container::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, transparent 0%, rgba(13, 73, 62, 0.1) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.post-card:hover .post-thumb-container::after {
  opacity: 1;
}

.post-body {
  padding: 24px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.post-title {
  font-size: 1.25rem;
  margin: 0 0 12px;
  line-height: 1.4;
}

.post-title a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 700;
  display: block;
  background: linear-gradient(135deg, var(--maharah-forest) 0%, var(--maharah-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: all 0.3s ease;
}

.post-card:hover .post-title a {
  transform: translateX(-5px);
}

.post-excerpt {
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.6;
  flex-grow: 1;
}

.read-more {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px !important;
  margin-top: 20px !important;
  background: linear-gradient(135deg, var(--maharah-forest) 0%, var(--maharah-gold) 100%);
  color: #ffffff;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(13, 73, 62, 0.15);
}

.read-more:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(13, 73, 62, 0.25);
  filter: brightness(1.05);
}

/* ====== Post Meta ====== */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.post-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tag-item {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(187, 154, 112, 0.1);
  color: var(--maharah-gold);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid rgba(187, 154, 112, 0.2);
  transition: all 0.3s ease;
}

.tag-item:hover {
  background: rgba(187, 154, 112, 0.2);
  border-color: var(--maharah-gold);
  transform: translateY(-2px);
}

/* ====== Pagination ====== */
.pagination {
  margin: 40px 0;
  display: flex !important;
  justify-content: center !important;
  gap: 10px !important;
  flex-wrap: wrap;
}

.pagination ul {
  display: flex !important;
  justify-content: center !important;
  gap: 10px !important;
  flex-wrap: wrap;
  list-style: none !important;
  margin: 0;
  padding: 0;
  position: relative !important;
}

.pagination li {
  display: inline-flex;
  position: relative !important;
}

.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  padding: 0 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  background: var(--bg-card);
  font-weight: 600;
  transition: all 0.3s ease;
  position: relative !important;
}

.pagination .page-numbers:hover {
  border-color: var(--maharah-gold);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.pagination .page-numbers.current {
  background: linear-gradient(135deg, var(--maharah-forest) 0%, var(--maharah-gold) 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(13, 73, 62, 0.2);
}

/* ====== Single Article ====== */
.single-article {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 40px;
  box-shadow: var(--shadow-md);
  margin-top: 40px;
  backdrop-filter: blur(10px);
}

.single-article header {
  margin-bottom: 32px;
  text-align: center;
}

.single-article h1 {
  margin-bottom: 24px;
}

.single-article img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  margin: 24px 0;
}

.entry-content {
  font-size: 1.1rem;
  line-height: 1.8;
  color: var(--text-primary);
}

.entry-content h2,
.entry-content h3 {
  margin-top: 32px;
  margin-bottom: 16px;
}

.entry-content p {
  margin-bottom: 16px;
}

.single-meta {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 2px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.single-meta > div {
  margin-bottom: 12px;
}

.single-meta strong {
  color: var(--text-primary);
  font-weight: 700;
}

.single-meta a {
  color: var(--maharah-gold);
  font-weight: 600;
}

.single-meta a:hover {
  color: var(--maharah-gold-hover);
  text-decoration: underline;
}

/* ====== Footer ====== */
.site-footer {
  margin-top: 60px;
  border-top: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--maharah-forest) 0%, var(--maharah-gold) 100%);
  color: #ffffff;
  padding: 40px 0 20px;
}

.site-footer .wrap {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.copy {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
}

.footer-nav a {
  color: rgba(255, 255, 255, 0.9);
  padding: 8px 12px;
}

.footer-nav a:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* ====== Search Form ====== */
.search-form {
  display: flex;
  gap: 12px;
  margin: 40px 0;
  max-width: 600px;
  margin-inline: auto;
}

.search-field {
  flex: 1;
  padding: 14px 20px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: all 0.3s ease;
}

.search-field:focus {
  outline: none;
  border-color: var(--maharah-gold);
  box-shadow: 0 0 0 3px rgba(187, 154, 112, 0.1);
}

.search-submit {
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--maharah-forest) 0%, var(--maharah-gold) 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(13, 73, 62, 0.2);
}

.search-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(13, 73, 62, 0.3);
  filter: brightness(1.1);
}

/* ====== Category Filter ====== */
.category-filter {
  display: flex;
  gap: 12px;
  margin: 32px 0;
  flex-wrap: wrap;
  justify-content: center;
}

.filter-item {
  padding: 10px 20px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
}

.filter-item:hover,
.filter-item.active {
  background: linear-gradient(135deg, var(--maharah-forest) 0%, var(--maharah-gold) 100%);
  color: #ffffff;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(13, 73, 62, 0.2);
}

/* ====== Responsive Design ====== */
@media (max-width: 768px) {
  h1 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 1.4rem;
  }

  .single-article {
    padding: 24px;
  }

  .site-header .wrap {
    flex-direction: column;
    text-align: center;
  }

  .main-nav ul {
    justify-content: center;
  }

  .search-form {
    flex-direction: column;
  }

  .search-submit {
    width: 100%;
  }
}

/* ====== Accessibility ====== */
.screen-reader-text {
  position: absolute;
  clip: rect(1px, 1px, 1px, 1px);
  padding: 0;
  border: 0;
  height: 1px;
  width: 1px;
  overflow: hidden;
  word-wrap: normal !important;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--maharah-forest);
  color: #ffffff;
  padding: 8px 16px;
  z-index: 10000;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 0;
}

/* Focus Styles */
a:focus,
button:focus,
input:focus {
  outline: 2px solid var(--maharah-gold);
  outline-offset: 2px;
}

/* ====== Animations ====== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.post-card {
  animation: fadeInUp 0.6s ease backwards;
}

.post-card:nth-child(1) { animation-delay: 0.1s; }
.post-card:nth-child(2) { animation-delay: 0.2s; }
.post-card:nth-child(3) { animation-delay: 0.3s; }
.post-card:nth-child(4) { animation-delay: 0.4s; }
.post-card:nth-child(5) { animation-delay: 0.5s; }
.post-card:nth-child(6) { animation-delay: 0.6s; }
.post-card:nth-child(7) { animation-delay: 0.7s; }
.post-card:nth-child(8) { animation-delay: 0.8s; }
.post-card:nth-child(9) { animation-delay: 0.9s; }

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
/* =========================================
   MAHARAH STRICT FIXES (ADD TO BOTTOM OF FILE)
   ========================================= */

/* 1. FORCE HEADER RESET (إلغاء التثبيت وتصغير الحجم) */
.site-header, header.site-header {
    position: fixed !important; /* تثبيت الهيدر */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 80px !important;
    padding: 0 !important;
    background: linear-gradient(135deg, #0D493E 0%, #0a3830 100%) !important;
}

/* 2. FLEX LAYOUT FOR HEADER (ترتيب أفقي) */
.header-flex-container, .site-header .wrap {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: 80px !important;
    padding: 0 20px !important;
    max-width: 1400px;
    margin: 0 auto;
}

/* 3. LOGO SIZE (تصغير اللوجو) */
.brand-logo, .branding img {
    height: 50px !important;
    width: auto !important;
    max-width: 120px !important;
    margin: 0 !important;
}

/* 4. CARD BUTTONS (تحسين أزرار البطاقات) */
.post-body {
    display: flex;
    flex-direction: column;
}

.post-excerpt {
    flex-grow: 1; /* يدفع الزر للأسفل */
}

.read-more, a.read-more {
    display: inline-block !important;
    width: fit-content !important;
    margin-top: 25px !important; /* مسافة من الأعلى */
    padding: 8px 25px !important;
    height: auto !important;
    background: #0D493E !important;
    color: #fff !important;
    border-radius: 6px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
}

/* 5. PAGINATION FIX (إصلاح تكدس الأرقام) */
.pagination, .pagination ul, ul.page-numbers {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
    margin: 40px auto !important;
    padding: 0 !important;
    list-style: none !important;
}

.pagination li {
    display: inline-flex !important;
    margin: 0 !important;
}

.pagination .page-numbers {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 40px !important;
    height: 40px !important;
    border: 1px solid #ddd !important;
    border-radius: 5px !important;
    padding: 0 !important;
    position: static !important; /* إلغاء أي تموضع مطلق */
}