.hpb-carousel {
    position: relative;
    width: 100%;
    max-width: 100%;
    direction: rtl;
    overflow: hidden;
}

.hpb-carousel__swiper {
    width: 100%;
    max-width: 100%;
    padding: 0 0 36px;
    overflow: hidden;
    box-sizing: border-box;
}

/* Horizontal slide track even before Swiper initializes */
.hpb-carousel .swiper-wrapper {
    display: flex;
    flex-direction: row;
    align-items: stretch;
}

.hpb-carousel .swiper-slide {
    flex-shrink: 0;
    height: auto;
    box-sizing: border-box;
}

/* Fallback scroll when Swiper JS/CSS has not initialized yet */
.hpb-carousel__swiper:not(.swiper-initialized) .swiper-wrapper {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: var(--hpb-gap, 16px);
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.hpb-carousel__swiper:not(.swiper-initialized) .swiper-slide {
    flex: 0 0 calc((100% - (var(--hpb-cols, 4) - 1) * var(--hpb-gap, 16px)) / var(--hpb-cols, 4));
    min-width: 140px;
    scroll-snap-align: start;
    opacity: 1;
    animation: none;
}

@media (max-width: 575.98px) {
    .hpb-carousel__swiper:not(.swiper-initialized) .swiper-slide {
        flex: 0 0 calc((100% - (var(--hpb-cols-mobile, var(--hpb-cols, 1)) - 1) * var(--hpb-gap, 16px)) / var(--hpb-cols-mobile, var(--hpb-cols, 1)));
        min-width: 72px;
    }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .hpb-carousel__swiper:not(.swiper-initialized) .swiper-slide {
        flex: 0 0 calc((100% - (var(--hpb-cols-tablet, var(--hpb-cols, 2)) - 1) * var(--hpb-gap, 16px)) / var(--hpb-cols-tablet, var(--hpb-cols, 2)));
    }
}

.hpb-carousel__slide {
    height: auto;
    opacity: 0;
    animation: hpbCrEnter 0.55s ease forwards;
    animation-delay: var(--hpb-stagger, 0ms);
}

@keyframes hpbCrEnter {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: none; }
}

.hpb-carousel .hamta-product-card,
.hpb-carousel .hpb-product-loop.product-card {
    margin: 0 auto;
    max-width: 100%;
}

/* تامبنیل listing: نسبت یکسان برای هم‌ترازی کارت‌ها در کاروسل */
.hpb-carousel.hpb-listing-thumbs .hamta-product-card .product-image,
.hpb-carousel.hpb-listing-thumbs .hpb-product-loop.product-card .product-image {
    width: 100%;
    max-width: min(var(--hpb-listing-max-w-d, 300px), 100%);
    margin-inline: auto;
    aspect-ratio: 1 / 1;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

@media (max-width: 999px) {
    .hpb-carousel.hpb-listing-thumbs .hamta-product-card .product-image,
    .hpb-carousel.hpb-listing-thumbs .hpb-product-loop.product-card .product-image {
        max-width: min(var(--hpb-listing-max-w-t, var(--hpb-listing-max-w-d, 300px)), 100%);
    }
}

@media (max-width: 767px) {
    .hpb-carousel.hpb-listing-thumbs .hamta-product-card .product-image,
    .hpb-carousel.hpb-listing-thumbs .hpb-product-loop.product-card .product-image {
        max-width: min(var(--hpb-listing-max-w-m, var(--hpb-listing-max-w-t, 300px)), 100%);
    }
}

.hpb-carousel.hpb-listing-thumbs .hamta-product-card .product-image img,
.hpb-carousel.hpb-listing-thumbs .hamta-product-card .product-image picture,
.hpb-carousel.hpb-listing-thumbs .hamta-product-card .product-image picture img,
.hpb-carousel.hpb-listing-thumbs .hamta-listing-product-img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.hpb-carousel--marquee .swiper-wrapper {
    transition-timing-function: linear !important;
}

/* کاروسل «ارزش‌ها / What makes us» — یک کارت در فوکوس، بدون تغییر JS */
.hpb-carousel--values .swiper-slide {
    height: auto;
}

.hpb-carousel--values .hpb-card,
.hpb-carousel--values .hamta-product-card,
.hpb-carousel--values .hpb-product-loop.product-card {
    max-width: min(560px, 92vw);
    margin-inline: auto;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.hpb-carousel--values .hpb-card__body,
.hpb-carousel--values .hamta-product-card .product-info {
    padding: 1.25rem 1.5rem 1.5rem;
}

@media (min-width: 768px) {
    .hpb-carousel--values.swiper,
    .hpb-carousel--values .hpb-carousel__swiper {
        overflow: visible;
    }
}

/* Frame + nav shell */
.hpb-carousel__frame {
    position: relative;
    display: flex;
    align-items: stretch;
    width: 100%;
}

.hpb-carousel__frame > .hpb-carousel__swiper {
    flex: 1 1 auto;
    min-width: 0;
}

.hpb-carousel--pagination-on {
    padding-bottom: 44px;
}

.hpb-carousel--pag-progressbar {
    padding-bottom: 28px;
}

.hpb-carousel .hpb-carousel__arrow,
.hpb-carousel .swiper-button-prev,
.hpb-carousel .swiper-button-next {
    color: var(--hpb-nav-color, #000) !important;
    width: var(--hpb-nav-size, 36px) !important;
    height: var(--hpb-nav-size, 36px) !important;
    background: var(--hpb-nav-bg, transparent) !important;
    border: none !important;
    border-radius: 0;
    box-shadow: none !important;
    margin-top: 0 !important;
    top: 50% !important;
    transform: translateY(-50%);
}

.hpb-carousel .swiper-button-prev::after,
.hpb-carousel .swiper-button-next::after {
    font-size: 1.15rem;
    font-weight: 700;
}

.hpb-carousel--arrows-outside .hpb-carousel__frame,
.hpb-carousel--arrows-sides .hpb-carousel__frame {
    padding: 0 calc(var(--hpb-nav-size, 40px) + 16px);
}

.hpb-carousel__arrow--outside {
    position: relative !important;
    flex: 0 0 var(--hpb-nav-size, 40px);
    align-self: center;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    transform: none;
    z-index: 12;
}

.hpb-carousel__pagination.swiper-pagination {
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 10px !important;
    width: 100% !important;
    z-index: 15;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.hpb-carousel--pag-fraction .hpb-carousel__pagination.swiper-pagination-fraction {
    color: var(--hpb-dot-color, #fff);
    font-size: 14px;
    font-weight: 600;
}

.hpb-carousel--pag-progressbar .hpb-carousel__pagination.swiper-pagination-progressbar {
    height: 4px !important;
    background: rgba(255, 255, 255, 0.25);
}

.hpb-carousel--pag-progressbar .swiper-pagination-progressbar-fill {
    background: var(--hpb-dot-active, #0d6efd) !important;
}

.hpb-carousel__pagination .swiper-pagination-bullet {
    width: var(--hpb-dot-size, 8px);
    height: var(--hpb-dot-size, 8px);
    background: var(--hpb-dot-color, #94a3b8);
    opacity: 0.7;
}

.hpb-carousel__pagination .swiper-pagination-bullet-active {
    background: var(--hpb-dot-active, #0d6efd);
    opacity: 1;
}

.hpb-dots--square .swiper-pagination-bullet {
    border-radius: 2px;
}

.hpb-dots--bar .swiper-pagination-bullet {
    width: calc(var(--hpb-dot-size, 8px) * 2.5);
    border-radius: 3px;
}

/* Card layouts */
.hpb-card {
    position: relative;
    height: 100%;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15,23,42,0.05), 0 4px 16px rgba(15,23,42,0.07);
    transition: transform 0.32s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.32s ease;
}
.hpb-card-layout--horizontal {
    display: grid;
    grid-template-columns: 38% 1fr;
    gap: 12px;
    align-items: stretch;
}

.hpb-card-layout--horizontal .hpb-card__image {
    height: 100%;
}

.hpb-card-layout--overlay {
    position: relative;
}

.hpb-card-layout--overlay .hpb-card__body {
    position: absolute;
    inset: auto 0 0 0;
    padding: 16px;
    background: linear-gradient(transparent, rgba(15, 23, 42, 0.72));
    color: #fff;
}

.hpb-card-layout--overlay .hpb-card__title,
.hpb-card-layout--overlay .hpb-card__title a,
.hpb-card-layout--overlay .hpb-card__caption {
    color: #fff;
}

.hpb-card-frame--glass {
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.hpb-card-frame--bordered {
    border: 1px solid #e2e8f0;
}

.hpb-media-item {
    position: relative;
}

/* Badges */
.hpb-badges {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
}

.hpb-badge {
    position: absolute;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    border-radius: 6px;
    pointer-events: auto;
}

.hpb-badge--pos-top_left { top: 10px; left: 10px; right: auto; bottom: auto; }
.hpb-badge--pos-top_center { top: 10px; left: 50%; transform: translateX(-50%); }
.hpb-badge--pos-top_right { top: 10px; right: 10px; left: auto; }
.hpb-badge--pos-bottom_left { bottom: 10px; left: 10px; top: auto; }
.hpb-badge--pos-bottom_center { bottom: 10px; left: 50%; transform: translateX(-50%); top: auto; }
.hpb-badge--pos-bottom_right { bottom: 10px; right: 10px; top: auto; }
.hpb-badge--pos-overlay_center { top: 50%; left: 50%; transform: translate(-50%, -50%); }

.hpb-badge__countdown {
    display: inline-flex;
    gap: 4px;
    direction: ltr;
}

.hpb-badge__cd-unit {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    min-width: 28px;
    padding: 2px 4px;
    background: rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    font-size: 10px;
}

.hpb-badge__cd-unit span {
    font-size: 13px;
    font-weight: 800;
}

.hpb-badge__countdown-label {
    display: block;
    font-size: 10px;
    margin-bottom: 4px;
}

.hpb-card-hover--lift .hpb-card:hover,
.hpb-card-hover--lift .hamta-product-card:hover,
.hpb-card-hover--lift .hpb-product-loop.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
}

.hpb-card__image {
    display: block;
    overflow: hidden;
}

.hpb-card__image img,
.hpb-card__image .hamta-listing-product-picture,
.hpb-card__image .hamta-listing-product-picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
    display: block;
}

.hpb-card-hover--zoom .hpb-card:hover .hpb-card__image img {
    transform: scale(1.05);
}

.hpb-media__video,
.hpb-media__image {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 220px;
    object-fit: contain;
    border-radius: 10px;
    display: block;
}

.hpb-icon-item {
    text-align: center;
    padding: 20px;
    text-decoration: none;
    color: inherit;
}

.hpb-icon__box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: 16px;
    background: #f8fafc;
}

/* ═══════════════════════════════════════════════════
   کارت پست مدرن (hpb-post-card)
   ═══════════════════════════════════════════════════ */

.hpb-post-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #fff;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.05), 0 6px 24px rgba(15, 23, 42, 0.07);
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.32s ease;
}

.hpb-post-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 48px rgba(15, 23, 42, 0.14);
}

/* تصویر */
.hpb-post-card__thumb {
    display: block;
    overflow: hidden;
    position: relative;
    aspect-ratio: 16 / 10;
    background: #f1f5f9;
    flex-shrink: 0;
}

.hpb-post-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: block;
}

.hpb-post-card:hover .hpb-post-card__thumb img {
    transform: scale(1.07);
}

/* badge دسته‌بندی */
.hpb-post-card__cat {
    position: absolute;
    top: 14px;
    inset-inline-start: 14px;
    padding: 4px 14px;
    background: rgba(13, 110, 253, 0.9);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    backdrop-filter: blur(4px);
    letter-spacing: 0.04em;
    line-height: 1.6;
}

/* بدنه */
.hpb-post-card__body {
    padding: 22px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1 1 auto;
}

/* تاریخ */
.hpb-post-card__date {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    font-weight: 500;
    color: #94a3b8;
    letter-spacing: 0.02em;
}

.hpb-post-card__date::before {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #0d6efd;
    flex-shrink: 0;
}

/* تیتر */
.hpb-post-card__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hpb-post-card__title a {
    text-decoration: none;
    color: #0f172a;
    transition: color 0.2s ease;
}

.hpb-post-card__title a:hover {
    color: #0d6efd;
}

/* خلاصه */
.hpb-post-card__excerpt {
    margin: 0;
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.75;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1 1 auto;
}

/* ادامه مطلب */
.hpb-post-card__more {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #0d6efd;
    text-decoration: none;
    border-top: 1px solid #f1f5f9;
    transition: gap 0.22s ease, color 0.22s ease;
}

.hpb-post-card__more:hover {
    gap: 10px;
    color: #0b5ed7;
}

.hpb-post-card__more svg {
    flex-shrink: 0;
    transition: transform 0.22s ease;
}

.hpb-post-card:hover .hpb-post-card__more svg {
    transform: translateX(-4px);
}

/* RTL — فلش به سمت چپ */
[dir="rtl"] .hpb-post-card__more svg {
    transform: scaleX(-1);
}
[dir="rtl"] .hpb-post-card:hover .hpb-post-card__more svg {
    transform: scaleX(-1) translateX(-4px);
}

/* ارتفاع مساوی در carousel */
.hpb-carousel .hpb-post-card {
    height: 100%;
}

.hpb-carousel .swiper-slide {
    height: auto;
}

/* ── بهبود کارت پایه (hpb-card) ──────────────────── */

.hpb-card__image {
    aspect-ratio: 16 / 10;
}

.hpb-card__body {
    padding: 18px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hpb-card__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hpb-card__title a {
    text-decoration: none;
    color: #0f172a;
    transition: color 0.2s ease;
}

.hpb-card__title a:hover {
    color: #0d6efd;
}

.hpb-card__caption {
    margin: 0;
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.7;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hpb-card__btn {
    align-self: flex-start;
    margin-top: 4px;
    padding: 8px 22px;
    background: #0d6efd;
    color: #fff !important;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.2s ease;
    border: none;
    cursor: pointer;
    display: inline-block;
}

.hpb-card__btn:hover {
    background: #0b5ed7;
    transform: translateY(-2px);
}

/* کارت تصویر-تنها (show_title=0, show_caption=0) */
.hpb-post-card--image-only .hpb-post-card__thumb {
    aspect-ratio: 4 / 3;
    border-radius: 14px;
}

.hpb-post-card--image-only .hpb-post-card__thumb img {
    border-radius: 14px;
}

/* ═══════════════════════════════════════════════════
   کارت دسته‌بندی (hpb-cat-card)
   ═══════════════════════════════════════════════════ */

.hpb-cat-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.07);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.28s ease;
}

.hpb-cat-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 36px rgba(15, 23, 42, 0.13);
}

.hpb-cat-card__media {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #f1f5f9;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.hpb-cat-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.45s ease;
    display: block;
}

.hpb-cat-card:hover .hpb-cat-card__media img {
    transform: scale(1.07);
}

.hpb-cat-card__icon {
    font-size: 2.4rem;
    color: #812990;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.hpb-cat-card__media-placeholder {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #e2e8f0;
    display: block;
}

.hpb-cat-card__body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.hpb-cat-card__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hpb-cat-card__count {
    font-size: 0.78rem;
    color: #94a3b8;
    font-weight: 500;
}

/* Admin CSS for category source panel */
.hpb-cat-panel { margin-top: 10px; }
.hpb-cat-mode-row { gap: 16px; margin-bottom: 10px; }
.hpb-cat-manual-section { margin-top: 10px; }
.hpb-cat-items-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.hpb-cat-item-row { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; background: #fafafa; }
.hpb-cat-item-row__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.hpb-cat-term-select { flex: 1; }
.hpb-cat-item-row__fields { margin-bottom: 8px; }
.hpb-cat-item-row__media { margin-top: 8px; }
.hpb-cat-taxonomy-wrap { display: block; margin-bottom: 10px; }

/* ═══════════════════════════════════════════════════
   کارت پست — حالت Overlay (متن روی تصویر)
   ═══════════════════════════════════════════════════ */

.hpb-post-card--overlay {
    display: block;
    height: 100%;
    min-height: 200px;
    text-decoration: none;
    color: #fff;
    border-radius: 14px;
    overflow: hidden;
    position: relative;
}

.hpb-post-card--overlay .hpb-post-card__bg {
    height: 100%;
    min-height: inherit;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

/* گرادیان تاریک از پایین */
.hpb-post-card--overlay .hpb-post-card__overlay-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(15, 23, 42, 0) 30%,
        rgba(15, 23, 42, 0.55) 65%,
        rgba(15, 23, 42, 0.88) 100%
    );
    border-radius: inherit;
    pointer-events: none;
}

/* badge دسته‌بندی */
.hpb-post-card--overlay .hpb-post-card__cat {
    position: absolute;
    top: 12px;
    inset-inline-start: 12px;
    padding: 3px 12px;
    background: rgba(129, 41, 144, 0.88);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 999px;
    backdrop-filter: blur(4px);
    letter-spacing: 0.04em;
    z-index: 2;
}

/* محتوای پایین کارت */
.hpb-post-card--overlay .hpb-post-card__overlay-foot {
    position: relative;
    z-index: 2;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hpb-post-card--overlay .hpb-post-card__date {
    font-size: 11px;
    color: rgba(203, 213, 225, 0.8);
    font-weight: 500;
}

.hpb-post-card--overlay .hpb-post-card__title {
    font-size: 0.98rem;
    font-weight: 700;
    color: #f1f5f9;
    line-height: 1.45;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* hover: zoom تصویر */
.hpb-post-card--overlay .hpb-post-card__bg {
    transition: transform 0.45s ease;
}

.hpb-post-card--overlay:hover .hpb-post-card__bg {
    transform: scale(1.03);
}

.hpb-post-card--overlay .hpb-post-card__no-image {
    height: 100%;
    min-height: inherit;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    display: flex;
    align-items: flex-end;
    padding: 20px;
}
