/*
کادرهای داخل متن: محصول [sc_product] و مقاله [sc_article] — در مقاله‌ها و در توضیحات محصول
(توضیح کامل: inline.php). هر کادر با «عرضی که دارد» چیده می‌شود، نه با عرض صفحه:
در ستون پهن افقی، در ستون باریک (موبایل، نیمهٔ یک کانتینر، ردیف کنار هم) جمع‌وجور.
*/

.sc-pbox,
.sc-abox,
.sc-ibox-slider,
.sc-ibox-row {
    --ib-line:    var(--jr-line, var(--line-paper));
    --ib-bg:      var(--surface-paper-alt);
    --ib-ink:     var(--ink-primary);
    --ib-soft:    var(--ink-soft);
    --ib-subtle:  var(--ink-subtle);
    --ib-brand:   var(--brand);
    --ib-brand-h: var(--brand-h);
    --ib-r:       var(--border-radius-l);
}

/* ---------- یک کادر ---------- */

.sc-pbox,
.sc-abox {
    container-type: inline-size;       /* چیدمانِ داخل، تابع عرض خود کادر */
    box-sizing: border-box;
    flex: 1 1 18rem;                   /* داخل هر ظرف فلکس: کنار هم، هرکدام حداقل ~۲۹۰px */
    min-width: 0;
    margin: 2em 0;
    line-height: 1.7;
}
.sc-pbox__in,
.sc-abox__in {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.25rem;
    height: 100%;
    box-sizing: border-box;
    padding: .875rem 1rem;
    border: 1px solid var(--ib-line);
    border-radius: var(--ib-r);
    background: var(--ib-bg);
}

/* کل کارت قابل کلیک: لینک نام روی تمام کادر کشیده می‌شود؛ دکمه‌ها بالای آن، کار خودشان را می‌کنند */
.sc-pbox__in,
.sc-abox__in { position: relative; transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease; }
.sc-pbox .sc-pbox__name::after,
.sc-abox .sc-abox__name::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: var(--ib-r); }
.sc-pbox .sc-pbox__name:focus-visible { outline: none; }
.sc-pbox .sc-pbox__name:focus-visible::after,
.sc-abox .sc-abox__name:focus-visible::after { outline: 2px solid var(--ib-brand); outline-offset: 2px; }
.sc-abox .sc-abox__name:focus-visible { outline: none; }
.sc-pbox__actions,
.sc-abox__actions { position: relative; z-index: 2; }
.sc-pbox__in:hover,
.sc-abox__in:hover { border-color: color-mix(in srgb, var(--ib-brand) 35%, var(--ib-line)); background: var(--surface-base); box-shadow: 0 6px 20px rgb(var(--shadow-rgb) / calc(.06 * var(--shadow-strength))); }
.sc-pbox__img, .sc-abox__img { transition: transform .5s cubic-bezier(.2, .7, .2, 1); }
.sc-pbox__in:hover .sc-pbox__img,
.sc-abox__in:hover .sc-abox__img { transform: scale(1.04); }

/* لینک‌های داخل کادر: زیرخط و رنگ لینک‌های قالب/متن روی آن‌ها نیاید */
.sc-pbox a, .sc-pbox a:hover, .sc-pbox a:focus, .sc-pbox a:visited,
.sc-abox a, .sc-abox a:hover, .sc-abox a:focus, .sc-abox a:visited { text-decoration: none !important; box-shadow: none; }

.sc-pbox__media,
.sc-abox__media { display: block; overflow: hidden; border-radius: var(--border-radius-m); background: var(--surface-base); }
.sc-pbox__media { aspect-ratio: 1; }
.sc-abox__media { aspect-ratio: 4 / 3; }
.sc-pbox__img { display: block; width: 100%; height: 100%; object-fit: contain; border-radius: 0 !important; mix-blend-mode: multiply; }
.sc-abox__img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 0 !important; }

.sc-pbox__body,
.sc-abox__body { display: grid; gap: .3rem; min-width: 0; }
.sc-pbox__eyebrow,
.sc-abox__eyebrow { font-size: .75rem; font-weight: 600; color: var(--ib-brand); }

.sc-pbox .sc-pbox__name,
.sc-pbox .sc-pbox__name:visited,
.sc-abox .sc-abox__name,
.sc-abox .sc-abox__name:visited {
    font-family: var(--font-headings);
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.6;
    color: var(--ib-ink);
    text-decoration: none;
}
.sc-pbox .sc-pbox__name:hover,
.sc-abox .sc-abox__name:hover,
.sc-pbox__in:hover .sc-pbox__name,
.sc-abox__in:hover .sc-abox__name { color: var(--ib-brand-h) !important; }
.sc-pbox .sc-pbox__name, .sc-abox .sc-abox__name { color: var(--ib-ink) !important; }

.sc-pbox__price { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; font-size: .9375rem; color: var(--ib-ink); }
.sc-pbox__price del { color: var(--ib-subtle); font-size: .85em; }
.sc-pbox__price ins { text-decoration: none; }
.sc-pbox__off { padding: .1rem .45rem; border-radius: var(--border-radius-full); background: var(--status-promo); color: var(--on-dark); font-size: .75rem; }

.sc-abox__excerpt {
    margin: 0 !important;
    font-size: .875rem;
    line-height: 1.85;
    color: var(--ib-soft);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}
.sc-abox__meta { font-size: .75rem; color: var(--ib-subtle); }

.sc-pbox__actions,
.sc-abox__actions { display: flex; align-items: center; gap: .5rem; }
.sc-pbox .sc-pbox__btn,
.sc-pbox .sc-pbox__btn:visited,
.sc-abox .sc-abox__btn,
.sc-abox .sc-abox__btn:visited {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: 2.5rem;
    padding: 0 1.15rem;
    border-radius: var(--border-radius-full);
    background: var(--ib-brand);
    font-size: .875rem;
    font-weight: 600;
    color: var(--on-brand);
    text-decoration: none;
    white-space: nowrap;
}
.sc-abox .sc-abox__btn,
.sc-abox .sc-abox__btn:visited { border: 1px solid var(--ib-brand); background: var(--surface-base); color: var(--ib-brand-h); }
.sc-pbox .sc-pbox__btn:hover, .sc-pbox .sc-pbox__btn:focus-visible { background: var(--ib-brand-h); color: var(--on-brand) !important; }
.sc-abox .sc-abox__btn:hover, .sc-abox .sc-abox__btn:focus-visible { background: var(--ib-brand); border-color: var(--ib-brand); color: var(--on-brand) !important; }
.sc-pbox .sc-pbox__btn { color: var(--on-brand) !important; }
.sc-abox .sc-abox__btn { color: var(--ib-brand-h) !important; }
.sc-abox .sc-abox__btn:hover svg, .sc-pbox .sc-pbox__btn:hover svg { color: var(--on-brand); }
.sc-abox__btn svg { transform: scaleX(-1); }    /* RTL: پیکان به سمت چپ */

.sc-pbox .sc-pbox__add,
.sc-pbox .sc-pbox__add:visited {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--ib-brand);
    border-radius: 50%;
    color: var(--ib-brand);
    text-decoration: none;
}
.sc-pbox .sc-pbox__add { color: var(--ib-brand) !important; background: var(--surface-base); }
.sc-pbox .sc-pbox__add:hover { background: var(--ib-brand); color: var(--on-brand) !important; }
.sc-pbox__add.loading { opacity: .5; }
.sc-pbox .added_to_cart { display: none; }

/* کادر باریک (موبایل، نیمهٔ یک کانتینر، کارت‌های ردیف): عکس و متن کنار هم، دکمه‌ها زیرشان */
@container (max-width: 34rem) {
    .sc-pbox__in,
    .sc-abox__in { grid-template-columns: 5rem minmax(0, 1fr); gap: .6rem .9rem; padding: .75rem; }
    .sc-pbox__actions,
    .sc-abox__actions { grid-column: 1 / -1; }
    .sc-pbox .sc-pbox__btn,
    .sc-abox .sc-abox__btn { flex: 1; }
    .sc-pbox .sc-pbox__name,
    .sc-abox .sc-abox__name { font-size: .975rem; }
    .sc-abox__excerpt { display: none; }
}


/* ---------- چند کادر کنار هم: [sc_product count="2"] / ids="…" ---------- */

.sc-ibox-slider { margin: 2em 0; }

.sc-ibox-row {
    display: flex;
    gap: .875rem;
    margin: 0;
    padding: 2px 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;                       /* نوار اسکرول پیش‌فرض نه؛ نوار پیشرفت خودمان زیرش */
    list-style: none;
    -webkit-overflow-scrolling: touch;
}
.sc-ibox-row::-webkit-scrollbar { display: none; }
.sc-ibox-row > .sc-pbox,
.sc-ibox-row > .sc-abox {
    flex: 1 0 min(19rem, 82%);                   /* هر کادر حداقل ~۳۰۴px؛ جا کم شد، ردیف کشیدنی می‌شود */
    margin: 0;
    scroll-snap-align: start;
}
.sc-ibox-row.is-dragging,
.sc-ibox-row.is-moving { scroll-snap-type: none; }
.sc-ibox-row.is-dragging { cursor: grabbing; user-select: none; }
.sc-ibox-row.is-dragging a { pointer-events: none; }
.sc-ibox-row a, .sc-ibox-row img { -webkit-user-drag: none; }
@media (hover: hover) and (pointer: fine) { .sc-ibox-row.can-drag { cursor: grab; } }

/* نوار پیشرفت + دکمه‌ها (فقط وقتی ردیف از عرض بیرون می‌زند) */
.sc-ibox-nav {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-top: .875rem;
}
.sc-ibox-nav[hidden] { display: none; }
.sc-ibox-nav__track {
    position: relative;
    flex: 1;
    height: 4px;
    border-radius: var(--border-radius-full);
    background: color-mix(in srgb, var(--ib-ink) 9%, transparent);
    overflow: hidden;
}
.sc-ibox-nav__thumb {
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-start: calc(var(--tp, 0) * (100% - var(--tw, .3) * 100%));
    width: calc(var(--tw, .3) * 100%);
    border-radius: inherit;
    background: var(--ib-brand);
    transition: inset-inline-start .12s linear;
}
.sc-ibox-nav__btn {
    --f: 1;
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--ib-line);
    border-radius: 50%;
    background: var(--surface-base);
    color: var(--ib-ink);
    cursor: pointer;
    box-shadow: 0 1px 3px rgb(var(--shadow-rgb) / calc(.06 * var(--shadow-strength)));
    transition: background-color .2s ease, color .2s ease, border-color .2s ease, opacity .2s ease;
}
.sc-ibox-nav__btn svg { transform: scaleX(var(--f)); }
.sc-ibox-nav__prev { --f: -1; }
html[dir="rtl"] .sc-ibox-nav__prev { --f: 1; }
html[dir="rtl"] .sc-ibox-nav__next { --f: -1; }
.sc-ibox-nav__btn:hover:not(:disabled) { border-color: var(--ib-brand); background: var(--ib-brand); color: var(--on-brand); }
.sc-ibox-nav__btn:disabled { opacity: .35; cursor: default; box-shadow: none; }
.sc-ibox-nav__btn:focus-visible { outline: 2px solid var(--ib-brand); outline-offset: 2px; }
/* لمسی: فقط نوار پیشرفت (کشیدن با انگشت طبیعی‌تر از دکمه است) */
@media (hover: none), (max-width: 767px) {
    .sc-ibox-nav__btn { display: none; }
    .sc-ibox-nav { margin-top: .75rem; }
    .sc-ibox-nav__track { height: 3px; max-width: 8rem; margin-inline: auto; }
}

/* اگر کادرها را خودتان در یک کانتینر فلکس (افقی) بگذارید، کنار هم و هم‌قد می‌نشینند */
.is-layout-flex > .sc-pbox, .is-layout-flex > .sc-abox,
.gb-container > .sc-pbox, .gb-container > .sc-abox { margin: 0; }

/* خیلی باریک (مثلاً دو کادر در یک کانتینر فلکس روی موبایل): کارت عمودی */
@container (max-width: 15.5rem) {
    .sc-pbox__in,
    .sc-abox__in { grid-template-columns: minmax(0, 1fr); justify-items: stretch; text-align: center; gap: .5rem; padding: .65rem; }
    .sc-pbox__media { width: 5.5rem; justify-self: center; }
    .sc-abox__media { width: 100%; }
    .sc-pbox__price { justify-content: center; font-size: .875rem; }
    .sc-pbox__eyebrow, .sc-abox__eyebrow { display: none; }
    .sc-pbox .sc-pbox__name, .sc-abox .sc-abox__name { font-size: .875rem; line-height: 1.7; }
    .sc-pbox__actions, .sc-abox__actions { flex-direction: column-reverse; align-items: stretch; }
    .sc-pbox .sc-pbox__add { display: none; }    /* جای کم: فقط «مشاهده و خرید» */
    .sc-pbox .sc-pbox__btn, .sc-abox .sc-abox__btn { padding: 0 .6rem; font-size: .8125rem; }
}
