/* ═══════════════════════════════════════════════════════════
   ArtKeyz — Cart Drawer
   ═══════════════════════════════════════════════════════════ */

/* ── Overlay ── */
#cart-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0; pointer-events: none;
  transition: opacity .35s ease;
}
body.cart-open #cart-overlay {
  opacity: 1; pointer-events: all;
}

/* ── Drawer ── */
#cart-drawer {
  position: fixed;
  top: 0; right: 0;
  width: 420px; max-width: 100vw;
  /* height: 100dvh prend en compte la barre d'adresse mobile Safari
     qui apparaît/disparaît au scroll — empêche le footer "Passer commande"
     de déborder hors écran. Fallback 100vh pour vieux navigateurs. */
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  background: #0c0c0c;
  border-left: 1px solid rgba(201,169,110,0.18);
  z-index: 999;
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .38s cubic-bezier(0.4, 0, 0.2, 1);
  overscroll-behavior: contain;
}
body.cart-open #cart-drawer {
  transform: translateX(0);
  box-shadow: -20px 0 60px rgba(0,0,0,0.6);
}

/* ── Header ── */
.cart-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 24px 24px 18px;
  border-bottom: 1px solid rgba(201,169,110,0.1);
  flex-shrink: 0;
}
.cart-head-label {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 18px; letter-spacing: 0.35em;
  color: #fff; text-transform: uppercase;
}
.cart-head-count {
  font-size: 10px; letter-spacing: 0.2em;
  color: rgba(232,213,163,0.3); margin-top: 4px;
  text-transform: uppercase;
}
#cart-close {
  background: none; border: none; cursor: pointer;
  color: rgba(232,213,163,0.35); padding: 4px; line-height: 0;
  transition: color .2s; flex-shrink: 0;
}
#cart-close:hover { color: #c9a96e; }

/* ── Body ── */
.cart-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(201,169,110,0.15) transparent;
  /* Smooth scroll iOS + empêche le scroll chain vers le body */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  min-height: 0; /* indispensable pour que flex:1 + overflow marche dans flex col */
}
.cart-body::-webkit-scrollbar { width: 3px; }
.cart-body::-webkit-scrollbar-thumb {
  background: rgba(201,169,110,0.15); border-radius: 2px;
}

/* ── Empty state ── */
.cart-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 72px 32px; text-align: center; gap: 12px;
}
.cart-empty-icon {
  width: 68px; height: 68px;
  border: 1px solid rgba(201,169,110,0.15); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(201,169,110,0.25); margin-bottom: 4px;
}
.cart-empty-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 16px; letter-spacing: 0.25em; color: #fff;
  text-transform: uppercase;
}
.cart-empty-sub {
  font-size: 11px; color: rgba(232,213,163,0.3);
  letter-spacing: 0.04em; line-height: 1.6;
}
.cart-empty-cta {
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: #c9a96e; text-decoration: none;
  margin-top: 8px; transition: color .2s;
}
.cart-empty-cta:hover { color: #e8d5a3; }

/* ── Item ── */
.cart-item {
  display: flex;
  border-bottom: 1px solid rgba(201,169,110,0.07);
  transition: background .2s;
}
.cart-item:last-child { border-bottom: none; }
.cart-item:hover { background: rgba(255,255,255,0.015); }

.cart-item-accent {
  width: 3px; flex-shrink: 0; opacity: 0.7;
}
.cart-item-body {
  padding: 16px 18px 14px; flex: 1; min-width: 0;
}
.cart-item-series {
  font-size: 8px; letter-spacing: 0.3em; text-transform: uppercase;
  color: rgba(232,213,163,0.3); margin-bottom: 3px;
}
.cart-item-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 17px; letter-spacing: 0.1em; color: #fff; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cart-item-option {
  font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase;
  color: #c9a96e; margin-top: 4px;
  opacity: 0.85;
}
.cart-item-custom {
  font-size: 9px; color: rgba(232,213,163,0.28); line-height: 1.5;
  margin-top: 4px; letter-spacing: 0.02em;
}
.cart-item-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px;
}

/* Quantity controls */
.cart-item-qty { display: flex; align-items: center; }
.qty-btn {
  width: 26px; height: 26px;
  background: rgba(201,169,110,0.07);
  border: 1px solid rgba(201,169,110,0.15);
  color: rgba(232,213,163,0.55); font-size: 15px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .2s, color .2s; user-select: none;
}
.qty-btn:first-child { border-radius: 2px 0 0 2px; }
.qty-btn:last-child  { border-radius: 0 2px 2px 0; }
.qty-btn:hover { background: rgba(201,169,110,0.18); color: #c9a96e; }
.qty-value {
  width: 32px; height: 26px;
  background: rgba(201,169,110,0.05);
  border-top: 1px solid rgba(201,169,110,0.15);
  border-bottom: 1px solid rgba(201,169,110,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: rgba(232,213,163,0.75);
  font-family: 'Montserrat', sans-serif;
}

.cart-item-right { display: flex; align-items: center; gap: 14px; }
.cart-item-price {
  font-family: 'Cormorant Garamond', serif;
  font-size: 19px; font-weight: 300; color: #c9a96e; white-space: nowrap;
}
.cart-item-remove {
  background: none; border: none; cursor: pointer;
  color: rgba(232,213,163,0.18); padding: 4px; line-height: 0;
  transition: color .2s;
}
.cart-item-remove:hover { color: rgba(200,60,60,0.75); }

/* ── Footer ── */
.cart-foot {
  flex-shrink: 0;
  padding: 18px 24px 28px;
  border-top: 1px solid rgba(201,169,110,0.1);
  display: none; /* shown via JS */
  flex-direction: column; gap: 10px;
}
.cart-subtotal {
  display: flex; align-items: baseline; justify-content: space-between;
}
.cart-subtotal-label {
  font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(232,213,163,0.35);
}
.cart-subtotal-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 30px; font-weight: 300; color: #c9a96e;
}
.cart-delivery-note {
  font-size: 9px; color: rgba(232,213,163,0.22);
  letter-spacing: 0.05em; text-align: center;
  padding: 6px 0 10px;
  border-bottom: 1px solid rgba(201,169,110,0.07);
}
.cart-checkout-btn {
  display: block; width: 100%;
  padding: 16px; border: none; border-radius: 2px;
  background: #c9a96e; color: #080808;
  font-family: 'Montserrat', sans-serif;
  font-size: 10px; font-weight: 500; letter-spacing: 0.3em;
  text-transform: uppercase; text-align: center; text-decoration: none;
  cursor: pointer; transition: background .25s;
}
.cart-checkout-btn:hover { background: #e8d5a3; }

/* ── Toggle button (injecté dans le nav) ── */
.cart-toggle-btn {
  position: relative;
  background: none; border: none; cursor: pointer;
  color: rgba(232,213,163,0.4); padding: 0 2px;
  line-height: 0; display: flex; align-items: center;
  transition: color .3s;
}
.cart-toggle-btn:hover { color: #c9a96e; }
/* Cart toggle positionné en direct dans header/nav-icons */
header > .cart-toggle-btn {
  margin-left: auto;
  flex-shrink: 0;
}

.nav-icons > .cart-toggle-btn {
  color: rgba(255,255,255,0.9);
}
.nav-icons > .cart-toggle-btn:hover {
  color: #c9a96e;
}

/* Toujours visible même quand nav-icons est masqué sur mobile */
.nav-icons:has(.cart-toggle-btn) {
  display: flex !important;
}

.cart-badge {
  position: absolute; top: -7px; right: -9px;
  min-width: 17px; height: 17px;
  background: #c9a96e; border-radius: 9px;
  display: none;
  align-items: center; justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-size: 9px; font-weight: 600; color: #080808;
  padding: 0 4px; letter-spacing: 0;
  pointer-events: none;
}

/* ── Prevent body scroll when open ──
   position: fixed + top/left avec variable --cart-scroll-y permet de bloquer
   la page dessous sans perdre la position de scroll, et empêche le "rubber band"
   sur iOS Safari qui décalait le drawer vers le haut. */
body.cart-open {
  overflow: hidden;
  position: fixed;
  top: var(--cart-scroll-y, 0);
  left: 0;
  right: 0;
  width: 100%;
  touch-action: none;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  #cart-drawer {
    width: 100vw;
    border-left: none;
  }
  /* Footer sticky : toujours visible, safe-area iPhone Home indicator */
  .cart-foot {
    padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  }
}
