/* ================================================
   POLINO — Cart
   Header badge + slide-in drawer.
   ================================================ */

@import './variables.css';

/* ------------------------------------------------------------ header button */

.cart-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: var(--radius-sm);
  color: var(--olive-dark);
  background: transparent;
  cursor: pointer;
  transition:
    color            var(--duration-base) var(--ease-out),
    background-color var(--duration-base) var(--ease-out);
}

.cart-btn:hover { color: var(--terra); background: rgba(201, 106, 58, 0.10); }
.cart-btn:focus-visible { outline: 2px solid var(--terra); outline-offset: 2px; }
.cart-btn svg { width: 21px; height: 21px; }

.cart-btn__count {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: var(--weight-semi);
  font-variant-numeric: lining-nums tabular-nums;
  line-height: 1;
  color: var(--white-mosaic);
  background: var(--cta-brick);
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 2px var(--bg);
  transform: scale(0);
  transition: transform var(--duration-base) var(--ease-spring);
}

.cart-btn.has-items .cart-btn__count { transform: scale(1); }

/* ------------------------------------------------------------------ drawer */

.cart-backdrop {
  position: fixed;
  inset: 0;
  /* Above the sticky header (--z-header), or the drawer's own title bar ends
     up hidden underneath it. */
  z-index: var(--z-overlay);
  background: rgba(26, 26, 26, 0.42);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}
.cart-backdrop.is-shown { opacity: 1; }

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: calc(var(--z-overlay) + 1);
  width: min(400px, 100vw);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--card-border);
  box-shadow: var(--shadow-xl);
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-out);
}
.cart-drawer.is-shown { transform: translateX(0); }

body.cart-open { overflow: hidden; }

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

.cart-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--paper);
  flex: none;
}

.cart-drawer__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--olive-dark);
}

.cart-drawer__close {
  width: 36px;
  height: 36px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--text-light);
  background: transparent;
  cursor: pointer;
  transition: color var(--duration-base), background-color var(--duration-base);
}
.cart-drawer__close:hover { color: var(--olive-dark); background: var(--paper); }
.cart-drawer__close:focus-visible { outline: 2px solid var(--terra); outline-offset: 2px; }

.cart-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-6);
}

/* -------------------------------------------------------------------- rows */

.cart-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--paper);
}

.cart-item__img {
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.cart-item__img img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cart-item__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.cart-item__title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  line-height: var(--leading-snug);
  color: var(--olive-dark);
  text-decoration: none;
  /* Etsy names run long — two lines is the whole budget in a 400px drawer. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cart-item__title:hover { color: var(--terra); }

.cart-item__price {
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--text-light);
  font-variant-numeric: lining-nums tabular-nums;
}

.cart-item__qty {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  flex: none;
}

.cart-item__qty button {
  width: 30px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: var(--text-base);
  color: var(--text-light);
  background: transparent;
  cursor: pointer;
  transition: color var(--duration-base), background-color var(--duration-base);
}
.cart-item__qty button:hover { color: var(--olive-dark); background: var(--paper); }
.cart-item__qty button:focus-visible { outline: 2px solid var(--terra); outline-offset: -2px; }

.cart-item__qty span {
  min-width: 20px;
  text-align: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  font-variant-numeric: lining-nums tabular-nums;
  color: var(--olive-dark);
}

.cart-item__remove {
  width: 28px;
  height: 28px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-light);
  opacity: 0.6;
  background: transparent;
  cursor: pointer;
  transition: color var(--duration-base), opacity var(--duration-base);
}
.cart-item__remove:hover { color: var(--clay); opacity: 1; }
.cart-item__remove:focus-visible { outline: 2px solid var(--terra); outline-offset: 1px; opacity: 1; }

/* ------------------------------------------------------------ empty / load */

.cart-empty, .cart-loading {
  text-align: center;
  padding: var(--space-16) var(--space-4);
  color: var(--text-light);
}

.cart-empty__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--olive-dark);
  margin-bottom: var(--space-2);
}

.cart-empty__hint { font-size: var(--text-sm); margin-bottom: var(--space-6); }

/* ------------------------------------------------------------------- foot */

.cart-drawer__foot {
  flex: none;
  padding: var(--space-5) var(--space-6) calc(var(--space-6) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--paper);
  background: var(--card-bg);
}

.cart-sum {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.cart-sum__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: var(--text-light);
}

.cart-sum__value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: var(--weight-semi);
  color: var(--olive-dark);
  font-variant-numeric: lining-nums tabular-nums;
}

.cart-checkout { width: 100%; justify-content: center; text-align: center; }

.cart-clear {
  display: block;
  width: 100%;
  margin-top: var(--space-3);
  padding: var(--space-2);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-light);
  background: transparent;
  cursor: pointer;
  transition: color var(--duration-base);
}
.cart-clear:hover { color: var(--clay); }
.cart-clear:focus-visible { outline: 2px solid var(--terra); outline-offset: 2px; }
