/*
 * Captain Greek cart items scroll only.
 *
 * Purpose:
 * - only #mini-cart.minicart-items scrolls
 * - title/header stays fixed
 * - footer/cart-sum-wrap stays fixed
 * - shell does not scroll
 *
 * Does NOT touch:
 * - footer padding
 * - quantity controls
 * - delete button
 * - product image/card styling
 * - templates
 */

/* Stop the whole popup / drawer from scrolling. */
html body .mfp-wrap.cart-modal,
html body .mfp-wrap.cart-modal[style],
html body .mfp-wrap.cart-modal.cg-cart-items-scroll-ready,
html body .mfp-wrap.cart-modal.cg-cart-items-scroll-ready[style] {
  overflow: hidden !important;
  overflow-x: hidden !important;
  overflow-y: hidden !important;
}

html body .mfp-wrap.cart-modal .mfp-container,
html body .mfp-wrap.cart-modal .mfp-content,
html body .mfp-wrap.cart-modal .minicart-wrapper.minicart-slide,
html body .mfp-wrap.cart-modal .block-minicart,
html body .mfp-wrap.cart-modal #minicart-content-wrapper,
html body .mfp-wrap.cart-modal .block-minicart .block-content {
  min-height: 0 !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;

  overflow: hidden !important;
  overflow-x: hidden !important;
  overflow-y: hidden !important;
}

/* Make the drawer content: product region above, footer below. */
html body .mfp-wrap.cart-modal .block-minicart .block-content {
  display: grid !important;
  grid-template-rows: minmax(0, 1fr) auto !important;
  min-height: 0 !important;
}

/*
 * Current common structure:
 * .block-content
 *   .minicart-items-wrapper
 *     .title-top
 *     ol#mini-cart.minicart-items
 *   .cart-sum-wrap
 *
 * This makes title fixed and only the ol scrollable.
 */
html body .mfp-wrap.cart-modal .minicart-items-wrapper {
  grid-row: 1 !important;

  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;

  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;

  margin: 0 !important;
  padding: 0 !important;

  overflow: hidden !important;
  overflow-x: hidden !important;
  overflow-y: hidden !important;

  background: transparent !important;
}

html body .mfp-wrap.cart-modal .title-top {
  grid-row: 1 !important;
  position: relative !important;
  z-index: 5 !important;
  flex: 0 0 auto !important;
}

/* The ONLY scrollable cart region. */
html body .mfp-wrap.cart-modal #mini-cart.minicart-items,
html body .mfp-wrap.cart-modal ol#mini-cart.minicart-items,
html body .mfp-wrap.cart-modal .minicart-items-wrapper > #mini-cart.minicart-items {
  grid-row: 2 !important;

  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;

  margin: 0 !important;

  overflow-y: auto !important;
  overflow-x: hidden !important;

  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
  scrollbar-gutter: auto !important;
}

/* Keep footer fixed in the bottom row; do not override its padding. */
html body .mfp-wrap.cart-modal .cart-sum-wrap {
  grid-row: 2 !important;
  flex: 0 0 auto !important;
  align-self: end !important;

  overflow: hidden !important;
  overflow-x: hidden !important;
  overflow-y: hidden !important;
}

/*
 * Alternate/patched structure:
 * .block-content
 *   .title-top
 *   .minicart-items-wrapper
 *     ol#mini-cart
 *   .cart-sum-wrap
 */
html body .mfp-wrap.cart-modal .block-content.cg-cart-title-outside {
  grid-template-rows: auto minmax(0, 1fr) auto !important;
}

html body .mfp-wrap.cart-modal .block-content.cg-cart-title-outside > .title-top {
  grid-row: 1 !important;
}

html body .mfp-wrap.cart-modal .block-content.cg-cart-title-outside > .minicart-items-wrapper {
  grid-row: 2 !important;
  display: block !important;
  min-height: 0 !important;
  height: auto !important;
  overflow: hidden !important;
}

html body .mfp-wrap.cart-modal .block-content.cg-cart-title-outside > .minicart-items-wrapper > #mini-cart.minicart-items {
  height: 100% !important;
  max-height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

html body .mfp-wrap.cart-modal .block-content.cg-cart-title-outside > .cart-sum-wrap {
  grid-row: 3 !important;
}

/* Subtle scrollbar for desktop. */
html body .mfp-wrap.cart-modal #mini-cart.minicart-items::-webkit-scrollbar {
  width: 9px;
}

html body .mfp-wrap.cart-modal #mini-cart.minicart-items::-webkit-scrollbar-track {
  background: transparent;
}

html body .mfp-wrap.cart-modal #mini-cart.minicart-items::-webkit-scrollbar-thumb {
  background: rgba(184, 155, 101, .34);
  border-radius: 999px;
  border: 2px solid #fffaf0;
}

/* Mobile: same rule, product list only scrolls. */
@media (max-width: 767px) {
  html body .mfp-wrap.cart-modal #mini-cart.minicart-items,
  html body .mfp-wrap.cart-modal ol#mini-cart.minicart-items {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
  }

  html body .mfp-wrap.cart-modal .minicart-items-wrapper {
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html body .mfp-wrap.cart-modal .cart-sum-wrap {
    overflow: hidden !important;
  }
}
