/* ==========================================================================
   Quantity steppers: single product page + mini-cart.
   Markup: inc/cart-quantity.php (product) and woocommerce/cart/mini-cart.php.
   Loaded globally (the mini-cart is in the nav on every page).
   ========================================================================== */

/* -------------------------------------------------------------------------
   Single product. at-protocol-shortcode.css (shop-bridge, every product page)
   hides `.at-sp-layout__form .quantity` with !important. The theme only wraps
   the input in .at-sp-qty when the product may be bought in several units, so
   the override below is limited to that wrapper; configured products keep
   their hidden quantity of one.
   ---------------------------------------------------------------------- */
.at-woo .at-sp-layout__form .at-sp-qty {
  display: inline-flex;
  align-items: stretch;
  flex: 0 0 auto;
  border: 1px solid var(--border-1);
  border-radius: 8px;
  background: var(--pure-white, #fff);
  overflow: hidden;
  transition: border-color var(--dur-fast, 120ms) ease;
}
.at-woo .at-sp-layout__form .at-sp-qty[hidden] { display: none !important; }
.at-woo .at-sp-layout__form .at-sp-qty:focus-within { border-color: var(--rubber-black); }

.at-woo .at-sp-layout__form .at-sp-qty .quantity {
  display: flex !important;
  align-items: stretch;
  margin: 0;
}
.at-woo .at-sp-layout__form .at-sp-qty .quantity .qty {
  width: 48px;
  min-height: 48px;
  margin: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  color: var(--fg-1);
  -moz-appearance: textfield;
  appearance: textfield;
}
.at-woo .at-sp-layout__form .at-sp-qty .quantity .qty::-webkit-outer-spin-button,
.at-woo .at-sp-layout__form .at-sp-qty .quantity .qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.at-woo .at-sp-layout__form .at-sp-qty .quantity .qty:focus { outline: none; box-shadow: none; }

.at-woo .at-sp-layout__form .at-sp-qty__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
  transition: background-color var(--dur-fast, 120ms) ease, color var(--dur-fast, 120ms) ease;
}
.at-woo .at-sp-layout__form .at-sp-qty__btn:hover:not(:disabled) { background: var(--bg-subtle); color: var(--fg-1); }
.at-woo .at-sp-layout__form .at-sp-qty__btn:focus-visible { outline: 2px solid var(--performance-orange); outline-offset: -2px; }
.at-woo .at-sp-layout__form .at-sp-qty__btn:disabled { color: var(--fg-3); opacity: .45; cursor: default; }

/* Phones: stepper and button share the first row; the button takes the rest. */
@media (max-width: 540px) {
  .at-woo .at-sp-layout__form .at-sp-qty__btn { width: 40px; }
  .at-woo .at-sp-layout__form .at-sp-qty .quantity .qty { width: 40px; font-size: 16px; } /* 16px: no iOS zoom */
  .at-woo .at-sp-layout__form form.cart:has(.at-sp-qty:not([hidden])) .single_add_to_cart_button {
    flex: 1 1 0;
    min-width: 0;
    padding-left: 16px !important;
    padding-right: 16px !important;
    white-space: nowrap;
  }
}

/* Cart page: fixed quantity (one-per-line products, personalised offers). */
.at-woo .at-qty-fixed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-md, 8px);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  color: var(--fg-2);
}

/* -------------------------------------------------------------------------
   Mini-cart line stepper (editable lines only).
   ---------------------------------------------------------------------- */
#at-minicart .at-minicart-qtyrow,
.at-minicart-qtyrow {
  order: 1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}
.at-minicart-qtyrow .at-minicart-qty--unit { white-space: nowrap; }

.at-minicart-stepper {
  display: inline-flex;
  align-items: stretch;
  height: 32px;
  border: 1px solid var(--border-1);
  border-radius: 999px;
  background: var(--pure-white, #fff);
  overflow: hidden;
  transition: border-color var(--dur-fast, 120ms) ease, opacity var(--dur-fast, 120ms) ease;
}
.at-minicart-stepper:focus-within { border-color: var(--rubber-black); }
.at-minicart-stepper.is-busy { opacity: .55; pointer-events: none; }

.at-minicart-stepper__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
  transition: background-color var(--dur-fast, 120ms) ease, color var(--dur-fast, 120ms) ease;
}
.at-minicart-stepper__btn:hover:not(:disabled) { background: var(--bg-subtle); color: var(--fg-1); }
.at-minicart-stepper__btn:focus-visible { outline: 2px solid var(--performance-orange); outline-offset: -2px; }
.at-minicart-stepper__btn:disabled { color: var(--fg-3); opacity: .45; cursor: default; }

.at-minicart-stepper__input,
#at-minicart .at-minicart-stepper__input {
  width: 34px;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-1);
  -moz-appearance: textfield;
  appearance: textfield;
}
.at-minicart-stepper__input::-webkit-outer-spin-button,
.at-minicart-stepper__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.at-minicart-stepper__input:focus { outline: none; }

.at-minicart-qty-error {
  order: 3;
  margin: 4px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--danger);
}

/* Touch screens: 40px targets. */
@media (pointer: coarse) {
  .at-minicart-stepper { height: 40px; }
  .at-minicart-stepper__btn { width: 40px; }
  .at-minicart-stepper__input,
  #at-minicart .at-minicart-stepper__input { width: 38px; font-size: 16px; } /* 16px: no iOS zoom */
}

@media (prefers-reduced-motion: reduce) {
  .at-sp-qty,
  .at-sp-qty__btn,
  .at-minicart-stepper,
  .at-minicart-stepper__btn { transition: none; }
}
