/**
 * استایل‌های اختصاصی ماژول سکشن مقالات صفحه اصلی (سکشن پایانی صفحه اصلی)
 * مجله تخصصی فناوری و راهنمای خرید - rpkala.ir
 *
 * مشخصات و ابعاد طبق دستور کاربر:
 * - عنوان اصلی: سایز 1.5rem، وزن ۹۰۰، رنگ rgb(15 23 42 / 1)
 * - زیرعنوان: سایز 0.75rem، رنگ rgb(100 116 139 / 1)
 * - دکمه مشاهده همه: هماهنگ با سایر دکمه‌های مشاهده همه صفحه اصلی
 * - تگ روی عکس: رنگ سفید، وزن ۷۰۰، سایز 10px، بک‌گراند rgb(2 132 199 / 1)، بردر ردیوس 0.5rem، پدینگ بالا/پایین 0.25rem و چپ/راست 0.625rem، موقعیت بالا و راست 0.75rem
 * - ارتفاع عکس: height: 12rem;
 * - متای تاریخ و زمان مطالعه: رنگ rgb(148 163 184 / 1)، وزن ۵۰۰، سایز 11px
 * - عنوان مقاله: رنگ rgb(15 23 42 / 1)، ارتفاع خط 1.625، وزن ۷۰۰، سایز 0.875rem (ثابت در ۲ خط و پایدار برای عناوین یک‌خطی)
 * - خلاصه مقاله: رنگ rgb(100 116 139 / 1)، ارتفاع خط 1.625، سایز 0.75rem
 * - دکمه مطالعه: رنگ rgb(3 44 100 / 1)، وزن ۷۰۰، سایز 0.75rem
 * - پدینگ باکس سفید محتوا: 1.25rem
 * - فاصله بین کارت‌ها: 1.5rem
 *
 * @package RPKala_Toolkit
 * @since   1.0.0
 */

:root {
    --rp-blog-sec-container-width: 1230px;
    --rp-blog-sec-card-radius: 1.25rem;
    --rp-blog-sec-font: 'iransansx', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --rp-blog-sec-primary: rgb(3 44 100 / 1);
    --rp-blog-sec-text-dark: rgb(15 23 42 / 1);
    --rp-blog-sec-text-muted: rgb(100 116 139 / 1);
    --rp-blog-sec-text-subtle: rgb(148 163 184 / 1);
    --rp-blog-sec-tag-bg: rgb(2 132 199 / 1);
    --rp-blog-sec-border: rgb(241 245 249 / 1);
}

.rp-blog-section,
.rp-blog-section * {
    box-sizing: border-box !important;
    font-family: var(--rp-blog-sec-font) !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   ۱. کانتینر بیرونی سکشن مقالات - فاصله استاندارد ۲.۵ رِم
   ========================================================================== */
.rp-blog-section {
    width: 100%;
    margin-top: 0 !important;
    margin-bottom: 2.5rem !important; /* فاصله استاندارد ۲.۵ رِم بین سکشن‌ها */
    position: relative;
    z-index: 2;
    direction: rtl !important;
}

.rp-blog-section-container {
    width: 100%;
    max-width: var(--rp-blog-sec-container-width);
    margin-left: auto;
    margin-right: auto;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* ==========================================================================
   ۲. هدر سکشن: عنوان و زیرعنوان در راست، دکمه مشاهده همه در چپ
   ========================================================================== */
.rp-blog-section-header {
    display: flex;
    align-items: center; /* تراز عمودی دقیق با عناوین هدر */
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 0.25rem;
}

.rp-blog-section-title-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: right;
}

.rp-blog-section-title {
    font-size: 1.5rem !important; /* سایز 1.5rem */
    font-weight: 900 !important; /* وزن ۹۰۰ */
    color: var(--rp-blog-sec-text-dark) !important; /* رنگ rgb(15 23 42 / 1) */
    line-height: 1.3 !important;
    margin: 0 0 0.35rem 0 !important;
    letter-spacing: -0.02em;
}

.rp-blog-section-desc {
    font-size: 0.75rem !important; /* سایز 0.75rem */
    font-weight: 500 !important;
    color: var(--rp-blog-sec-text-muted) !important; /* رنگ rgb(100 116 139 / 1) */
    line-height: 1.6 !important;
    margin: 0 !important;
}

/* دکمه مشاهده همه مقالات در سمت چپ هماهنگ با سایر دکمه‌های مشاهده همه */
.rp-blog-section-view-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgb(3 44 100 / 0.85) !important;
    font-size: 0.875rem !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    transition: all 0.2s ease;
    align-self: center !important;
    padding: 0 !important;
}

.rp-blog-section-view-all svg {
    transition: transform 0.2s ease, stroke 0.2s ease;
    flex-shrink: 0;
    stroke: currentColor;
}

.rp-blog-section-view-all:hover {
    color: var(--rp-blog-sec-primary) !important; /* رنگ سرمه‌ای برند rgb(3 44 100 / 1) */
}

.rp-blog-section-view-all:hover svg {
    transform: translateX(-4px);
    stroke: var(--rp-blog-sec-primary) !important;
}

/* ==========================================================================
   ۳. شبکه ۳ ستونه کارت‌های مقالات (فاصله بین کارت‌ها ۱.۵ رِم)
   ========================================================================== */
.rp-blog-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem !important; /* فاصله بین کارت‌های مقاله 1.5rem */
    width: 100%;
    align-items: stretch;
}

/* ==========================================================================
   ۴. کارت مقاله وبلاگ
   ========================================================================== */
.rp-blog-card {
    background: #ffffff;
    border: 1px solid var(--rp-blog-sec-border);
    border-radius: var(--rp-blog-sec-card-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.04), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.3s ease;
    position: relative;
    height: 100%;
}

.rp-blog-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.04);
    border-color: rgba(3, 44, 100, 0.18);
}

/* لینک سراسری کلیک روی کارت */
.rp-blog-card-overlay-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
    text-decoration: none !important;
}

/* ==========================================================================
   ۵. کادر تصویر شاخص مقاله
   ارتفاع 12rem و قرارگیری تگ روی عکس در بالا راست
   ========================================================================== */
.rp-blog-card-media {
    width: 100%;
    height: 12rem !important; /* ارتفاع عکس 12rem */
    position: relative;
    overflow: hidden;
    background-color: #f1f5f9;
}

.rp-blog-card-img-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none !important;
}

.rp-blog-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.rp-blog-card:hover .rp-blog-card-img {
    transform: scale(1.05);
}

/* تگ دسته‌بندی روی عکس:
   رنگ سفید، وزن ۷۰۰، سایز 10px، پدینگ 0.25rem 0.625rem،
   بک‌گراند rgb(2 132 199 / 1)، بردر ردیوس 0.5rem، موقعیت بالا و راست 0.75rem */
.rp-blog-card-tag {
    position: absolute;
    top: 0.75rem !important;
    right: 0.75rem !important;
    z-index: 2;
    background-color: var(--rp-blog-sec-tag-bg) !important; /* rgb(2 132 199 / 1) */
    color: #ffffff !important; /* رنگ سفید */
    font-size: 10px !important; /* سایز 10px */
    font-weight: 700 !important; /* وزن ۷۰۰ */
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    padding-left: 0.625rem !important;
    padding-right: 0.625rem !important;
    border-radius: 0.5rem !important; /* 0.5rem بردر ردیوس */
    line-height: 1.3 !important;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.rp-blog-card-tag:hover {
    background-color: #0369a1 !important;
    transform: translateY(-1px);
}

/* ==========================================================================
   ۶. باکس سفید محتوای پایین مقاله
   پدینگ 1.25rem
   ========================================================================== */
.rp-blog-card-body {
    padding: 1.25rem !important; /* پدینگ 1.25rem */
    background: #ffffff;
    display: flex;
    flex-direction: column;
    flex: 1;
    text-align: right;
}

/* ردیف تاریخ و زمان مطالعه:
   رنگ rgb(148 163 184 / 1)، وزن ۵۰۰، سایز 11px */
.rp-blog-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px !important; /* سایز 11px */
    font-weight: 500 !important; /* وزن ۵۰۰ */
    color: var(--rp-blog-sec-text-subtle) !important; /* rgb(148 163 184 / 1) */
    margin-bottom: 0.65rem;
    line-height: 1.4;
}

.rp-blog-card-meta-dot {
    opacity: 0.6;
    font-size: 9px;
}

/* عنوان مقاله:
   رنگ rgb(15 23 42 / 1)، ارتفاع خط 1.625، وزن ۷۰۰، سایز 0.875rem
   ارتفاع ثابت معادل ۲ خط جهت پایداری کامل در عنوان‌های یک‌خطی */
.rp-blog-card-title-wrap {
    margin-bottom: 0.65rem;
}

.rp-blog-card-title {
    font-size: 0.875rem !important; /* سایز 0.875rem */
    font-weight: 700 !important; /* وزن ۷۰۰ */
    line-height: 1.625 !important; /* ارتفاع خط 1.625 */
    color: var(--rp-blog-sec-text-dark) !important; /* رنگ rgb(15 23 42 / 1) */
    margin: 0 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-break: break-word;
    /* تضمین پایداری و یکنواختی در تمام کارت‌ها چه عنوان ۱ خط باشد چه ۲ خط */
    min-height: calc(0.875rem * 1.625 * 2) !important;
    max-height: calc(0.875rem * 1.625 * 2) !important;
    transition: color 0.2s ease;
}

.rp-blog-card-title-link {
    color: inherit !important;
    text-decoration: none !important;
}

.rp-blog-card:hover .rp-blog-card-title {
    color: var(--rp-blog-sec-primary) !important;
}

/* خلاصه مقاله:
   رنگ rgb(100 116 139 / 1)، ارتفاع خط 1.625، سایز 0.75rem
   محدود به ۲ خط با حداقل ارتفاع مشخص جهت پایداری کارت‌ها */
.rp-blog-card-excerpt {
    font-size: 0.75rem !important; /* سایز 0.75rem */
    line-height: 1.625 !important; /* ارتفاع خط 1.625 */
    color: var(--rp-blog-sec-text-muted) !important; /* رنگ rgb(100 116 139 / 1) */
    margin: 0 0 1rem 0 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    word-break: break-word;
    min-height: calc(0.75rem * 1.625 * 2) !important;
    max-height: calc(0.75rem * 1.625 * 2) !important;
}

/* دکمه مطالعه:
   رنگ rgb(3 44 100 / 1)، وزن ۷۰۰، سایز 0.75rem */
.rp-blog-card-footer {
    margin-top: auto;
    padding-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* در RTL به سمت چپ هدایت می‌شود */
}

.rp-blog-card-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem !important; /* سایز 0.75rem */
    font-weight: 700 !important; /* وزن ۷۰۰ */
    color: var(--rp-blog-sec-primary) !important; /* رنگ rgb(3 44 100 / 1) */
    text-decoration: none !important;
    transition: all 0.2s ease;
}

.rp-blog-card-btn svg {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.rp-blog-card:hover .rp-blog-card-btn {
    color: #0284c7 !important;
}

.rp-blog-card:hover .rp-blog-card-btn svg {
    transform: translateX(-4px);
}

/* ==========================================================================
   ۷. ریسپانسیو و بهینه‌سازی تبلت و موبایل
   ========================================================================== */
@media (max-width: 1024px) {
    .rp-blog-cards-grid {
        gap: 1rem !important;
    }

    .rp-blog-card-media {
        height: 11rem !important;
    }

    .rp-blog-card-body {
        padding: 1rem !important;
    }
}

@media (max-width: 768px) {
    .rp-blog-section {
        margin-top: 0 !important;
        margin-bottom: 2rem !important;
        width: 100% !important;
    }

    .rp-blog-section-container {
        padding-left: 1rem !important;  /* فاصله دقیق ۱ رِم از لبه چپ */
        padding-right: 1rem !important; /* فاصله دقیق ۱ رِم از لبه راست */
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* هدر تک‌خطی هماهنگ: عنوان در راست، لینک مشاهده همه در چپ */
    .rp-blog-section-header {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        margin-bottom: 1rem !important;
        padding-bottom: 0 !important;
        width: 100% !important;
        gap: 0.5rem !important;
    }

    .rp-blog-section-title-group {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: right !important;
        flex: 1 !important;
        min-width: 0 !important;
    }

    .rp-blog-section-title {
        font-size: 1.15rem !important;
        font-weight: 900 !important;
        color: #0f172a !important;
        line-height: 1.3 !important;
        margin: 0 !important;
        white-space: nowrap !important;
        letter-spacing: -0.02em !important;
    }

    .rp-blog-section-desc {
        display: none !important; /* حذف زیرعنوان در هدر موبایل جهت حفظ چینش تک‌خطی طبق تصویر نمونه */
    }

    .rp-blog-section-view-all {
        font-size: 0.8rem !important;
        font-weight: 800 !important;
        color: var(--rp-blog-sec-primary) !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        text-decoration: none !important;
        align-self: center !important;
    }

    .rp-blog-section-view-all svg {
        width: 15px !important;
        height: 15px !important;
        stroke-width: 2.5 !important;
        stroke: var(--rp-blog-sec-primary) !important;
    }

    /* چیدمان ستونی ۳ مقاله آخر با فاصله استاندارد */
    .rp-blog-cards-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
        width: 100% !important;
    }

    /* کارت افقی شیک و اپلیکیشنی طبق تصویر نمونه */
    .rp-blog-card {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        background: #ffffff !important;
        border: 1px solid #f1f5f9 !important;
        border-radius: 1.25rem !important; /* ۲۰ پیکسل گوشه‌های گرد */
        padding: 0.85rem 1rem !important;
        gap: 0.85rem !important;
        box-shadow: 0 2px 10px -2px rgba(0, 0, 0, 0.03) !important;
        position: relative !important;
        height: auto !important;
        min-height: 110px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        transition: transform 0.2s ease, box-shadow 0.2s ease !important;
    }

    .rp-blog-card:active {
        transform: scale(0.99) !important;
    }

    /* کادر عکس مربعی با گوشه‌های گرد ۱۶ پیکسل در سمت راست */
    .rp-blog-card-media {
        width: 95px !important;
        height: 95px !important;
        min-width: 95px !important;
        border-radius: 1rem !important;
        overflow: hidden !important;
        order: 1 !important; /* قرارگیری در سمت راست در RTL */
        flex-shrink: 0 !important;
        position: relative !important;
        z-index: 2 !important;
        background-color: #f8fafc !important;
    }

    .rp-blog-card-img-link {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
    }

    .rp-blog-card-img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        border-radius: inherit !important;
    }

    .rp-blog-card-tag {
        display: none !important; /* پنهان‌سازی تگ روی عکس در موبایل جهت خلوت و تمیز بودن کادر عکس */
    }

    /* بدنه متنی کارت در سمت چپ */
    .rp-blog-card-body {
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        order: 2 !important; /* قرارگیری در سمت چپ در RTL */
        flex: 1 1 auto !important;
        min-width: 0 !important;
        padding: 0 !important;
        height: 95px !important; /* هم‌ارتفاع با باکس عکس جهت تراز عمودی دقیق بالا و پایین */
        text-align: right !important;
        position: relative !important;
        z-index: 2 !important;
    }

    /* عنوان مقاله در بالای باکس متن */
    .rp-blog-card-title-wrap {
        order: 1 !important;
        margin-bottom: 0 !important;
        width: 100% !important;
    }

    .rp-blog-card-title {
        font-size: 0.85rem !important;
        font-weight: 800 !important;
        color: #0f172a !important;
        line-height: 1.45 !important;
        margin: 0 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        word-break: break-word !important;
        min-height: unset !important;
        max-height: calc(0.85rem * 1.45 * 2) !important;
        letter-spacing: -0.01em !important;
    }

    .rp-blog-card-title-link {
        color: #0f172a !important;
        text-decoration: none !important;
        transition: color 0.2s ease;
    }

    /* متای زمان مطالعه و تاریخ در پایین باکس متن */
    .rp-blog-card-meta {
        order: 2 !important;
        margin-bottom: 0 !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        font-size: 0.72rem !important;
        font-weight: 500 !important;
        color: #94a3b8 !important;
        line-height: 1.2 !important;
    }

    /* چیدمان زمان مطالعه در راست، نقطه در وسط، و تاریخ در چپ */
    .rp-blog-card-readtime {
        order: 1 !important;
    }

    .rp-blog-card-meta-dot {
        order: 2 !important;
        opacity: 0.7 !important;
        font-size: 8px !important;
    }

    .rp-blog-card-date {
        order: 3 !important;
    }

    /* عدم نمایش خلاصه و دکمه ادامه مطلب در کارت فشرده موبایل طبق تصویر نمونه */
    .rp-blog-card-excerpt,
    .rp-blog-card-footer {
        display: none !important;
    }
}

@media (max-width: 360px) {
    .rp-blog-card {
        padding: 0.75rem 0.85rem !important;
        gap: 0.65rem !important;
    }

    .rp-blog-card-media {
        width: 82px !important;
        height: 82px !important;
        min-width: 82px !important;
        border-radius: 0.85rem !important;
    }

    .rp-blog-card-body {
        height: 82px !important;
    }

    .rp-blog-card-title {
        font-size: 0.78rem !important;
    }

    .rp-blog-card-meta {
        font-size: 0.68rem !important;
    }
}
