/* ── Cart Drawer ──
   Self-contained on purpose: this file is loaded on every page (home,
   shop, checkout), so it doesn't lean on classes defined only in
   shop.css/checkout.css (e.g. .purchase__summary-row). Everything the
   drawer needs lives here, built from the same global.css tokens
   (--gold, --black-card, --border-divider, etc.) as the rest of the
   site. */

/* ── Nav cart toggle + badge ── */
.site-nav__cart-btn {
  position: relative;
}

.site-nav__cart-btn svg {
  width: 18px;
  height: 18px;
}

.site-nav__cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--gold);
  color: var(--black);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.site-nav__cart-badge[hidden] {
  display: none;
}

/* ── Backdrop ──
   Sits behind the drawer. There's no JS toggle for it — visibility is
   driven purely by the drawer's own .is-open class via the sibling
   selector below, so the backdrop element must come immediately after
   the drawer element in the DOM. */
.cart-backdrop {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cart-drawer.is-open ~ .cart-backdrop {
  opacity: 1;
  visibility: visible;
}

/* ── Drawer shell ── */
.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 960;
  display: flex;
  flex-direction: column;
  width: min(420px, 100vw);
  height: 100vh;
  background: var(--black-card);
  border-left: 1px solid var(--border-divider);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.cart-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-divider);
  flex-shrink: 0;
}

.cart-drawer__title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--white);
}

.cart-drawer__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 18px;
  line-height: 1;
  transition: border-color 0.2s, color 0.2s;
}

.cart-drawer__close:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.cart-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.cart-drawer__empty {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: 56px 0;
}

.cart-drawer__empty[hidden] {
  display: none;
}

.cart-drawer__items {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cart-drawer__footer {
  flex-shrink: 0;
  padding: 18px 24px 24px;
  border-top: 1px solid var(--border-divider);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cart-drawer__footer[hidden] {
  display: none;
}

.cart-drawer__subtotal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
}

.cart-drawer__note {
  margin-top: -6px;
  font-size: 12px;
  color: var(--text-dim);
}

.cart-drawer__checkout-btn {
  width: 100%;
}

.cart-drawer__checkout-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cart-drawer__checkout-btn:disabled:hover {
  opacity: 0.5;
  transform: none;
}

/* ── Line items (markup built by js/cart.js renderCart()) ── */
.cart-item {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-divider);
}

.cart-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.cart-item__image {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--black);
  border: 1px solid var(--border-divider);
  flex-shrink: 0;
}

.cart-item__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cart-item__info {
  min-width: 0;
}

.cart-item__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-item__meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.cart-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.cart-item__stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--black-input);
  flex-shrink: 0;
}

.cart-item__stepper button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-primary);
  transition: background 0.15s;
}

.cart-item__stepper button:hover {
  background: var(--black-elevated);
}

.cart-item__stepper span {
  min-width: 22px;
  text-align: center;
  font-size: 13px;
  color: var(--text-primary);
}

.cart-item__price {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.cart-item__remove {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

.cart-item__remove:hover {
  color: #e5806a;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .cart-drawer {
    width: 100vw;
  }
}