/* ── Nav cart icon + badge ──────────────────────────────────────────── */
.cart-toggle {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Push the cart toward the right edge so it sits with the theme
     toggle (the nav-inner uses space-between, which would otherwise
     leave the cart floating in the middle-right). */
  margin-left: auto;
  margin-right: 8px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.cart-toggle:hover { background: var(--surface-2); border-color: var(--border-hover); }
.cart-count {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 700;
  background: #FF3B30;
  color: white;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.cart-count.has-items { opacity: 1; transform: scale(1); }

/* ── Mobile cart entry inside the hamburger dropdown ──────────────────
   The standalone icon is hidden below 880 px; cart.js injects this
   link into every .nav-links dropdown. Styled smaller than the main
   nav items so it reads as a secondary action, with the live count
   pinned to the right edge as a small pill. */
.nav-cart-link { display: none; }

@media (max-width: 880px) {
  .cart-toggle { display: none !important; }
  .nav-cart-link {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px !important;
    margin-top: 4px;
    font-size: 13px !important;
    font-weight: 500 !important;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--text-secondary) !important;
    border-top: 1px solid var(--border);
    background: transparent !important;
    border-radius: 0 !important;
  }
  .nav-cart-link:hover,
  .nav-cart-link:focus {
    color: var(--text-primary) !important;
    background: var(--surface-2) !important;
  }
  .nav-cart-link-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 700;
    background: var(--surface-2);
    color: var(--text-tertiary);
    line-height: 1;
    letter-spacing: 0;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .nav-cart-link-count.has-items {
    background: #FF3B30;
    color: white;
  }
}

/* ── Drawer shell ───────────────────────────────────────────────────── */
.cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
.cart-drawer.is-open { pointer-events: auto; }
.cart-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.42);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.cart-drawer.is-open .cart-backdrop { opacity: 1; }

.cart-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 92vw);
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}
.cart-drawer.is-open .cart-panel { transform: translateX(0); }

body.cart-open { overflow: hidden; }

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.cart-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  margin: 0;
}
.cart-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--surface-2);
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cart-close:hover { background: var(--surface); }

.cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 16px;
}

.cart-empty {
  padding: 60px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

.cart-items {
  list-style: none;
  padding: 0;
  margin: 0;
}
.cart-item {
  display: grid;
  /* First column matches the 72px live-3D thumbnail (.cart-item-thumb); a
     stale 56px here let the thumb overflow into the text column. */
  grid-template-columns: 72px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 16px 8px;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }

.cart-item-swatch {
  width: 72px; height: 72px;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.08);
}
.cart-item-swatch-combo {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.cart-item-swatch-combo > span {
  flex: 1;
  display: block;
}

/* Live 3D viewer thumbnail (replaces the color-swatch tile). The
   .model-card wrapper exists for shop-stl.js's event delegation but
   we override its visual styling here so the thumb looks like a
   product image, not a mini card. */
.cart-item-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  /* override .model-card */
  display: block;
  padding: 0;
  margin: 0;
  box-shadow: none;
  transform: none !important;
  transition: none;
}
.cart-item-thumb:hover {
  transform: none !important;
  box-shadow: none;
}
.cart-item-thumb .model-stl-viewer {
  width: 100% !important;
  height: 100% !important;
}
.cart-item-thumb-empty {
  /* shown when a SKU has no STL files mapped */
  background: var(--surface-2);
}

.cart-item-info { min-width: 0; }
.cart-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.1px;
  margin-bottom: 2px;
  line-height: 1.3;
}
.cart-item-color {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.cart-item-fee {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  margin: -4px 0 8px;
}
.cart-item-qty {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}
.cart-qty-btn {
  width: 24px; height: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cart-qty-btn:hover { background: var(--surface-2); }
.cart-qty-val {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
  color: var(--text-primary);
}
.cart-item-remove {
  margin-left: 8px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 6px;
  text-decoration: underline;
}
.cart-item-remove:hover { color: #FF3B30; }

.cart-item-price {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.cart-footer {
  padding: 18px 24px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.cart-totals {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.cart-totals-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}
.cart-totals-amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
.cart-shipping-note {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 0 0 14px;
}
.cart-checkout-btn {
  width: 100%;
  padding: 14px 18px;
  background: var(--text-primary);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s ease;
}
.cart-checkout-btn:hover:not(:disabled) { opacity: 0.86; }
.cart-checkout-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Add-to-Cart confirm flash */
.shop-btn.is-added {
  background: #34C759 !important;
  border-color: #34C759 !important;
}
