:root {
  --cart-bg: rgba(10, 10, 10, 0.96);
  --cart-border: rgba(255, 215, 0, 0.18);
  --cart-highlight: #ffd700;
  --cart-text: #ffffff;
  --cart-muted: #888;
  --cart-danger: #ff5f5f;
}

.cart-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  z-index: 1200;
}

.cart-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: min(400px, 100vw);
  height: 100vh;
  background: var(--cart-bg);
  border-left: 1px solid var(--cart-border);
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  transition: right 0.3s ease;
  z-index: 1250;
  display: flex;
  overflow-x: hidden; /* Prevent horizontal scroll on drawer */
}

.cart-drawer.active {
  right: 0;
}

.cart-drawer__panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  outline: none;
}

.cart-drawer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.75rem 1.5rem 1.25rem;
  border-bottom: 1px solid var(--cart-border);
  gap: 1rem;
}

.cart-drawer__title {
  font-family: 'Gagalin', var(--heading-font, inherit);
  font-size: 1.75rem;
  color: var(--cart-highlight);
}

.cart-drawer__subtitle {
  display: block;
  margin-top: 0.35rem;
  color: var(--cart-muted);
  font-family: 'Inter', var(--body-font, inherit);
  font-size: 0.9rem;
}

.cart-drawer__close {
  background: none;
  border: none;
  color: var(--cart-text);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  transition: transform 0.2s ease, color 0.2s ease;
}

.cart-drawer__close:hover,
.cart-drawer__close:focus-visible {
  transform: rotate(90deg);
  color: var(--cart-highlight);
}

.cart-drawer__body {
  flex: 1;
  overflow-y: auto; /* Allow vertical scrolling on the body */
  overflow-x: hidden; /* Prevent horizontal scrolling */
  padding: 1rem 1.5rem 0.5rem;
  -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.cart-items {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.cart-notice {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.3);
  color: var(--cart-text);
  font-size: 0.85rem;
  line-height: 1.4;
}

.cart-notice strong {
  color: var(--cart-highlight);
}

.cart-item {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  width: 100%;
  box-sizing: border-box;
  position: relative;
  align-items: stretch;
  transition: all 0.2s ease;
}

.cart-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 215, 0, 0.2);
}

.cart-item__image {
  width: auto;
  max-width: 140px;
  height: auto;
  max-height: 300px;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.cart-item__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  padding-right: 6rem; /* Extra room for inline price/remove */
}

.cart-item__info {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
}

.cart-item__info p {
  margin: 0;
  color: var(--cart-muted);
  font-size: 1rem;
  line-height: 1.6;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.cart-item__actions {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 0.75rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  min-width: 5rem;
}

.cart-item__price {
  font-weight: 700;
  color: var(--cart-highlight);
  font-size: 1.1rem;
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.cart-item__remove {
  background: none;
  border: none;
  color: var(--cart-highlight);
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.15s ease;
  white-space: nowrap;
  font-weight: 700;
  padding: 0;
  margin: 0;
  border-radius: 0;
}

.cart-item__remove:hover {
  opacity: 0.7;
}

.cart-item__remove:hover,
.cart-item__remove:focus-visible {
  color: var(--cart-danger);
}

.cart-drawer__footer {
  padding: 1.25rem 1.5rem 1.75rem;
  border-top: 1px solid var(--cart-border);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.cart-boost-summary {
  display: none;
}

.cart-boost-summary.is-visible {
  display: block;
}

.cart-boost-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  color: var(--cart-text);
}

.cart-boost-card--quiet {
  opacity: 0.7;
}

.cart-boost-card--loading {
  align-items: center;
  justify-content: center;
  flex-direction: row;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.cart-boost-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  row-gap: 0.5rem;
}

.cart-boost-pill {
  flex: 1 1 30%;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(10, 10, 10, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  min-width: 0;
}

.cart-boost-pill[data-pill="boost"] .cart-boost-pill__value {
  color: var(--cart-highlight);
}

.cart-boost-pill__icon {
  font-size: 1rem;
  line-height: 1;
}

.cart-boost-pill__label {
  opacity: 0.7;
  letter-spacing: 0.01em;
}

.cart-boost-pill__value {
  margin-left: auto;
}

.cart-boost-note {
  font-size: 0.75rem;
  color: var(--cart-muted);
  text-align: center;
}

.cart-boost-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--cart-highlight);
  display: inline-flex;
  animation: cartBoostPulse 1.1s ease-in-out infinite;
}

@keyframes cartBoostPulse {
  0% { opacity: 0.4; }
  50% { opacity: 1; }
  100% { opacity: 0.4; }
}

.cart-drawer__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Inter', var(--body-font, inherit);
  font-weight: 600;
  color: var(--cart-text);
}

.cart-drawer__total span:last-child.cart-total--pending {
  color: var(--cart-muted);
  font-weight: 500;
}

.cart-drawer__checkout {
  background: var(--cart-highlight);
  border: none;
  color: #000;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cart-drawer__checkout:hover,
.cart-drawer__checkout:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 15px 30px rgba(255, 215, 0, 0.25);
}

.cart-drawer__checkout:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.cart-drawer__clear {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--cart-text);
  padding: 0.9rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
}

.cart-drawer__clear:hover,
.cart-drawer__clear:focus-visible {
  background: rgba(255, 255, 255, 0.12);
}

.cart-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--cart-muted);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 14px;
}

.cart-empty__icon {
  font-size: 2.25rem;
  margin-bottom: 0.5rem;
}

.cart-empty__cta {
  margin-top: 1.25rem;
  padding: 0.65rem 1.4rem;
  border-radius: 999px;
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.3);
  color: var(--cart-highlight);
  cursor: pointer;
  font-weight: 600;
}

.cart-empty__cta:hover,
.cart-empty__cta:focus-visible {
  background: rgba(255, 215, 0, 0.25);
}

.cart-toast__item {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(10, 10, 10, 0.85);
  border: 1px solid rgba(255, 215, 0, 0.35);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  color: var(--cart-text);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1400;
  pointer-events: none;
}

.cart-toast__item.show {
  opacity: 1;
  transform: translateY(0);
}

.cart-count--pulse {
  animation: cartPulse 0.6s ease;
}

@keyframes cartPulse {
  0% {
    transform: scale(1);
  }

  40% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

body.cart-open {
  overflow: hidden;
}

@media (max-width: 540px) {

  .cart-drawer__header,
  .cart-drawer__body,
  .cart-drawer__footer {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .cart-item {
    gap: 1rem;
    padding: 1rem;
  }

  .cart-item__image {
    width: auto;
    max-width: 110px;
    height: auto;
    max-height: 250px;
    border-radius: 12px;
  }

  .cart-item__content {
    padding-right: 5rem;
  }

  .cart-item__info p {
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .cart-item__actions {
    top: 50%;
    transform: translateY(-50%);
    right: 0.5rem;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    min-width: 4.25rem;
    gap: 0.5rem;
  }

  .cart-item__price {
    font-size: 0.95rem;
  }
  
  .cart-item__remove {
    font-size: 0.82rem;
    padding: 0;
  }

  .cart-boost-card {
    padding: 0.7rem 0.8rem;
  }

  .cart-boost-pill {
    flex: 1 1 100%;
  }

  .cart-boost-pill__value {
    font-size: 0.95rem;
  }
}
