/* ==========================================================================
   SELLFY — semua CSS yang berhubungan dengan Sellfy ada di file ini.
   Pasangan:  partials/sellfy/*.hbs  dan  assets/js/sellfy/*.js
   Isi:
     1. Variabel posisi baris tombol beli
     2. Cart Sellfy (kanan atas)
     3. Tombol beli di dalam setiap card reel (.feed-buy__item)
     4. Tampilan tombol beli (Add to cart | Select size... | harga)
     5. Checkout bottom sheet (mobile)
   ========================================================================== */

/* ---------- 1. Variabel ---------- */
:root {
    --buy-bottom: 76px;    /* jarak baris tombol beli dari bawah layar */
    --buy-h: 49px;         /* tinggi tombol beli (lihat bagian 4) */
    --buy-max-w: 320px;    /* lebar maksimal tombol beli */
}
@media (max-width: 480px) {
    :root { --buy-h: 46px; } /* tombol beli lebih kecil di layar kecil */
}

/* ---------- 2. Cart Sellfy (kanan atas) ----------
   Sellfy memberi inline style "position: fixed; top: 18px; right: 18px".
   !important diperlukan untuk menimpa inline style tersebut.
   Isi tombol (ikon, teks, warna) ada di dalam iframe Sellfy →
   hanya bisa diubah lewat Custom code di dashboard Sellfy. */
#sellfy-shopping-cart {
    position: fixed !important;
    top: 14px !important;
    right: 18px !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 31 !important;
}
@media (min-width: 661px) {
    /* reel: kolom 580px di tengah layar */
    #sellfy-shopping-cart {
        right: calc(50vw - 290px + 18px) !important;
    }
    /* homepage, halaman berikutnya & halaman tag: selebar layar */
    .home-template #sellfy-shopping-cart,
    .paged #sellfy-shopping-cart,
    .tag-template #sellfy-shopping-cart { right: 18px !important; }
}
@media (max-width: 660px) {
    /* panel keranjang jangan sampai keluar dari sisi kiri layar */
    #sellfy-shopping-cart iframe {
        max-width: calc(100vw - 36px) !important;
    }
}

/* ---------- 3. Tombol beli di dalam setiap card reel ----------
   sellfy-buy.js menaruh tombol beli DI DALAM card post-nya (.feed-item),
   jadi tombol ikut bergeser bersama gambar & share saat di-swipe.
   Kiri & kanan 14px → tombol beli tepat di tengah.
   (Share ada di baris bawah bersama Home, Menu & sound — screen.css.) */
.feed-buy__item {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: var(--buy-bottom);
    z-index: 6;
    display: flex;
    justify-content: center;
    pointer-events: none;     /* area kosong tidak menghalangi swipe */
}
.feed-buy__item .sellfy-buy-wrap {
    width: 100%;
    margin: 0 !important;     /* embed lama punya "margin: 32px 0" */
    --sb-width: var(--buy-max-w) !important; /* embed lama ikut lebar theme → share tetap sejajar */
}
.feed-buy__item .sellfy-buy-wrap a {
    pointer-events: auto;     /* hanya tombolnya yang bisa diklik */
}

/* ---------- 4. Tampilan tombol beli ----------
   Dulu ditulis di setiap post; sekarang bawaan theme.
   Ubah warna lewat variabel --sb-* di bawah. */
.sellfy-buy-wrap {
    --sb-bg: #fff;            /* latar tombol utama */
    --sb-bg-hover: #fafafa;   /* latar saat hover & active */
    --sb-add-bg: #000;        /* latar "Add to cart" */
    --sb-add-color: #fff;     /* teks "Add to cart" */
    --sb-add-bg-hover: #333;  /* "Add to cart" saat hover & active */
    --sb-text: #111;          /* teks harga */
    --sb-muted: #777;         /* teks "Select size..." */
    --sb-width: var(--buy-max-w); /* lebar maksimal tombol */

    display: flex;
    justify-content: center;
}
.sellfy-buy-wrap a {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto; /* kiri | tengah (boleh menyusut) | kanan */
    align-items: center;
    gap: 12px;
    width: min(100%, var(--sb-width));
    box-sizing: border-box;
    padding: 5px;
    background: var(--sb-bg) !important;
    border: 0 !important;      /* tanpa border (!important → juga untuk embed lama) */
    border-radius: 999px;
    box-shadow: none !important; /* tanpa bayangan */
    color: var(--sb-text) !important;
    font-size: 15px;          /* px, bukan rem → ukuran sama di theme mana pun */
    line-height: 1;
    text-decoration: none !important;
    cursor: pointer;
}
.sellfy-buy-wrap a:hover,
.sellfy-buy-wrap a.active {
    background: var(--sb-bg-hover) !important;
}
.sellfy-buy-wrap a .sb-add {
    padding: 12px 20px;
    background: var(--sb-add-bg);
    border-radius: 999px;
    color: var(--sb-add-color);
    font-weight: 600;
    white-space: nowrap;
}
.sellfy-buy-wrap a:hover .sb-add,
.sellfy-buy-wrap a.active .sb-add {
    background: var(--sb-add-bg-hover);
}
.sellfy-buy-wrap a .sb-size {
    min-width: 0;             /* izinkan kolom tengah menyusut */
    overflow: hidden;
    text-overflow: ellipsis;  /* terpotong rapi jika layar sempit */
    white-space: nowrap;
    text-align: center;
    color: var(--sb-muted);
}
.sellfy-buy-wrap a .sb-price {
    padding-right: 16px;
    color: var(--sb-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
@media (max-width: 480px) {
    .sellfy-buy-wrap a { gap: 8px; font-size: 14px; }
    .sellfy-buy-wrap a .sb-add { padding: 11px 16px; }
    .sellfy-buy-wrap a .sb-price { padding-right: 12px; }
}

/* ---------- 5. Checkout bottom sheet (mobile, sellfy-sheet.js) ---------- */
.sellfy-sheet {
    position: fixed;
    inset: 0;
    z-index: 4000001;         /* di atas reel, slider, grid, Cart, dan menu */
}
.sellfy-sheet[hidden] {
    display: none;
}
.sellfy-sheet__overlay {
    position: absolute;
    inset: 0;
    background: rgba(8,8,10,0.6);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.sellfy-sheet__panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 90dvh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.sellfy-sheet.is-open .sellfy-sheet__overlay {
    opacity: 1;
}
.sellfy-sheet.is-open .sellfy-sheet__panel {
    transform: translateY(0);
}
.sellfy-sheet__bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 8px 10px 8px 16px;
    border-bottom: 1px solid rgba(16,16,20,0.08);
}
.sellfy-sheet__close {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgba(16,16,20,0.06);
    color: var(--ink);
    cursor: pointer;
}
.sellfy-sheet__close:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}
.sellfy-sheet__frame {
    flex: 1;
    width: 100%;
    border: 0;
}
/* Pop-up Sellfy mana pun sedang terbuka (badge, Add to cart, Cart di menu):
   halaman di belakangnya tidak bisa di-scroll */
html:has(.sellfy-sheet.is-open) body {
    overflow: hidden;
}
/* Pop-up dari sellfy-cart-popup.js (item "Cart" di menu, Add to cart & panel
   Cart di desktop): di desktop lebar 480px, tengah bawah. */
@media (min-width: 769px) {
    .menu-cart-sheet .sellfy-sheet__panel {
        max-width: 480px;
        margin: 0 auto;
    }
}
@media (prefers-reduced-motion: reduce) {
    .sellfy-sheet__overlay,
    .sellfy-sheet__panel { transition: none; }
}
