/* ============================================================
   cart-polish.css — Batch 6 (UI/UX polish: cart + checkout)
   Adds CTA to empty state, loading skeleton, inline form error
   hints, payment radio-card check glyph + hint line, modifier
   summary readability, order summary grid alignment, retry
   button on checkout status.
   Consumes tokens from resources/css/tokens.css (brand/neutral/
   semantic/spacing/radius). All additive; no existing rules
   overridden destructively.
   ============================================================ */

/* ==========================================================
   A1 — Empty cart CTA (below existing icon + title + text)
   ========================================================== */
.cart-empty-state__cta {
  margin-block-start: var(--space-sm, 0.75rem);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding-inline: 1.25rem;
  text-decoration: none;
}

.cart-empty-state__cta i,
.cart-empty-state__cta svg {
  flex-shrink: 0;
}

[dir="rtl"] .cart-empty-state__cta .fa-arrow-right,
[dir="rtl"] .cart-empty-state__cta .fa-arrow-left {
  transform: scaleX(-1);
}

/* ==========================================================
   A4 / E4 — CSS-only skeleton shimmer (used for distance
   pricing panel and payment summary list empty state)
   ========================================================== */
@keyframes cart-skeleton-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

.cart-skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-muted, #f3f4f6) 0%,
    var(--color-surface-subtle, #e5e7eb) 50%,
    var(--color-surface-muted, #f3f4f6) 100%
  );
  background-size: 200% 100%;
  animation: cart-skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm, 6px);
  color: transparent;
  user-select: none;
  pointer-events: none;
}

.payment-summary-list:empty::before {
  content: "";
  display: block;
  height: 72px;
  width: 100%;
  border-radius: var(--radius-sm, 6px);
  background: linear-gradient(
    90deg,
    var(--color-surface-muted, #f3f4f6) 0%,
    var(--color-surface-subtle, #e5e7eb) 50%,
    var(--color-surface-muted, #f3f4f6) 100%
  );
  background-size: 200% 100%;
  animation: cart-skeleton-shimmer 1.4s ease-in-out infinite;
  margin-block-end: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .cart-skeleton,
  .payment-summary-list:empty::before {
    animation: none;
  }
}

/* ==========================================================
   A5 — Checkout status retry button (shown only on error)
   Uses existing .checkout-status.error class toggled by
   checkoutStep.js. No JS logic added — pure CSS visibility
   + a reload-on-click anchor that the HTML authors.
   ========================================================== */
.checkout-status__retry {
  display: none;
  align-items: center;
  gap: 6px;
  margin-inline-start: 8px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  cursor: pointer;
  min-height: 32px;
  line-height: 1.2;
}

.checkout-status__retry:hover,
.checkout-status__retry:focus-visible {
  background: rgba(153, 27, 27, 0.08);
}

.checkout-status.error .checkout-status__retry {
  display: inline-flex;
}

/* ==========================================================
   B2 — Inline form error hint (shown via <small class="form-error">
   paired to inputs via aria-describedby="err-{id}").
   Each input lives inside a .customer-grid__field wrapper so
   the small can sit directly below the input without breaking
   the parent grid layout.
   ========================================================== */
.customer-grid__field {
  display: flex;
  flex-direction: column;
  min-inline-size: 0;
}

.customer-grid__field > input,
.customer-grid__field > select,
.customer-grid__field > textarea {
  width: 100%;
}

.form-error {
  display: block;
  margin-block-start: 4px;
  margin-block-end: 2px;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--color-danger, #dc2626);
  font-weight: 500;
}

.form-error:empty,
.form-error[hidden] {
  display: none !important;
}

.form-error::before {
  content: "⚠";
  margin-inline-end: 0.35em;
  display: inline-block;
  font-weight: 700;
}

/* B3 — bridge legacy .field-error class to shared tokens so
   both error paths render consistently. */
input.field-error,
select.field-error,
textarea.field-error {
  border-color: var(--color-danger, #dc2626);
  box-shadow: inset 0 0 0 1px var(--color-danger, #dc2626);
}

/* B4 — live email success indicator (no JS; pure CSS via :valid) */
input[type="email"].has-success-indicator:valid:not(:placeholder-shown):not(:focus):not([aria-invalid="true"]),
.delivery-info input[type="email"]:valid:not(:placeholder-shown):not(:focus):not([aria-invalid="true"]) {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23059669'><path d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  padding-inline-end: 34px;
}

[dir="rtl"] .delivery-info input[type="email"]:valid:not(:placeholder-shown):not(:focus):not([aria-invalid="true"]),
[dir="rtl"] input[type="email"].has-success-indicator:valid:not(:placeholder-shown):not(:focus):not([aria-invalid="true"]) {
  background-position: left 10px center;
  padding-inline-end: revert;
  padding-inline-start: 34px;
}

/* ==========================================================
   C3 — Payment method checkmark + thicker border on selected
   state (non-color redundancy). Existing color/box-shadow
   styling remains in cart.css; this layer adds the glyph.
   ========================================================== */
.payment-method-option {
  /* guarantee ::after absolute anchor works */
  position: relative;
}

.payment-method-option:has(input[type="radio"]:checked) {
  border-width: 2.5px;
  /* compensate border growth so label stays centered */
  padding-block: calc(12px - 1px);
  padding-inline: calc(14px - 1px);
}

.payment-method-option:has(input[type="radio"]:checked)::after {
  content: "";
  position: absolute;
  inset-block-start: 6px;
  inset-inline-end: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-success, #059669);
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z'/></svg>");
  -webkit-mask-size: 14px 14px;
          mask-size: 14px 14px;
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
  box-shadow: 0 1px 3px rgba(5, 150, 105, 0.35);
  pointer-events: none;
}

/* C2 — keyboard focus ring on the full card (not just the hidden input) */
.payment-method-option:has(input[type="radio"]:focus-visible) {
  outline: 2px solid var(--color-brand, #2563eb);
  outline-offset: 2px;
}

/* C4 — description hint line under option name */
.payment-method-option {
  flex-wrap: wrap;
  align-content: flex-start;
}

.payment-method-option__name {
  flex: 1 1 auto;
  min-inline-size: 0;
}

.payment-method-option__hint {
  flex-basis: 100%;
  padding-inline-start: calc(32px + 0.6rem);
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--color-text-muted, #6b7280);
  font-weight: 400;
  margin-block-start: 2px;
  overflow-wrap: anywhere;
}

.payment-method-option__hint:empty {
  display: none;
}

/* C5 — normalize PayPal icon frame */
.payment-method-option__icon--paypal {
  width: 32px;
  padding: 0;
}

.payment-method-option__icon--paypal img {
  width: 28px;
  height: 14px;
  object-fit: contain;
}

/* ==========================================================
   D1–D3 — Modifier summary readability
   Parent is .cart-item which sets color inherit; this lifts
   modifier text to body text colour with explicit size ≥ 14px
   and replaces the bare comma separator with a dot glyph for
   subtle grouping.
   ========================================================== */
.cart-item-extras-summary {
  font-size: clamp(0.875rem, 2.5vw, 0.95rem);
  line-height: 1.5;
  color: var(--color-text, #1f2937);
  row-gap: 2px;
}

.cart-item-extras-summary__name {
  color: var(--color-text, #1f2937);
  font-weight: 500;
}

/* suppress the legacy trailing comma (added in cart.css:2169) */
.cart-item-extras-summary__item:not(:last-child)::after {
  content: "·" !important;
  color: var(--color-border, #d1d5db);
  padding-inline: 0.5em;
  font-weight: 700;
  opacity: 0.9;
}

@media (max-width: 540px) {
  .cart-item-extras-summary__price {
    font-size: 0.875rem; /* was 0.8rem — below 14px target */
  }
}

/* ==========================================================
   E1 — Order summary row grid alignment
   Consistent label/value alignment across tax / processor /
   shipping / discount / total rows.
   ========================================================== */
.cart-summary__row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: var(--space-sm, 0.5rem);
}

.cart-summary__total {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: var(--space-sm, 0.5rem);
}

.cart-summary__row-note {
  font-size: 0.75rem;
  color: var(--color-text-muted, #6b7280);
  display: inline-block;
  margin-inline-start: 4px;
}

/* ==========================================================
   E3 — Edit-cart action inside payment modal footer row.
   Existing .payment-modal__cta is a flex row with
   justify-content: center. We override to space-between so
   the edit-cart sits at the start edge and confirm stays in
   the middle/end of the row. On small screens both wrap to
   full width.
   ========================================================== */
.payment-modal__cta {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-xs, 8px);
  align-items: center;
}

.payment-modal__edit-cart {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--color-border, #e5e7eb);
  background: transparent;
  color: var(--color-text, #1f2937);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.payment-modal__edit-cart:hover,
.payment-modal__edit-cart:focus-visible {
  background: var(--color-surface-muted, #f3f4f6);
  border-color: var(--color-text-muted, #6b7280);
  outline: none;
}

[dir="rtl"] .payment-modal__edit-cart .fa-arrow-left,
[dir="rtl"] .payment-modal__edit-cart .fa-arrow-right {
  transform: scaleX(-1);
}

@media (max-width: 640px) {
  .payment-modal__cta {
    justify-content: center;
  }
  .payment-modal__edit-cart {
    order: 2;
    width: 100%;
    justify-content: center;
  }
}

/* ==========================================================
   A6 — Search page empty state
   ========================================================== */
.search-empty-state {
  padding: clamp(24px, 4vw, 40px);
  text-align: center;
  border: 1px dashed var(--color-border, #e5e7eb);
  border-radius: var(--radius-md, 12px);
  background: var(--color-surface-subtle, #f9fafb);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm, 0.75rem);
  align-items: center;
}

.search-empty-state__icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.08);
  color: var(--color-brand, #2563eb);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-empty-state__icon svg {
  width: 26px;
  height: 26px;
}

.search-empty-state__title {
  color: var(--color-text, #1f2937);
  font-size: 1rem;
  font-weight: 600;
}

.search-empty-state__text {
  color: var(--color-text-muted, #6b7280);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
}
