/* =========================================================================
   Product page rails (bpr-), vertical book cards (bpc-) and the
   "bought together" bundle (bpt-). One row each, native scroll-snap
   (no Swiper), arrows that know where the row starts and ends.
   Mirror to public/themes/theme_aster/public/assets/css/ after editing.
   ========================================================================= */

.bp-scope .bpr-section, .bp-scope .bpt { margin-block-start: 36px; }
.bpr-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-block-end: 14px; }
.bpr-title { font-size: 21px; font-weight: 800; margin: 0; color: var(--bp-ink, #1c1613); letter-spacing: -.01em; }
.bpr-sub { margin: 4px 0 0; font-size: 13.5px; color: var(--bp-muted, #6b6b6b); }

/* arrows */
.bp-scope .bpr-arrows { display: flex; gap: 8px; flex: 0 0 auto; }
.bp-scope .bpr-arrow {
    inline-size: 40px; block-size: 40px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--bp-line, #e5e5e5); background: var(--bp-surface, #fff);
    color: var(--bp-ink, #1c1613); font-size: 15px; cursor: pointer;
    transition: background-color .18s ease, color .18s ease, border-color .18s ease, opacity .18s ease;
}
.bp-scope .bpr-arrow:hover:not(:disabled) { background: var(--bp-brand, #4A2E1C); border-color: var(--bp-brand, #4A2E1C); color: #fff; }
.bp-scope .bpr-arrow:focus-visible { outline: 2px solid var(--bp-brand, #4A2E1C); outline-offset: 2px; }
.bp-scope .bpr-arrow:disabled { opacity: .35; cursor: default; }
.bpr-section.bpr-fits .bpr-arrows { visibility: hidden; }

/* rail */
.bpr { position: relative; }
.bpr-track {
    --bpr-card: 180px;
    display: grid; grid-auto-flow: column; grid-auto-columns: var(--bpr-card);
    gap: 16px;
    overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scroll-behavior: smooth;
    padding: 2px 2px 10px;
    scrollbar-width: none;
}
.bpr-track::-webkit-scrollbar { display: none; }
.bpr-dense .bpr-track { --bpr-card: 168px; }
.bpr::before, .bpr::after {
    content: ""; position: absolute; z-index: 2; inset-block: 0 10px; inline-size: 36px; pointer-events: none;
    opacity: 0; transition: opacity .2s ease;
}
.bpr::before { inset-inline-start: 0; background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0)); }
.bpr::after { inset-inline-end: 0; background: linear-gradient(to left, #fff, rgba(255, 255, 255, 0)); }
[dir="rtl"] .bpr::before { background: linear-gradient(to left, #fff, rgba(255, 255, 255, 0)); }
[dir="rtl"] .bpr::after { background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0)); }
body[theme="dark"] .bpr::before, body[theme="dark"] .bpr::after { display: none; }
.bpr.has-before::before, .bpr.has-after::after { opacity: 1; }

/* vertical book card */
.bpc {
    scroll-snap-align: start;
    display: flex; flex-direction: column; gap: 8px;
    min-width: 0; padding: 10px; border-radius: 12px;
    background: var(--bp-surface, #fff); border: 1px solid var(--bp-line-soft, #eee);
    transition: border-color .2s ease;
}
.bpc:hover { border-color: var(--bp-line, #e0e0e0); }
.bpc-cover { position: relative; display: block; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: #f4f1ec; }
.bpc-cover img { inline-size: 100%; block-size: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.bpc:hover .bpc-cover img { transform: scale(1.035); }
/* spine shade on the binding side (right in Arabic, left otherwise) */
.bpc-cover::after {
    content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; inline-size: 10px; pointer-events: none;
    background: linear-gradient(to right, rgba(0, 0, 0, .18), rgba(0, 0, 0, 0));
}
[dir="rtl"] .bpc-cover::after { background: linear-gradient(to left, rgba(0, 0, 0, .18), rgba(0, 0, 0, 0)); }
.bpc-badge {
    position: absolute; inset-block-start: 8px; inset-inline-end: 8px; z-index: 1;
    padding: 2px 7px; border-radius: 6px; background: #b42318; color: #fff; font-size: 11.5px; font-weight: 700;
}
.bpc-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.bpc-title {
    font-size: 13.5px; font-weight: 700; line-height: 1.45; color: var(--bp-ink, #1c1613) !important;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-block-size: 2.9em;
}
.bpc-title:hover { color: var(--bp-brand, #4A2E1C) !important; }
.bpc-rating { font-size: 12px; color: var(--bp-ink-soft, #3d3d3d); display: flex; align-items: center; gap: 4px; }
.bpc-rating i { color: #c58b00; }
.bpc-rating span { color: var(--bp-muted, #6b6b6b); }
.bpc-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-block-start: auto; }
.bpc-price strong { font-size: 15px; font-weight: 800; color: var(--bp-ink, #1c1613); }
.bpc-price del { font-size: 12px; color: var(--bp-muted, #6b6b6b); }
.bp-scope .bpc-add {
    position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    inline-size: 100%; min-block-size: 36px; border-radius: 8px;
    border: 1px solid var(--bp-brand, #4A2E1C); background: transparent; color: var(--bp-brand, #4A2E1C);
    font-size: 13px; font-weight: 700; cursor: pointer; transition: background-color .18s ease, color .18s ease;
}
.bp-scope .bpc-add:hover, .bpc-add.is-done { background: var(--bp-brand, #4A2E1C); color: #fff; }
.bp-scope .bpc-add.is-loading .bpc-add-label { opacity: 0; }
.bpc-soldout { display: block; text-align: center; font-size: 12.5px; color: var(--bp-muted, #6b6b6b); padding: 8px 0; }

/* ---------- bought together ---------- */
.bpt-box {
    display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: stretch;
    border: 1px solid var(--bp-line, #e5e5e5); border-radius: 12px; background: var(--bp-surface, #fff); padding: 18px;
}
.bpt-items { list-style: none; margin: 0; padding: 0; display: flex; align-items: stretch; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.bpt-items::-webkit-scrollbar { display: none; }
.bpt-item { display: flex; align-items: stretch; flex: 0 1 190px; min-width: 150px; }
.bpt-plus { align-self: center; flex: 0 0 auto; font-size: 22px; font-weight: 300; color: var(--bp-muted, #6b6b6b); padding-inline: 10px; }
.bpt-card {
    position: relative; display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0;
    padding: 10px; border-radius: 10px; border: 1px solid var(--bp-line-soft, #eee); cursor: pointer;
    transition: opacity .2s ease;
}
.bpt-card.is-off { opacity: .45; }
.bp-scope .bpt-check {
    position: absolute; inset-block-start: 14px; inset-inline-start: 14px; z-index: 2;
    inline-size: 20px; block-size: 20px; accent-color: var(--bp-brand, #4A2E1C); cursor: pointer;
}
.bpt-cover { display: block; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden; background: #f4f1ec; }
.bpt-cover img { inline-size: 100%; block-size: 100%; object-fit: cover; display: block; }
.bpt-name { font-size: 13px; font-weight: 600; line-height: 1.45; color: var(--bp-ink, #1c1613); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bpt-name em { display: block; font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--bpx-accent, #9a5a2a); }
.bpt-price { font-size: 14px; font-weight: 800; color: var(--bp-ink, #1c1613); margin-block-start: auto; }
.bpt-sum { display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 18px; border-radius: 10px; background: var(--bp-bg-tint, #f5f5f4); }
.bpt-sum-label { font-size: 14px; color: var(--bp-ink-soft, #3d3d3d); }
.bpt-count { color: var(--bp-muted, #6b6b6b); }
.bpt-sum-value { font-size: 26px; font-weight: 800; color: var(--bp-ink, #1c1613); }
.bp-scope .bpt-add {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-block-size: 46px; border-radius: 10px; border: 0; background: var(--bp-brand, #4A2E1C); color: #fff;
    font-size: 15px; font-weight: 700; cursor: pointer; transition: opacity .18s ease;
}
.bp-scope .bpt-add:hover { opacity: .92; }
.bp-scope .bpt-add:disabled { opacity: .5; cursor: default; }
.bp-scope .bpt-add.is-busy { pointer-events: none; opacity: .7; }
.bpt .bpr { margin-block-start: 16px; }

@media (max-width: 991.98px) { .bpt-box { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
    .bpr-title { font-size: 18px; }
    .bpr-arrows { display: none; }
    .bpr-track { --bpr-card: 44vw; gap: 10px; }
    .bpr-dense .bpr-track { --bpr-card: 40vw; }
    .bpc { padding: 8px; }
    .bpt-box { padding: 12px; }
    .bpt-item { flex: 0 0 40vw; min-width: 0; }
    .bpt-plus { padding-inline: 6px; }
}
@media (prefers-reduced-motion: reduce) {
    .bpr-track { scroll-behavior: auto; }
    .bpc-cover img { transition: none; }
}
