/* =========================================================
   BLOG.CSS
   خاص بصفحات المدونة والمقالات فقط:
   - blog.html (الشبكة + الفلاتر)
   - post1.html إلى post6.html (المقالات)
   ========================================================= */


/* =========================================================
   01. BLOG SECTION (blog.html)
========================================================= */

.blog-section,
.blog-page-section {
    background: var(--bg-primary);
}

.blog-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
}


/* =========================================================
   02. BLOG FILTERS
   يستخدمها JS: .blog-filter-btn
========================================================= */

.blog-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 38px;
}

.blog-filter-btn {
    min-height: 42px;
    padding: 7px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    background: var(--surface);
    font-weight: 700;
    cursor: pointer;
    transition:
        background-color var(--transition-fast),
        color var(--transition-fast),
        border-color var(--transition-fast),
        transform var(--transition-fast);
}

.blog-filter-btn:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    color: var(--primary);
}

.blog-filter-btn.active {
    border-color: var(--primary);
    color: #ffffff;
    background: var(--primary);
}


/* =========================================================
   03. BLOG CARD
   يستخدمها JS: .blog-card
   (يدعم الكلاسين: .blog-content و .blog-card-content)
========================================================= */

.blog-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition:
        transform var(--transition),
        box-shadow var(--transition),
        border-color var(--transition);
}

.blog-card:hover {
    transform: translateY(-7px);
    border-color: rgba(55, 118, 171, 0.3);
    box-shadow: var(--shadow-md);
}

.blog-card.is-hidden {
    display: none;
}

.blog-image,
.blog-card-image {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    background: var(--bg-tertiary);
}

.blog-image img,
.blog-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.blog-card:hover .blog-image img,
.blog-card:hover .blog-card-image img {
    transform: scale(1.06);
}

.blog-content,
.blog-card-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 24px;
}

.blog-category,
.blog-card-category {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
}

.blog-content h3,
.blog-card-content h3 {
    margin-bottom: 10px;
    margin-top: 10px;
    font-size: 1.2rem;
    line-height: 1.55;
}

.blog-content p,
.blog-card-content p {
    margin-bottom: 18px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.blog-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.blog-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: auto;
    color: var(--primary);
    font-size: 0.88rem;
    font-weight: 800;
    transition:
        gap var(--transition),
        color var(--transition);
}

.blog-link:hover {
    gap: 12px;
    color: var(--primary-dark);
}


/* =========================================================
   04. ARTICLE HERO (صفحة المقال)
========================================================= */

.article-hero {
    padding-top: 160px;
    padding-bottom: 90px;
    background: linear-gradient(180deg, rgba(55, 118, 171, 0.08), transparent);
    text-align: center;
}

.article-hero-content {
    max-width: 780px;
    margin: 0 auto;
}

.article-hero h1,
.article-title {
    margin: 15px 0;
    font-size: clamp(2.4rem, 5vw, 4rem);
    line-height: 1.2;
}

.article-hero p,
.article-excerpt {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 700px;
    margin: 0 auto;
}


/* =========================================================
   05. ARTICLE META + AUTHOR
========================================================= */

.article-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.article-category {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    border: 1px solid rgba(55, 118, 171, 0.25);
    border-radius: var(--radius-full);
    color: var(--primary);
    background: rgba(55, 118, 171, 0.08);
    font-size: 0.8rem;
    font-weight: 800;
}

.article-author {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 30px;
}

.author-avatar {
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    font-size: 1.3rem;
    font-weight: 900;
    box-shadow: 0 8px 20px rgba(55, 118, 171, 0.28);
}

.article-author > div:last-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: right;
}

.article-author strong {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.article-author span {
    font-size: 0.78rem;
    color: var(--text-muted);
}


/* =========================================================
   06. ARTICLE LAYOUT (content + sidebar)
========================================================= */

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
    gap: 50px;
}

.article-content,
.project-article {
    min-width: 0;
}


/* =========================================================
   07. ARTICLE SECTIONS + BLOCKS
========================================================= */

.article-section {
    padding: 35px 0;
    border-bottom: 1px solid var(--border);
}

.article-section:first-child {
    padding-top: 0;
}

.article-section:last-child {
    border-bottom: 0;
}

.article-section h2,
.article-block h2 {
    margin-bottom: 18px;
    font-size: clamp(1.55rem, 3vw, 2.15rem);
    line-height: 1.45;
}

.article-section h3,
.article-block h3 {
    margin-top: 22px;
    margin-bottom: 10px;
    font-size: 1.15rem;
}

.article-section p,
.article-block p {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

.article-section strong,
.article-block strong {
    color: var(--text-primary);
}

.article-block {
    padding: 25px 0;
    border-bottom: 1px solid var(--border);
}

.article-block:last-child {
    border-bottom: 0;
}


/* =========================================================
   08. ARTICLE FEATURED IMAGE
========================================================= */

.article-featured-image {
    margin: 0 0 35px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-tertiary);
    box-shadow: var(--shadow-md);
}

.article-featured-image img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.article-featured-image figcaption {
    padding: 12px 18px;
    color: var(--text-muted);
    background: var(--surface);
    font-size: 0.82rem;
    text-align: center;
    border-top: 1px solid var(--border);
}


/* =========================================================
   09. ARTICLE CALLOUT
========================================================= */

.article-callout {
    margin: 25px 0;
    padding: 20px 22px;
    border-right: 4px solid var(--primary);
    border-radius: var(--radius-md);
    background: rgba(55, 118, 171, 0.07);
}

.article-callout strong {
    display: block;
    margin-bottom: 5px;
    color: var(--primary);
}

.article-callout p {
    margin-bottom: 0;
}

.article-callout.warning {
    border-right-color: var(--accent);
    background: rgba(255, 138, 0, 0.07);
}

.article-callout.warning strong {
    color: var(--accent);
}


/* =========================================================
   10. ARTICLE LISTS
========================================================= */

.article-list {
    margin: 18px 0;
    padding-right: 22px;
    list-style: none;
}

.article-list li {
    position: relative;
    margin-bottom: 9px;
    color: var(--text-secondary);
}

.article-list li::before {
    content: "•";
    position: absolute;
    right: -20px;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 900;
}

/* قوائم عادية بدون كلاس داخل المقال (مثل post6) */
.article-block > ul,
.article-block > ol {
    margin: 18px 0;
    padding-right: 22px;
}

.article-block > ul li,
.article-block > ol li {
    margin-bottom: 9px;
    color: var(--text-secondary);
    position: relative;
    list-style: none;
}

.article-block > ul li::before {
    content: "•";
    position: absolute;
    right: -20px;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 900;
}

.article-block > ol {
    counter-reset: article-counter;
}

.article-block > ol li {
    counter-increment: article-counter;
}

.article-block > ol li::before {
    content: counter(article-counter) ".";
    position: absolute;
    right: -28px;
    color: var(--primary);
    font-weight: 900;
}


/* =========================================================
   11. CODE BLOCK (نفس تنسيق projects.css)
========================================================= */

.code-block {
    position: relative;
    overflow-x: auto;
    margin: 22px 0;
    border: 1px solid #263247;
    border-radius: var(--radius-md);
    background: #0f172a;
    direction: ltr;
    text-align: left;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.code-block pre {
    margin: 0;
    padding: 22px;
    color: #e6edf6;
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
    font-size: 0.84rem;
    line-height: 1.8;
    white-space: pre;
}

.code-block code {
    font-family: inherit;
}

/* دعم مباشر لـ pre > code */
.article-content > pre,
.article-block > pre {
    overflow-x: auto;
    margin: 22px 0;
    padding: 22px;
    border: 1px solid #263247;
    border-radius: var(--radius-md);
    background: #0f172a;
    color: #e6edf6;
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
    font-size: 0.84rem;
    line-height: 1.8;
    direction: ltr;
    text-align: left;
    white-space: pre;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.article-content > pre code,
.article-block > pre code {
    font-family: inherit;
    color: inherit;
    background: transparent;
    padding: 0;
}

/* Code inline داخل النص */
.article-content p code,
.article-content li code,
.article-block p code,
.article-block li code,
.article-section p code {
    padding: 2px 7px;
    border-radius: 5px;
    color: var(--primary);
    background: rgba(55, 118, 171, 0.10);
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
    font-size: 0.88em;
    direction: ltr;
    unicode-bidi: embed;
}


/* =========================================================
   12. ARTICLE SHARE BUTTONS
========================================================= */

.article-share {
    margin-top: 45px;
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.article-share h3 {
    margin-bottom: 18px;
    font-size: 1.1rem;
}

.share-actions,
.share-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 8px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    background: var(--bg-secondary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition:
        transform var(--transition),
        color var(--transition),
        border-color var(--transition),
        background-color var(--transition);
}

.share-btn:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
    color: var(--primary);
}


/* =========================================================
   13. ARTICLE SIDEBAR + TOC
========================================================= */

.article-sidebar {
    position: sticky;
    top: 105px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-self: start;
}

.article-sidebar-card,
.article-sidebar-inner {
    padding: 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.article-sidebar-card h2,
.article-sidebar-card h3,
.article-sidebar-inner h2,
.article-sidebar-inner h3 {
    margin-bottom: 15px;
    font-size: 1.05rem;
}

.article-toc {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.article-toc a {
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    transition:
        background-color var(--transition-fast),
        color var(--transition-fast);
}

.article-toc a:hover {
    color: var(--primary);
    background: rgba(55, 118, 171, 0.08);
}


/* =========================================================
   14. RELATED POSTS
========================================================= */

.related-posts {
    background: var(--bg-secondary);
}

.related-posts .section-header,
.related-posts .section-heading {
    max-width: 760px;
    margin: 0 auto 55px;
    text-align: center;
}

.related-posts .section-heading h2 {
    margin: 10px 0 15px;
    font-size: clamp(2rem, 4vw, 2.8rem);
}


/* =========================================================
   15. RESPONSIVE - LARGE TABLETS (≤1100px)
========================================================= */

@media (max-width: 1100px) {

    .blog-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* =========================================================
   16. RESPONSIVE - TABLETS (≤900px)
========================================================= */

@media (max-width: 900px) {

    .article-layout {
        grid-template-columns: 1fr;
    }

    .article-sidebar {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* =========================================================
   17. RESPONSIVE - MOBILE (≤650px)
========================================================= */

@media (max-width: 650px) {

    .blog-grid {
        grid-template-columns: 1fr;
    }

    .blog-filters {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 7px;
        scrollbar-width: thin;
    }

    .blog-filter-btn {
        flex: 0 0 auto;
    }

    .article-hero {
        padding-top: 125px;
        padding-bottom: 65px;
    }

    .article-hero h1,
    .article-title {
        font-size: 2.15rem;
    }

    .article-excerpt {
        font-size: 0.92rem;
    }

    .article-section {
        padding: 28px 0;
    }

    .article-block {
        padding: 20px 0;
    }

    .article-sidebar {
        display: flex;
    }

    .article-share {
        padding: 20px;
    }

    .code-block pre,
    .article-content > pre,
    .article-block > pre {
        padding: 17px;
        font-size: 0.75rem;
    }
}


/* =========================================================
   18. RESPONSIVE - VERY SMALL (≤400px)
========================================================= */

@media (max-width: 400px) {

    .share-actions,
    .share-buttons {
        flex-direction: column;
    }

    .share-btn {
        width: 100%;
    }
}