/* ══════════════════════════════════════
   Back Acres Farm Store — Global Cart CSS
   Loaded on ALL frontend pages.
   ══════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400&family=Outfit:wght@300;400;500;600&display=swap');

:root {
  --bafs-cream: #F5F0E8;
  --bafs-cream-dark: #EDE6D8;
  --bafs-bark: #3B2F20;
  --bafs-bark-light: #5C4A36;
  --bafs-sage: #6B7F5E;
  --bafs-sage-light: #8FA67E;
  --bafs-gold: #C4973B;
  --bafs-gold-light: #D4AD5A;
  --bafs-text: #4A4035;
  --bafs-red: #A34A3B;
  --bafs-font-display: 'Cormorant Garamond', Georgia, serif;
  --bafs-font-body: 'Outfit', -apple-system, sans-serif;
  --bafs-nav-height: 0px; /* Set dynamically by JS */
}

/* ── Cart Overlay ── */
.bafs-cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 37, 32, 0.5);
  z-index: 99998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s, visibility 0.4s;
}

.bafs-cart-overlay.open { opacity: 1; visibility: visible; }

/* ── Cart Drawer ──
   KEY FIX: top uses --bafs-nav-height so it sits below the site nav.
   Height is reduced by that same amount.
*/
.bafs-cart-drawer {
  position: fixed;
  top: var(--bafs-nav-height, 0px);
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: var(--bafs-cream);
  z-index: 99999;
  transform: translateX(100%);
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 60px rgba(42,37,32,0.15);
  font-family: var(--bafs-font-body);
}

.bafs-cart-drawer.open { transform: translateX(0); }

.bafs-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--bafs-cream-dark);
  flex-shrink: 0;
}

.bafs-cart-header h3 {
  font-family: var(--bafs-font-display) !important;
  font-size: 1.5rem !important;
  font-weight: 600 !important;
  color: var(--bafs-bark) !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.3 !important;
}

.bafs-cart-close {
  background: none !important;
  border: none !important;
  cursor: pointer;
  color: var(--bafs-bark-light);
  padding: 0.25rem !important;
  transition: color 0.3s, transform 0.3s;
  line-height: 0 !important;
}

.bafs-cart-close:hover { color: var(--bafs-bark); transform: rotate(90deg); }
.bafs-cart-close svg { width: 24px; height: 24px; display: block; }

.bafs-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.75rem;
}

.bafs-cart-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--bafs-bark-light);
}

.bafs-cart-empty p { margin: 0 !important; }

.bafs-cart-item {
  display: flex;
  gap: 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--bafs-cream-dark);
}

.bafs-cart-item-img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bafs-cream-dark);
}

.bafs-cart-item-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bafs-cart-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
}

.bafs-cart-item-name {
  font-family: var(--bafs-font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--bafs-bark);
  line-height: 1.2;
}

.bafs-cart-item-price {
  font-size: 0.82rem;
  color: var(--bafs-bark-light);
}

.bafs-cart-item-qty {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 0.35rem;
}

.bafs-qty-btn {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--bafs-cream-dark) !important;
  background: #fff !important;
  color: var(--bafs-bark) !important;
  font-size: 1rem !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: border-color 0.2s, background 0.2s;
  padding: 0 !important;
  line-height: 1 !important;
  min-height: 0 !important;
}

.bafs-qty-btn:first-child { border-radius: 6px 0 0 6px !important; }
.bafs-qty-btn:last-child { border-radius: 0 6px 6px 0 !important; }
.bafs-qty-btn:hover { border-color: var(--bafs-bark-light) !important; background: var(--bafs-cream-dark) !important; }

.bafs-cart-item-qty > span {
  width: 36px;
  height: 28px;
  border-top: 1.5px solid var(--bafs-cream-dark);
  border-bottom: 1.5px solid var(--bafs-cream-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 500;
  background: #fff;
  color: var(--bafs-bark);
}

.bafs-cart-item-remove {
  align-self: flex-start;
  background: none !important;
  border: none !important;
  color: var(--bafs-bark-light) !important;
  cursor: pointer;
  padding: 0.2rem !important;
  opacity: 0.4;
  transition: opacity 0.3s, color 0.3s;
  flex-shrink: 0;
  line-height: 0 !important;
}

.bafs-cart-item-remove:hover { opacity: 1; color: var(--bafs-red) !important; }
.bafs-cart-item-remove svg { width: 16px; height: 16px; display: block; }

/* ── Cart Footer ── */
.bafs-cart-footer {
  padding: 1.5rem 1.75rem;
  border-top: 1px solid var(--bafs-cream-dark);
  background: #fff;
  flex-shrink: 0;
}

.bafs-cart-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.bafs-cart-subtotal span {
  font-size: 0.9rem;
  color: var(--bafs-bark-light);
}

.bafs-cart-subtotal strong {
  font-family: var(--bafs-font-display);
  font-size: 1.5rem;
  color: var(--bafs-bark);
}

.bafs-checkout-btn {
  display: block !important;
  width: 100% !important;
  padding: 1rem !important;
  background: var(--bafs-gold) !important;
  color: var(--bafs-bark) !important;
  border: none !important;
  border-radius: 10px !important;
  font-family: var(--bafs-font-body) !important;
  font-size: 0.82rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.12em !important;
  text-transform: uppercase !important;
  cursor: pointer !important;
  transition: background 0.3s, transform 0.2s, box-shadow 0.3s !important;
  text-align: center !important;
  line-height: 1.4 !important;
}

.bafs-checkout-btn:hover {
  background: var(--bafs-gold-light) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(196, 151, 59, 0.35);
}

.bafs-checkout-btn:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

.bafs-stripe-note {
  margin-top: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--bafs-bark-light);
  opacity: 0.6;
}

/* ── Floating Cart Button ── */
.bafs-floating-cart {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 99997;
  width: 56px;
  height: 56px;
  border-radius: 50% !important;
  background: var(--bafs-bark) !important;
  color: var(--bafs-cream) !important;
  border: none !important;
  cursor: pointer !important;
  box-shadow: 0 4px 24px rgba(42,37,32,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s, box-shadow 0.3s;
  padding: 0 !important;
  min-height: 0 !important;
  line-height: 0 !important;
}

.bafs-floating-cart:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(42,37,32,0.4);
}

.bafs-floating-cart svg { width: 24px; height: 24px; display: block; }

.bafs-floating-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--bafs-gold);
  color: var(--bafs-bark);
  font-family: var(--bafs-font-body);
  font-size: 0.65rem;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Toast ── */
.bafs-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bafs-bark);
  color: var(--bafs-cream);
  padding: 0.85rem 1.5rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-family: var(--bafs-font-body);
  z-index: 100000;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-shadow: 0 10px 40px rgba(42,37,32,0.25);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s;
  pointer-events: none;
  white-space: nowrap;
}

.bafs-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.bafs-toast svg { width: 18px; height: 18px; color: var(--bafs-sage-light); flex-shrink: 0; display: block; }

/* ── Responsive ── */
@media (max-width: 550px) {
  .bafs-cart-drawer { width: 100%; max-width: 100vw; }
  .bafs-floating-cart { bottom: 1.25rem; right: 1.25rem; }
}
