/*
Theme Name: APKGT
Theme URI: https://apkgt.com/
Author: APKGT Team
Author URI: https://apkgt.com/
Description: قالب ووردبريس خفيف وسريع جداً، مخصص لمدونات التطبيقات والألعاب. كود نظيف بدون أي مكتبات خارجية أو أطر عمل ثقيلة، متوافق 100% مع سياسات Google AdSense ومعايير Core Web Vitals، ويدعم RTL واللغة العربية.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: apkgt
Tags: rtl-language-support, blog, news, one-column, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready
*/

/* ==========================================================================
   ملاحظة مهمة: الكتلة (Header Block) أعلاه إلزامية في WordPress
   وهي ما يجعل القالب يظهر في: المظهر ← الثيمات
   ========================================================================== */

/* ==========================================================================
   1) إعادة الضبط (Reset) + المتغيرات العامة
   ========================================================================== */
:root {
  /* الألوان الأساسية - غيّرها من مكان واحد فقط */
  --apkgt-bg: #ffffff;
  --apkgt-surface: #f6f8fb;
  --apkgt-text: #1e293b;
  --apkgt-text-soft: #64748b;
  --apkgt-primary: #2563eb;      /* اللون الرئيسي (أزرق) */
  --apkgt-primary-dark: #1e40af;
  --apkgt-accent: #10b981;       /* لون التمييز (أخضر) - يصلح لأزرار التحميل */
  --apkgt-border: #e2e8f0;

  /* المسافات والقياسات */
  --apkgt-radius: 12px;
  --apkgt-container: 1200px;
  --apkgt-gap: 24px;

  /* الخط: نظامي 100% بدون تحميل خطوط خارجية = سرعة أعلى */
  --apkgt-font: -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Kufi Arabic", "Tajawal", Arial, sans-serif;
}

/* إعادة ضبط بسيطة وحديثة */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--apkgt-font);
  font-size: 16px;
  line-height: 1.7;
  color: var(--apkgt-text);
  background-color: var(--apkgt-bg);
}

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

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

a:hover {
  color: var(--apkgt-primary-dark);
}

ul,
ol {
  list-style: none;
}

/* ==========================================================================
   2) أدوات مساعدة عامة (Utilities)
   ========================================================================== */

/* الحاوية: تتمحور وتتكيف مع كل الشاشات */
.container {
  max-width: var(--apkgt-container);
  margin-inline: auto; /* خاصية منطقية = تعمل تلقائياً مع RTL و LTR */
  padding-inline: 16px;
}

/* إخفاء النصوص مع إبقائها متاحة لقارئات الشاشة (SEO + إتاحة) */
.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  width: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute !important;
  word-wrap: normal !important;
}

/* رابط تخطي التنقل: مهم لقارئات الشاشة */
.skip-link {
  position: absolute;
  top: -48px;
  right: 16px;
  z-index: 999;
  background: var(--apkgt-primary);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 8px 8px;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
  color: #fff;
}

/* ==========================================================================
   3) الترويسة (Header) والتنقل
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--apkgt-border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}

/* الشعار: صورة مخصصة أو اسم الموقع */
.site-branding {
  display: flex;
  align-items: center;
}

.site-branding .custom-logo {
  max-height: 40px;
  width: auto;
}

.site-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--apkgt-text);
  letter-spacing: -0.02em;
}

.site-title:hover {
  color: var(--apkgt-primary);
}

/* القائمة الرئيسية */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-menu a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--apkgt-text);
}

.nav-menu a:hover {
  background: var(--apkgt-surface);
  color: var(--apkgt-primary);
}

/* زر قائمة الجوال: مخفي على الشاشات الكبيرة */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 0;
  padding: 8px;
  cursor: pointer;
}

.menu-toggle-bar {
  width: 24px;
  height: 2.5px;
  border-radius: 2px;
  background: var(--apkgt-text);
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ==========================================================================
   4) عنوان الصفحة الرئيسية
   ========================================================================== */
.page-heading {
  text-align: center;
  padding-block: 32px 8px;
}

.page-title {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  font-weight: 800;
  color: var(--apkgt-text);
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--apkgt-text-soft);
  font-size: 0.98rem;
}

/* ==========================================================================
   5) شبكة بطاقات المقالات (قلب الصفحة الرئيسية)
   ========================================================================== */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--apkgt-gap);
  padding-block: 24px 40px;
}

.post-card {
  background: var(--apkgt-surface);
  border: 1px solid var(--apkgt-border);
  border-radius: var(--apkgt-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 30px rgba(2, 6, 23, 0.1);
}

/* الصورة المميزة: مقاس ثابت 16/10 لمنع اهتزاز التخطيط (CLS) */
.post-card-thumb {
  display: block;
  aspect-ratio: 16 / 10;
  background: #e8edf5;
}

.post-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.post-card-title {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.55;
}

.post-card-title a {
  color: var(--apkgt-text);
}

.post-card-title a:hover {
  color: var(--apkgt-primary);
}

.post-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--apkgt-text-soft);
}

.post-card-meta .post-category a {
  color: var(--apkgt-primary);
  font-weight: 500;
}

.post-card-excerpt {
  font-size: 0.88rem;
  color: var(--apkgt-text-soft);
  margin-top: auto; /* يدفع المقتطف للأسفل في البطاقات غير المتساوية */
}

/* ==========================================================================
   6) ترقيم الصفحات (بدون أي إضافة خارجية)
   ========================================================================== */
.pagination {
  padding-block: 8px 48px;
  text-align: center;
}

.pagination .nav-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding-inline: 12px;
  border-radius: 10px;
  border: 1px solid var(--apkgt-border);
  background: #fff;
  color: var(--apkgt-text);
  font-weight: 600;
  font-size: 0.9rem;
}

.pagination .page-numbers:hover {
  border-color: var(--apkgt-primary);
  color: var(--apkgt-primary);
}

.pagination .page-numbers.current {
  background: var(--apkgt-primary);
  border-color: var(--apkgt-primary);
  color: #fff;
}

/* ==========================================================================
   7) محتوى المقالات (تنسيقات Gutenberg الأساسية)
   ========================================================================== */
.entry-content {
  font-size: 1.04rem;
  line-height: 1.9;
  color: var(--apkgt-text);
}

.entry-content p {
  margin-block: 1em;
}

.entry-content h2,
.entry-content h3,
.entry-content h4 {
  margin-block: 1.6em 0.5em;
  font-weight: 800;
  line-height: 1.4;
}

.entry-content img {
  border-radius: var(--apkgt-radius);
  margin-block: 1.2em;
}

.entry-content ul,
.entry-content ol {
  margin-block: 1em;
  padding-inline-start: 1.5em;
}

.entry-content ul {
  list-style: disc;
}

.entry-content ol {
  list-style: decimal;
}

.entry-content blockquote {
  border-inline-start: 4px solid var(--apkgt-primary);
  padding-inline-start: 1em;
  color: var(--apkgt-text-soft);
  font-style: italic;
  margin-block: 1.5em;
}

.entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin-block: 1.5em;
  font-size: 0.95rem;
}

.entry-content th,
.entry-content td {
  border: 1px solid var(--apkgt-border);
  padding: 10px 14px;
  text-align: start;
}

.entry-content th {
  background: var(--apkgt-surface);
  font-weight: 700;
}

/* ==========================================================================
   8) زر عام (سيُستخدم لاحقاً في أزرار التحميل داخل المقالات)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 999px;
  border: 0;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--apkgt-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--apkgt-primary-dark);
  color: #fff;
}

.btn-accent {
  background: var(--apkgt-accent);
  color: #fff;
}

.btn-accent:hover {
  opacity: 0.92;
  color: #fff;
}

/* ==========================================================================
   9) حالة "لا توجد مقالات"
   ========================================================================== */
.no-posts {
  text-align: center;
  padding-block: 80px;
}

.no-posts h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.no-posts p {
  color: var(--apkgt-text-soft);
}

/* ==========================================================================
   10) التذييل (Footer) ومنطقة الودجات
   ========================================================================== */
.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  padding-block: 40px 24px;
  margin-top: 48px;
}

.footer-widgets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--apkgt-gap);
  padding-bottom: 32px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  margin-bottom: 24px;
}

.footer-widget-title {
  font-size: 1rem;
  color: #fff;
  margin-bottom: 12px;
}

.footer-widget a {
  color: #94a3b8;
}

.footer-widget a:hover {
  color: #fff;
}

.footer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: #94a3b8;
}

/* ==========================================================================
   11) إتاحة الوصول: حالة التركيز الواضحة
   ========================================================================== */
a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--apkgt-primary);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ==========================================================================
   12) التجاوب مع الشاشات الصغيرة
   ========================================================================== */
@media (max-width: 1024px) {
  .nav-menu {
    gap: 0;
  }

  .nav-menu a {
    padding: 8px 10px;
    font-size: 0.9rem;
  }
}

@media (max-width: 782px) {
  /* إظهار زر القائمة وإخفاء القائمة خلفه */
  .menu-toggle {
    display: flex;
  }

  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    background: #fff;
    border-bottom: 1px solid var(--apkgt-border);
    box-shadow: 0 16px 30px rgba(2, 6, 23, 0.08);
  }

  .main-nav.is-open {
    display: block;
  }

  .nav-menu {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    gap: 4px;
  }

  .nav-menu a {
    display: block;
    padding: 12px 14px;
  }

  .posts-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
  }

  .footer-bottom {
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .posts-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    padding-block: 24px 4px;
  }
}

/* ==========================================================================
   13) الطباعة: صفحة نظيفة عند الطباعة
   ========================================================================== */
@media print {
  .site-header,
  .site-footer,
  .pagination {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}
