/* ==========================================================================
   Mini-cart (plan 06a) — MiniCart.dc.html. Content of #mk-minicart (this block),
   dialog/overlay/mobile panel (Task 4), toast + «✓ У кошику» (Task 5).
   ========================================================================== */

/* The icon is a link now (inc/minicart.php); header.css keeps its 44×44 box, mask icon and red counter. */
#mini-cart a.cart-head { color: var(--mk-ink); text-decoration: none; }
/* Safety net: Porto's hover popup must never come back next to our dialog. */
#mini-cart .cart-popup { display: none !important; }

/* ---- Panel content ---- */
.mk-mc { color: var(--mk-ink); font-size: 15px; line-height: 1.5; text-align: left; }
.mk-mc :where(h2, p, ul, li) { margin: 0; padding: 0; list-style: none; }
.mk-mc .widget_shopping_cart_content,
.mk-mc__inner { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }

.mk-mc__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 8px 8px 20px; border-bottom: 1px solid var(--mk-line); }
.mk-mc__title { font-size: 18px; line-height: 1.3; font-weight: 700; color: var(--mk-ink); letter-spacing: 0; text-transform: none; }
.mk-mc__close,
.mk-mc-item__remove {
	flex: 0 0 44px; display: inline-flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--mk-ink); cursor: pointer;
}
.mk-mc-item__remove { color: var(--mk-ink-2); }
.mk-mc__close:hover, .mk-mc-item__remove:hover { color: var(--mk-red); }
.mk-mc svg { display: block; }

/* Free-delivery line (paper band, green 6 px bar) */
.mk-mc-free { padding: 14px 20px; background: var(--mk-paper); border-bottom: 1px solid var(--mk-line); }
.mk-mc-free__text { margin-bottom: 8px; font-size: 14px; line-height: 1.4; }
.mk-mc-free__text b { font-weight: 700; }
.mk-mc-free__ok { font-weight: 700; color: var(--mk-green); }
.mk-mc-free__bar { height: 6px; background: var(--mk-line); overflow: hidden; }
.mk-mc-free__fill { display: block; height: 100%; background: var(--mk-green); }
.mk-mc-free__note { margin-top: 6px; font-size: 12px; line-height: 1.4; color: var(--mk-ink-2); }
@media (prefers-reduced-motion: no-preference) { .mk-mc-free__fill { transition: width .3s ease; } }

/* Rows: 64 px image · name / «140 ₴ × 2» / stepper + sum · ✕ */
.mk-mc__list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.mk-mc-item { display: grid; grid-template-columns: 64px minmax(0, 1fr) 44px; gap: 12px; align-items: start; padding: 14px 8px 12px 20px; border-bottom: 1px solid var(--mk-line); }
.mk-mc-item.is-busy { opacity: .6; }
.mk-mc-item__img { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; padding: 4px; box-sizing: border-box; background: var(--mk-paper); }
.mk-mc-item__img a { display: flex; width: 100%; height: 100%; align-items: center; justify-content: center; }
.mk-mc-item__img img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.mk-mc-item__body { min-width: 0; }
.mk-mc-item__name {
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
	font-weight: 500; font-size: 14px; line-height: 1.35; color: var(--mk-ink); text-decoration: none;
}
a.mk-mc-item__name:hover, a.mk-mc-item__name:focus-visible { color: var(--mk-red); }
.mk-mc-item dl.variation { margin: 2px 0 0; font-size: 13px; color: var(--mk-ink-2); }
.mk-mc-item__meta { margin-top: 2px; font-size: 13px; color: var(--mk-ink-2); }
.mk-mc-item__row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.mk-mc-qty { display: inline-flex; align-items: center; border: 1px solid var(--mk-line); }
.mk-mc-qty__btn { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 0; background: transparent; font: inherit; font-size: 18px; line-height: 1; color: var(--mk-ink); cursor: pointer; }
.mk-mc-qty__btn:hover:not([disabled]) { color: var(--mk-red); }
.mk-mc-qty__btn[disabled] { color: #8a817c; cursor: default; } /* disabled tone from DesignSystem «Неактивна» */
.mk-mc-qty__val { width: 30px; text-align: center; font-weight: 500; }
.mk-mc-item__sum { font-weight: 700; font-size: 16px; white-space: nowrap; }
/* Focus rings inside the scrolling list: draw them inside the control so overflow never clips them. */
.mk-mc__list a:focus-visible, .mk-mc__list button:focus-visible { outline-offset: -3px; box-shadow: none; }

/* Totals and buttons */
.mk-mc__foot { flex: 0 0 auto; padding: 16px 20px 20px; background: #fff; }
.mk-mc__total { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.mk-mc__total span { font-size: 17px; font-weight: 700; }
.mk-mc__total strong { font-size: 22px; font-weight: 700; }
.mk-mc__actions { display: flex; flex-direction: column; gap: 10px; }
.mk-mc__actions .mk-btn { width: 100%; box-sizing: border-box; }
.mk-mc__note { margin-top: 10px; font-size: 13px; color: var(--mk-ink-2); text-align: center; }

/* Empty state (board 3) */
.mk-mc__empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 36px 24px 28px; text-align: center; }
.mk-mc__empty svg { color: var(--mk-ink-2); }
.mk-mc__empty-title { margin-top: 4px; font-weight: 700; font-size: 20px; line-height: 1.3; }
.mk-mc__empty-text { color: var(--mk-ink-2); font-size: 14px; }
.mk-mc__empty .mk-btn { width: 100%; margin-top: 14px; box-sizing: border-box; }

/* Phones / tablets (board 4): 16 px gutters, no threshold note, totals pinned with a soft shadow */
@media (max-width: 991px) {
	.mk-mc__head { padding-left: 16px; }
	.mk-mc-free { padding: 12px 16px; }
	.mk-mc-free__note { display: none; }
	.mk-mc-item { padding: 14px 4px 12px 16px; }
	.mk-mc__foot { border-top: 1px solid var(--mk-line); padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 20px rgba(48, 42, 40, .06); }
	.mk-mc__total { margin-bottom: 12px; }
	.mk-mc__note { margin-top: 8px; }
}

/* ---- Dialog, overlay, scroll lock (Task 4) ---- */
html.mk-mc-opened { overflow: hidden; }
html.mk-mc-opened body { padding-right: var(--mk-mc-sbw, 0px); }
.mk-mc-overlay[hidden], .mk-mc[hidden] { display: none !important; }

/* Desktop: dims the page under the header (board 1); below 992 px --mk-mc-top is 0 and it covers everything. */
.mk-mc-overlay { position: fixed; left: 0; right: 0; bottom: 0; top: var(--mk-mc-top, 0px); z-index: 1099; background: rgba(48, 42, 40, .5); }

/* Phones / tablets (board 4): full-height panel from the right. */
.mk-mc {
	position: fixed; z-index: 1100; top: 0; right: 0; bottom: 0; box-sizing: border-box;
	width: 100%; max-width: 390px; height: 100%; height: 100dvh;
	display: flex; flex-direction: column; background: #fff;
}
/* Desktop (board 1): 392 px dropdown under the header, right edge on the 1280 px content grid (50 % + 616).
   With a classic scrollbar the scroll lock widens the viewport by --mk-mc-sbw while body keeps the page in place with
   padding-right, so the grid centre moves left by half of it. */
@media (min-width: 992px) {
	.mk-mc {
		top: var(--mk-mc-top, 0px); bottom: auto; right: max(16px, calc(50% - 616px + var(--mk-mc-sbw, 0px) / 2));
		width: 392px; max-width: calc(100vw - 32px); height: auto; max-height: calc(100vh - var(--mk-mc-top, 0px) - 16px);
		border: 1px solid var(--mk-line); box-shadow: 0 12px 32px rgba(48, 42, 40, .16);
	}
}
.mk-mc[aria-busy="true"] .mk-mc-qty__btn, .mk-mc[aria-busy="true"] .mk-mc-item__remove { pointer-events: none; }

/* Motion only when allowed (base.css also switches every animation off under reduce). */
@media (prefers-reduced-motion: no-preference) {
	.mk-mc { animation: mk-mc-fade .15s ease-out; }
	@keyframes mk-mc-fade { from { opacity: 0; } }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 991px) {
	.mk-mc { animation: mk-mc-slide .25s ease-out; }
	@keyframes mk-mc-slide { from { transform: translateX(100%); } }
}
/* Porto's hover / touch .open arrow under the icon (#mini-cart .cart-icon:after) belongs to its dropped .cart-popup. */
#header #mini-cart .cart-icon::after { content: none; display: none; }

/* ---- «Додано в кошик» toast (Task 5, board 2) ---- */
/* The container is always in the DOM (a live region) and has no size until the JS puts the card in. */
.mk-mc-toast { position: fixed; z-index: 1098; top: var(--mk-mc-toast-top, 0px); left: 0; right: 0; }
@media (min-width: 992px) { .mk-mc-toast { left: auto; right: max(16px, calc(50% - 616px)); width: 360px; } }
.mk-mc-toast__card {
	box-sizing: border-box; background: #fff; border: 1px solid var(--mk-line); border-top: 3px solid var(--mk-green);
	box-shadow: 0 12px 32px rgba(48, 42, 40, .16); color: var(--mk-ink); font-size: 15px; line-height: 1.5; text-align: left;
}
@media (max-width: 991px) { .mk-mc-toast__card { border-left: 0; border-right: 0; } }
.mk-mc-toast :where(p) { margin: 0; }
.mk-mc-toast svg { display: block; flex: 0 0 auto; }
.mk-mc-toast__head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 4px 16px; }
.mk-mc-toast__title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--mk-green); }
.mk-mc-toast__close {
	flex: 0 0 44px; display: inline-flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--mk-ink); cursor: pointer;
}
.mk-mc-toast__close:hover { color: var(--mk-red); }
.mk-mc-toast__item { display: flex; gap: 12px; align-items: center; padding: 0 16px 14px; }
.mk-mc-toast__img { flex: 0 0 56px; height: 56px; display: flex; align-items: center; justify-content: center; padding: 4px; box-sizing: border-box; background: var(--mk-paper); }
.mk-mc-toast__img img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.mk-mc-toast__text { min-width: 0; }
.mk-mc-toast__name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 500; font-size: 14px; line-height: 1.35; }
.mk-mc-toast__meta { font-size: 13px; color: var(--mk-ink-2); }
.mk-mc-toast__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--mk-line); background: var(--mk-paper); }
.mk-mc-toast__sum { font-size: 14px; color: var(--mk-ink-2); }
.mk-mc-toast__sum b { font-weight: 700; color: var(--mk-ink); }
.mk-mc-toast__go { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 700; color: var(--mk-red); text-decoration: none; }
.mk-mc-toast__go:hover { color: var(--mk-red-700); }
@media (prefers-reduced-motion: no-preference) {
	.mk-mc-toast__card { animation: mk-mc-drop .2s ease-out; }
	@keyframes mk-mc-drop { from { opacity: 0; transform: translateY(-6px); } }
}

/* ---- «✓ У кошику» on the card button after an AJAX add (catalog cards, related products, home cards) ---- */
/* Out-specify shop.css (`body ul.products li.product-col .add-links .button[:hover]` with !important) and
   home.css (`.mk-pcard .add_to_cart_button.added::after { content: " ✓" }`). */
body ul.products li.product-col .add-links .button.mk-in-cart,
body ul.products li.product-col .add-links .button.mk-in-cart:hover,
body ul.products li.product-col .add-links .button.mk-in-cart:focus-visible,
body .mk-pcard .add_to_cart_button.mk-in-cart,
body .mk-pcard .add_to_cart_button.mk-in-cart:hover,
body .mk-pcard .add_to_cart_button.mk-in-cart:focus-visible {
	gap: 6px; padding-left: 12px; padding-right: 12px;
	background: var(--mk-green) !important; border-color: var(--mk-green) !important; color: #fff !important;
}
/* shop.css widens the button on card hover (`li.product-col.product-default:hover .add-links .button`); keep it steady. */
body ul.products li.product-col.product-default:hover .add-links .button.mk-in-cart { padding-left: 12px; padding-right: 12px; }
/* Hover: a darker green, so the button still reads as a control (it adds one more). */
body ul.products li.product-col .add-links .button.mk-in-cart:hover,
body .mk-pcard .add_to_cart_button.mk-in-cart:hover {
	background: color-mix(in srgb, var(--mk-green) 82%, #000) !important; border-color: color-mix(in srgb, var(--mk-green) 82%, #000) !important;
}
body .mk-pcard .add_to_cart_button.mk-in-cart.added::after { content: none; }
/* Narrow catalog cards (2 columns ≤ 420 px, 3 columns around 576–650 px): «✓ У кошику» is wider than «В кошик» and the
   shop.css grid (minmax(0, 1fr) auto) would squeeze the price under it. The card with an in-cart button keeps the
   price at its own width and gives the button the rest; the label may wrap to two lines inside the 44 px button. */
body ul.products li.product-col .product-content:has(.mk-in-cart) { grid-template-columns: max-content minmax(0, 1fr); }
body ul.products li.product-col .product-content:has(.mk-in-cart) .add-links-wrap { justify-self: end; min-width: 0; max-width: 100%; }
body ul.products li.product-col .add-links .button.mk-in-cart { min-width: 0; max-width: 100%; white-space: normal; }
body ul.products li.product-col .add-links .button.mk-in-cart span { min-width: 0; line-height: 1.1; text-align: left; }
@media (max-width: 767px) {
	body ul.products li.product-col .add-links .button.mk-in-cart,
	body ul.products li.product-col.product-default:hover .add-links .button.mk-in-cart { gap: 4px; padding-left: 8px; padding-right: 8px; }
}
.add_to_cart_button.mk-in-cart svg { display: block; flex: 0 0 14px; }
