/* ==========================================================================
   Cartello — ST Custom Checkout (extension/module/custom)
   Loaded standalone via addStyle() on this route only — not part of the
   theme bundle, so selectors don't need heavy scoping, but are scoped to
   .st-page-form anyway for consistency with account.css / checkout.css.
   ========================================================================== */

/* ── Loading overlay (custom_block.render) ──────────────────────────────── */
.custom_lock {
  position: relative;
}
.custom_lock::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--white);
  opacity: 0.5;
  z-index: 100;
}
.custom_lock::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--accent);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: 64px;
  mask-size: 64px;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='0' fill='none' stroke='%23fff' stroke-width='3'%3E%3Canimate attributeName='r' values='0;40' dur='1s' begin='-0.5s' repeatCount='indefinite'/%3E%3Canimate attributeName='opacity' values='1;0' dur='1s' begin='-0.5s' repeatCount='indefinite'/%3E%3C/circle%3E%3Ccircle cx='50' cy='50' r='0' fill='none' stroke='%23fff' stroke-width='3'%3E%3Canimate attributeName='r' values='0;40' dur='1s' begin='0s' repeatCount='indefinite'/%3E%3Canimate attributeName='opacity' values='1;0' dur='1s' begin='0s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='0' fill='none' stroke='%23fff' stroke-width='3'%3E%3Canimate attributeName='r' values='0;40' dur='1s' begin='-0.5s' repeatCount='indefinite'/%3E%3Canimate attributeName='opacity' values='1;0' dur='1s' begin='-0.5s' repeatCount='indefinite'/%3E%3C/circle%3E%3Ccircle cx='50' cy='50' r='0' fill='none' stroke='%23fff' stroke-width='3'%3E%3Canimate attributeName='r' values='0;40' dur='1s' begin='0s' repeatCount='indefinite'/%3E%3Canimate attributeName='opacity' values='1;0' dur='1s' begin='0s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E");
  z-index: 101;
}

/* ── Page shell ───────────────────────────────────────────────────────── */
.st-page-form {
  padding-block: var(--space-6) var(--space-16);
}
.st-page-form h1 {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-8);
}

/* Breadcrumb — same remap as checkout.css / cart page */
.st-page-form .breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  padding: 0 !important;
  margin-bottom: var(--space-5) !important;
  background: none !important;
  border-radius: 0 !important;
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  gap: 0;
}
.st-page-form .breadcrumb > li { display: flex; align-items: center; }
.st-page-form .breadcrumb > li + li::before {
  content: "/" !important;
  padding: 0 0.5rem !important;
  opacity: 0.4;
  color: var(--color-text-muted);
}
.st-page-form .breadcrumb a { color: inherit; }
.st-page-form .breadcrumb a:hover { color: var(--accent); }
.st-page-form .breadcrumb > .active,
.st-page-form .breadcrumb > li:last-child a {
  color: var(--color-heading);
  font-weight: var(--fw-semibold);
}

/* Sticky sidebar — same offset formula as .st-cart-sidebar in checkout.css;
   custom.twig's inline script corrects `top` to the real header height on
   load (fixed selector: was querying the wrong `.lv-header`, now `.st-header`). */
.custom-sticky-block {
  align-self: flex-start;
  position: sticky;
  top: calc(var(--header-h) + var(--space-6));
}

/* ── Fieldset card (customer / login / cart / shipping / payment / comment) */
.custom-fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  background: var(--color-surface);
}
.custom-legend {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-snug);
  margin-bottom: var(--space-4);
  color: var(--color-heading);
  padding-bottom: var(--space-3);
  border-bottom: var(--hairline-strong);
  display: block;
}
.custom-fieldset-body .custom-legend { margin-bottom: var(--space-4); }

/* ── Bootstrap 5 form remap (form-label / form-control / form-select / form-check) */
.st-page-form .form-label {
  font-size: var(--fs-sm2);
  font-weight: var(--fw-medium);
  color: var(--color-heading);
  display: block;
  margin-bottom: var(--space-1);
}
.st-page-form .form-control,
.st-page-form .form-select {
  display: block !important;
  width: 100% !important;
  padding: 0.72em 0.95em !important;
  font-size: var(--fs-sm2) !important;
  font-family: inherit !important;
  color: var(--color-text) !important;
  background: var(--white) !important;
  border: 1px solid var(--color-border-strong) !important;
  border-radius: var(--radius) !important;
  box-shadow: none !important;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  line-height: 1.5;
  height: auto !important;
  -webkit-appearance: none;
  appearance: none;
}
.st-page-form .form-control:focus,
.st-page-form .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: var(--shadow-focus) !important;
}
.st-page-form .form-control::placeholder { color: var(--gray-400); }
.st-page-form .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2385858C' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.9em center !important;
  padding-right: 2.5em !important;
  cursor: pointer;
}
.st-page-form textarea.form-control { resize: vertical; min-height: 100px; }

.st-page-form .form-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-left: 0;
  min-height: 0;
}
.st-page-form .form-check-input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  margin: 0 !important;
  cursor: pointer;
  flex: none;
}
.st-page-form .form-check-label {
  font-size: var(--fs-sm2);
  color: var(--color-text);
  cursor: pointer;
}

/* Required-field marker (JS toggles .required on the wrapper) */
.st-page-form [id^="customer-field"].required > .form-label::after,
.st-page-form [id^="shipping-field"].required > .form-label::after {
  content: " *";
  color: var(--color-sale);
}

/* Validation error state */
.st-page-form .has-error .form-control,
.st-page-form .has-error .form-select {
  border-color: #dc2626 !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .12) !important;
}
.st-page-form .text-danger {
  font-size: var(--fs-xs) !important;
  color: #dc2626 !important;
  margin-top: var(--space-1);
  display: block;
}

/* ── Cart list (row layout — distinct from the /checkout/cart table) ───── */
.st-cart-list {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  overflow: hidden;
}

.st-cart-item {
  display: flex;
  padding: var(--space-4);
  border-bottom: var(--hairline);
  gap: var(--space-4);
  align-items: center;
}
.st-cart-item:last-child { border-bottom: none; }

.st-cart-item__thumb {
  flex-shrink: 0;
  display: block;
  width: 72px;
  height: 72px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--gray-50);
}
.st-cart-item__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.st-cart-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.st-cart-item__name {
  font-size: var(--fs-sm2);
  font-weight: var(--fw-semibold);
  color: var(--color-heading);
  text-decoration: none;
  line-height: 1.35;
  display: block;
  transition: color var(--dur) var(--ease);
}
.st-cart-item__name:hover { color: var(--accent); }
.st-cart-item__badge { margin-left: var(--space-1); font-size: var(--fs-sm); }
.st-cart-item__meta {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  line-height: 1.35;
}

.st-cart-item__foot {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-1);
  flex-wrap: wrap;
}
.st-cart-item__price {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
}
.st-cart-item__total {
  font-size: var(--fs-sm2);
  font-weight: var(--fw-bold);
  color: var(--color-heading);
  font-variant-numeric: tabular-nums;
}

/* Quantity stepper — matches minicart's .st-minicart__stepper look */
.st-cart-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 28px;
}
.st-cart-qty__btn {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
  color: var(--color-heading);
  transition: background var(--dur) var(--ease);
  padding: 0;
  flex-shrink: 0;
}
.st-cart-qty__btn:hover:not(:disabled) {
  background: var(--color-bg-alt);
}
.st-cart-qty__btn:disabled { opacity: .35; cursor: default; }
.st-cart-qty__input {
  width: 34px;
  height: 28px;
  border: none;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  text-align: center;
  font-size: var(--fs-sm2);
  font-weight: var(--fw-semibold);
  color: var(--color-heading);
  background: none;
  outline: none;
  padding: 0;
}

/* Remove button */
.st-cart-item__remove {
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: var(--fs-sm2);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  padding: 0;
}
.st-cart-item__remove:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* ── Totals ───────────────────────────────────────────────────────────── */
.custom-cart-total {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-surface);
  margin-bottom: var(--space-4);
}
.custom-cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--hairline);
  font-size: var(--fs-sm2);
}
.custom-cart-total-row:last-child { border-bottom: none; }
.custom-cart-total-final {
  background: var(--gray-50);
  font-size: var(--fs-base);
}
.custom-cart-total-label { color: var(--color-text-muted); }
.custom-cart-total-final .custom-cart-total-label { color: var(--color-heading); }
.custom-cart-total-value {
  font-weight: var(--fw-bold);
  color: var(--color-heading);
  font-variant-numeric: tabular-nums;
}
.custom-cart-total-final .custom-cart-total-value { font-size: var(--fs-lg); }

/* ── Modules accordion (coupon / voucher / reward / shipping-estimate) ──
   Panel styling (.st-total-panel / .st-panel-toggle) lives in checkout.css
   (bundled site-wide), since extension/total/* also renders on /checkout/cart. */
.custom-modules-accordion { margin-bottom: var(--space-4); }

/* ── Payment block — dim while re-fetching after shipping change ────────── */
#custom-payment {
  transition: opacity var(--dur-md) var(--ease);
}
#custom-payment.st-updating {
  opacity: 0.4;
  pointer-events: none;
}
.st-payment-changed { margin-top: var(--space-1); }

/* ── Auth links (customer legend: "Already have an account? Log in") ────── */
.st-auth-links {
  font-size: var(--fs-sm);
  font-weight: var(--fw-regular);
}
.st-auth-links a {
  color: var(--accent);
  text-decoration: none;
}
.st-auth-links a:hover { text-decoration: underline; }

.st-registration-notice { margin-top: var(--space-3) !important; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
/* .btn-st-buy / .btn-st-ghost are defined globally in components.css
   (bundled site-wide) since extension/total/* also renders on /checkout/cart. */
.btn-st-buy[disabled] { opacity: 0.6; cursor: not-allowed; }

.st-btn-order { width: 100%; justify-content: center; }

/* ── Checkout control (agree checkbox + order button) ────────────────────── */
.st-checkout-control {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  background: var(--color-surface);
}

/* ── Login modal ──────────────────────────────────────────────────────── */
#modal-st-login .modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
#modal-st-login .modal-header {
  border-bottom: none;
  padding-bottom: 0;
}
#modal-st-login .modal-title { color: var(--color-heading); }

/* ── Auto-registration notice — info look WITHOUT .alert class ──
   Not a Bootstrap .alert, so global $('.alert').remove() (cart/shipping
   updates, checkout steps) can never wipe it. Spacing from utilities. */
.st-registration-notice {
  color: #055160;
  background-color: #cff4fc;
  border: 1px solid #b6effb;
  border-radius: .375rem;
}
