/* ============================== CART: header toggle ============================== */
.cart-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}
.cart-toggle:hover {
  color: var(--color-primary);
  background: var(--color-surface-offset);
}
.cart-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}
.cart-badge[hidden] {
  display: none;
}
.cart-badge.bump {
  animation: cartBadgeBump 0.35s ease;
}
@keyframes cartBadgeBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* ============================== CART: product card button ============================== */
.add-to-cart-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.add-to-cart-btn.is-added {
  color: var(--color-primary-hover);
}

/* ============================== CART: toast ============================== */
.cart-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 12px);
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 600;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.cart-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.cart-toast strong {
  color: var(--color-primary);
}

/* ============================== CART: drawer shell ============================== */
.cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  visibility: hidden;
  pointer-events: none;
}
.cart-drawer[data-open="true"] {
  visibility: visible;
  pointer-events: auto;
}
.cart-drawer-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 6, 0.6);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.cart-drawer[data-open="true"] .cart-drawer-overlay {
  opacity: 1;
}
.cart-drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(440px, 100%);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.35);
}
.cart-drawer[data-open="true"] .cart-drawer-panel {
  transform: translateX(0);
}

.cart-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
}
.cart-drawer-head h2 {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}
.cart-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
}
.cart-drawer-close:hover {
  color: var(--color-primary);
  background: var(--color-surface-offset);
}

.cart-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

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

/* ---- Empty state ---- */
.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  padding-block: var(--space-16) var(--space-8);
}
.cart-empty svg {
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}
.cart-empty p {
  margin: 0;
  color: var(--color-text);
  font-weight: 600;
}
.cart-empty-sub {
  font-weight: 400 !important;
  color: var(--color-text-muted) !important;
  font-size: var(--text-sm);
  max-width: 28ch;
}
.cart-empty[hidden] {
  display: none;
}

/* ---- Cart item rows ---- */
.cart-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.cart-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-divider);
}
.cart-item:last-child {
  border-bottom: none;
}
.cart-item-img {
  width: 64px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-offset);
}
.cart-item-info h4 {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 2px;
}
.cart-item-category {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-bottom: var(--space-1);
}
.cart-item-price {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}
.cart-item-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}
.cart-qty-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 600;
}
.cart-qty-input {
  width: 48px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-family: var(--font-body);
}
.cart-item-remove {
  background: none;
  border: none;
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.cart-item-remove:hover {
  color: var(--color-error, #c0554a);
}
.cart-notes-input {
  width: 100%;
  min-height: 50px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  resize: vertical;
}
.cart-notes-input::placeholder {
  color: var(--color-text-faint);
}
.cart-notes-input:focus,
.cart-qty-input:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* ---- Checkout step ---- */
.cart-back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: var(--space-4);
}
.cart-back-link:hover {
  color: var(--color-primary);
}
.cart-checkout-intro {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}
.cart-field {
  display: block;
  margin-bottom: var(--space-4);
}
.cart-field span {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
}
.cart-field span em {
  font-style: normal;
  font-weight: 400;
  text-transform: none;
  color: var(--color-text-faint);
}
.cart-field input,
.cart-field select,
.cart-field textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-family: var(--font-body);
}
.cart-field select {
  appearance: auto;
  cursor: pointer;
}
.cart-zip-status {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.4;
}
.cart-zip-status[hidden] {
  display: none;
}
.cart-field input:focus,
.cart-field select:focus,
.cart-field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}
.cart-field-error {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  color: #ef4444;
  line-height: 1.4;
}
.cart-field-error[hidden] {
  display: none;
}
.cart-field input.has-error,
.cart-field select.has-error {
  border-color: #ef4444;
}
.cart-field-hint {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  line-height: 1.4;
}
.cart-field-file input[type='file'] {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-size: var(--text-xs);
}
.cart-field-file input[type='file']::file-selector-button,
.cart-field-file input[type='file']::-webkit-file-upload-button {
  margin-right: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-primary);
  color: var(--color-bg);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition-interactive);
}
.cart-field-file input[type='file']:hover::file-selector-button,
.cart-field-file input[type='file']:hover::-webkit-file-upload-button {
  opacity: 0.85;
}
.cart-field-file input[type='file'].has-error {
  border-color: #ef4444;
}

/* ---- Shipping method selector ---- */
.cart-shipping-methods {
  margin-bottom: var(--space-4);
}
.cart-shipping-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.cart-shipping-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.cart-shipping-option:has(input:checked) {
  border-color: var(--color-primary);
}
.cart-shipping-option.is-selected {
  border-color: var(--color-primary);
}
.cart-shipping-option input[type="radio"] {
  flex-shrink: 0;
  width: auto;
  accent-color: var(--color-primary);
}
.cart-shipping-methods .cart-shipping-option-text {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: var(--space-2);
  row-gap: 2px;
  width: 100%;
  font-size: var(--text-sm);
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
}
.cart-shipping-options .cart-shipping-option-name {
  display: inline;
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 600;
}
.cart-shipping-options .cart-shipping-option-price {
  display: inline;
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
  font-size: var(--text-sm);
  color: var(--color-primary);
  font-weight: 700;
  white-space: nowrap;
}
.cart-shipping-note {
  margin: var(--space-2) 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--color-text-faint);
}

/* ---- Order summary (subtotal / tax / total) ---- */
.cart-order-summary {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.cart-summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  padding: var(--space-1) 0;
}
.cart-summary-row span:last-child {
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}
.cart-summary-row--total {
  border-top: 1px solid var(--color-divider);
  margin-top: var(--space-2);
  padding-top: var(--space-3);
  font-weight: 700;
  color: var(--color-text);
}
.cart-summary-row--total span:last-child {
  font-family: var(--font-display);
  font-size: var(--text-md);
  color: var(--color-primary);
}
.cart-summary-row[hidden] {
  display: none;
}
.cart-summary-note {
  margin: var(--space-3) 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--color-text-faint);
}
.cart-submit-btn {
  width: 100%;
  margin-top: var(--space-2);
}
.cart-form-status {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
}
.cart-form-status.is-error {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

/* ---- Footer ---- */
.cart-drawer-foot {
  flex-shrink: 0;
  padding: var(--space-4) var(--space-5) var(--space-5);
  border-top: 1px solid var(--color-divider);
  background: var(--color-surface);
}
.cart-drawer-foot[hidden] {
  display: none;
}
.cart-field-zip {
  margin-bottom: var(--space-3);
}
.cart-field-zip input {
  max-width: 140px;
}
.cart-foot-summary {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  text-align: center;
}
.cart-drawer-foot .btn {
  width: 100%;
}

@media (max-width: 480px) {
  .cart-drawer-panel {
    width: 100%;
  }
}
