/*
Theme Name: مدار نيوز
Theme URI: https://example.com/madar-news
Author: Madar
Author URI: https://example.com
Description: قالب ووردبريس عربي أصلي لمدونة أو مجلة أو موقع إخباري. تصميم نظيف بخلفية بيضاء وعنوان أحمر داكن، دعم كامل للغة العربية واتجاه RTL، متجاوب مع الجوال والأجهزة اللوحية وسطح المكتب، مع بطاقات مقالات وأقسام تصنيفات وجدول محتويات تلقائي وأزرار مشاركة.
Version: 1.0.0
Requires at least: 6.3
Tested up to: 6.7
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: madar
Tags: news, magazine, blog, rtl, arabic, responsive, custom-logo, custom-menu, threaded-comments
*/

/* ============================================================
   مدار نيوز — أنماط القالب
   ============================================================ */

:root {
    --primary: #AA0909;
    --primary-dark: #8a0707;
    --bg: #FFFFFF;
    --text: #222222;
    --muted: #777777;
    --border: #E5E5E5;
    --footer-bg: #282828;
    --related-head: #EAF0F5;
    --fb: #1877F2;
    --x: #1DA1F2;
    --wa: #25D366;
    --radius: 10px;
    --container: 1200px;
    --shadow: 0 1px 4px rgba(0, 0, 0, .07);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 17px;
    line-height: 1.8;
    direction: rtl;
    text-align: right;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { line-height: 1.5; margin: 0 0 .6em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-right: 1.4em; }
button, input, select, textarea { font-family: inherit; font-size: 1rem; }
.screen-reader-text {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap;
}

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------------- الترويسة ---------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.site-header .container {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 64px;
    padding-top: 10px;
    padding-bottom: 10px;
}
.site-branding { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.site-branding a { color: #fff; display: flex; align-items: center; gap: 10px; }
.site-branding a:hover { text-decoration: none; }
.site-title {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
}
.custom-logo { max-height: 44px; width: auto; }

.header-search { flex: 1; display: flex; justify-content: center; }
.header-search .search-form { width: 100%; max-width: 480px; position: relative; }
.header-search .search-field {
    width: 100%;
    height: 42px;
    border: none;
    border-radius: 999px;
    padding: 0 44px 0 18px;
    background: #fff;
    color: #333;
    outline: none;
    font-size: 15px;
}
.header-search .search-submit {
    position: absolute;
    top: 50%;
    left: 6px;
    transform: translateY(-50%);
    width: 32px; height: 32px;
    border: none; border-radius: 50%;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.header-search .search-submit svg { width: 20px; height: 20px; }

.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .6);
    border-radius: 8px;
    color: #fff;
    width: 42px; height: 42px;
    cursor: pointer;
    align-items: center; justify-content: center;
    flex-shrink: 0;
}
.menu-toggle svg { width: 24px; height: 24px; }

.primary-nav { display: none; background: var(--primary-dark); }
.primary-nav.open { display: block; }
.primary-nav ul {
    list-style: none; margin: 0; padding: 8px 0;
    display: flex; flex-direction: column;
}
.primary-nav a {
    display: block; padding: 10px 20px; color: #fff; font-weight: 700;
}
.primary-nav a:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }
.mobile-search { display: none; padding: 12px 20px; background: var(--primary-dark); }
.mobile-search .search-form { position: relative; }
.mobile-search .search-field {
    width: 100%; height: 42px; border: none; border-radius: 999px;
    padding: 0 44px 0 18px; outline: none;
}
.mobile-search .search-submit {
    position: absolute; top: 50%; left: 6px; transform: translateY(-50%);
    width: 32px; height: 32px; border: none; border-radius: 50%;
    background: transparent; color: var(--primary); cursor: pointer;
}

/* ---------------- عناوين الأقسام ---------------- */
.section-heading {
    margin: 34px 0 22px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    position: relative;
}
.section-heading h2,
.section-heading .section-title {
    margin: 0;
    color: var(--primary);
    font-size: 26px;
    font-weight: 800;
}
.section-heading::after {
    content: "";
    position: absolute;
    bottom: -1px; right: 0;
    width: 110px; height: 3px;
    background: var(--primary);
}
.section-heading .archive-description { color: var(--muted); font-size: 15px; margin-top: 8px; }

/* ---------------- بلوكات التصنيفات ---------------- */
.cat-blocks {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    margin-bottom: 10px;
}
.cat-block {
    padding: 18px 20px;
    border-left: 1px solid var(--border);
}
.cat-block:last-child { border-left: none; }
.cat-block-title {
    margin: 0 0 10px;
    font-size: 19px;
    font-weight: 800;
    display: flex; align-items: center; gap: 8px;
}
.cat-block-title a { color: var(--primary); }
.cat-block-title .cat-icon {
    width: 22px; height: 22px; flex-shrink: 0; color: var(--primary);
}
.cat-block ul { list-style: none; margin: 0; padding: 0; }
.cat-block li { margin: 2px 0; }
.cat-block li a { color: var(--text); font-size: 15px; }
.cat-block li a:hover { color: var(--primary); }
.cat-block .no-children { color: var(--muted); font-size: 14px; }

/* ---------------- شبكة المقالات والبطاقات ---------------- */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin: 10px 0 30px;
}
.post-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .18s ease, box-shadow .18s ease;
}
.post-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0, 0, 0, .12); }
.post-card .card-thumb { display: block; aspect-ratio: 16 / 9; overflow: hidden; }
.post-card .card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.post-card .card-thumb-fallback {
    width: 100%; height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, #d33 55%, #f08a8a 100%);
    display: flex; align-items: center; justify-content: center;
    color: rgba(255, 255, 255, .9); font-weight: 800; font-size: 34px;
}
.post-card .card-body { padding: 14px 14px 18px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.post-card .card-meta { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }

/* أعمدة الشبكة من لوحة التحكم */
.posts-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.posts-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.posts-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* هيدر غير مثبّت */
.site-header.not-sticky { position: static; }

/* روابط التواصل في التذييل */
.footer-social { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0 0 16px; }
.footer-social-link {
    display: inline-block; padding: 6px 16px; border-radius: 999px;
    background: rgba(255, 255, 255, .12); color: #fff; font-size: 14px; font-weight: 700;
}
.footer-social-link:hover { background: var(--primary); text-decoration: none; }

/* خانات الإعلانات */
.ad-slot { margin: 18px 0; text-align: center; overflow: hidden; }
.ad-slot img { margin: 0 auto; }
.post-card .card-title {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.65;
    text-align: center;
}
.post-card .card-title a { color: var(--primary); }
.post-card .card-title a:hover { text-decoration: underline; }

/* ---------------- ترقيم الصفحات ---------------- */
.pagination { margin: 10px 0 40px; text-align: center; }
.pagination .nav-links { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.pagination .page-numbers {
    display: inline-block; min-width: 38px; height: 38px; line-height: 38px;
    padding: 0 10px; border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); background: #fff; font-weight: 700;
}
.pagination .page-numbers.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination a.page-numbers:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

/* ---------------- المقال المنفرد ---------------- */
.single-column { max-width: 860px; margin: 0 auto; }
.breadcrumb {
    display: inline-block;
    background: #f2f2f2;
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 14px;
    color: var(--muted);
    margin: 26px 0 14px;
}
.breadcrumb a { color: var(--text); }
.breadcrumb .sep { margin: 0 6px; color: #aaa; }

.entry-header .entry-title {
    font-size: 30px;
    font-weight: 800;
    color: #111;
    margin: 0 0 12px;
}
.entry-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.entry-meta {
    font-size: 14px;
    color: var(--muted);
    border-right: 3px solid var(--primary);
    padding-right: 10px;
}
.entry-meta a { color: var(--text); font-weight: 700; }
.share-buttons { display: flex; gap: 8px; }
.share-buttons a {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.share-buttons a:hover { opacity: .85; text-decoration: none; }
.share-buttons .share-fb { background: var(--fb); }
.share-buttons .share-x { background: var(--x); }
.share-buttons .share-wa { background: var(--wa); }
.share-buttons svg { width: 18px; height: 18px; fill: #fff; }

.entry-thumb { margin: 0 0 22px; border-radius: var(--radius); overflow: hidden; }
.entry-thumb img { width: 100%; }
.entry-content { font-size: 18px; }
.entry-content h2 { font-size: 24px; margin-top: 1.4em; }
.entry-content h3 { font-size: 20px; margin-top: 1.3em; }
.entry-content blockquote {
    border-right: 3px solid var(--primary);
    margin: 1em 0; padding: .4em 1em; background: #fafafa; color: #444;
}
.entry-content figure { margin: 1.2em 0; }
.entry-content figcaption { font-size: 14px; color: var(--muted); text-align: center; }

/* جدول المحتويات */
.toc {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0 0 24px;
    background: #fff;
}
.toc-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px; cursor: pointer;
}
.toc-head h2 { margin: 0; font-size: 18px; font-weight: 800; color: var(--primary); }
.toc-toggle { background: none; border: none; color: var(--primary); font-size: 20px; cursor: pointer; line-height: 1; }
.toc-list { margin: 0; padding: 0 18px 14px; list-style: none; }
.toc-list li { margin: 4px 0; }
.toc-list a { color: var(--primary); font-size: 16px; }
.toc-list .toc-h3 { padding-right: 18px; font-size: 15px; }
.toc.collapsed .toc-list { display: none; }
.toc-empty { display: none; }

/* مواضيع مرتبطة */
.related-box { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 30px 0; }
.related-box-head {
    background: var(--related-head);
    padding: 12px 18px;
    font-weight: 800; font-size: 18px; color: #1d3a4f;
    margin: 0;
}
.related-box ul { list-style: none; margin: 0; padding: 12px 18px; }
.related-box li { padding: 6px 0; border-bottom: 1px dashed var(--border); }
.related-box li:last-child { border-bottom: none; }
.related-box li a { color: var(--text); font-weight: 700; }
.related-box li a:hover { color: var(--primary); }

.also-see { margin: 34px 0 40px; }

/* ---------------- التعليقات ---------------- */
.comments-area { margin: 30px 0 50px; border-top: 1px solid var(--border); padding-top: 24px; }
.comments-title { font-size: 22px; font-weight: 800; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list .children { list-style: none; padding-right: 30px; }
.comment-body { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.comment-meta { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.comment-author { font-weight: 800; color: var(--text); }
.comment-reply-link { font-size: 14px; }
.comment-form label { display: block; font-weight: 700; margin-bottom: 4px; }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    width: 100%; border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 12px; margin-bottom: 12px;
}
.comment-form .submit,
.form-submit .submit {
    background: var(--primary); color: #fff; border: none; border-radius: 8px;
    padding: 10px 26px; font-weight: 800; cursor: pointer;
}
.comment-form .submit:hover { background: var(--primary-dark); }

/* ---------------- البحث و404 ---------------- */
.search-heading { font-size: 24px; font-weight: 800; margin: 30px 0 6px; }
.search-heading span { color: var(--primary); }
.no-results { text-align: center; padding: 40px 0 60px; }
.no-results p { color: var(--muted); }
.not-found { text-align: center; padding: 70px 0 90px; }
.not-found h1 { font-size: 72px; color: var(--primary); margin: 0; }
.not-found h2 { font-size: 26px; }
.not-found .btn-home {
    display: inline-block; margin-top: 14px;
    background: var(--primary); color: #fff; border-radius: 999px;
    padding: 10px 28px; font-weight: 800;
}
.not-found .btn-home:hover { background: var(--primary-dark); text-decoration: none; }
.not-found .search-form, .no-results .search-form { position: relative; max-width: 480px; margin: 20px auto 0; }
.not-found .search-field, .no-results .search-field {
    width: 100%; height: 46px; border: 1px solid var(--border); border-radius: 999px;
    padding: 0 48px 0 18px; outline: none;
}
.not-found .search-submit, .no-results .search-submit {
    position: absolute; top: 50%; left: 6px; transform: translateY(-50%);
    width: 34px; height: 34px; border: none; border-radius: 50%;
    background: var(--primary); color: #fff; cursor: pointer;
}

/* ---------------- التذييل ---------------- */
.site-footer {
    background: var(--footer-bg);
    color: #ddd;
    text-align: center;
    padding: 34px 20px 44px;
    margin-top: 20px;
}
.site-footer .footer-copy { color: #bbb; font-size: 15px; margin: 0 0 14px; }
.site-footer .footer-copy a { color: #fff; }
.footer-menu { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: center; }
.footer-menu a { color: #fff; font-size: 15px; }
.footer-menu a:hover { color: #fff; text-decoration: underline; }

/* زر العودة للأعلى */
.back-to-top {
    position: fixed;
    bottom: 22px; left: 22px;
    width: 46px; height: 46px;
    border: none; border-radius: 50%;
    background: var(--primary);
    color: #fff; font-size: 20px; line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center; justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
    z-index: 200;
}
.back-to-top.visible { display: flex; }
.back-to-top:hover { background: var(--primary-dark); }

/* ---------------- التجاوب ---------------- */
@media (max-width: 1024px) {
    .cat-blocks { grid-template-columns: repeat(2, 1fr); }
    .cat-block:nth-child(2n) { border-left: none; }
    .cat-block { border-bottom: 1px solid var(--border); }
    .posts-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    body { font-size: 16px; }
    .site-header .container { gap: 12px; }
    .site-title { font-size: 23px; }
    .header-search { display: none; }
    .menu-toggle { display: flex; margin-right: auto; }
    .mobile-search.open { display: block; }
    .cat-blocks { grid-template-columns: repeat(2, 1fr); }
    .posts-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
    .entry-header .entry-title { font-size: 24px; }
    .entry-content { font-size: 17px; }
    .section-heading h2, .section-heading .section-title { font-size: 22px; }
}
@media (max-width: 480px) {
    .cat-blocks { grid-template-columns: 1fr; }
    .cat-block { border-left: none; border-bottom: 1px solid var(--border); }
    .posts-grid { grid-template-columns: 1fr; }
    .entry-meta-row { flex-direction: column; align-items: flex-start; }
    .post-card .card-title { font-size: 16px; }
}
