/* =========================
   Vars & Base
   ========================= */
.view-hash-wrapper {
    --vh-gap: 16px; /* از کنترل Items Gap */
    --vh-pill-h: 40px; /* از کنترل Pill Height */
    --vh-pad-x: 16px; /* از کنترل Pill Horizontal Padding */
    direction: rtl;
}

/* اسکرول افقی (حالت لیستی) */
.view-hash-scroller {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--vh-gap, 16px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px;
    scroll-behavior: smooth;
}

/* Snap از طریق data-attr روی wrapper */
.view-hash-wrapper[data-snap="proximity"] .view-hash-scroller {
    scroll-snap-type: x proximity;
}

.view-hash-wrapper[data-snap="mandatory"] .view-hash-scroller {
    scroll-snap-type: x mandatory;
}

/* مخفی کردن اسکرولبار */
.view-hash--hide-scrollbar .view-hash-scroller::-webkit-scrollbar {
    display: none;
    height: 0;
}

.view-hash--hide-scrollbar .view-hash-scroller {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* انتخاب‌پذیری بهتر روی موبایل */
.view-hash-scroller, .view-hash-pill {
    -webkit-tap-highlight-color: transparent;
}

/* =========================
   Pill
   ========================= */
.view-hash-pill {
    flex: 0 0 auto; /* برای اسکرول افقی */
    scroll-snap-align: start;
    height: var(--vh-pill-h, 40px);
    padding: 0 var(--vh-pad-x, 16px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-direction: row-reverse; /* RTL: علامت # سمت راست */
    border-radius: 22px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .06), inset 0 0 0 1px rgba(255, 255, 255, .6);
    text-decoration: none;
    white-space: nowrap;
    transition: transform .15s ease, box-shadow .2s ease;
    min-width: 0;
}

.view-hash-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
}

.view-hash-text {
    font-weight: 700;
    font-size: 14px;
    color: #242633; /* با کنترل text_color override می‌شود */
    line-height: 1;
}

.view-hash-hash {
    margin-inline-start: 8px;
    font-weight: 900;
    font-size: 16px;
    line-height: 1;
    opacity: .75;
}

/* =========================
   Swiper (دسکتاپ/تبلت)
   ========================= */
.view-hash-swiper {
    width: 100%;
}

.view-hash-swiper .swiper-wrapper {
    align-items: stretch;
}

.view-hash-swiper .swiper-slide {
    width: auto;
}

/* =========================
   Grid (موبایل)
   ========================= */
.view-hash-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--vh-gap, 16px);
}

.view-hash-grid .view-hash-pill {
    width: 100%;
    justify-content: center;
    flex: initial;
    height: 48px;
    border-radius: 56px;
    box-sizing: border-box;
}

/* =========================
   Alternating Colors (Odd/Even)
   ========================= */

/* پس‌زمینه ODD */
.view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(odd),
.view-hash-wrapper .view-hash-scroller .view-hash-pill:nth-child(odd),
.view-hash-wrapper .view-hash-swiper .swiper-slide:nth-child(odd) .view-hash-pill {
    background-color: var(--view-secondary-100);
}

/* پس‌زمینه EVEN */
.view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(even),
.view-hash-wrapper .view-hash-scroller .view-hash-pill:nth-child(even),
.view-hash-wrapper .view-hash-swiper .swiper-slide:nth-child(even) .view-hash-pill {
    background-color: var(--view-primary-100);
}

/* رنگ # در ODD */
.view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(odd) .view-hash-hash,
.view-hash-wrapper .view-hash-scroller .view-hash-pill:nth-child(odd) .view-hash-hash,
.view-hash-wrapper .view-hash-swiper .swiper-slide:nth-child(odd) .view-hash-pill .view-hash-hash {

    color: var(--view-secondary);
}

/* رنگ # در EVEN */
.view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(even) .view-hash-hash,
.view-hash-wrapper .view-hash-scroller .view-hash-pill:nth-child(even) .view-hash-hash,
.view-hash-wrapper .view-hash-swiper .swiper-slide:nth-child(even) .view-hash-pill .view-hash-hash {
    color: var(--view-primary);
}

/* =========================
   Small Responsive Tweaks
   ========================= */
@media (max-width: 767px) {
    .view-hash-pill {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 767px) {
    /* هر چیزی از قبل هست خنثی کن */
    .view-hash-wrapper .view-hash-grid .view-hash-pill {
        background-color: transparent !important;
    }

    /* هر ردیف دوم (با شروع از 1) تنظیم شطرنجی */
    .view-hash-wrapper .view-hash-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--vh-gap, 16px);
    }

    /* الگو شطرنجی: ستون راست و چپ متفاوت */
    .view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(4n + 1),
    .view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(4n + 4) {
        background-color: var(--view-primary-100) !important; /* آبی */
    }

    .view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(4n + 2),
    .view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(4n + 3) {
        background-color: var(--view-secondary-100) !important; /* قرمز */
    }

    /* رنگ علامت # برای هارمونی با پس‌زمینه */
    .view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(4n + 1) .view-hash-hash,
    .view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(4n + 4) .view-hash-hash {
        color: var(--view-primary) !important;
    }

    .view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(4n + 2) .view-hash-hash,
    .view-hash-wrapper .view-hash-grid .view-hash-pill:nth-child(4n + 3) .view-hash-hash {
        color: var(--view-secondary) !important;
    }
}
