/**
 * emadbrz – Courses/Products section: کارت دوره مطابق طراحی، ووکامرس، دوزبانه + RTL.
 */

.emadbrz-products {
    --pc-gold: #d4a017;
    --pc-gold-light: #e6b422;
    --pc-blue: #3b82f6;
    --pc-blue-light: #60a5fa;
    --pc-card-bg: #1a1a1d;
    --pc-card-bg-alt: #161618;
    --pc-bar-track: rgba(255, 255, 255, 0.1);
    --pc-text: rgba(255, 255, 255, 0.95);
    --pc-muted: rgba(255, 255, 255, 0.5);
    --pc-border: rgba(255, 255, 255, 0.08);
    padding: clamp(3rem, 8vw, 5rem) 20px;
    position: relative;
    overflow: hidden;
}

/* تزئین ظریف پس‌زمینه سکشن */
.emadbrz-products::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
    pointer-events: none;
}

.emadbrz-products__wrap {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ========== هدر سکشن ========== */
.emadbrz-products__head {
    text-align: center;
    margin-bottom: clamp(2rem, 4vw, 3rem);
    position: relative;
}

.emadbrz-products__title {
    margin: 0 0 0.5rem;
    font-size: clamp(1.75rem, 3.5vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.9) 50%, var(--pc-gold-light) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.emadbrz-products__title::after {
    content: '';
    display: block;
    width: 4rem;
    height: 3px;
    margin: 0.6rem auto 0;
    background: linear-gradient(90deg, transparent, var(--pc-gold), transparent);
    border-radius: 2px;
}

.emadbrz-products__subtitle {
    margin: 0 0 1rem;
    font-size: clamp(0.95rem, 1.2vw, 1.05rem);
    color: var(--pc-muted);
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.emadbrz-products--rtl .emadbrz-products__subtitle {
    margin-left: auto;
    margin-right: auto;
}

.emadbrz-products__view-all {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--pc-gold-light);
    text-decoration: none;
    border: 1px solid rgba(212, 160, 23, 0.35);
    padding: 0.4rem 1rem;
    border-radius: 100px;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.emadbrz-products__view-all:hover {
    color: #fff;
    border-color: var(--pc-gold);
    background: rgba(212, 160, 23, 0.12);
}

/* ========== گرید کارت‌ها ========== */
.emadbrz-products__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(1.25rem, 2.5vw, 1.75rem);
}

/* ========== کارت محصول — کوتاه‌تر، جذاب‌تر، خلاقانه ========== */
.emadbrz-product-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: var(--pc-card-bg);
    border: 1px solid var(--pc-border);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease, border-color 0.25s;
}

/* خط تاپ گرادیانی طلایی (تزئین) */
.emadbrz-product-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--pc-gold-light), var(--pc-gold), transparent);
    opacity: 0.6;
    z-index: 1;
    transition: opacity 0.3s;
}

.emadbrz-product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(212, 160, 23, 0.15), 0 0 40px rgba(212, 160, 23, 0.08);
    border-color: rgba(255, 255, 255, 0.1);
}

.emadbrz-product-card:hover::before {
    opacity: 1;
}

.emadbrz-product-card__link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
    min-height: 0;
}

/* بخش تصویر — ارتفاع کمتر (نسبت پهن‌تر) */
.emadbrz-product-card__media {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    flex-shrink: 0;
}

/* گرادیان نرم پایین تصویر برای عمق */
.emadbrz-product-card__media::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.4), transparent);
    pointer-events: none;
}

.emadbrz-product-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.emadbrz-product-card__link:hover .emadbrz-product-card__img {
    transform: scale(1.08);
}

.emadbrz-product-card__img--placeholder {
    background: linear-gradient(135deg, #2a2a2e 0%, #1e1e22 100%);
    display: block;
}

/* بوکمارک — ظریف‌تر با حلقه نوری */
.emadbrz-product-card__bookmark {
    position: absolute;
    bottom: 10px;
    left: 10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: background 0.25s, transform 0.25s, color 0.25s;
    z-index: 1;
}

.emadbrz-product-card__link:hover .emadbrz-product-card__bookmark {
    background: rgba(212, 160, 23, 0.25);
    color: var(--pc-gold-light);
    border-color: rgba(212, 160, 23, 0.5);
    transform: scale(1.05);
}

.emadbrz-product-card__bookmark svg {
    width: 16px;
    height: 16px;
}

.emadbrz-products--rtl .emadbrz-product-card__bookmark {
    left: auto;
    right: 10px;
}

/* بدنه کارت — فشرده‌تر و تمیز */
.emadbrz-product-card__body {
    padding: 0.95rem 1rem;
    background: linear-gradient(180deg, var(--pc-card-bg) 0%, var(--pc-card-bg-alt) 100%);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-height: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.emadbrz-product-card__name {
    margin: 0;
    font-size: clamp(0.9rem, 1.05vw, 1rem);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--pc-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}

.emadbrz-product-card__link:hover .emadbrz-product-card__name {
    color: #fff;
}

/* مدرس / نویسنده */
.emadbrz-product-card__instructor {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--pc-muted);
}

.emadbrz-product-card__instructor-avatar {
    flex-shrink: 0;
}

.emadbrz-product-card__avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: block;
    object-fit: cover;
}

.emadbrz-product-card__instructor-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.emadbrz-product-card__instructor-check {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: #22c55e;
}

.emadbrz-product-card__instructor-check svg {
    width: 100%;
    height: 100%;
}

/* نوار تخفیف — طراحی بازنویسی‌شده: نوار باریک طلایی + درصد کنارش */
.emadbrz-product-card__bar {
    position: relative;
    display: inline-block;
    width: 88px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: visible;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.emadbrz-products--rtl .emadbrz-product-card__bar {
    margin-right: 0;
    margin-left: auto;
}

/* بخش پر شده */
.emadbrz-product-card__bar-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 50%; /* توسط inline style پر می‌شود */
    min-width: 0;
    background: linear-gradient(90deg, var(--pc-gold) 0%, var(--pc-gold-light) 100%);
    border-radius: 999px;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.emadbrz-products--rtl .emadbrz-product-card__bar-fill {
    left: auto;
    right: 0;
}

/* درصد: کنار نوار، نه روی آن */
.emadbrz-product-card__bar-label {
    position: absolute;
    top: 50%;
    left: calc(100% + 6px);
    transform: translateY(-50%);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--pc-gold-light);
    white-space: nowrap;
    z-index: 1;
}

.emadbrz-products--rtl .emadbrz-product-card__bar-label {
    left: auto;
    right: calc(100% + 6px);
}

/* قیمت و آمار در یک ردیف */
.emadbrz-product-card__price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 0.15rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.emadbrz-product-card__prices {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.35rem;
    min-width: 0;
}

.emadbrz-product-card__price-old {
    font-size: 0.8rem;
    color: var(--pc-muted);
    text-decoration: line-through;
}

.emadbrz-product-card__price-current {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--pc-gold-light);
    transition: color 0.2s;
}

.emadbrz-product-card__link:hover .emadbrz-product-card__price-current {
    color: var(--pc-gold);
}

.emadbrz-product-card__price-current .woocommerce-Price-amount {
    color: inherit;
}

/* آمار: بازدید، نظر، دانشجو */
.emadbrz-product-card__stats {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.emadbrz-product-card__stat {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.72rem;
    color: var(--pc-muted);
    transition: color 0.2s;
}

.emadbrz-product-card__link:hover .emadbrz-product-card__stat {
    color: rgba(255, 255, 255, 0.65);
}

.emadbrz-product-card__stat svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    opacity: 0.9;
}

.emadbrz-products--rtl .emadbrz-product-card__stats {
    flex-direction: row-reverse;
}

/* پیام خالی */
.emadbrz-products__empty {
    text-align: center;
    color: var(--pc-muted);
    font-size: 1rem;
    margin: 0;
    padding: 2rem;
}

/* ========== انیمیشن اسکرول ========== */
.emadbrz-products__head,
.emadbrz-product-card {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1), transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.emadbrz-products.is-visible .emadbrz-products__head { opacity: 1; transform: translateY(0); transition-delay: 0.05s; }
.emadbrz-products.is-visible .emadbrz-products__grid .emadbrz-product-card:nth-child(1) { opacity: 1; transform: translateY(0); transition-delay: 0.12s; }
.emadbrz-products.is-visible .emadbrz-products__grid .emadbrz-product-card:nth-child(2) { opacity: 1; transform: translateY(0); transition-delay: 0.2s; }
.emadbrz-products.is-visible .emadbrz-products__grid .emadbrz-product-card:nth-child(3) { opacity: 1; transform: translateY(0); transition-delay: 0.28s; }

@media (prefers-reduced-motion: reduce) {
    .emadbrz-products__head,
    .emadbrz-product-card {
        opacity: 1;
        transform: none;
        transition: none;
    }
}

/* ========== رسپانسیو ========== */
@media (max-width: 991px) {
    .emadbrz-products__grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .emadbrz-products.is-visible .emadbrz-products__grid .emadbrz-product-card:nth-child(3) {
        grid-column: 1 / -1;
    }
    .emadbrz-products__grid .emadbrz-product-card:nth-child(3) {
        max-width: 400px;
        margin-inline: auto;
        width: 100%;
    }
}

@media (max-width: 575px) {
    .emadbrz-products {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
    .emadbrz-products__grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    .emadbrz-products__grid .emadbrz-product-card:nth-child(3) {
        max-width: none;
    }
    .emadbrz-product-card__body {
        padding: 1rem 1rem;
    }
    .emadbrz-product-card__price-row {
        flex-wrap: wrap;
    }
    .emadbrz-product-card__stats {
        width: 100%;
        justify-content: flex-end;
    }
}

@media (max-width: 380px) {
    .emadbrz-product-card__media {
        aspect-ratio: 16 / 9;
    }
    .emadbrz-product-card__body {
        padding: 0.85rem 0.9rem;
    }
}
