/* ============================================================
   Add to Cart button - responsive (2026-06-12)
   Goal: cap the width at 187px (the previous width), narrow smoothly and continuously with the screen width, keep the text visible throughout, never switch to an icon.

   Key point: Journal has a high-priority rule that pins the button to full width:
     `#product-product .stepper-group.cart-group #button-cart { width:100% !important }` (specificity: 2 ids + 2 classes)
   It can only be overridden with equal or higher specificity plus !important, so the selectors below copy its ancestor chain and add .btn-cart.

   Width = clamp(96px, 44vw, 187px):
     · viewport >= 425px -> capped at 187px
     · viewport < 425px -> shrinks smoothly at 44vw (320 -> 141, 360 -> 158, 390 -> 172)
   To change where shrinking starts or how fast it shrinks, edit 44vw; to change the cap, edit both 187px values; to change the minimum width, edit 96px.
   ============================================================ */

#product-product .stepper-group.cart-group #button-cart.btn-cart {
  width: clamp(96px, 44vw, 187px) !important;   /* follows the viewport and shrinks smoothly, capped at 187 */
  max-width: 187px !important;
  min-width: 0 !important;
  box-sizing: border-box !important;            /* makes the width above the total width of the button */
  padding-left: 14px !important;
  padding-right: 14px !important;
  overflow: hidden !important;
}

/* Text: at normal phone widths "Add to Cart" is shown in full; if it ever becomes too narrow to fit, it ends with an ellipsis */
#product-product .stepper-group.cart-group #button-cart.btn-cart .btn-text {
  display: block;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- Keep the wishlist (heart) right next to the add-to-cart button and never let it wrap ----- */
/* .buttons-wrapper originally had flex-wrap:wrap + a full-width hidden Buy Now + a heart with margin-left:auto,
   which pushed the heart to the far right and dropped it to the next line on narrow screens. The rules below fix all of that. */
.button-group-page .buttons-wrapper {
  flex-wrap: nowrap !important;     /* no wrapping, all three on one line */
  align-items: center !important;
}
/* cart-group(quantity + button): may shrink, does not grow, leaves room for the heart */
.button-group-page .buttons-wrapper .cart-group {
  flex: 0 1 auto !important;
  min-width: 0 !important;
}
/* Hide the extra Buy Now button that is currently not displayed (offsetHeight=0): it takes up a whole row and breaks the layout;
   to enable Buy Now later, just delete this rule */
.button-group-page .buttons-wrapper .extra-group {
  display: none !important;
}
/* Heart: sits right next to the button (removes the auto margin that pushed it to the far right), fixed size, never compressed */
.button-group-page .buttons-wrapper .wishlist-compare {
  flex: 0 0 auto !important;
  margin-left: 8px !important;
}
/* When the row runs out of space, let the add-to-cart button shrink (instead of pushing the heart down); its text is then truncated */
#product-product .stepper-group.cart-group #button-cart.btn-cart {
  flex-shrink: 1 !important;
}

/* ----- When the text no longer fits (<=345px, button already down to about 125px): replace the text with a cart icon -----
   Key point: this tier does NOT hard-code a width; the button keeps using the smooth flex shrink above,
   so the width stays continuous across the breakpoint (125 -> 124) with no jump, and the icon button keeps shrinking slowly with the screen, never a cliff.
   To make the switch to the icon happen earlier or later, change the 345px below. */
@media (max-width: 345px) {
  #product-product .stepper-group.cart-group #button-cart.btn-cart {
    min-width: 44px !important;     /* the icon button never gets smaller than this (fallback for extremely narrow screens); otherwise it still shrinks smoothly via flex */
    /* White cart SVG over the dark background (no icon-font dependency, most robust); width/padding/flex are untouched to keep it continuous */
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%20576%20512%27%3E%3Cpath%20fill%3D%27%23ffffff%27%20d%3D%27M0%2024C0%2010.7%2010.7%200%2024%200H69.5c22%200%2041.5%2012.8%2050.6%2032h411c26.3%200%2045.5%2025%2038.6%2050.4l-41%20152.3c-8.5%2031.4-37%2053.3-69.5%2053.3H170.7l5.4%2028.5c2.2%2011.3%2012.1%2019.5%2023.6%2019.5H488c13.3%200%2024%2010.7%2024%2024s-10.7%2024-24%2024H199.7c-34.6%200-64.3-24.6-70.7-58.5L77.4%2054.5c-.7-3.8-4-6.5-7.9-6.5H24C10.7%2048%200%2037.3%200%2024zM128%20464a48%2048%200%201%201%2096%200%2048%2048%200%201%201-96%200zm336-48a48%2048%200%201%201%200%2096%2048%2048%200%201%201%200-96z%27%2F%3E%3C%2Fsvg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center center !important;
    background-size: 22px 22px !important;
  }
  /* Hide the text (kept for accessibility) */
  #product-product .stepper-group.cart-group #button-cart.btn-cart .btn-text {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
}
