/* Sitewide cart count badge (Shop nav + mobile cart icon). */
.site-header__cart-badge {
  position: absolute;
  top: -0.35rem;
  right: -0.45rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding-inline: 0.35rem;
  border-radius: 9999px;
  background-color: #dc2626;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

/* display:flex above must not override the HTML hidden attribute. */
.site-header__cart-badge[hidden] {
  display: none !important;
}

/* Floating cart control (bottom-right). Cache-safe placeholder; shown via fragments. */
.qm-cart-fab {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 9999px;
  background-color: #b91c1c;
  color: #fff;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.28);
  text-decoration: none;
  transition:
    transform 0.15s ease,
    background-color 0.15s ease;
}

.qm-cart-fab:hover,
.qm-cart-fab:focus-visible {
  background-color: #991b1b;
  color: #fff;
  outline: none;
  transform: scale(1.05);
}

.qm-cart-fab:focus-visible {
  box-shadow:
    0 4px 16px rgb(0 0 0 / 0.28),
    0 0 0 3px #fff,
    0 0 0 5px #b91c1c;
}

.qm-cart-fab__icon {
  display: block;
  width: 1.35rem;
  height: 1.35rem;
}

.qm-cart-fab__count {
  position: absolute;
  top: -0.2rem;
  right: -0.2rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding-inline: 0.35rem;
  border-radius: 9999px;
  background-color: #1b1815;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}

.qm-cart-fab[hidden] {
  display: none !important;
}

/* No need for a shortcut while already checking out / viewing cart. */
body.woocommerce-checkout .qm-cart-fab,
body.woocommerce-cart .qm-cart-fab,
body.cfw-checkout .qm-cart-fab {
  display: none !important;
}

@media (max-width: 639.98px) {
  .qm-cart-fab {
    right: 1rem;
    bottom: 1rem;
    width: 3.25rem;
    height: 3.25rem;
  }
}

/* —— Thin side cart —— */
.qm-side-cart[hidden] {
  display: none !important;
}

.qm-side-cart {
  position: fixed;
  inset: 0;
  /* Beat chrome menu (120), legacy #nav-popup (1000), and sticky headers. */
  z-index: 100000 !important;
  pointer-events: none;
}

.qm-side-cart[data-open='true'] {
  pointer-events: auto;
}

/* Keep nav / menu gradient under the cart overlay while open. */
html.qm-side-cart-open .site-header,
html.qm-side-cart-open .site-header.is-menu-open,
html.qm-side-cart-open #qm-global-alert,
html.qm-side-cart-open #nav-popup,
html.qm-side-cart-open header.fixed,
body.qm-side-cart-open .site-header,
body.qm-side-cart-open .site-header.is-menu-open,
body.qm-side-cart-open #qm-global-alert,
body.qm-side-cart-open #nav-popup,
body.qm-side-cart-open header.fixed {
  z-index: 1 !important;
}

.qm-side-cart__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(0 0 0 / 0.72);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.qm-side-cart[data-open='true'] .qm-side-cart__overlay {
  opacity: 1;
}

.qm-side-cart__panel {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: min(100%, 24rem);
  height: 100%;
  background: #fff;
  color: #1b1815;
  box-shadow: -8px 0 28px rgb(0 0 0 / 0.18);
  transform: translateX(100%);
  transition: transform 0.28s ease;
}

.qm-side-cart[data-open='true'] .qm-side-cart__panel {
  transform: translateX(0);
}

.qm-side-cart__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid #e5e7eb;
  background: #1b1815;
  color: #fff;
}

.qm-side-cart__title {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.qm-side-cart__title-icon {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  color: currentColor;
}

.qm-side-cart__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: inherit;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.qm-side-cart__close:hover,
.qm-side-cart__close:focus-visible {
  background: rgb(255 255 255 / 0.12);
  outline: none;
}

.qm-side-cart__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  background: #fff;
}

.qm-side-cart__panel.is-loading .qm-side-cart__body {
  opacity: 0.55;
  pointer-events: none;
}

.qm-side-cart__loading {
  padding: 1.5rem 1.15rem;
  color: #6b7280;
  font-size: 0.9rem;
}

.qm-side-cart__loading[hidden] {
  display: none !important;
}

.qm-side-cart__empty-wrap {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1.25rem;
}

.qm-side-cart__empty {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.qm-side-cart__continue {
  margin: 0;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 0.375rem;
  background: #1b1815;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.qm-side-cart__lines {
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.qm-side-cart__line {
  position: relative;
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid #e5e7eb;
  transition: background-color 0.15s ease;
}

.qm-side-cart__line:has(.qm-side-cart__hit:hover),
.qm-side-cart__line:has(.qm-side-cart__hit:focus-visible) {
  background-color: #f9fafb;
}

.qm-side-cart__hit {
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  text-decoration: none;
  color: inherit;
}

.qm-side-cart__hit:focus-visible {
  outline: 2px solid #b91c1c;
  outline-offset: -2px;
}

.qm-side-cart__thumb {
  position: relative;
  z-index: 0;
  overflow: hidden;
  border-radius: 0.375rem;
  background: #f3f4f6;
  aspect-ratio: 1;
}

.qm-side-cart__thumb-img,
.qm-side-cart__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qm-side-cart__details {
  position: relative;
  z-index: 0;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.35rem;
}

.qm-side-cart__name {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
  line-height: 1.3;
}

.qm-side-cart__line:has(.qm-side-cart__hit:hover) .qm-side-cart__name,
.qm-side-cart__line:has(.qm-side-cart__hit:focus-visible) .qm-side-cart__name {
  text-decoration: underline;
}

.qm-side-cart__meta {
  color: #6b7280;
  font-size: 0.8rem;
}

.qm-side-cart__meta dl,
.qm-side-cart__meta p {
  margin: 0;
}

.qm-side-cart__price {
  font-size: 0.9rem;
  font-weight: 600;
}

.qm-side-cart__controls {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.qm-side-cart__qty {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  overflow: hidden;
  background: #fff;
}

.qm-side-cart__qty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: #f3f4f6;
  color: #1b1815;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.qm-side-cart__qty-btn:hover:not(:disabled),
.qm-side-cart__qty-btn:focus-visible:not(:disabled) {
  background: #e5e7eb;
  outline: none;
}

.qm-side-cart__qty-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.qm-side-cart__qty-value {
  min-width: 1.5rem;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.qm-side-cart__remove {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  margin-left: auto;
  padding: 0.25rem;
  border: 0;
  border-radius: 0.25rem;
  background: #fff;
  color: #6b7280;
  cursor: pointer;
  line-height: 0;
}

.qm-side-cart__remove:hover,
.qm-side-cart__remove:focus-visible {
  color: #b91c1c;
}

.qm-side-cart__remove-icon {
  display: block;
  flex-shrink: 0;
}

.qm-side-cart__footer {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 1rem 1.15rem 1.25rem;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
}

.qm-side-cart__subtotal {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 700;
}

.qm-side-cart__checkout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 0.375rem;
  background: #b91c1c;
  color: #fff;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.qm-side-cart__checkout:hover,
.qm-side-cart__checkout:focus-visible {
  background: #991b1b;
  color: #fff;
  outline: none;
}

html.qm-side-cart-open,
body.qm-side-cart-open {
  overflow: hidden;
}

body.woocommerce-checkout .qm-side-cart,
body.woocommerce-cart .qm-side-cart,
body.cfw-checkout .qm-side-cart {
  display: none !important;
}

/* Mobile menu Cart row: keep badge positioned on the link. */
#nav-popup .js-qm-side-cart-open,
.site-header__drawer-nav .js-qm-side-cart-open {
  position: relative;
}
