/*
 * Cart drawer (inc/cart-drawer.php, js/cart-drawer.js). The markup has no <p>.
 * Type and controls follow the product page: Neue Haas Unica, 52px buttons with 8px corners
 * and tracked capitals, warm beige borders. Everything sits on one left and one right edge
 * (the panel padding); no row adds a horizontal inset of its own.
 */

.ags-cart-drawer,
.ags-cart-empty--page {
  --ags-cart-gold: #C49564;
  --ags-cart-gold-dark: #A97B4B;
  --ags-cart-accent: #8D6235;
  --ags-cart-dark: #201600;
  --ags-cart-text: #565049;
  --ags-cart-muted: #6F6A63;
  --ags-cart-border: #DCD3C3;
  --ags-cart-line: #E8E2D9;
  --ags-cart-tint: #F7F4EF;
  --ags-cart-pad: 24px;
}

.ags-cart-drawer {
  position: fixed;
  inset: 0;
  z-index: 100000;
  color: var(--ags-cart-dark);
  font-family: 'Neue Haas Unica', sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

.ags-cart-drawer[hidden] {
  display: none;
}

/* Scroll lock; the scrollbar's width stays as padding so the page does not shift. */
body.ags-cart-open {
  overflow: hidden;
  padding-right: var(--ags-scrollbar, 0px);
}

.ags-cart-drawer__overlay {
  position: absolute;
  inset: 0;
  background: rgba(32, 22, 0, 0.4);
  opacity: 0;
  transition: opacity var(--ags-close, 0.3s) var(--ags-ease-close, ease);
}

.ags-cart-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(460px, 100%);
  padding: 0 var(--ags-cart-pad) var(--ags-cart-pad);
  background: #fff;
  box-shadow: -12px 0 40px rgba(32, 22, 0, 0.08);
  outline: 0;
  transform: translateX(100%);
  transition: transform var(--ags-close, 0.3s) var(--ags-ease-close, ease);
}

/* Motion tokens in css/pages.css: the backdrop and the panel move together, both ways. */
.ags-cart-drawer.is-open .ags-cart-drawer__overlay {
  opacity: 1;
  transition: opacity var(--ags-open, 0.45s) var(--ags-ease, ease-out);
}

.ags-cart-drawer.is-open .ags-cart-drawer__panel {
  transform: none;
  transition: transform var(--ags-open, 0.45s) var(--ags-ease, ease-out);
}

@media (prefers-reduced-motion: reduce) {
  .ags-cart-drawer__overlay,
  .ags-cart-drawer__panel {
    transition: none !important;
  }
}

/* Title bar */

.ags-cart-drawer__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  height: 76px;
}

.ags-cart-drawer .ags-cart-drawer__title {
  font-size: 20px;
  line-height: 24px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* 40px hit area; the 18px cross ends on the panel's right edge. */
.ags-cart-drawer .ags-cart-drawer__close {
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  margin-right: -14px;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

/* The cross: Phosphor's x (inc/icons.php) */
.ags-cart-drawer__close::before,
.ags-cart-item__remove::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  background: currentColor;
  -webkit-mask: url("../img/ph/x.svg") center / contain no-repeat;
  mask: url("../img/ph/x.svg") center / contain no-repeat;
  transform: translate(-50%, -50%);
}

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

/* Count and "Очистити" */

.ags-cart-panel__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ags-cart-line);
  color: var(--ags-cart-text);
  font-size: 14px;
  line-height: 20px;
}

.ags-cart-drawer .ags-cart-panel__clear {
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--ags-cart-muted);
  font: inherit;
  text-decoration: underline;
  text-decoration-color: var(--ags-cart-border);
  text-underline-offset: 4px;
  cursor: pointer;
  transition: color 0.2s, text-decoration-color 0.2s;
}

/* Items */

.ags-cart-items {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  /* The remove buttons reach past the edge (their empty hit area): no horizontal scroll for them. */
  overflow-x: hidden;
  overscroll-behavior: contain;
  list-style: none;
  scrollbar-width: thin;
}

.ags-cart-item {
  --thumb: 96px;
  display: grid;
  grid-template-columns: var(--thumb) minmax(0, 1fr);
  gap: 16px;
  margin: 0;
  padding: 20px 0;
  border-bottom: 1px solid var(--ags-cart-line);
}

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

.ags-cart-item__thumb {
  display: block;
  width: var(--thumb);
  height: calc(var(--thumb) * 1.125);
  overflow: hidden;
  background: var(--ags-cart-tint);
  border-radius: 8px;
}

.ags-cart-item__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

/* The body is as tall as the photo: name on its top edge, stepper and price on its bottom edge. */
.ags-cart-item__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: calc(var(--thumb) * 1.125);
}

.ags-cart-item__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.ags-cart-item__name {
  padding-top: 1px;
  font-size: 14px;
  line-height: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ags-cart-drawer .ags-cart-item__name a {
  color: var(--ags-cart-dark);
  text-decoration: none;
  transition: color 0.2s;
}

/* Labels other plugins append to the name (gifts) */
.ags-cart-item__name > div {
  margin-top: 4px;
  letter-spacing: 0;
  text-transform: none;
}

/* 24px hit area; the 12px cross ends on the price's right edge, level with the name's first line. */
.ags-cart-drawer .ags-cart-item__remove {
  position: relative;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  margin: -3px -6px 0 0; /* The 12px cross ends where the prices end. */
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--ags-cart-muted);
  cursor: pointer;
  transition: color 0.2s;
}

.ags-cart-item__remove::before {
  width: 16px;
  height: 16px;
}

.ags-cart-item__sub {
  display: -webkit-box;
  margin-top: 6px;
  overflow: hidden;
  color: var(--ags-cart-accent);
  font-size: 11px;
  line-height: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ags-cart-item__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 12px;
}

.ags-cart-item__qty {
  color: var(--ags-cart-text);
  font-size: 14px;
}

.ags-cart-item__price {
  font-size: 16px;
  font-weight: 800;
  line-height: 20px;
  white-space: nowrap;
}

.ags-cart-item__price del {
  margin-right: 6px;
  color: var(--ags-cart-muted);
  font-size: 13px;
  font-weight: 400;
}

.ags-cart-item__price ins {
  text-decoration: none;
}

/* Quantity stepper, a smaller copy of the product page field */

.ags-cart-stepper {
  display: inline-grid;
  grid-template-columns: 32px 28px 32px;
  height: 36px;
  border: 1px solid var(--ags-cart-border);
  border-radius: 8px;
}

.ags-cart-drawer .ags-cart-stepper button {
  display: grid;
  place-items: center;
  width: auto;
  min-width: 0;
  height: auto;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--ags-cart-dark);
  cursor: pointer;
  transition: color 0.2s;
}

.ags-cart-drawer .ags-cart-stepper button:disabled {
  color: var(--ags-cart-border);
  cursor: default;
}

.ags-cart-stepper__value {
  display: grid;
  place-items: center;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.is-loading .ags-cart-items,
.is-loading .ags-cart-panel__bottom {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.2s;
}

/* Bottom: packaging, subtotal, checkout */

.ags-cart-panel__bottom {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  border-top: 1px solid var(--ags-cart-line);
}

.ags-cart-panel__subtotal {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 18px 0;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ags-cart-panel__subtotal span:last-child {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
  white-space: nowrap;
}

.ags-cart-button,
.ags-cart-button:visited {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 15px 20px;
  background: var(--ags-cart-gold);
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-family: 'Neue Haas Unica', sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.14em;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  transition: background-color 0.2s;
}

.ags-cart-button:focus-visible {
  background: var(--ags-cart-gold-dark);
  color: #fff;
}

/* Packaging */

.ags-cart-packaging {
  border-bottom: 1px solid var(--ags-cart-line);
}

.ags-cart-drawer .ags-cart-packaging__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: auto;
  min-height: 52px;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--ags-cart-dark);
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

/* The chevron is drawn 5px inside its 24px box: pull it to the edge. */
.ags-cart-packaging__toggle svg {
  flex: 0 0 24px;
  margin-right: -7px;
  color: var(--ags-cart-muted);
  transition: transform var(--ags-pop-close, 0.2s) var(--ags-ease-close, ease);
}

.ags-cart-packaging.is-open .ags-cart-packaging__toggle svg {
  transform: rotate(180deg);
  transition: transform var(--ags-pop-open, 0.3s) var(--ags-ease, ease-out);
}

/* Opens by its height: the grid row goes from 0fr to 1fr, the inner box clips the list. */
.ags-cart-packaging__content {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows var(--ags-pop-close, 0.2s) var(--ags-ease-close, ease), opacity var(--ags-pop-close, 0.2s) var(--ags-ease-close, ease);
}

.ags-cart-packaging.is-open .ags-cart-packaging__content {
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows var(--ags-pop-open, 0.3s) var(--ags-ease, ease-out), opacity var(--ags-pop-open, 0.3s) var(--ags-ease, ease-out);
}

/* Restored after the fragments replace the drawer content: no animation. */
.ags-cart-packaging.is-instant .ags-cart-packaging__content,
.ags-cart-packaging.is-instant .ags-cart-packaging__toggle svg {
  transition: none;
}

.ags-cart-packaging__inner {
  min-height: 0;
  overflow: hidden;
}

.ags-cart-packaging__list {
  display: grid;
  max-height: 34vh;
  overflow-y: auto;
  padding-bottom: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .ags-cart-packaging__content,
  .ags-cart-packaging__toggle svg {
    transition: none;
  }
}

.ags-cart-packaging__product {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
}

.ags-cart-packaging__product:first-child {
  padding-top: 0;
}

.ags-cart-packaging__product + .ags-cart-packaging__product {
  border-top: 1px solid var(--ags-cart-line);
}

.ags-cart-packaging__image {
  display: block;
  width: 56px;
  height: 56px;
  background: var(--ags-cart-tint);
  border-radius: 8px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.ags-cart-packaging__details {
  min-width: 0;
}

.ags-cart-packaging__name {
  font-size: 13px;
  line-height: 18px;
}

.ags-cart-packaging__price {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 800;
  line-height: 18px;
}

.ags-cart-drawer .ags-cart-packaging__button {
  min-width: 92px;
  height: 36px;
  padding: 0 14px;
  background: #fff;
  border: 1px solid var(--ags-cart-border);
  border-radius: 8px;
  color: var(--ags-cart-dark);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.ags-cart-drawer .ags-cart-packaging__button:disabled {
  border-color: var(--ags-cart-line);
  color: var(--ags-cart-muted);
  cursor: default;
}

/* Empty cart (drawer and the cart page) */

.ags-cart-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  font-family: 'Neue Haas Unica', sans-serif;
  text-align: center;
}

.ags-cart-empty .ags-cart-empty__title {
  margin: 0;
  color: var(--ags-cart-dark);
  font-size: 22px;
  line-height: 28px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ags-cart-empty .ags-cart-empty__text {
  max-width: 300px;
  margin: 12px 0 28px;
  color: var(--ags-cart-muted);
  font-size: 15px;
  line-height: 22px;
}

.ags-cart-empty .ags-cart-button {
  width: auto;
  min-width: 260px;
}

/* Full width of the content column, on the page title's left edge. */
.ags-cart-empty--page {
  margin: 8px 0 64px;
  padding: 72px 40px;
  background: var(--ags-cart-tint);
  border-radius: 12px;
}

/* Hover only where there is a pointer: on phones a tap leaves :hover stuck. */

@media (hover: hover) {
  .ags-cart-drawer .ags-cart-panel__clear:hover {
    color: var(--ags-cart-dark);
    text-decoration-color: currentColor;
  }

  .ags-cart-drawer .ags-cart-item__name a:hover {
    color: var(--ags-cart-accent);
  }

  .ags-cart-drawer .ags-cart-item__remove:hover {
    color: var(--ags-cart-dark);
  }

  .ags-cart-drawer .ags-cart-stepper button:hover:not(:disabled) {
    color: var(--ags-cart-accent);
  }

  .ags-cart-drawer .ags-cart-packaging__button:hover:not(:disabled) {
    border-color: var(--ags-cart-gold);
    color: var(--ags-cart-accent);
  }

  .ags-cart-button:hover {
    background: var(--ags-cart-gold-dark);
    color: #fff;
  }
}

@media (max-width: 767px) {
  .ags-cart-drawer {
    --ags-cart-pad: 16px;
  }

  .ags-cart-drawer__top {
    height: 64px;
  }

  .ags-cart-item {
    --thumb: 84px;
    gap: 14px;
    padding: 16px 0;
  }

  /* Bigger touch targets: 40px for the cross, 40px stepper buttons. */
  .ags-cart-drawer .ags-cart-item__remove {
    flex-basis: 40px;
    width: 40px;
    height: 40px;
    margin: -11px -14px -8px 0;
  }

  .ags-cart-stepper {
    grid-template-columns: 40px 28px 40px;
    height: 40px;
  }

  .ags-cart-packaging__product {
    gap: 12px;
  }

  .ags-cart-empty--page {
    margin: 0 0 40px;
    padding: 48px 20px;
  }

  .ags-cart-empty .ags-cart-button {
    width: 100%;
    min-width: 0;
  }
}
