/* =========================================================
   Essence Soaps & Candles — cart-drawer.css
   Slide-out cart DRAWER. Right-side panel on desktop;
   bottom-sheet (100dvh-aware) on mobile. Amethyst/plum palette,
   reuses the toast/badge gradient language from store.css.
   Tokens (--amethyst, --plum, --heather, --stone, --cream, radii,
   shadows, fonts) come from styles.css / store.css; fallbacks below
   keep it self-sufficient.
   ========================================================= */

:root {
  --drawer-w: 420px;
  --drawer-z: 2400;            /* above header (100) + toast wrap (2000) */
}

/* ---------------- Scrim ---------------- */
.ed-scrim {
  position: fixed;
  inset: 0;
  background: rgba(44, 44, 48, 0.46);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  z-index: var(--drawer-z);
  transition: opacity 0.32s var(--ease, ease), visibility 0s linear 0.32s;
}
.ed-scrim.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.32s var(--ease, ease);
}

/* ---------------- Panel ---------------- */
.ed-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: min(var(--drawer-w), 100vw);
  background: var(--cream, #FAF8FB);
  box-shadow: -24px 0 60px rgba(74, 59, 99, 0.22);
  z-index: calc(var(--drawer-z) + 1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.38s var(--ease, cubic-bezier(0.22, 1, 0.36, 1));
  will-change: transform;
  font-family: var(--font-body, "Inter", sans-serif);
}
.ed-drawer.open { transform: translateX(0); }

/* ---------------- Header ---------------- */
.ed-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(185, 168, 208, 0.35);
  background: var(--white, #fff);
}
.ed-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head, serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--plum, #4A3B63);
}
.ed-title .ed-count {
  font-family: var(--font-body, sans-serif);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--white, #fff);
  background: linear-gradient(135deg, var(--amethyst, #7E6BA6), var(--plum, #4A3B63));
  min-width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 999px;
  padding: 0 6px;
}
.ed-close {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--heather, #B9A8D0);
  background: var(--white, #fff);
  border-radius: 12px;
  color: var(--plum, #4A3B63);
  cursor: pointer;
  transition: background 0.25s var(--ease, ease), color 0.25s var(--ease, ease), border-color 0.25s var(--ease, ease);
}
.ed-close:hover { background: var(--stone, #EDECEF); color: var(--amethyst, #7E6BA6); border-color: var(--amethyst, #7E6BA6); }
.ed-close svg { width: 18px; height: 18px; }

/* ---------------- Scroll body ---------------- */
.ed-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- Free-shipping progress bar ---- */
.ed-ship {
  background: rgba(126, 107, 166, 0.08);
  border: 1px solid rgba(126, 107, 166, 0.25);
  border-radius: 14px;
  padding: 12px 14px;
}
.ed-ship.unlocked {
  background: linear-gradient(135deg, rgba(126, 107, 166, 0.16), rgba(185, 168, 208, 0.22));
  border-color: rgba(126, 107, 166, 0.45);
}
.ed-ship-msg {
  font-size: 0.84rem;
  color: var(--plum, #4A3B63);
  font-weight: 500;
  margin-bottom: 9px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.ed-ship.unlocked .ed-ship-msg { font-weight: 700; }
.ed-ship-msg b { font-weight: 700; }
.ed-ship-track {
  height: 7px;
  border-radius: 999px;
  background: var(--stone, #EDECEF);
  overflow: hidden;
}
.ed-ship-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--heather, #B9A8D0), var(--amethyst, #7E6BA6));
  transition: width 0.45s var(--ease, ease);
}

/* ---- Line items ---- */
.ed-items { display: flex; flex-direction: column; gap: 12px; }
.ed-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: start;
  background: var(--white, #fff);
  border: 1px solid rgba(185, 168, 208, 0.28);
  border-radius: 14px;
  padding: 12px;
  box-shadow: var(--shadow-sm, 0 2px 10px rgba(74, 59, 99, 0.06));
}
.ed-thumb {
  width: 64px; height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: linear-gradient(140deg, var(--heather, #B9A8D0), var(--amethyst, #7E6BA6));
}
.ed-row-info { min-width: 0; }
.ed-row-name {
  font-family: var(--font-head, serif);
  font-size: 1.04rem;
  font-weight: 600;
  color: var(--plum, #4A3B63);
  line-height: 1.18;
  text-decoration: none;
  display: block;
}
.ed-row-name:hover { color: var(--amethyst, #7E6BA6); }
.ed-row-size { font-size: 0.78rem; color: var(--warm-gray, #8A8A8F); margin-top: 1px; }
.ed-row-controls { display: flex; align-items: center; gap: 12px; margin-top: 9px; }

/* compact qty stepper — mirrors store.css .cart-qty */
.ed-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--stone, #EDECEF);
  border-radius: 999px;
  overflow: hidden;
  background: var(--white, #fff);
}
.ed-qty button {
  width: 28px; height: 28px;
  border: none;
  background: var(--cream, #FAF8FB);
  color: var(--plum, #4A3B63);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s var(--ease, ease), color 0.2s var(--ease, ease);
}
.ed-qty button:hover { background: var(--stone, #EDECEF); color: var(--amethyst, #7E6BA6); }
.ed-qty input {
  width: 34px; height: 28px;
  border: none;
  text-align: center;
  font-family: var(--font-body, sans-serif);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--plum, #4A3B63);
  background: transparent;
  -moz-appearance: textfield;
}
.ed-qty input::-webkit-outer-spin-button,
.ed-qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.ed-remove {
  background: none; border: none;
  color: var(--warm-gray, #8A8A8F);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
  transition: color 0.25s var(--ease, ease);
}
.ed-remove:hover { color: var(--plum, #4A3B63); }
.ed-row-right { text-align: right; }
.ed-row-price {
  font-weight: 700;
  color: var(--plum, #4A3B63);
  font-size: 0.95rem;
  white-space: nowrap;
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
}
.ed-row-free {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--amethyst, #7E6BA6);
  background: rgba(126, 107, 166, 0.12);
  border-radius: 999px;
  padding: 2px 8px;
}

/* ---- Soap freebie nudge ---- */
.ed-nudge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, rgba(126, 107, 166, 0.10), rgba(185, 168, 208, 0.18));
  border: 1px solid rgba(185, 168, 208, 0.5);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--plum, #4A3B63);
}
.ed-nudge .ed-nudge-ico { font-size: 1.05rem; line-height: 1; flex-shrink: 0; }
.ed-nudge.unlocked {
  background: linear-gradient(135deg, rgba(126, 107, 166, 0.20), rgba(185, 168, 208, 0.28));
  border-color: rgba(126, 107, 166, 0.5);
}

/* ---- Cross-sell "Complete the ritual" ---- */
.ed-cross { border-top: 1px solid var(--stone, #EDECEF); padding-top: 14px; }
.ed-cross-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--warm-gray, #8A8A8F);
  margin: 0 0 11px;
}
.ed-cross-list { display: flex; flex-direction: column; gap: 10px; }
.ed-cross-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 11px;
  align-items: center;
  background: var(--white, #fff);
  border: 1px solid rgba(185, 168, 208, 0.28);
  border-radius: 12px;
  padding: 9px 11px;
}
.ed-cross-thumb {
  width: 48px; height: 48px;
  border-radius: 9px;
  object-fit: cover;
  background: linear-gradient(140deg, var(--heather, #B9A8D0), var(--amethyst, #7E6BA6));
}
.ed-cross-info { min-width: 0; }
.ed-cross-name {
  font-family: var(--font-head, serif);
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--plum, #4A3B63);
  line-height: 1.15;
  text-decoration: none;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ed-cross-name:hover { color: var(--amethyst, #7E6BA6); }
.ed-cross-meta {
  font-size: 0.74rem;
  color: var(--warm-gray, #8A8A8F);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ed-cross-meta b {
  color: var(--amethyst, #7E6BA6);
  font-weight: 700;
  font-variant-numeric: lining-nums tabular-nums;
}
.ed-quickadd {
  width: 34px; height: 34px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amethyst, #7E6BA6), var(--plum, #4A3B63));
  color: var(--white, #fff);
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm, 0 2px 10px rgba(74, 59, 99, 0.06));
  transition: transform 0.2s var(--ease, ease), box-shadow 0.2s var(--ease, ease);
}
.ed-quickadd:hover { transform: translateY(-2px) scale(1.05); box-shadow: var(--shadow-md, 0 10px 30px rgba(74, 59, 99, 0.10)); }
.ed-quickadd:active { transform: scale(0.95); }

/* ---- Empty state ---- */
.ed-empty {
  text-align: center;
  margin: auto;
  padding: 40px 20px;
}
.ed-empty .ed-empty-ico { font-size: 2.4rem; display: block; margin-bottom: 12px; }
.ed-empty h3 { font-size: 1.4rem; color: var(--plum, #4A3B63); margin-bottom: 8px; }
.ed-empty p { color: var(--warm-gray, #8A8A8F); font-size: 0.9rem; margin: 0 0 20px; }

/* ---------------- Sticky footer ---------------- */
.ed-foot {
  flex-shrink: 0;
  border-top: 1px solid rgba(185, 168, 208, 0.35);
  background: var(--white, #fff);
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
}
.ed-foot-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 0.9rem;
  color: var(--charcoal, #2C2C30);
  padding: 3px 0;
}
.ed-foot-line .ed-money {
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
}
.ed-foot-line.ed-savings { color: var(--amethyst, #7E6BA6); font-weight: 600; }
.ed-foot-line.ed-subtotal {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--plum, #4A3B63);
  margin-top: 4px;
}
.ed-checkout {
  width: 100%;
  margin-top: 12px;
  padding: 15px;
  font-size: 1rem;
}
.ed-foot-note {
  text-align: center;
  color: var(--warm-gray, #8A8A8F);
  font-size: 0.74rem;
  margin: 10px 0 0;
}

/* lock background scroll while open */
body.ed-open { overflow: hidden; }

/* ---------------- Mobile: bottom sheet ---------------- */
@media (max-width: 560px) {
  .ed-drawer {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 22px 22px 0 0;
    transform: translateY(100%);
    box-shadow: 0 -24px 60px rgba(74, 59, 99, 0.24);
  }
  .ed-drawer.open { transform: translateY(0); }
  .ed-head { border-radius: 22px 22px 0 0; position: relative; }
  /* grab handle */
  .ed-head::before {
    content: "";
    position: absolute;
    top: 7px; left: 50%;
    transform: translateX(-50%);
    width: 38px; height: 4px;
    border-radius: 999px;
    background: var(--heather, #B9A8D0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ed-drawer, .ed-scrim, .ed-ship-fill, .ed-quickadd { transition: none !important; }
}
