/*
Theme Name: Alamuna Fast Theme
Theme URI: https://alamuna.net
Author: Alamuna
Description: قالب عربي مخصص فائق السرعة ومتوافق مع السيو ومعايير E-E-A-T وتجربة الهاتف.
Version: 1.0.5
Text Domain: alamuna
*/

:root {
    --primary: #8b181a;
    --primary-dark: #6d1113;
    --bg-body: #f4f5f7;
    --bg-card: #ffffff;
    --text-heading: #111111;
    --text-body: #2c2c2c;
    --border-color: #eeeeee;
}

body.dark-mode {
    --bg-body: #121212;
    --bg-card: #1e1e1e;
    --text-heading: #f5f5f5;
    --text-body: #e0e0e0;
    --border-color: #2e2e2e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    max-width: 100%;
    overflow-x: clip;
}

/* النص العادي: الخط الطبيعي الواضح للنظام */
body {
    font-family: system-ui, -apple-system, 'Segoe UI', Tahoma, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-body);
    font-size: 16px;
    line-height: 1.8;
    direction: rtl;
}

a { text-decoration: none; color: inherit; transition: color 0.2s; }
img { max-width: 100%; height: auto; display: block; }
ul { list-style: none; }
ins.adsbygoogle, iframe { max-width: 100% !important; }

/* السماح بالكتابة والتحديد داخل جميع حقول البحث والإدخال */
input, textarea, .search-input, .wp-block-search__input {
    -webkit-user-select: text !important;
    user-select: text !important;
    -webkit-touch-callout: default !important;
}

.container {
    width: 92%;
    max-width: 1200px;
    margin: 0 auto;
}

/* --- العناوين (خط Cairo مخصص للعناوين فقط) --- */
h1, h2, h3, h4,
.site-title, .nav-list, .widget-title, .category-tag,
.search-btn, .wp-block-search__button, .btn-home {
    font-family: 'Cairo', system-ui, sans-serif;
}

h1, h2, h3, h4 {
    color: var(--text-heading);
    font-weight: 700;
    line-height: 1.4;
}

h2 { font-size: 33px; color: #111; margin-bottom: 15px; }
h3 { font-size: 24px; color: #333; margin-top: 22px; margin-bottom: 10px; }
h4 { font-size: 20px; color: #444; margin-top: 20px; margin-bottom: 8px; }

body.dark-mode h1, body.dark-mode h2, body.dark-mode h3, body.dark-mode h4 {
    color: var(--text-heading);
}

/* النص العادي داخل المقالات والبطاقات */
article p, article li, article ul, article ol, article blockquote,
main p, main li, .entry-content p, .entry-content li, .post-excerpt {
    font-family: system-ui, -apple-system, 'Segoe UI', Tahoma, Arial, sans-serif;
    color: var(--text-body);
    opacity: 1;
    font-size: 17px;
    line-height: 1.85;
    margin-bottom: 16px;
}

.entry-content ul, .entry-content ol { padding-right: 22px; list-style: disc; }
.entry-content ol { list-style: decimal; }
.entry-content blockquote {
    border-right: 4px solid var(--primary);
    background: rgba(139, 24, 26, 0.05);
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 4px;
}

/* --- الجداول بلون الموقع + محاذاة يمين + متجاوبة مع الهاتف --- */
.entry-content table, table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

table th, table td {
    text-align: right !important;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    font-size: 15px;
}

table thead th, table tr:first-child th {
    background-color: var(--primary);
    color: #ffffff !important;
    font-weight: 700;
    font-family: 'Cairo', sans-serif;
}

table tbody tr:nth-child(even) {
    background-color: rgba(139, 24, 26, 0.04);
}

@media (max-width: 768px) {
    .entry-content table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

/* --- الهيدر للكمبيوتر (PC >= 769px) --- */
.site-header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 99999;
}

.top-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 0;
}

.social-icons { display: flex; gap: 8px; }
.social-icon {
    width: 34px; height: 34px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; transition: transform 0.2s;
}
.social-icon:hover { transform: translateY(-2px); }
.social-icon svg { width: 16px; height: 16px; fill: currentColor; }

.bg-telegram { background-color: #2AABEE; }
.bg-youtube { background-color: #FF0000; }
.bg-instagram { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%); }
.bg-x { background-color: #000000; }
.bg-facebook { background-color: #1877F2; }

.site-branding { text-align: center; }
.site-title { font-size: 42px; font-weight: 900; line-height: 1.1; margin: 0; }
.site-title a { color: #1a1a1a; }
body.dark-mode .site-title a { color: #ffffff; }
.site-description { font-size: 13px; color: #666; margin-top: 4px; }

.header-utils { display: flex; gap: 10px; align-items: center; }
.util-btn {
    width: 38px; height: 38px; border-radius: 50%; border: none;
    background-color: var(--primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: opacity 0.2s;
}
.util-btn:hover { opacity: 0.9; }
.util-btn svg { width: 18px; height: 18px; fill: currentColor; }

.mobile-menu-toggle { display: none; }

/* شريط التنقل */
.main-nav { background-color: var(--primary); color: #ffffff; position: relative; }
.nav-list { display: flex; flex-wrap: wrap; }
.nav-list li a {
    display: block; padding: 12px 18px; font-weight: 700; font-size: 15px; color: #fff;
}
.nav-list li a:hover, .nav-list li.current-menu-item a { background-color: rgba(0, 0, 0, 0.2); }

/* صناديق البحث (الهيدر + الودجات) */
.header-search-bar {
    display: none;
    background: var(--bg-card);
    padding: 15px 0;
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    position: relative;
    z-index: 99999;
}
.header-search-bar.active { display: block; }

.search-form,
.wp-block-search__inside-wrapper {
    display: flex;
    gap: 8px;
    max-width: 100%;
}

.search-input,
.wp-block-search__input,
.widget_search input[type="search"] {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 16px !important;
    min-height: 44px !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    pointer-events: auto !important;
    touch-action: manipulation;
    position: relative;
    z-index: 10;
    background: var(--bg-card);
    color: var(--text-heading);
    outline: none;
}

.search-btn,
.wp-block-search__button,
.widget_search .search-submit {
    background-color: var(--primary) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 4px;
    padding: 10px 20px !important;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
}

/* منطقة الإعلان أسفل الهيدر (بعرض كامل) */
.header-ad-area { margin: 20px auto 0; text-align: center; }
.header-ad-area:empty { display: none; margin: 0; }

/* --- الهيدر والقائمة للموبايل (<= 768px) --- */
@media (max-width: 768px) {
    .site-header {
        background-color: var(--primary);
        border-bottom: none;
        position: relative !important;
        top: auto !important;
        z-index: 99999 !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    }

    .top-header-inner { padding: 10px 0; gap: 8px; }
    .social-icons { display: none !important; }

    .mobile-menu-toggle {
        display: inline-flex !important;
        background: rgba(255,255,255,0.18);
        width: 40px; height: 40px; border-radius: 6px; border: none;
        color: #fff; align-items: center; justify-content: center; cursor: pointer;
        flex-shrink: 0;
    }
    .mobile-menu-toggle svg { width: 22px; height: 22px; fill: currentColor; }

    .site-branding { flex: 1; min-width: 0; text-align: center; padding: 0 6px; }
    .site-title { font-size: 24px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .site-title a, .site-description { color: #ffffff !important; }
    .site-description { display: none; }

    .header-utils { gap: 6px; flex-shrink: 0; }
    .util-btn { background: rgba(255,255,255,0.18); width: 38px; height: 38px; border-radius: 6px; }

    .main-nav { display: none; background-color: var(--primary-dark); }
    .main-nav.active { display: block; }
    .nav-list { flex-direction: column; padding: 8px 0; }
    .nav-list li a { padding: 12px 15px; border-bottom: 1px solid rgba(255,255,255,0.1); }
}

/* --- تخطيط المحتوى والشريط الجانبي --- */
.main-wrapper {
    display: flex;
    gap: 28px;
    margin-top: 28px;
    margin-bottom: 45px;
    align-items: flex-start;
}
.content-area { flex: 2; min-width: 0; max-width: 100%; }
.sidebar { flex: 1; min-width: 0; max-width: 100%; }

/* بطاقة المقال في الرئيسية والأرشيف */
.post-card {
    background: var(--bg-card);
    display: flex;
    margin-bottom: 22px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    max-width: 100%;
}

.post-thumb {
    flex: 0 0 45%;
    width: 45%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}
.post-thumb img { width: 100%; height: 100%; object-fit: cover; }

.post-details { flex: 0 0 55%; width: 55%; padding: 22px; min-width: 0; }

.category-tag {
    background-color: var(--primary); color: #fff;
    padding: 3px 10px; font-size: 12px; font-weight: 700;
    border-radius: 3px; display: inline-block; margin-bottom: 10px;
}

.post-title { font-size: 22px; margin-top: 0; margin-bottom: 10px; line-height: 1.4; }
.post-title a:hover { color: var(--primary); }

.post-meta {
    font-size: 13px; color: #666; margin-bottom: 12px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
}
.meta-author, .meta-date { display: inline-flex; align-items: center; gap: 6px; }
.meta-avatar { width: 24px !important; height: 24px !important; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.meta-date svg { width: 14px; height: 14px; fill: #777; }

.post-excerpt { font-size: 15.5px; color: var(--text-body); margin-bottom: 0; line-height: 1.75; }

/* --- صفحة المقال المفرد + E-E-A-T --- */
.single-article {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    max-width: 100%;
}

.breadcrumbs { font-size: 13px; color: #777; margin-bottom: 15px; }
.breadcrumbs a:hover { color: var(--primary); }

.single-title { font-size: 32px; margin-bottom: 15px; line-height: 1.4; }
.single-featured-img {
    width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
    border-radius: 6px; margin: 20px 0;
}

/* توسيط إجباري لجميع الصور والإنفوجرافيك داخل المقالات */
.entry-content .wp-block-image,
.entry-content figure {
    margin: 24px auto !important;
    text-align: center !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    float: none !important;
    clear: both !important;
}

.entry-content img:not(.wp-smiley) {
    display: block !important;
    margin-left: auto !important;
    margin-right: auto !important;
    float: none !important;
}

.entry-content figcaption {
    text-align: center !important;
    font-size: 14px;
    color: #777;
    margin-top: 8px;
}

/* صندوق الكاتب E-E-A-T */
.author-box {
    display: flex; gap: 18px; align-items: center;
    background: var(--bg-body); padding: 20px;
    border-radius: 6px; margin-top: 35px;
    border-right: 4px solid var(--primary);
}
.author-avatar { flex-shrink: 0 !important; width: 70px !important; height: 70px !important; }
.author-avatar img { width: 70px !important; height: 70px !important; border-radius: 50%; object-fit: cover; }
.author-info h4 { margin: 0 0 5px 0; font-size: 18px; }
.author-info p { margin: 0; font-size: 14.5px; }

/* مقالات ذات صلة */
.related-posts { margin-top: 35px; padding-top: 25px; border-top: 1px solid var(--border-color); }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 15px; }
.related-card img { aspect-ratio: 16 / 9; object-fit: cover; border-radius: 4px; margin-bottom: 8px; }
.related-card h4 { font-size: 15px; margin: 0; line-height: 1.4; }

/* الشريط الجانبي */
.sidebar-widget {
    background: var(--bg-card); padding: 20px; margin-bottom: 24px;
    border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    max-width: 100%;
}
.sidebar-widget:empty, .widget_block:empty { display: none !important; }

.sidebar-widget h2,
.sidebar-widget h3,
.sidebar-widget .wp-block-heading,
.widget-title {
    border-right: 4px solid var(--primary);
    padding-right: 12px;
    margin-top: 0 !important;
    margin-bottom: 16px !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.4 !important;
}

.popular-list li {
    display: flex; gap: 12px; padding: 10px 0;
    border-bottom: 1px solid var(--border-color); align-items: center;
}
.popular-list li:last-child { border-bottom: none; }
.pop-img { width: 75px; height: 52px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.pop-title { font-size: 14px; font-weight: 600; line-height: 1.4; }

/* الترقيم */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 25px; }
.pagination .page-numbers {
    padding: 8px 14px; background: var(--bg-card); border-radius: 4px;
    font-weight: 700; font-size: 14px; border: 1px solid var(--border-color);
}
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* --- صفحة البحث و 404 --- */
.search-header-box, .no-results-box {
    background: var(--bg-card); padding: 25px; border-radius: 6px;
    margin-bottom: 24px; box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    border-right: 4px solid var(--primary);
}
.search-page-title { font-size: 26px; margin-bottom: 8px; }
.search-page-title span { color: var(--primary); }
.search-count { font-size: 14px; color: #777; margin-bottom: 15px; }

.btn-home {
    display: inline-block; background-color: var(--primary);
    color: #fff !important; padding: 10px 25px; border-radius: 4px; font-weight: 700;
}
.btn-home:hover { background-color: var(--primary-dark); }

/* --- إعدادات الموبايل الشاملة (<= 768px) --- */
@media (max-width: 768px) {
    .container { width: 94% !important; max-width: 100% !important; }
    .main-wrapper { flex-direction: column; margin-top: 15px; gap: 20px; }
    .content-area, .sidebar { flex: none !important; width: 100% !important; max-width: 100% !important; }

    .post-card { flex-direction: column; }
    .post-thumb, .post-details { flex: none; width: 100%; }
    .post-details { padding: 16px; }
    .post-title { font-size: 20px !important; }

    .breadcrumbs { display: none !important; }
    .single-article { padding: 16px; }

    /* أحجام خطوط العناوين في الموبايل */
    h1, .single-title, article h1 {
        font-size: 26px !important; line-height: 1.5 !important;
        word-break: normal !important; overflow-wrap: break-word !important;
    }
    .entry-content h2, article h2 {
        font-size: 23px !important; line-height: 1.5 !important;
        margin-top: 23px !important; margin-bottom: 12px !important;
    }
    .entry-content h3, article h3 {
        font-size: 20px !important; line-height: 1.4 !important;
        margin-top: 20px !important; margin-bottom: 10px !important;
    }

    /* إخفاء البحث والأكثر مشاهدة في المقالات والصفحات ونتائج البحث على الموبايل */
    body.single .widget_search,
    body.page .widget_search,
    body.search .widget_search,
    body.single .sidebar-widget:has(.wp-block-search),
    body.page .sidebar-widget:has(.wp-block-search),
    body.search .sidebar-widget:has(.wp-block-search),
    body.single .widget_popular_posts,
    body.page .widget_popular_posts,
    body.single .widget_post_views_counter_list_widget,
    body.page .widget_post_views_counter_list_widget {
        display: none !important;
    }

    /* إخفاء إعلان أسفل الهيدر وإعلانات الشريط الجانبي في الموبايل نهائياً */
    .header-ad-area,
    .sidebar-mid-ad,
    .sidebar .widget_custom_html,
    .sidebar .widget_ad_space,
    .sidebar .sidebar-widget:has(ins.adsbygoogle),
    .sidebar .sidebar-widget:has(iframe),
    .sidebar .sidebar-widget:has(.pc-only-ad) {
        display: none !important;
    }

    .related-grid { grid-template-columns: 1fr; }
    .author-box { flex-direction: column; text-align: center; }
}

/* إظهار إعلانات الشريط الجانبي على الكمبيوتر في (الرئيسية والأقسام فقط) وإخفاؤها في المقالات والصفحات والبحث */
body:not(.home):not(.archive):not(.category) .sidebar .widget_custom_html,
body:not(.home):not(.archive):not(.category) .sidebar .widget_ad_space,
body:not(.home):not(.archive):not(.category) .sidebar .sidebar-widget:has(ins.adsbygoogle),
body:not(.home):not(.archive):not(.category) .sidebar .sidebar-widget:has(iframe),
body:not(.home):not(.archive):not(.category) .sidebar .sidebar-widget:has(.pc-only-ad) {
    display: none !important;
}

/* إخفاء إعلان أسفل الهيدر داخل الصفحات الثابتة على الكمبيوتر والموبايل معاً */
body.page .header-ad-area {
    display: none !important;
}

/* --- شريط التقدم في القراءة + زر الصعود للأعلى --- */
.reading-progress-bar {
    position: fixed;
    top: 0;
    right: 0;
    width: 0%;
    height: 4px;
    background-color: var(--primary);
    z-index: 99999;
    transition: width 0.08s linear;
    pointer-events: none;
}

.scroll-top-btn {
    position: fixed;
    bottom: 22px;
    left: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: opacity 0.25s, visibility 0.25s, transform 0.25s, background-color 0.2s;
}
.scroll-top-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.scroll-top-btn:hover { background-color: var(--primary-dark); }
.scroll-top-btn svg { width: 22px; height: 22px; fill: currentColor; }

/* --- الفوتر (#121212) --- */
.site-footer {
    background-color: #121212;
    color: #fff;
    padding: 40px 15px 25px;
    direction: rtl;
}
.footer-container { max-width: 1100px; margin: 0 auto; }
.footer-top {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 25px; padding-bottom: 20px; border-bottom: 1px solid #333;
}
.footer-logo { font-family: 'Cairo', sans-serif; font-size: 30px; font-weight: 900; color: #fff; }
.footer-social { display: flex; gap: 8px; }
.footer-social a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%; color: #fff; transition: transform 0.2s;
}
.footer-social a:hover { transform: translateY(-3px); }
.footer-social svg { width: 18px; height: 18px; fill: currentColor; }

.footer-social .facebook { background-color: #1877F2; }
.footer-social .x-twitter { background-color: #000000; }
.footer-social .instagram { background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%); }
.footer-social .youtube { background-color: #FF0000; }
.footer-social .telegram { background-color: #2AABEE; }

.footer-navigation { margin-bottom: 20px; }
.footer-menu-items {
    display: flex; justify-content: center; flex-wrap: wrap;
    gap: 12px 28px; list-style: none;
}
.footer-menu-items li a { color: #cccccc; font-size: 15px; font-family: 'Cairo', sans-serif; }
.footer-menu-items li a:hover { color: #ffffff; }

.footer-copyright { text-align: center; color: #ffffff; font-size: 14px; padding-top: 10px; }

@media (max-width: 768px) {
    .footer-top { flex-direction: column; gap: 18px; text-align: center; }
}