/* ==========================================================================
   Cart panel and checkout
   The slide-out cart is built by js/cart-ui.js; checkout errors by
   js/stripe-checkout.js. Uses the tokens defined in site.css.
   ========================================================================== */

/* Overlay behind the open cart */
.cart-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  visibility: hidden;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.cart-overlay.active {
  visibility: visible;
  opacity: 1;
}

/* Slide-out panel */
.cart-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 28rem;
  height: 100vh;
  height: 100dvh;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  visibility: hidden;
  transform: translateX(100%);
  transition: transform 0.25s ease, visibility 0.25s ease;
}

.cart-panel.active {
  visibility: visible;
  transform: translateX(0);
}

body.cart-open {
  overflow: hidden;
}

.cart-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--rule);
}

.cart-header h3 {
  margin: 0;
  font-size: var(--text-lg);
}

.cart-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  padding: 0;
  font-size: 1.75rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  background: none;
  border: 0;
}

.cart-close:hover {
  color: var(--ink);
}

.cart-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.cart-content.hidden,
.cart-empty.hidden {
  display: none;
}

.cart-items {
  flex: 1;
  padding: 0 var(--space-5);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* One item */
.cart-item {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--rule);
}

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

.item-image {
  flex-shrink: 0;
  width: 5rem;
  height: 5rem;
  overflow: hidden;
  background: var(--wash);
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-details {
  flex: 1;
  min-width: 0;
}

.item-title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
}

.item-description {
  margin: 0 0 var(--space-1);
  font-size: var(--text-xs);
  line-height: 1.35;
  color: var(--ink-soft);
}

.item-price {
  font-size: var(--text-sm);
  font-weight: 600;
}

.quantity-price {
  margin-left: var(--space-2);
  font-weight: 400;
  color: var(--ink-soft);
}

.item-controls {
  display: flex;
  flex-basis: 100%;
  align-items: center;
  justify-content: space-between;
}

.quantity-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.qty-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--control-h);
  height: var(--control-h);
  padding: 0;
  font-size: var(--text-base);
  line-height: 1;
  cursor: pointer;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.qty-btn:hover:not(:disabled) {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

.qty-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.quantity {
  min-width: 1.5rem;
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
}

.remove-item {
  min-height: var(--control-h);
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-soft);
  cursor: pointer;
  background: none;
  border: 0;
}

.remove-item:hover {
  color: var(--error);
  text-decoration: underline;
}

/* Footer: total and actions */
.cart-footer {
  flex-shrink: 0;
  padding: var(--space-4) var(--space-5) calc(var(--space-5) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rule);
}

.cart-total {
  margin-bottom: var(--space-4);
}

.total-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-weight: 600;
}

.total-price {
  font-size: var(--text-lg);
}

.cart-actions {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--space-2);
}

.btn-checkout,
.btn-continue-shopping,
.btn-clear-cart {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-h);
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  border-radius: var(--radius);
}

.btn-checkout,
.btn-continue-shopping {
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
}

.btn-checkout:hover,
.btn-continue-shopping:hover {
  background: #333;
  border-color: #333;
}

.btn-clear-cart {
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
}

.btn-clear-cart:hover {
  background: var(--wash);
}

/* Empty state */
.cart-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-7) var(--space-5);
  text-align: center;
}

.cart-empty h4 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-lg);
}

.cart-empty p {
  max-width: 18rem;
  margin: 0 0 var(--space-5);
  font-size: var(--text-sm);
  color: var(--ink-soft);
}

/* Notifications inside the panel (cart-ui.js, stripe-checkout.js) */
.cart-notification,
.checkout-error {
  position: absolute;
  top: 100%;
  right: var(--space-5);
  left: var(--space-5);
  z-index: 10;
}

.cart-notification,
.error-content {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  background: var(--wash);
  border-left: 2px solid var(--ink);
}

.cart-notification-error,
.error-content {
  color: var(--error);
  border-left-color: var(--error);
}

.error-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.error-close {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  font-size: var(--text-lg);
  line-height: 1;
  color: inherit;
  cursor: pointer;
  background: none;
  border: 0;
}
