/* =========================================================================
   MDJ cart — header button + drawer.
   Scope: .sh-cart, .cart-drawer and their children ONLY. Extends the Light
   Organism system (site.css) and the vitrine plate language (shop.css); adds
   no parallel system and overrides no existing selector.

   Desktop: a side drawer. Mobile: a bottom sheet, because a thumb reaches the
   bottom of a phone and not the top-right corner of a full-height panel.
   ========================================================================= */

.cart-sr-only {
  position: fixed; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---- header button ------------------------------------------------------- */
.sh-cart {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: none; cursor: pointer;
  background: none; border: 0.5px solid var(--lo-line); border-radius: 8px;
  color: var(--lo-spark);
  transition: border-color 0.3s var(--ease-organic), color 0.3s var(--ease-organic), background 0.3s var(--ease-organic);
}
.sh-cart:hover { border-color: var(--lo-gold); color: var(--lo-gold-bright); background: rgba(201, 162, 75, 0.05); }
.sh-cart:focus-visible { outline: 1px solid var(--lo-gold); outline-offset: 4px; }
/* The badge carries a number, so the count never depends on colour alone. */
.sh-cart-badge {
  position: absolute; top: -5px; inset-inline-end: -5px; min-width: 17px; height: 17px;
  display: grid; place-items: center; padding: 0 4px; border-radius: 999px;
  background: linear-gradient(178deg, #edca6b 0%, var(--lo-gold-bright) 48%, #cba13f 100%);
  color: #1b160a; font-family: var(--lo-sans); font-size: 10.5px; font-weight: 700;
  font-variant-numeric: lining-nums tabular-nums; line-height: 1;
  box-shadow: 0 0 0 1.5px rgba(9, 12, 22, 0.9);
}

/* ---- the drawer --------------------------------------------------------- */
body.cart-open { overflow: hidden; }
body.cart-open #siteRoot { overflow: hidden; }

.cart-drawer { position: fixed; inset: 0; z-index: 140; }
.cart-shade {
  position: absolute; inset: 0; border: 0; cursor: pointer;
  background: rgba(4, 6, 13, 0.72); backdrop-filter: blur(5px);
  opacity: 0; transition: opacity 0.28s var(--ease-organic);
}
.cart-drawer.is-in .cart-shade { opacity: 1; }

.cart-panel {
  position: absolute; inset-block: 0; inset-inline-end: 0;
  width: min(430px, 100vw); display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0d1220 0%, var(--lo-canvas) 60%);
  border-inline-start: 0.5px solid var(--hairline);
  box-shadow: -30px 0 80px rgba(2, 4, 10, 0.72);
  transform: translateX(100%);
  transition: transform 0.36s var(--ease-ignite);
}
html[dir='rtl'] .cart-panel { transform: translateX(-100%); }
.cart-drawer.is-in .cart-panel { transform: translateX(0); }

.cart-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex: none;
  padding: 22px clamp(18px, 4vw, 26px) 16px;
  border-bottom: 0.5px solid var(--lo-line);
}
.cart-title {
  margin: 0; display: flex; align-items: baseline; gap: 11px; flex-wrap: wrap;
  font-family: var(--lo-display); font-weight: 500; font-size: 24px; color: var(--lo-ivory);
}
html[dir='rtl'] .cart-title { font-family: var(--lo-display-he); font-weight: 700; font-size: 22px; }
.cart-count {
  font-family: var(--lo-sans); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--lo-faint);
  font-variant-numeric: lining-nums tabular-nums;
}
html[dir='rtl'] .cart-count { letter-spacing: 0.06em; }
.cart-x {
  flex: none; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer;
  background: none; border: 0.5px solid var(--lo-line); border-radius: 8px; color: var(--lo-spark);
  transition: border-color 0.3s var(--ease-organic), color 0.3s var(--ease-organic);
}
.cart-x:hover { border-color: var(--lo-gold); color: var(--lo-gold-bright); }
.cart-x:focus-visible { outline: 1px solid var(--lo-gold); outline-offset: 3px; }

.cart-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.cart-scroll::-webkit-scrollbar { width: 8px; }
.cart-scroll::-webkit-scrollbar-thumb { background: var(--lo-line); border-radius: 6px; }

/* ---- a line ------------------------------------------------------------- */
.cart-lines { list-style: none; margin: 0; padding: 6px clamp(18px, 4vw, 26px); }
.cart-line {
  display: grid; grid-template-columns: 68px minmax(0, 1fr) 28px; gap: 14px;
  padding: 18px 0; border-bottom: 0.5px solid rgba(201, 162, 75, 0.1);
  align-items: start;
}
.cart-line:last-child { border-bottom: 0; }

/* the same lit-plate language as the shop grid, at thumbnail scale */
.cl-plate {
  position: relative; display: block; width: 68px; aspect-ratio: 1; border-radius: 9px;
  overflow: hidden; box-shadow: 0 0 0 0.5px var(--lo-plate-line);
}
.cl-bg-light { background: radial-gradient(120% 104% at 50% 34%, var(--lo-plate) 0%, var(--lo-plate-deep) 100%); }
.cl-bg-dark { background: radial-gradient(120% 104% at 50% 34%, #1a2136 0%, var(--lo-plate-dark) 100%); }
.cl-plate img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 9%; }
.cl-bg-light img { mix-blend-mode: multiply; }

.cl-body { min-width: 0; }
.cl-name {
  display: block; text-decoration: none; font-family: var(--lo-display); font-weight: 500;
  font-size: 16.5px; line-height: 1.28; color: var(--lo-ivory);
  transition: color 0.3s var(--ease-organic);
}
html[dir='rtl'] .cl-name { font-family: var(--lo-display-he); font-weight: 700; font-size: 15.5px; }
.cl-name:hover { color: var(--lo-gold-bright); }
.cl-name:focus-visible { outline: 1px solid var(--lo-gold); outline-offset: 3px; }
.cl-opts {
  margin: 6px 0 0; font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--lo-muted);
}
html[dir='rtl'] .cl-opts { letter-spacing: 0.04em; }
.cl-warn { margin: 7px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--lo-gold); }
.cl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.cl-unit { margin: 7px 0 0; font-size: 11px; color: var(--lo-faint); unicode-bidi: isolate; }

.cl-qty { display: inline-flex; align-items: center; border: 0.5px solid var(--lo-line); border-radius: 8px; overflow: hidden; }
.cl-q {
  width: 32px; height: 34px; display: grid; place-items: center; cursor: pointer;
  background: none; border: 0; color: var(--lo-spark); font-size: 15px; line-height: 1;
  transition: background 0.25s var(--ease-organic), color 0.25s var(--ease-organic);
}
.cl-q:hover:not([disabled]) { background: rgba(201, 162, 75, 0.08); color: var(--lo-gold-bright); }
.cl-q[disabled] { color: var(--lo-line); cursor: default; }
.cl-q:focus-visible { outline: 1px solid var(--lo-gold); outline-offset: -2px; }
.cl-qn {
  width: 34px; height: 34px; text-align: center; background: none; border: 0;
  border-inline: 0.5px solid var(--lo-line); color: var(--lo-ivory);
  font-family: var(--lo-sans); font-size: 13.5px; font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
}
.cl-qn:focus-visible { outline: 1px solid var(--lo-gold); outline-offset: -2px; }
.cl-price {
  font-family: var(--lo-sans); font-size: 14.5px; font-weight: 600; color: var(--lo-body);
  letter-spacing: 0.04em; font-variant-numeric: lining-nums tabular-nums; unicode-bidi: isolate;
}
.cl-rm {
  width: 28px; height: 28px; display: grid; place-items: center; cursor: pointer;
  background: none; border: 0; border-radius: 6px; color: var(--lo-faint);
  transition: color 0.25s var(--ease-organic), background 0.25s var(--ease-organic);
}
.cl-rm:hover { color: var(--lo-ivory); background: rgba(255, 255, 255, 0.05); }
.cl-rm:focus-visible { outline: 1px solid var(--lo-gold); outline-offset: 2px; }

/* ---- foot: subtotal, checkout, the two disclosures ---------------------- */
.cart-foot {
  padding: 20px clamp(18px, 4vw, 26px) calc(24px + env(safe-area-inset-bottom, 0px));
  border-top: 0.5px solid var(--lo-line);
  background: rgba(10, 13, 24, 0.6);
}
.cart-sub { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.cart-sub .cs-k {
  font-size: var(--fs-label); font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--lo-muted);
}
html[dir='rtl'] .cart-sub .cs-k { letter-spacing: 0.06em; }
.cart-sub .cs-v {
  font-family: var(--lo-sans); font-size: 21px; font-weight: 600; color: var(--lo-ivory);
  letter-spacing: 0.03em; font-variant-numeric: lining-nums tabular-nums; unicode-bidi: isolate;
}
.cart-sub-note { margin: 8px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--lo-faint); }
.btn-ignite.cart-go { width: 100%; margin-top: 18px; padding: 17px 22px; font-size: 14.5px; letter-spacing: 0.07em; }
.btn-ignite.cart-go[disabled] { cursor: default; filter: saturate(0.55) brightness(0.85); }
.cart-note { margin: 14px 0 0; font-size: 11.5px; line-height: 1.7; color: var(--lo-faint); }
.cart-note-did { color: var(--lo-spark-dim); }
.cart-note-did::before {
  content: ''; display: inline-block; width: 4px; height: 4px; margin-inline-end: 7px;
  vertical-align: 1px; transform: rotate(45deg); background: var(--lo-gold-bright);
}
.cart-keep {
  display: inline-block; margin-top: 16px; cursor: pointer; background: none; border: 0; padding: 6px 0;
  text-decoration: none; font-family: var(--lo-sans); font-size: var(--fs-label); font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--lo-muted);
  transition: color 0.3s var(--ease-organic);
}
html[dir='rtl'] .cart-keep { letter-spacing: 0.06em; }
.cart-keep:hover { color: var(--lo-gold-bright); }
.cart-keep:focus-visible { outline: 1px solid var(--lo-gold); outline-offset: 3px; }

/* ---- empty + leaving states -------------------------------------------- */
.cart-empty { padding: clamp(56px, 12vh, 90px) clamp(20px, 5vw, 30px); text-align: center; }
.cart-empty .ce-glyph { display: block; font-size: 20px; color: var(--lo-gold); opacity: 0.7; }
.cart-empty .ce-title { margin: 18px 0 0; font-family: var(--lo-display); font-size: 20px; color: var(--lo-ivory); }
html[dir='rtl'] .cart-empty .ce-title { font-family: var(--lo-display-he); font-weight: 700; }
.cart-empty .ce-body { margin: 10px 0 0; font-size: 13.5px; line-height: 1.75; color: var(--lo-muted); max-width: 30ch; margin-inline: auto; }

.cart-leaving { padding: clamp(70px, 16vh, 120px) 24px; text-align: center; }
.cart-leaving p { margin: 20px 0 0; font-size: 14px; color: var(--lo-spark-dim); letter-spacing: 0.02em; }
.cl-spin {
  display: inline-block; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--lo-line); border-top-color: var(--lo-gold-bright);
  animation: cart-spin 0.9s linear infinite;
}
@keyframes cart-spin { to { transform: rotate(360deg); } }

/* ---- Add to cart on the product page ----------------------------------- */
.pd-addrow { display: flex; align-items: stretch; gap: 10px; margin-top: clamp(22px, 3vh, 30px); }
.pd-qty { display: inline-flex; align-items: center; border: 0.5px solid var(--lo-line); border-radius: 9px; overflow: hidden; flex: none; }
.pd-qty button {
  width: 40px; align-self: stretch; display: grid; place-items: center; cursor: pointer;
  background: none; border: 0; color: var(--lo-spark); font-size: 16px;
  transition: background 0.25s var(--ease-organic), color 0.25s var(--ease-organic);
}
.pd-qty button:hover:not([disabled]) { background: rgba(201, 162, 75, 0.08); color: var(--lo-gold-bright); }
.pd-qty button[disabled] { color: var(--lo-line); cursor: default; }
.pd-qty button:focus-visible { outline: 1px solid var(--lo-gold); outline-offset: -2px; }
.pd-qty input {
  /* Stretch like the two buttons beside it. Without this the input collapses to its line-height —
     20px on a phone — so the one control a reader is most likely to tap to type a quantity had the
     smallest target in the buy box. Height comes from the row, so the type size is untouched. */
  width: 42px; align-self: stretch; text-align: center; background: none; border: 0;
  border-inline: 0.5px solid var(--lo-line); color: var(--lo-ivory);
  font-family: var(--lo-sans); font-size: 14px; font-weight: 600;
  font-variant-numeric: lining-nums tabular-nums;
}
.pd-qty input:focus-visible { outline: 1px solid var(--lo-gold); outline-offset: -2px; }
.btn-ignite.pd-add { flex: 1; min-width: 0; }
.pd-qty-note { margin: 10px 0 0; font-size: 11px; color: var(--lo-faint); }

/* ---- mobile: a bottom sheet ------------------------------------------- */
@media (max-width: 640px) {
  .cart-panel {
    inset: auto 0 0 0; width: 100%; max-height: 92svh;
    border-inline-start: 0; border-top: 0.5px solid var(--hairline);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -26px 70px rgba(2, 4, 10, 0.75);
    transform: translateY(100%);
  }
  html[dir='rtl'] .cart-panel { transform: translateY(100%); }
  .cart-drawer.is-in .cart-panel { transform: translateY(0); }
  /* a grab handle, so it reads as a sheet rather than a stuck panel */
  .cart-head::before {
    content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 3px; border-radius: 999px; background: var(--lo-line);
  }
  .cart-head { position: relative; padding-top: 24px; }
  .cart-title { font-size: 21px; }
  .cart-line { grid-template-columns: 58px minmax(0, 1fr) 28px; gap: 12px; padding: 16px 0; }
  .cl-plate { width: 58px; }
  /* Thumb-sized controls: every one clears 42px, and the two that a mis-tap would cost the most
     — remove, and close — get the full 44. */
  .cl-q { width: 42px; height: 42px; }
  .cl-qn { width: 42px; height: 42px; }
  .cl-rm { width: 44px; height: 44px; }
  .cart-x { width: 44px; height: 44px; }
  /* the cart opener is how the whole flow is reached — it gets the full 44 like close and remove */
  .sh-cart { width: 44px; height: 44px; }
  .pd-qty button { width: 44px; }
  /* "Continue shopping" is quiet by design, but quiet is a matter of colour and type, not of hit
     area: it was a 26px target. The padding grows, the type does not, so nothing looks louder. */
  .cart-keep {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 6px 14px;
  }
  /* the remove column widens to match its new target */
  .cart-line { grid-template-columns: 58px minmax(0, 1fr) 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .cart-shade, .cart-panel, .sh-cart, .cl-q, .cl-rm, .cart-keep, .cl-name { transition: none; }
  .cl-spin { animation: none; border-top-color: var(--lo-line); }
}
