/* Blog Grid Widget v1.1.0 — Direction-aware (RTL / LTR) */

/* ──────────────────────────────────────────────
   WRAPPER & GRID
────────────────────────────────────────────── */
.bgw-wrap {
    position: relative;
}
/* جهت از روی صفت dir روی wrapper تعیین می‌شود — همه فرزندان ارث می‌برند */
.bgw-wrap[dir="rtl"] { direction: rtl; }
.bgw-wrap[dir="ltr"] { direction: ltr; }

.bgw-grid {
    display: grid;
    grid-template-columns: repeat(var(--bgw-cols-d, 3), 1fr);
    gap: var(--bgw-rgap-d, 24px) var(--bgw-gap-d, 24px);
}

@media (max-width: 1024px) {
    .bgw-grid {
        grid-template-columns: repeat(var(--bgw-cols-t, 2), 1fr);
        gap: var(--bgw-rgap-t, 16px) var(--bgw-gap-t, 16px);
    }
}

@media (max-width: 767px) {
    .bgw-grid {
        grid-template-columns: repeat(var(--bgw-cols-m, 1), 1fr);
        gap: var(--bgw-rgap-m, 16px) var(--bgw-gap-m, 12px);
    }
}

/* ──────────────────────────────────────────────
   CARD LINK WRAPPER
────────────────────────────────────────────── */
.bgw-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* ──────────────────────────────────────────────
   CARD
────────────────────────────────────────────── */
.bgw-card {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    box-sizing: border-box;
}

/* ──────────────────────────────────────────────
   IMAGE AREA
────────────────────────────────────────────── */
.bgw-img-wrap {
    position: relative;
    width: 100%;
    height: 280px;
    flex-shrink: 0;
    overflow: hidden;
}

/* تصویر با border-bottom طلایی و radius پایین */
.bgw-img {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-color: #111;
    z-index: 1;
    border-top:    0;
    border-left:   0;
    border-right:  0;
    border-bottom: 1px solid #C9A96E;
    border-bottom-left-radius:  20px;
    border-bottom-right-radius: 20px;
    border-top-left-radius:     0;
    border-top-right-radius:    0;
    box-sizing: border-box;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}
.bgw-card:hover .bgw-img {
    transform: scale(1.03);
}

/* ──────────────────────────────────────────────
   REVEAL — از پایین به بالا (همان منطق اسلایدر)
────────────────────────────────────────────── */
.bgw-reveal {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    height: 100%;
    z-index: 3;
    background: #1f1f1f;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    transform: translateY(100%);
    transition: transform 0.55s cubic-bezier(0.32, 0.72, 0.24, 1);
    will-change: transform;
    pointer-events: none;
}
.bgw-card:hover .bgw-reveal {
    transform: translateY(0);
    pointer-events: auto;
}

/* محتوای reveal */
.bgw-rc {
    flex: 1;
    width: 100%;
    padding: 18px 22px 22px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: start;
}
.bgw-wrap[dir="rtl"] .bgw-rc { text-align: right; }
.bgw-wrap[dir="ltr"] .bgw-rc { text-align: left; }

.bgw-ol-icon {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 14px;
}
.bgw-ol-icon * { display: block; }

.bgw-quote-char {
    color: rgba(255,255,255,0.85);
    font-size: 48px;
    line-height: 1;
    font-family: Georgia, 'Times New Roman', serif;
    font-weight: 700;
    user-select: none;
}

.bgw-excerpt {
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    line-height: 1.85;
    margin: 0 0 14px;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bgw-link {
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1.5px solid #C9A96E;
    padding-bottom: 3px;
    text-decoration: none;
    align-self: flex-start;
    cursor: pointer;
    transition: color 0.2s ease;
}
.bgw-link:hover { color: #C9A96E; }

/* ──────────────────────────────────────────────
   PANEL (پایین کارت)
────────────────────────────────────────────── */
.bgw-panel {
    flex-shrink: 0;
    width: 100%;
    background: #1a1a1a;
    padding: 16px 22px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 90px;
}
.bgw-cat {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #C9A96E;
    margin-bottom: 6px;
    line-height: 1.4;
}
.bgw-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* تراز متن پانل — جلوگیری از تحمیل text-align قالب راست‌چین */
.bgw-wrap[dir="rtl"] .bgw-panel,
.bgw-wrap[dir="rtl"] .bgw-cat,
.bgw-wrap[dir="rtl"] .bgw-title,
.bgw-wrap[dir="rtl"] .bgw-excerpt { text-align: right; }
.bgw-wrap[dir="ltr"] .bgw-panel,
.bgw-wrap[dir="ltr"] .bgw-cat,
.bgw-wrap[dir="ltr"] .bgw-title,
.bgw-wrap[dir="ltr"] .bgw-excerpt { text-align: left; }

/* ──────────────────────────────────────────────
   PAGINATION — عددی مربعی (مطابق تصویر)
────────────────────────────────────────────── */
.bgw-pagination-wrap {
    margin-top: 40px;
    width: 100%;
}
.bgw-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.bgw-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    background: #111;
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition:
        background 0.22s ease,
        border-color 0.22s ease,
        color 0.22s ease;
    box-sizing: border-box;
    /* مربع تیز — بدون border-radius */
    border-radius: 0;
    line-height: 1;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* hover */
.bgw-page-btn:not(.bgw-active):not(.bgw-disabled):not(.bgw-ellipsis):hover {
    background: rgba(201,169,110,0.15);
    border-color: rgba(201,169,110,0.5);
    color: #C9A96E;
}

/* صفحه فعال — طلایی */
.bgw-page-btn.bgw-active {
    background: #C9A96E;
    border-color: #C9A96E;
    color: #111;
    cursor: default;
    pointer-events: none;
}

/* disabled */
.bgw-page-btn.bgw-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

/* ellipsis */
.bgw-page-btn.bgw-ellipsis {
    cursor: default;
    pointer-events: none;
    letter-spacing: 0.05em;
}

/* آیکون SVG داخل دکمه قبلی/بعدی */
.bgw-page-btn.bgw-prev svg,
.bgw-page-btn.bgw-next svg {
    display: block;
    flex-shrink: 0;
}
/* در حالت چپ‌چین جهت فلش‌ها برعکس می‌شود */
.bgw-wrap[dir="ltr"] .bgw-page-btn.bgw-prev svg,
.bgw-wrap[dir="ltr"] .bgw-page-btn.bgw-next svg {
    transform: scaleX(-1);
}

/* ──────────────────────────────────────────────
   RESPONSIVE
────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .bgw-img-wrap   { height: 240px; }
    .bgw-excerpt    { -webkit-line-clamp: 3; }
}

@media (max-width: 767px) {
    .bgw-img-wrap   { height: 220px; }
    .bgw-cat        { font-size: 11px; }
    .bgw-title      { font-size: 13.5px; }
    .bgw-excerpt    { font-size: 12px; -webkit-line-clamp: 3; }
    .bgw-quote-char { font-size: 36px; }
    /* touch tap جایگزین hover در موبایل */
    .bgw-card.bgw-t .bgw-reveal { transform: translateY(0); pointer-events: auto; }
    .bgw-card.bgw-t .bgw-img    { transform: scale(1.03); }
    /* دکمه‌های صفحه‌بندی کوچکتر در موبایل */
    .bgw-page-btn { width: 38px; height: 38px; font-size: 12px; }
}

/* ──────────────────────────────────────────────
   ELEMENTOR EDITOR — نمایش reveal در ویرایشگر
────────────────────────────────────────────── */
.elementor-editor-active .bgw-reveal {
    transform: translateY(0) !important;
}
