/* ═══════════════════ CART DRAWER — header cart button + slide-in bag ═══════════════════
   Companion to inc/cart-drawer.php + js/cart-drawer.js. Enqueued site-wide
   after header-nav.css.

   - z-index: scrim 100 / panel 101, above the product page's .pd-sticky
     bar (90).
   - The panel uses top/bottom:0 rather than height:100vh, so mobile browser
     toolbars don't cut off the checkout button. It also clears the WP
     admin bar.
   - Explicit resets on every button/link: style.css and custom.css style
     bare button/a/h2, and those styles would otherwise leak in.
   - Focus-visible rings are set here because custom.css sets
     :focus { outline: none }. */

/* ───────────── Cart button (in the nav pill) ───────────── */
.nav__cart {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; flex: none; padding: 0; margin: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, 0.12); color: #fff; transition: background 0.18s ease;
}
.nav__cart:hover,
.nav__cart:focus { background: rgba(255, 255, 255, 0.2); color: #fff; }
.nav__cart:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.nav__cart svg { width: 20px; height: 20px; display: block; }
.nav__cart-count {
  position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: #fff; box-shadow: 0 0 0 2px rgba(18, 17, 14, 0.85);
  font-family: var(--sans); font-size: 10.5px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
/* display:flex above would otherwise beat the [hidden] attribute */
.nav__cart-count[hidden] { display: none; }

/* one copy per breakpoint: desktop = in the menu's actions <li>,
   mobile = in the header pill beside the burger */
.nav__cart--mobile { display: none; }

@media (max-width: 1199px) {
  .genesis-nav-menu .menu-item--actions .nav__cart { display: none; }
  .site-header > .wrap > .nav__cart--mobile {
    display: flex;
    margin-left: auto;   /* push right, next to the burger */
    margin-right: -14px; /* .wrap's 26px gap → 12px between cart and burger */
  }
}
@media (max-width: 480px) {
  .site-header > .wrap > .nav__cart--mobile { margin-right: -2px; } /* .wrap gap is 12px here */
}

/* ───────────── Scrim ───────────── */
.cart-scrim {
  position: fixed; inset: 0; z-index: 100; background: rgba(12, 12, 13, 0.32);
  opacity: 0; visibility: hidden; transition: opacity 0.28s ease, visibility 0.28s;
}
.cart-scrim.is-open { opacity: 1; visibility: visible; }

html.cart-is-open { overflow: hidden; }

/* ───────────── Panel ───────────── */
.cart-panel {
  position: fixed; top: 0; bottom: 0; right: 0; z-index: 101; width: min(400px, 92vw);
  background: #fbfaf8; box-shadow: -30px 0 70px -30px rgba(12, 12, 13, 0.35);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
}
.cart-panel.is-open { transform: translateX(0); }
/* Closed, the panel sits off-screen but its shadow reached 70px back onto every
   page (a grey band down the right edge). Hide it once the slide-out finishes;
   this also keeps keyboard focus out of the closed drawer. */
.cart-panel:not(.is-open) { visibility: hidden; transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.38s; }
.admin-bar .cart-panel { top: 32px; }
@media (max-width: 782px) { .admin-bar .cart-panel { top: 46px; } }

.cart-panel__head {
  display: flex; align-items: center; justify-content: space-between; flex: none;
  padding: clamp(22px, 3vh, 28px) clamp(20px, 3vw, 28px) 18px; border-bottom: 1px solid var(--line);
}
.cart-panel__title {
  font-family: var(--sans); font-weight: 500; font-size: 19px; line-height: 1.2;
  letter-spacing: -0.01em; color: var(--ink); margin: 0;
}
.cart-panel__close {
  width: 36px; height: 36px; flex: none; padding: 0; border: 0; border-radius: 50%;
  background: #f4f2ed; color: var(--ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.18s ease;
}
.cart-panel__close:hover,
.cart-panel__close:focus { background: #e9e6df; color: var(--ink); }
.cart-panel__close svg { width: 16px; height: 16px; }

.cart-panel__error {
  flex: none; margin: 14px clamp(20px, 3vw, 28px) 0; padding: 10px 13px; border-radius: 10px;
  background: rgba(239, 108, 35, 0.1); color: #a8440f;
  font-family: var(--sans); font-size: 13px; line-height: 1.45;
}

.cart-panel__items { flex: 1; overflow-y: auto; padding: 6px clamp(20px, 3vw, 28px); transition: opacity 0.2s ease; }
.cart-panel.is-busy .cart-panel__items { opacity: 0.55; pointer-events: none; }
.cart-panel__empty { font-family: var(--sans); font-size: 14.5px; color: var(--ink-soft); text-align: center; margin: 64px 0 0; }

/* ───────────── Line items ───────────── */
.cart-item { display: flex; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.cart-item__media { flex: none; display: block; }
.cart-item__img { width: 62px; height: 62px; display: block; border-radius: 12px; background: #f4f2ed; object-fit: contain; padding: 8px; box-sizing: border-box; }
.cart-item__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cart-item__name,
.cart-item__name:hover { font-family: var(--sans); font-size: 14.5px; font-weight: 600; color: var(--ink); line-height: 1.25; text-decoration: none; }
.cart-item__name:hover { color: var(--accent); }
.cart-item__mode { font-family: var(--sans); font-size: 12px; color: var(--ink-soft); }
.cart-item__qty { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.cart-item__qty button {
  width: 24px; height: 24px; flex: none; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: #fff;
  cursor: pointer; font-family: var(--sans); font-size: 14px; line-height: 1; color: var(--ink);
  display: flex; align-items: center; justify-content: center; transition: background 0.15s ease, opacity 0.15s ease;
}
.cart-item__qty button:hover,
.cart-item__qty button:focus { background: #f4f2ed; color: var(--ink); }
.cart-item__qty button:disabled { opacity: 0.4; cursor: default; background: #fff; }
.cart-item__qtyval { font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--ink); min-width: 12px; text-align: center; }
.cart-item__right { flex: none; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; }
.cart-item__price { font-family: var(--sans); font-size: 14.5px; font-weight: 600; color: var(--ink); }
.cart-item__remove { border: 0; background: none; padding: 4px; margin: 0; color: var(--ink-faint); cursor: pointer; transition: color 0.18s ease; }
.cart-item__remove:hover,
.cart-item__remove:focus { background: none; color: var(--accent); }
.cart-item__remove svg { width: 15px; height: 15px; display: block; }

/* ───────────── Footer ───────────── */
.cart-panel__foot { flex: none; padding: 18px clamp(20px, 3vw, 28px) clamp(20px, 3vh, 28px); border-top: 1px solid var(--line); }
.cart-panel__subtotal { display: flex; align-items: center; justify-content: space-between; font-family: var(--sans); font-size: 16px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.cart-panel__shipnote { font-family: var(--sans); font-size: 12px; color: var(--ink-soft); margin: 0 0 16px; text-wrap: pretty; }
.cart-panel__checkout,
.cart-panel__checkout:hover,
.cart-panel__checkout:focus {
  display: block; width: 100%; box-sizing: border-box; text-align: center; text-decoration: none;
  font-family: var(--sans); font-size: 15px; font-weight: 600; color: #fff; background: var(--accent);
  border: 0; border-radius: 999px; padding: 14px; cursor: pointer; transition: background 0.18s ease, transform 0.18s ease;
}
.cart-panel__checkout:hover { background: #e2611c; transform: translateY(-1px); }

.cart-panel__close:focus-visible,
.cart-item__qty button:focus-visible,
.cart-item__remove:focus-visible,
.cart-item__name:focus-visible,
.cart-panel__checkout:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 560px) { .cart-panel { width: 100vw; } }

@media (prefers-reduced-motion: reduce) {
  .cart-panel, .cart-scrim { transition: none; }
}

/* WooCommerce appends a "View cart" link after AJAX Add to Bag buttons.
   The drawer opens instead and the Cart page redirects, so hide the link
   everywhere. */
a.added_to_cart.wc-forward { display: none; }

/* cart-drawer.js: closed and settled, the drawer leaves the layout entirely
   (Safari tinted its bottom toolbar from the hidden dark scrim). */
.cart-scrim.is-idle, .cart-panel.is-idle { display: none; }
