/* ======================================================================
   Popup-checkout (cart drawer) — Cohort 1 (Amber Oud)
   Bootstrap-first: btn / d-flex / gap / px / py from Bootstrap.
   This file owns the off-canvas mechanics (Bootstrap's offcanvas isn't
   used because event.min.js MiniCart toggles `is-cart-widget-open` on
   the body) + premium polish.
   ====================================================================== */

/* Drawer root — fixed full-viewport overlay; hidden until JS opens it */
.cart-widget-side {
    position: fixed;
    inset: 0;
    z-index: 1090;
    pointer-events: none;
    visibility: hidden;
    transition: visibility 0s linear 0.3s;
}

.cart-widget-side.cart-widget-opened {
    pointer-events: auto;
    visibility: visible;
    transition: visibility 0s linear 0s;
}

/* Backdrop — fades in behind drawer */
.popup-checkout-1-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(var(--bs-body-color-rgb), 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: pointer;
}
.cart-widget-side.cart-widget-opened .popup-checkout-1-backdrop {
    opacity: 1;
}

/* Sliding panel — right-side off-canvas. z-index above the backdrop +
   above any sticky page elements (header sticky-top is 1030). */
.popup-checkout-1-panel {
    position: absolute;
    top: 0;
    right: 0;
    height: 100dvh;
    width: min(420px, 100vw);
    background: var(--bs-body-bg, var(--bs-body-bg));
    box-shadow: -8px 0 32px rgba(var(--bs-body-color-rgb), 0.18);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(.2,.8,.2,1);
    z-index: 2;
}

.popup-checkout-1-backdrop {
    z-index: 1;
}

/* Lock the page scroll while the drawer is open so the body's scrollbar
   doesn't bleed through over the drawer panel. */
html:has(.cart-widget-side.cart-widget-opened),
body:has(.cart-widget-side.cart-widget-opened) {
    overflow: hidden !important;
}

.cart-widget-side.cart-widget-opened .popup-checkout-1-panel {
    transform: translateX(0);
}

/* Heading */
.popup-checkout-1-head {
    background: var(--bs-body-bg);
    border-color: var(--bs-border-color) !important;
}

.popup-checkout-1-title {
    font-family: var(--bs-heading-font-family, inherit);
    color: var(--bs-body-color);
}

.popup-checkout-1-close:hover {
    color: var(--bs-primary) !important;
}

/* Items area — scrolls vertically only when content overflows.
   When 1-2 items only, body hugs content so the drawer never feels empty. */
.popup-checkout-1-body { scrollbar-width: thin; }
.popup-checkout-1-body::-webkit-scrollbar { width: 6px; }
.popup-checkout-1-body::-webkit-scrollbar-thumb {
    background: var(--bs-border-color);
    border-radius: 3px;
}

/* Cart item — applies BOTH to my static placeholder (.popup-checkout-1-item)
   AND to the JS-generated rows (.mini_cart_item from scripts.js). The JS
   template is the actual production markup; static is just for DOM structure
   reference — both share these visual rules. */
.popup-checkout-1-item,
.mini_cart_item {
    border: 1px solid var(--bs-border-color);
    border-radius: 0.625rem;
    padding: 10px 12px !important;
    background: var(--bs-body-bg);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 8px;
    position: relative;
}
.popup-checkout-1-item:hover,
.mini_cart_item:hover {
    border-color: var(--bs-primary);
    box-shadow: 0 4px 12px rgba(var(--bs-primary-rgb), 0.08);
}

/* JS template uses bare <a><img/><div/></a> — constrain the image */
.mini_cart_item > a {
    display: flex !important;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}
.mini_cart_item img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    flex-shrink: 0;
    border-radius: 0.5rem;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-secondary-bg);
}

.popup-checkout-1-thumb {
    border: 1px solid var(--bs-border-color);
    background: var(--bs-secondary-bg);
}

/* Cart line typography — JS sets fs-3 fw-600 (huge); override for sidebar */
.mini_cart_item .cart-info {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mini_cart_item .cart-info .fs-3 {
    font-size: 0.9rem !important;
    line-height: 1.35 !important;
    color: var(--bs-body-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}
.mini_cart_item .quantity {
    font-size: 0.82rem;
    color: var(--bs-secondary-color);
}
.mini_cart_item .cart-Price-amount {
    color: var(--bs-primary);
    font-weight: 700;
}
.mini_cart_item .cart-Price-amount-old {
    color: var(--bs-secondary-color);
    font-size: 0.78rem;
    margin-left: 4px;
}

.popup-checkout-1-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Remove × button — circular, top-right of item.
   Style the &times; text directly. line-height equals box height so the
   single character centers vertically; flex centers it horizontally. */
.popup-checkout-1-remove,
.mini_cart_item .remove_from_cart_button {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-body-bg) !important;
    border: 1px solid var(--bs-border-color);
    border-radius: 50%;
    color: var(--bs-secondary-color) !important;
    text-decoration: none !important;
    cursor: pointer;
    font-size: 18px !important;
    font-weight: 400;
    line-height: 1;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    padding: 0 !important;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    z-index: 10;
    text-align: center;
}
.popup-checkout-1-remove:hover,
.mini_cart_item .remove_from_cart_button:hover {
    background: var(--bs-danger) !important;
    border-color: var(--bs-danger);
    color: var(--bs-body-bg) !important;
    transform: scale(1.08);
}

/* Footer — sticks to bottom; subtotal + actions always visible */
.popup-checkout-1-foot {
    border-color: var(--bs-border-color) !important;
    background: linear-gradient(180deg, var(--bs-body-bg), var(--bs-secondary-bg)) !important;
}

.popup-checkout-1-subtotal-amount {
    font-family: var(--bs-heading-font-family, inherit);
}

.popup-checkout-1-btn-view {
    border-radius: 0.5rem;
    font-weight: 600;
    padding-block: 10px;
}

.popup-checkout-1-btn-checkout {
    border-radius: 0.5rem;
    font-weight: 600;
    padding-block: 12px;
    box-shadow: 0 4px 12px rgba(var(--bs-primary-rgb), 0.18);
}
.popup-checkout-1-btn-checkout:hover {
    box-shadow: 0 8px 20px rgba(var(--bs-primary-rgb), 0.28);
    transform: translateY(-1px);
}

/* Empty state hint when no items */
.popup-checkout-1-body:empty::before {
    content: "Your cart is empty.";
    display: block;
    text-align: center;
    color: var(--bs-secondary-color);
    padding: 48px 16px;
    font-size: 0.95rem;
}

@media (max-width: 575.98px) {
    .popup-checkout-1-panel { width: 100vw; }
}
