/* ==========================================================================
   Cachay Store · Checkout multipaso
   ========================================================================== */
.checkout-scrim {
  position: fixed; inset: 0;
  background: oklch(0% 0 0 / 0.65);
  z-index: var(--z-modal-scrim);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-standard);
}
.checkout-scrim.is-open { opacity: 1; pointer-events: auto; }
/* los avisos flotantes no deben tapar los pasos del checkout */
body:has(.checkout.is-open) .toast-stack { display: none; }

.checkout {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
}
@media (min-width: 860px) { .checkout { align-items: center; } }

.checkout-panel {
  pointer-events: auto;
  width: 100%;
  max-width: 620px;
  height: 100svh;
  max-height: 100svh;
  background: var(--bg-900);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--dur-slow) var(--ease-out);
}
.checkout.is-open .checkout-panel { transform: translateY(0); }
@media (min-width: 860px) {
  .checkout-panel { height: auto; max-height: 90svh; border-radius: var(--radius-xl); }
  .checkout .checkout-panel { transform: translateY(24px) scale(0.985); opacity: 0; transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out); }
  .checkout.is-open .checkout-panel { transform: none; opacity: 1; }
}

.checkout-head {
  flex-shrink: 0;
  padding: calc(var(--safe-t) + var(--sp-4)) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--line-dark-soft);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.checkout-head h3 { font-size: var(--fs-lg); flex: 1; }
.checkout-back, .checkout-close {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-on-dark);
  flex-shrink: 0;
  transition: background-color var(--dur-fast);
}
.checkout-back:hover, .checkout-close:hover { background: oklch(100% 0 0 / 0.08); }
.checkout-back svg, .checkout-close svg { width: 19px; height: 19px; }
.checkout-back[hidden] { display: none; }

/* pasos */
.checkout-steps {
  flex-shrink: 0;
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--line-dark-soft);
}
.step-pip { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.step-pip .bar { height: 3px; border-radius: 2px; background: var(--bg-750); transition: background-color var(--dur-base); }
.step-pip .txt { font-size: var(--fs-2xs); color: var(--ink-on-dark-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-pip.is-done .bar { background: var(--ok-500); }
.step-pip.is-current .bar { background: var(--red-500); }
.step-pip.is-current .txt { color: var(--ink-on-dark); font-weight: 600; }

.checkout-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--sp-5); -webkit-overflow-scrolling: touch; }
.checkout-foot {
  flex-shrink: 0;
  padding: var(--sp-4) var(--sp-5) calc(var(--safe-b) + var(--sp-4));
  border-top: 1px solid var(--line-dark-soft);
  background: var(--bg-900);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.checkout-foot .btn { width: 100%; }
.checkout-total-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: var(--sp-1); }
.checkout-total-row .label { font-size: var(--fs-sm); color: var(--ink-on-dark-dim); }
.checkout-total-row .value { font-size: var(--fs-lg); }

/* paso 1: productos */
.co-line { display: flex; gap: var(--sp-3); padding-block: var(--sp-3); border-bottom: 1px solid var(--line-dark-soft); }
.co-line:last-child { border-bottom: 0; }
.co-line img { width: 62px; height: 62px; object-fit: contain; background: oklch(100% 0 0); border-radius: var(--radius-sm); flex-shrink: 0; }
.co-line-info { flex: 1; min-width: 0; }
.co-line-name { font-size: var(--fs-sm); font-weight: 600; }
.co-line-meta { font-size: var(--fs-2xs); color: var(--ink-on-dark-faint); margin-top: 2px; }
.co-line-row { display: flex; align-items: center; justify-content: space-between; margin-top: var(--sp-2); gap: var(--sp-3); }
.co-line-price { font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-sm); }

.co-totals { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line-dark); display: grid; gap: var(--sp-2); }
.co-total-line { display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--ink-on-dark-dim); }
.co-total-line.is-total { font-size: var(--fs-md); color: var(--ink-on-dark); font-weight: 700; padding-top: var(--sp-2); border-top: 1px solid var(--line-dark-soft); }
.co-total-line .price { font-family: var(--font-mono); }

/* paso 2: formulario */
.co-form { display: grid; gap: var(--sp-4); }
.co-field { display: grid; gap: 6px; }
.co-field label { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-on-dark-dim); }
.co-field label .req { color: var(--red-400); }
.co-field input, .co-field select, .co-field textarea {
  width: 100%;
  background: var(--bg-850);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-md);
  padding: 0.85rem var(--sp-4);
  color: var(--ink-on-dark);
  font-size: 16px; /* evita zoom automático en iOS */
  min-height: 48px;
  transition: border-color var(--dur-fast);
}
.co-field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.co-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-4) center;
  padding-right: var(--sp-10);
}
.co-field input:focus, .co-field select:focus, .co-field textarea:focus { outline: none; border-color: var(--red-500); }
.co-field input::placeholder, .co-field textarea::placeholder { color: var(--ink-on-dark-faint); }
.co-field.has-error input, .co-field.has-error select, .co-field.has-error textarea { border-color: var(--red-500); }
.co-error { font-size: var(--fs-2xs); color: var(--red-400); display: none; }
.co-field.has-error .co-error { display: block; }
.co-row-2 { display: grid; gap: var(--sp-4); }
@media (min-width: 560px) { .co-row-2 { grid-template-columns: 1fr 1fr; } }
.co-hint { font-size: var(--fs-2xs); color: var(--ink-on-dark-faint); }

/* paso 3: métodos de pago */
.pay-list { display: grid; gap: var(--sp-3); }
.pay-option {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border: 1.5px solid var(--line-dark);
  border-radius: var(--radius-lg);
  background: var(--bg-850);
  cursor: pointer;
  transition: border-color var(--dur-fast), background-color var(--dur-fast), transform var(--dur-fast) var(--ease-out);
  text-align: left;
  width: 100%;
}
.pay-option:active { transform: scale(0.99); }
.pay-option.is-selected { border-color: var(--red-500); background: oklch(56% 0.21 27 / 0.10); }
.pay-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md);
  background: var(--bg-800); color: var(--red-400);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pay-option.is-selected .pay-icon { background: var(--red-500); color: oklch(100% 0 0); }
.pay-icon svg { width: 21px; height: 21px; }
.pay-text { flex: 1; min-width: 0; display: block; }
.pay-title { display: block; font-size: var(--fs-sm); font-weight: 700; }
.pay-desc { display: block; font-size: var(--fs-2xs); color: var(--ink-on-dark-faint); margin-top: 3px; line-height: 1.45; }
.pay-radio {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line-dark);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: border-color var(--dur-fast);
}
.pay-option.is-selected .pay-radio { border-color: var(--red-500); }
.pay-radio::after {
  content: ""; width: 11px; height: 11px; border-radius: 50%;
  background: var(--red-500);
  transform: scale(0);
  transition: transform var(--dur-fast) var(--ease-out);
}
.pay-option.is-selected .pay-radio::after { transform: scale(1); }

.pay-note {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  background: oklch(100% 0 0 / 0.05);
  border: 1px solid var(--line-dark);
  font-size: var(--fs-xs);
  color: var(--ink-on-dark-dim);
  line-height: 1.6;
}
.pay-note a { color: var(--red-400); text-decoration: underline; font-weight: 600; }

/* paso 4: resumen */
.co-summary-block { border: 1px solid var(--line-dark); border-radius: var(--radius-lg); padding: var(--sp-4); margin-bottom: var(--sp-4); }
.co-summary-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-3); }
.co-summary-head h4 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-on-dark-faint); }
.co-summary-edit { font-size: var(--fs-2xs); color: var(--red-400); text-decoration: underline; }
.co-summary-data { font-size: var(--fs-sm); color: var(--ink-on-dark-dim); line-height: 1.65; }
.co-summary-data strong { color: var(--ink-on-dark); font-weight: 600; }
.co-summary-line { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); padding-block: 3px; }
.co-summary-line .qty { color: var(--ink-on-dark-faint); }

.co-empty { text-align: center; padding: var(--sp-12) var(--sp-4); color: var(--ink-on-dark-faint); }
.co-empty svg { width: 48px; height: 48px; opacity: 0.4; margin: 0 auto var(--sp-4); }

.co-done { text-align: center; padding: var(--sp-8) var(--sp-4); }
.co-done-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: oklch(62% 0.16 149 / 0.15); color: var(--ok-500);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--sp-5);
}
.co-done-icon svg { width: 30px; height: 30px; }
.co-done h4 { font-size: var(--fs-xl); margin-bottom: var(--sp-3); }
.co-done p { font-size: var(--fs-sm); color: var(--ink-on-dark-dim); max-width: 34ch; margin-inline: auto; }
