/* ==========================================================
   WonderLab Cart & Checkout — Side Cart (v1.3.0+)

   Slide-out mini cart triggered from the header cart icon.
   Brand-styled drawer with subtle backdrop, optional free-shipping
   progress bar, item rows with qty − / + controls, and a single
   "View Full Cart" CTA at the bottom (per product spec — customer
   must go to /cart/ to see vouchers / points / final totals).
   ========================================================== */

/* ───────── Cart-icon badge ─────────
   Sits absolute, top-right of whichever element matches the
   selectors in WLCF_SIDE_CART.iconSelectors. JS injects the
   `.wlcf-side-cart-count-badge` into each matching icon parent. */

.wlcf-side-cart-icon-wrap {
    position: relative;
    display: inline-block;
}

.wlcf-side-cart-count-badge {
    position: absolute;
    /* Sit at the top-right CORNER of the cart icon, sticking out
       just past its top + right edges (notification-badge pattern).
       Previously this used `top: -3px; right: 0;` which only worked
       when the cart anchor had 20px horizontal padding (wlsite v1.0)
       — the badge sat in that padding instead of overlapping the
       icon glyph. When wlsite v1.1.2 dropped that padding to 0 (to
       give all four header icons uniform Divi margin: 0 11px),
       the anchor shrank to just the icon glyph width and the
       badge started covering the icon. Negative offsets fix the
       overlap independently of the anchor width. */
    top: -6px;
    right: 1px;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    box-sizing: border-box;
    border-radius: 999px;
    background: #851625;
    color: #fff;
    font-family: 'Geologica', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 10.5px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    letter-spacing: 0;
    pointer-events: none;
    border: 2px solid #fff;
    z-index: 5;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.wlcf-side-cart-count-badge.is-hidden {
    opacity: 0;
    transform: scale(0.6);
    pointer-events: none;
}

/* Subtle bump animation when the count changes (drives a re-render). */
@keyframes wlcfSideCartBadgePop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.25); }
    100% { transform: scale(1); }
}
.wlcf-side-cart-count-badge.is-bumping {
    animation: wlcfSideCartBadgePop 0.35s ease-out;
}


/* ───────── Drawer root ─────────
   Two stacked layers — overlay (full-screen dim) + the right-side
   panel that slides in. Hidden by default with pointer-events: none
   + opacity 0 so it never blocks clicks when closed. */

.wlcf-side-cart-root {
    position: fixed;
    inset: 0;
    z-index: 99999;
    pointer-events: none;
    font-family: 'Geologica', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wlcf-side-cart-root.is-open {
    pointer-events: auto;
}

.wlcf-side-cart-overlay {
    position: absolute;
    inset: 0;
    background: rgba(31, 36, 48, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.wlcf-side-cart-root.is-open .wlcf-side-cart-overlay {
    opacity: 1;
}

.wlcf-side-cart-panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 420px;
    max-width: 92vw;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
    transform: translateX(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    color: #1f2430;
}

/* v1.3.1: when the WP admin bar is visible (logged-in users) the
   panel's top edge would otherwise sit underneath it and the header
   title disappears. Push the panel down by the admin bar's height. */
body.admin-bar .wlcf-side-cart-panel {
    top: 32px;
    height: calc(100% - 32px);
}
@media (max-width: 782px) {
    body.admin-bar .wlcf-side-cart-panel {
        top: 46px;
        height: calc(100% - 46px);
    }
}

.wlcf-side-cart-root.is-open .wlcf-side-cart-panel {
    transform: translateX(0);
}


/* ───────── Header ───────── */

.wlcf-side-cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #ece6dd;
    flex-shrink: 0;
}

.wlcf-side-cart-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #1f2430;
    letter-spacing: -0.2px;
}

.wlcf-side-cart-count-inline {
    font-weight: 500;
    color: #777;
    margin-left: 4px;
    font-size: 14px;
}

.wlcf-side-cart-close {
    background: transparent;
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    line-height: 1;
    color: #555;
    transition: background 0.2s ease, color 0.2s ease;
}

.wlcf-side-cart-close:hover,
.wlcf-side-cart-close:focus {
    background: #fff5f6;
    color: #851625;
    outline: none;
}


/* ───────── Body ───────── */

.wlcf-side-cart-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px 22px;
    -webkit-overflow-scrolling: touch;
}

/* Free shipping strip — only renders when FSI is enabled site-wide
   and the cart has at least one item. */
.wlcf-side-cart-fsi {
    background: #fff5f6;
    border: 1px solid rgba(133, 22, 37, 0.15);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.wlcf-side-cart-fsi-text {
    margin: 0 0 8px;
    color: #1f2430;
    font-size: 13px;
    line-height: 1.4;
}

.wlcf-side-cart-fsi-text strong {
    color: #851625;
}

.wlcf-side-cart-fsi-bar {
    height: 6px;
    background: #f0e9dd;
    border-radius: 10px;
    overflow: hidden;
}

.wlcf-side-cart-fsi-bar > span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(to right, #6fdc8c, #ffd66b);
    transition: width 0.4s ease;
}

/* Empty cart state */
.wlcf-side-cart-empty {
    text-align: center;
    padding: 32px 8px;
    color: #777;
}

.wlcf-side-cart-empty p {
    margin: 0 0 12px;
    font-size: 14px;
}

.wlcf-side-cart-shop-link {
    color: #851625;
    font-weight: 600;
    text-decoration: none;
    font-size: 13px;
}

.wlcf-side-cart-shop-link:hover {
    text-decoration: underline;
}

/* Item list */
.wlcf-side-cart-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wlcf-side-cart-item {
    display: grid;
    grid-template-columns: 64px 1fr 24px;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 0;
}

/* v1.3.1: items separated by a top border on all but the first item
   (single divider per pair). The footer's own border-top then serves
   as the single "above subtotal" line — no double-stack of borders. */
.wlcf-side-cart-item + .wlcf-side-cart-item {
    border-top: 1px solid #ece6dd;
}

.wlcf-side-cart-item-thumb img,
.wlcf-side-cart-item-thumb .wlcf-side-cart-item-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #ece6dd;
    display: block;
}

.wlcf-side-cart-item-info {
    min-width: 0;
}

.wlcf-side-cart-item-name {
    margin: 0 0 2px;
    font-size: 13px;
    font-weight: 600;
    color: #1f2430;
    line-height: 1.35;
    overflow-wrap: break-word;
}

.wlcf-side-cart-item-sku {
    margin: 0 0 8px;
    font-size: 11px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.wlcf-side-cart-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* Qty control — circular outline buttons matching the cart page */
.wlcf-side-cart-qty {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.wlcf-side-cart-qty-btn {
    width: 26px;
    height: 26px;
    border: 1px solid #1f2430;
    border-radius: 50%;
    background: transparent;
    color: #1f2430;
    font-size: 14px;
    line-height: 1;
    font-weight: 400;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.wlcf-side-cart-qty-btn:hover,
.wlcf-side-cart-qty-btn:focus {
    background: #851625;
    border-color: #851625;
    color: #fff;
    outline: none;
}

.wlcf-side-cart-qty-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.wlcf-side-cart-qty-value {
    min-width: 18px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #1f2430;
}

.wlcf-side-cart-item-price {
    font-size: 14px;
    font-weight: 700;
    color: #851625;
    white-space: nowrap;
}

/* × remove link */
.wlcf-side-cart-item-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: #999;
    font-size: 18px;
    line-height: 1;
    text-decoration: none;
    border-radius: 50%;
    margin-top: 2px;
    transition: background 0.15s ease, color 0.15s ease;
}

.wlcf-side-cart-item-remove:hover,
.wlcf-side-cart-item-remove:focus {
    background: #fff5f6;
    color: #851625;
    text-decoration: none;
    outline: none;
}


/* ───────── Footer ───────── */

.wlcf-side-cart-footer {
    flex-shrink: 0;
    padding: 18px 22px;
    border-top: 1px solid #ece6dd;
    background: #fff;
}

.wlcf-side-cart-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    font-size: 16px;
}

.wlcf-side-cart-subtotal > span:first-child {
    color: #555;
    font-weight: 500;
}

.wlcf-side-cart-subtotal-value {
    color: #851625;
    font-weight: 700;
}

.wlcf-side-cart-cta {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 14px 22px;
    background: #851625;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
    border-radius: 999px;
    border: 1px solid #851625;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.wlcf-side-cart-cta:hover,
.wlcf-side-cart-cta:focus {
    background: #6b1020;
    border-color: #6b1020;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(133, 22, 37, 0.18);
    text-decoration: none;
}


/* ───────── Loading state during AJAX qty change ───────── */
.wlcf-side-cart-item.is-loading {
    opacity: 0.5;
    pointer-events: none;
}


/* ───────── Mobile (≤768px) ───────── */
@media (max-width: 768px) {
    .wlcf-side-cart-panel {
        width: 100vw;
        max-width: 100vw;
    }
    .wlcf-side-cart-header,
    .wlcf-side-cart-body,
    .wlcf-side-cart-footer {
        padding-left: 18px;
        padding-right: 18px;
    }
    /* Slightly larger touch targets on mobile */
    .wlcf-side-cart-close { width: 44px; height: 44px; font-size: 28px; }
    .wlcf-side-cart-qty-btn { width: 28px; height: 28px; font-size: 15px; }
}


/* When the admin chooses to disable the side cart on mobile, hide it
   entirely on small viewports — cart icon click falls through to /cart/. */
@media (max-width: 768px) {
    .wlcf-side-cart-root.wlcf-side-cart--no-mobile {
        display: none;
    }
}


/* ───────── Lock body scroll when drawer is open ───────── */
body.wlcf-side-cart-locked {
    overflow: hidden;
}
