/* ------------------------------------------------------------
  Cart drawer - the cart as a strip sliding in from the right.
  Markup: Views/CartDrawer. Behaviour: Content/Scripts/cartdrawer.js.

  Colours, radius and font come from the IvalsClima theme's :root variables
  (--iv-*, Themes/IvalsClima/Content/css/ivalsclima.css); the literals are
  fallbacks for when the theme does not define them.
   ------------------------------------------------------------ */

.cart-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(20, 40, 75, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh; /* fallback for browsers without dynamic viewport units */
  height: 100dvh; /* tracks the visible area when the mobile address bar shows or hides */
  z-index: 1001;
  display: flex;
  flex-direction: column;
  width: min(420px, 100vw);
  background: #fff;
  color: var(--iv-text, #26334d);
  font-size: 14px;
  box-shadow: -8px 0 32px rgba(20, 40, 75, 0.18);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
}

body.cart-drawer-open {
  overflow: hidden;
}

body.cart-drawer-open .cart-drawer-overlay {
  opacity: 1;
  visibility: visible;
}

body.cart-drawer-open .cart-drawer {
  transform: translateX(0);
  visibility: visible;
}

/* header */
.cart-drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--iv-border, #e4e8ef);
}

.cart-drawer-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--iv-navy, #14284b);
}

.cart-drawer-count {
  font-weight: 400;
  color: var(--iv-muted, #6b7686);
}

.cart-drawer-close {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--iv-navy, #14284b);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.cart-drawer-close:hover,
.cart-drawer-close:focus-visible {
  background: var(--iv-bg, #f4f6fa);
  color: var(--iv-red, #e30613);
}

/* Layout: header, free shipping block and footer (subtotal + buttons) are always visible; only
   the list of products scrolls. The body is a flex column that does not scroll itself. */
.cart-drawer-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.cart-drawer-state {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.cart-drawer-busy .cart-drawer-body {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.15s;
}

.cart-drawer-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 40px 20px;
  text-align: center;
  color: var(--iv-muted, #6b7686);
  font-size: 15px;
}

/* free shipping progress: a fixed row above the list */
.cart-drawer-freeship {
  flex: 0 0 auto;
  padding: 14px 20px;
  background: var(--iv-bg, #f4f6fa);
  border-bottom: 1px solid var(--iv-border, #e4e8ef);
}

.cart-drawer-freeship-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--iv-text, #26334d);
}

.cart-drawer-freeship-msg strong {
  color: var(--iv-navy, #14284b);
}

.cart-drawer-freeship-msg svg {
  flex: 0 0 auto;
}

.cart-drawer-freeship-bar {
  height: 8px;
  border-radius: 4px;
  background: #dbe3ef;
  overflow: hidden;
}

.cart-drawer-freeship-bar > span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--iv-blue, #0b4ea2);
  transition: width 0.45s ease;
}

.cart-drawer-freeship.is-done {
  background: #e8f7ee;
  border-bottom-color: #c9ebd6;
}

.cart-drawer-freeship.is-done .cart-drawer-freeship-msg {
  color: #0f7a3a;
  font-weight: 600;
}

.cart-drawer-freeship.is-done .cart-drawer-freeship-bar {
  background: #c9ebd6;
}

.cart-drawer-freeship.is-done .cart-drawer-freeship-bar > span {
  background: var(--iv-green, #16a34a);
}

.cart-drawer-notice {
  flex: 0 0 auto;
  margin: 12px 20px 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #fdecee;
  color: var(--iv-red-dark, #bf050f);
  font-size: 13px;
  line-height: 1.4;
}

/* lines */
.cart-drawer-items {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain; /* do not scroll the page behind the drawer at the end of the list */
  -webkit-overflow-scrolling: touch;
}

.cart-drawer-item {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--iv-border, #e4e8ef);
}

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

.cart-drawer-picture {
  flex: 0 0 76px;
  width: 76px;
  height: 76px;
  border-radius: 8px;
  background: var(--iv-bg, #f4f6fa);
  overflow: hidden;
}

.cart-drawer-picture img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cart-drawer-item.is-unavailable .cart-drawer-picture img {
  opacity: 0.55;
}

.cart-drawer-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cart-drawer-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.cart-drawer-name {
  font-weight: 600;
  line-height: 1.35;
  color: var(--iv-navy, #14284b);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.cart-drawer-name:hover,
.cart-drawer-name:focus-visible {
  color: var(--iv-red, #e30613);
}

.cart-drawer-remove {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--iv-muted, #6b7686);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.cart-drawer-remove:hover,
.cart-drawer-remove:focus-visible {
  background: #fdecee;
  color: var(--iv-red, #e30613);
}

.cart-drawer-attributes {
  font-size: 12px;
  line-height: 1.5;
  color: var(--iv-muted, #6b7686);
}

.cart-drawer-stock {
  font-size: 12px;
  line-height: 1.4;
  color: var(--iv-red-dark, #bf050f);
}

.cart-drawer-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}

.cart-drawer-price {
  font-weight: 700;
  color: var(--iv-navy, #14284b);
  white-space: nowrap;
}

.cart-drawer-qtytext {
  color: var(--iv-muted, #6b7686);
  font-size: 13px;
}

/* quantity stepper */
.cart-drawer-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--iv-border, #e4e8ef);
  border-radius: 6px;
  background: #fff;
}

.cart-drawer-step {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--iv-blue, #0b4ea2);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}

.cart-drawer-step:hover:not(:disabled),
.cart-drawer-step:focus-visible {
  background: var(--iv-bg, #f4f6fa);
}

.cart-drawer-step:disabled {
  color: var(--iv-border, #e4e8ef);
  cursor: default;
}

.cart-drawer-qty {
  min-width: 28px;
  text-align: center;
  font-weight: 600;
  color: var(--iv-navy, #14284b);
}

/* footer: subtotal and the two buttons */
.cart-drawer-foot {
  flex: 0 0 auto;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--iv-border, #e4e8ef);
  box-shadow: 0 -4px 12px rgba(20, 40, 75, 0.05);
}

.cart-drawer-totals {
  display: flex;
  flex-wrap: wrap; /* a long two-currency total drops to its own line instead of breaking mid-price */
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
  margin-bottom: 14px;
  font-size: 15px;
}

.cart-drawer-totals span {
  white-space: nowrap;
}

.cart-drawer-totals strong {
  margin-left: auto;
  font-size: 18px;
  color: var(--iv-navy, #14284b);
  text-align: right;
}

.cart-drawer-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cart-drawer-btn {
  display: block;
  padding: 13px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.cart-drawer-btn--primary {
  order: -1; /* the main action goes first, whichever way the markup lists them */
  background: var(--iv-red, #e30613);
  color: #fff;
}

.cart-drawer-btn--primary:hover,
.cart-drawer-btn--primary:focus-visible {
  background: var(--iv-red-dark, #bf050f);
  color: #fff;
}

.cart-drawer-btn--secondary {
  background: #fff;
  border-color: var(--iv-border, #e4e8ef);
  color: var(--iv-blue, #0b4ea2);
}

.cart-drawer-btn--secondary:hover,
.cart-drawer-btn--secondary:focus-visible {
  background: #f2f6fc;
  color: var(--iv-blue-dark, #0a3a7c);
}

@media (max-width: 420px) {
  .cart-drawer-item {
    padding: 14px 16px;
  }

  .cart-drawer-freeship {
    padding: 12px 16px;
  }

  .cart-drawer-foot {
    padding: 12px 16px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cart-drawer,
  .cart-drawer-overlay {
    transition: none;
  }
}

/* "Continue shopping": no fill, no border, quiet text, so that "Checkout" stays the only thing that draws the eye */
.cart-drawer-btn--ghost {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border-color: transparent;
  color: var(--iv-muted, #6b7686);
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
}

.cart-drawer-btn--ghost:hover,
.cart-drawer-btn--ghost:focus-visible {
  background: transparent;
  color: var(--iv-text, #26334d);
  text-decoration: underline;
}
