/* ============================================================
   Rock Box - Mini-cart drawer stylesheet
   ------------------------------------------------------------
   Slide-in drawer for the mini-cart. Charcoal brand treatment.
   Full-screen on mobile. Scroll contained to items list only.

   Loaded site-wide via wp_enqueue_style in wc-functions.php
   (rb_enqueue_mini_cart function).

   Structure:
     1. Overlay + drawer positioning + slide animation
     2. Height/scroll containment (header pinned, items scroll,
        footer pinned)
     3. Header
     4. Items list + item rows
     5. Item thumb, name, price
     6. Qty controls + remove
     7. Footer + subtotal + shipping note
     8. Buttons (Continue Shopping, Checkout)
     9. Empty state
     10. Busy state (during AJAX)
     11. Mobile responsive

   Brand palette: see rb-cart-shared.css (single source of truth
   for palette + font stacks, enqueued site-wide via
   rb_enqueue_cart_shared() in wc-functions.php).
   ============================================================ */

/* CRITICAL: WooCommerce injects two wrapper divs between drawer-body
   and widget_shopping_cart_content (.widget_shopping_cart and
   .hide_cart_widget_if_empty). These have no height constraint by
   default and grow to fit content, breaking the height chain that
   should let the items list scroll internally. Force both to fill
   available space and clip overflow. */

.rb-mini-cart-drawer .widget.widget_shopping_cart,
.rb-mini-cart-drawer .hide_cart_widget_if_empty {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    display: block;
    margin: 0;
    padding: 0;
}

/* --- 1. Overlay + drawer positioning + slide animation --- */

.rb-mini-cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100010;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease;
}

.rb-mini-cart-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.rb-mini-cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    height: 100dvh;
    width: 440px;
    max-width: 100vw;
    background: var(--rb-charcoal, #3d3d3b);
    z-index: 100011;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.25);
    transform: translateX(100%);
    transition: transform 250ms ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.rb-mini-cart-drawer.is-open {
    transform: translateX(0);
}

body.rb-mini-cart-open {
    overflow: hidden;
}


/* --- 2. Height/scroll containment ---
   Drawer is flex column. Drawer-body fills it. Mini-cart inside
   is another flex column with header (fixed), items (flex-1
   scrolling), footer (fixed). Every ancestor needs min-height:0
   so the scrolling middle can actually shrink. */

/* Drawer-body and WSC just pass height through - explicit 100% chain,
   overflow hidden to visually contain, no flex needed for these. */
.rb-mini-cart-drawer .rb-mini-cart-drawer-body {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    background: var(--rb-charcoal, #3d3d3b);
}

.rb-mini-cart-drawer .widget_shopping_cart_content {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    padding: 0;
    margin: 0;
    background: var(--rb-charcoal, #3d3d3b);
}

/* Mini-cart uses CSS Grid: header row auto, items row 1fr (takes remaining),
   footer row auto. This is the correct primitive for pinned-header /
   scrolling-middle / pinned-footer, avoiding fragile flex-shrink chains. */
.rb-mini-cart-drawer .rb-mini-cart {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    padding: 0;
    margin: 0;
    background: var(--rb-charcoal, #3d3d3b);
}

/* Also fix the theme's inline display:none on the widget wrapper
   once the drawer is open (JS toggles this too, CSS as safety). */
.rb-mini-cart-drawer.is-open .widget_shopping_cart {
    display: block !important;
}


/* --- 3. Header --- */

.rb-mini-cart-drawer .rb-mini-cart-header {
    flex-shrink: 0;
    padding: 22px 24px 20px;
    border-bottom: none;
    background: transparent;
}

.rb-mini-cart-drawer .rb-mini-cart-title {
    font-family: 'Raleway', sans-serif;
    font-size: 22px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
    color: var(--rb-white, #fff);
}


/* --- 4. Items list + item rows --- */

.rb-mini-cart-drawer .rb-mini-cart-items {
    min-height: 0;
    overflow-y: auto;
    margin: 0;
    padding: 24px 0 0;
    list-style: none;
    background: var(--rb-charcoal, #3d3d3b);
}

.rb-mini-cart-drawer .rb-mini-cart-items li {
    list-style: none;
    background: none;
}

.rb-mini-cart-drawer .rb-mini-cart .rb-mini-cart-items li.rb-mini-cart-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--rb-divider, #555553);
    margin: 0;
}

.rb-mini-cart-drawer .rb-mini-cart-item:last-child {
    border-bottom: none;
}


/* --- 5. Item thumb, name, price ---
   High-specificity selector on thumb img beats WC default 32px. */

.rb-mini-cart-drawer .rb-mini-cart-item-thumb {
    flex: 0 0 90px;
    width: 90px;
}

.rb-mini-cart-drawer .rb-mini-cart-item-thumb a {
    display: block;
}

.rb-mini-cart-drawer .rb-mini-cart .rb-mini-cart-items li.rb-mini-cart-item .rb-mini-cart-item-thumb img {
    display: block;
    width: 90px;
    height: 90px;
    max-width: 90px;
    object-fit: cover;
    margin: 0;
    padding: 0;
    border: none;
}

.rb-mini-cart-drawer .rb-mini-cart-item-details {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rb-mini-cart-drawer .rb-mini-cart .rb-mini-cart-items li.rb-mini-cart-item .rb-mini-cart-item-name {
    font-family: 'Raleway', sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--rb-white, #fff);
    text-decoration: none;
    display: block;
    word-break: break-word;
}

.rb-mini-cart-drawer .rb-mini-cart .rb-mini-cart-items li.rb-mini-cart-item .rb-mini-cart-item-name:hover,
.rb-mini-cart-drawer .rb-mini-cart .rb-mini-cart-items li.rb-mini-cart-item .rb-mini-cart-item-name:focus {
    color: var(--rb-red, #e4032c);
    text-decoration: none;
}

.rb-mini-cart-drawer .rb-mini-cart-item-price {
    font-family: 'Cabin', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--rb-warm-grey, #a4a1a0);
}

.rb-mini-cart-drawer .rb-mini-cart-item-price .quantity {
    font-family: 'Cabin', sans-serif;
    font-size: 13px;
    color: var(--rb-warm-grey, #a4a1a0);
}

.rb-mini-cart-drawer .rb-mini-cart-item-price .woocommerce-Price-amount {
    color: var(--rb-white, #fff);
    font-weight: 700;
}

/* Stock message row (rb_get_stock_message output) rendered from
   mini-cart.php template between item name and price. Displays as
   its own line above the qty/price. Colour comes from custom.css
   (single source of truth via .rb-stock.STATE selectors). */
.rb-mini-cart-drawer .rb-mini-cart-item-stock {
    margin: 4px 0 6px;
    font-size: 12px;
    line-height: 1.3;
}

/* --- 6. Qty controls + remove --- */

.rb-mini-cart-drawer .rb-mini-cart-item-controls {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.rb-mini-cart-drawer .rb-mini-cart-qty {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--rb-warm-grey, #a4a1a0);
    border-radius: 2px;
    overflow: hidden;
}

.rb-mini-cart-drawer .rb-mini-cart-qty-decrease,
.rb-mini-cart-drawer .rb-mini-cart-qty-increase {
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    padding: 0;
    font-family: 'Cabin', sans-serif;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    color: var(--rb-white, #fff);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease;
}

.rb-mini-cart-drawer .rb-mini-cart-qty-decrease:hover,
.rb-mini-cart-drawer .rb-mini-cart-qty-increase:hover {
    background: rgba(255, 255, 255, 0.1);
}

.rb-mini-cart-drawer .rb-mini-cart-qty-decrease:disabled,
.rb-mini-cart-drawer .rb-mini-cart-qty-increase:disabled {
    color: #555;
    background: transparent;
    cursor: not-allowed;
    opacity: 0.35;
}

.rb-mini-cart-drawer .rb-mini-cart-qty-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 4px;
    font-family: 'Cabin', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: var(--rb-white, #fff);
    background: transparent;
    border-left: 1px solid var(--rb-warm-grey, #a4a1a0);
    border-right: 1px solid var(--rb-warm-grey, #a4a1a0);
}

.rb-mini-cart-drawer .rb-mini-cart-remove {
    background: none;
    border: none;
    padding: 0;
    font-family: 'Cabin', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: var(--rb-warm-grey, #a4a1a0);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: color 150ms ease;
}

.rb-mini-cart-drawer .rb-mini-cart-remove:hover,
.rb-mini-cart-drawer .rb-mini-cart-remove:focus {
    color: var(--rb-red, #e4032c);
    text-decoration: underline;
}


/* --- 7. Footer + subtotal + shipping note --- */

.rb-mini-cart-drawer .rb-mini-cart-footer {
    flex-shrink: 0;
    padding: 20px 24px 24px;
    border-top: 1px solid var(--rb-divider, #555553);
    background: transparent;
}

.rb-mini-cart-drawer .rb-mini-cart-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: 'Raleway', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--rb-white, #fff);
    margin-bottom: 8px;
}

.rb-mini-cart-drawer .rb-mini-cart-subtotal-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rb-mini-cart-drawer .rb-mini-cart-subtotal-value,
.rb-mini-cart-drawer .rb-mini-cart-subtotal-value .woocommerce-Price-amount {
    color: var(--rb-white, #fff);
    font-weight: 700;
}

.rb-mini-cart-drawer .rb-mini-cart-shipping-note {
    font-family: 'Cabin', sans-serif;
    font-size: 12px;
    color: var(--rb-warm-grey, #a4a1a0);
    margin: 0 0 20px;
    text-align: left;
}


/* --- 8. Buttons (Continue Shopping, Checkout) --- */

.rb-mini-cart-drawer .rb-mini-cart-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rb-mini-cart-drawer .rb-mini-cart-continue {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    color: var(--rb-white, #fff);
    border: 1px solid var(--rb-white, #fff);
    font-family: 'Raleway', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease;
    box-sizing: border-box;
}

.rb-mini-cart-drawer .rb-mini-cart-continue:hover,
.rb-mini-cart-drawer .rb-mini-cart-continue:focus {
    background: var(--rb-white, #fff);
    color: var(--rb-charcoal, #3d3d3b);
    text-decoration: none;
}

.rb-mini-cart-drawer .rb-mini-cart-checkout {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: var(--rb-red, #e4032c);
    color: var(--rb-white, #fff);
    border: 1px solid var(--rb-red, #e4032c);
    font-family: 'Raleway', sans-serif;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 150ms ease, border-color 150ms ease;
    box-sizing: border-box;
}

.rb-mini-cart-drawer .rb-mini-cart-checkout:hover,
.rb-mini-cart-drawer .rb-mini-cart-checkout:focus {
    background: var(--rb-red-hover, #b60024);
    border-color: var(--rb-red-hover, #b60024);
    color: var(--rb-white, #fff);
    text-decoration: none;
}


/* --- 9. Empty state --- */

.rb-mini-cart-drawer .rb-mini-cart-empty {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 60px 24px 40px;
    text-align: center;
    overflow-y: auto;
}

.rb-mini-cart-drawer .rb-mini-cart-empty-message {
    font-family: 'Raleway', sans-serif;
    font-size: 16px;
    font-weight: 600;
    color: var(--rb-warm-grey, #a4a1a0);
    margin: 0 0 24px;
}

.rb-mini-cart-drawer .rb-mini-cart-empty .rb-mini-cart-continue {
    max-width: 260px;
}


/* --- 10. Busy state (during AJAX) --- */

.rb-mini-cart-drawer .rb-mini-cart-item-busy {
    opacity: 0.5;
    pointer-events: none;
}


/* --- 11. Mobile responsive --- */

@media (max-width: 767px) {
    .rb-mini-cart-drawer {
        width: 100vw;
        max-width: 100vw;
        box-shadow: none;
    }

    .rb-mini-cart-drawer .rb-mini-cart-header {
        padding: 16px 16px 12px;
    }

    .rb-mini-cart-drawer .rb-mini-cart-title {
        font-size: 20px;
    }

    .rb-mini-cart-drawer .rb-mini-cart-item {
        padding: 12px 16px;
        gap: 10px;
    }

    .rb-mini-cart-drawer .rb-mini-cart-item-thumb {
        flex: 0 0 72px;
        width: 72px;
    }

    .rb-mini-cart-drawer .rb-mini-cart .rb-mini-cart-items li.rb-mini-cart-item .rb-mini-cart-item-thumb img {
        width: 72px;
        height: 72px;
        max-width: 72px;
    }

    .rb-mini-cart-drawer .rb-mini-cart-footer {
        padding: 16px 16px 20px;
    }

    .rb-mini-cart-drawer .rb-mini-cart-empty {
        padding: 40px 16px 32px;
    }
}