/* Floating basket drawer (Concept B's own build of production's WPC Fly
   Cart). Loaded globally except cart/checkout (inc/integrations/rest-cart.php).
   Base dialog chrome (.bb-dialog, ::backdrop, head/body/foot padding, the
   <767px bottom-sheet rule) comes from assets/css/main.css - this file only
   adds what's specific to the basket drawer, kept small per the brief. */

.bb-minicart { width: min(400px, 92vw); max-height: 100dvh; height: 100dvh; margin: 0 0 0 auto; border-radius: var(--bb-r-panel) 0 0 var(--bb-r-panel); overflow: hidden; }
.bb-minicart[open] { animation: bbMinicartIn .25s var(--bb-ease); }
@keyframes bbMinicartIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
	.bb-minicart[open] { animation: none; }
}

/* .bb-dialog__inner is already display:flex;flex-direction:column (main.css);
   min-height:0 lets its flex children (head/body/foot) actually shrink to
   this fixed-height box instead of overflowing it. */
.bb-minicart__inner { height: 100%; min-height: 0; }

/* The body is the ONLY scrolling region: it grows to fill whatever the
   fixed-size head and foot leave behind (flex: 1 1 auto) and min-height: 0
   lets it shrink below its content's natural height - the classic flexbox
   fix without which a long basket pushed the foot (and its Checkout button)
   off-screen instead of scrolling. Head and foot never move. */
.bb-minicart__body { display: flex; flex-direction: column; gap: 20px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

.bb-minicart__loading { margin: 24px 0; color: var(--bb-muted); text-align: center; }

/* ---------- Head: a small muted icon button for "Clear basket" next to the
   close button, not a competing full-width control. ---------- */
.bb-minicart__head-actions { display: flex; align-items: center; gap: 4px; }
.bb-iconbtn--sm { width: 36px; height: 36px; color: var(--bb-muted); }
.bb-iconbtn--sm:hover { color: var(--bb-error); }
.bb-iconbtn--sm[aria-busy="true"] { opacity: .5; pointer-events: none; }

/* ---------- Inline "Clear all N items? Yes / Cancel" - replaces a browser
   confirm() dialog; sits directly under the head, above the scrolling body. ---------- */
.bb-minicart__clearconfirm { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 22px; background: var(--bb-pale-yellow); border-bottom: 1px solid var(--bb-border); }
.bb-minicart__clearconfirm p { margin: 0; font-size: .8125rem; font-weight: 700; }
.bb-minicart__clearconfirm-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.bb-minicart__clearconfirm-cancel { border: 0; background: none; color: var(--bb-ink-2); font: 700 .8125rem/1 var(--bb-font-body); text-decoration: underline; cursor: pointer; min-height: 36px; }

/* ---------- Item rows: 64px thumb | name + unit price | qty stepper | line
   total + remove, one row, vertically centred, with a divider between rows
   (not after the last one). ---------- */
.bb-minicart__lines { display: flex; flex-direction: column; }
.bb-minicart__line { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding-block: 16px; border-bottom: 1px solid var(--bb-border); }
.bb-minicart__lines .bb-minicart__line:first-child { padding-top: 0; }
.bb-minicart__lines .bb-minicart__line:last-child { border-bottom: 0; padding-bottom: 0; }
.bb-minicart__line[aria-busy="true"] { opacity: .5; }
.bb-minicart__line-media { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; padding: 6px; border: 1px solid var(--bb-border); border-radius: var(--bb-r-small); background: var(--bb-surface); flex: none; }
.bb-minicart__line-media img { width: 100%; height: 100%; object-fit: contain; }
.bb-minicart__line-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.bb-minicart__line-name { font-size: .875rem; font-weight: 600; line-height: 1.3; color: var(--bb-ink); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bb-minicart__line-name:hover { text-decoration: underline; }
/* Pack Size Selector label chip (e.g. "6-Pack") - label only, never the
   SKU/fulfilled-via internal detail (inc/pages/cart.php). */
.bb-minicart__line-packtag { display: inline-flex; align-self: flex-start; padding: 1px 7px; border-radius: var(--bb-r-pill); background: var(--bb-pale-yellow); color: var(--bb-ink); font-size: .6875rem; font-weight: 700; }
.bb-minicart__line-unit { font-size: .75rem; color: var(--bb-muted); }
/* Buttons are a full 44px touch target (--bb-touch), same as the basket
   page's stepper - the pill around them is only as tall as they are. */
.bb-minicart__line-qty { display: inline-flex; align-items: center; gap: 0; padding: 0 1px; border: 1.5px solid var(--bb-border-2); border-radius: var(--bb-r-control); background: var(--bb-surface); flex: none; }
.bb-minicart__line-qty .bb-qty__btn { display: grid; place-items: center; width: var(--bb-touch); height: var(--bb-touch); min-width: var(--bb-touch); border: 0; border-radius: var(--bb-r-small); background: transparent; color: var(--bb-ink); font-size: 1.0625rem; line-height: 1; cursor: pointer; }
.bb-minicart__line-qty .bb-qty__btn:hover { background: var(--bb-ground); }
.bb-minicart__line-qty .bb-qty__btn:disabled { opacity: .35; cursor: not-allowed; }
.bb-minicart__line-qty .bb-qty__btn:focus-visible { outline: 3px solid var(--bb-ink); outline-offset: 1px; }
.bb-minicart__line-qtyval { min-width: 20px; text-align: center; font-weight: 700; font-size: .875rem; }
.bb-minicart__line-totalwrap { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 2px; flex: none; }
.bb-minicart__line-total { font-size: 1rem; font-weight: 800; color: var(--bb-ink); white-space: nowrap; }
/* Text is small, but the tap target is still 44px tall (extra hit area via
   padding, not a bigger font), matching the qty buttons either side of it. */
.bb-minicart__line-remove { display: inline-flex; align-items: center; padding: 0 2px; margin: 0 -2px; border: 0; background: none; color: var(--bb-error); font: 700 .75rem/1.2 var(--bb-font-body); text-decoration: none; cursor: pointer; min-height: var(--bb-touch); }
.bb-minicart__line-remove:hover { text-decoration: underline; }
.bb-minicart__line-remove:focus-visible { outline: 2px solid var(--bb-error); outline-offset: 2px; border-radius: 4px; }

/* ---------- Empty state ---------- */
.bb-minicart__empty { display: flex; flex-direction: column; align-items: center; gap: 12px; margin: auto 0; padding: 40px 16px; text-align: center; color: var(--bb-muted); }
.bb-minicart__empty svg { color: var(--bb-border-2); }
.bb-minicart__empty-title { margin: 0; font: 700 1.0625rem/1.3 var(--bb-font-display); color: var(--bb-ink); }

/* ---------- Saving (only rendered when bb_core_cart_savings has data) ---------- */
.bb-minicart__saving { margin: 0; padding: 12px 14px; border-radius: var(--bb-r-small); background: var(--bb-soft-yellow); color: var(--bb-ink); font-size: .8125rem; font-weight: 700; line-height: 1.4; }

/* ---------- Free-delivery progress bar: only ever shown when
   /wp-json/bbt/v1/free-shipping (inc/pages/cart.php) returns a real,
   configured threshold - assets/js/mini-cart.js keeps it [hidden] otherwise.
   Same track/fill tokens as the basket page's own bar (assets/css/pages/cart.css
   .bb-freeship) for one consistent look. ---------- */
.bb-minicart__freeship { margin: 0; }
.bb-minicart__freeship-text { margin: 0 0 8px; font-size: .8125rem; font-weight: 700; color: var(--bb-ink); }
.bb-minicart__freeship-track { height: 6px; border-radius: var(--bb-r-pill); background: var(--bb-track); overflow: hidden; }
.bb-minicart__freeship-fill { height: 100%; width: 0%; border-radius: var(--bb-r-pill); background: var(--bb-yellow); transition: width .3s ease; }
.bb-minicart__freeship.is-reached .bb-minicart__freeship-fill { background: var(--bb-ink); }

/* ---------- "You might also like": a 2-up grid that keeps its columns at
   any drawer width (92vw down to 320px) rather than letting the compact
   card's own min-content squash unevenly. ---------- */
.bb-minicart__suggest-title { margin: 0 0 12px; font-size: 1.0625rem; }
.bb-grid--2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.bb-minicart__suggest .bb-card__media { height: 96px; padding: 8px; }
.bb-minicart__suggest .bb-card__body { padding: 2px 8px 8px; gap: 3px; }
.bb-minicart__suggest .bb-card__name { font-size: .75rem; min-height: 2.1em; }
.bb-minicart__suggest .bb-price { font-size: 1rem; }
.bb-minicart__suggest .bb-card__action .bb-btn { min-height: var(--bb-touch); font-size: .75rem; padding: 0 8px; }

/* ---------- Utility row: continue shopping / share / clear - plain text-like
   buttons so they read as secondary actions, never competing with Checkout. ---------- */
.bb-minicart__utility { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bb-minicart__util { display: inline-flex; align-items: center; gap: 5px; border: 0; background: none; padding: 4px 2px; color: var(--bb-ink-2); font: 700 .8125rem/1 var(--bb-font-body); cursor: pointer; min-height: var(--bb-touch); }
.bb-minicart__util:hover { text-decoration: underline; }
.bb-minicart__util[aria-busy="true"] { opacity: .5; pointer-events: none; }

/* ---------- Coupon: collapsed by default (Fly-Cart-style "Have a coupon?"). ---------- */
.bb-minicart__coupon-toggle { border: 0; background: none; padding: 2px; color: var(--bb-muted); font: 600 .8125rem/1 var(--bb-font-body); text-decoration: underline; cursor: pointer; min-height: 32px; }
.bb-minicart__coupon-row { display: flex; gap: 8px; margin-top: 8px; }
.bb-minicart__coupon-row .bb-input { flex: 1 1 auto; min-width: 0; min-height: var(--bb-touch); padding: 0 12px; border: 1.5px solid var(--bb-border-2); border-radius: var(--bb-r-control); background: var(--bb-surface); }
.bb-minicart__coupon-msg { margin: 6px 0 0; font-size: .75rem; font-weight: 600; color: var(--bb-success); }
.bb-minicart__coupon-msg.is-error { color: var(--bb-error); }
.bb-minicart__coupon-msg:empty { display: none; }

/* ---------- Footer: pinned by the body's flex/overflow rules above, never
   part of the scroll - subtotal line, delivery note, two full-width actions. ---------- */
.bb-minicart__foot { display: flex; flex-direction: column; gap: 12px; flex: none; }
.bb-minicart__note { margin: 0; font-size: .75rem; line-height: 1.4; color: var(--bb-muted); }
.bb-minicart__subtotal { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 1.0625rem; font-weight: 800; }
.bb-minicart__actions { display: flex; gap: 10px; }
.bb-minicart__actions .bb-btn { min-height: var(--bb-touch); flex: 1 1 0; }

@media (max-width: 767px) {
	/* The <767px bottom-sheet override in main.css resets width/margin/border-
	   radius for every .bb-dialog:not(.bb-drawer); this only fills the sheet
	   itself to the viewport height so a full basket still scrolls inside it. */
	.bb-minicart { height: 92dvh; max-height: 92dvh; }
}

@media (max-width: 374px) {
	/* 360/320px: keep the row readable rather than cramped - drop the inline
	   qty/total gap slightly and let the suggestion grid's card text breathe. */
	.bb-minicart__line { gap: 8px 10px; }
	.bb-minicart__line-media { width: 56px; height: 56px; }
	.bb-minicart__suggest .bb-card__media { height: 84px; }
}
