/* KIANO cart + checkout + add-to-cart + toast. Uses tokens from styles.css. */

/* ---------- add-to-cart control (product page) ---------- */
.add-to-cart {
  display: flex;
  align-items: stretch;
  gap: 12px;
  flex-wrap: wrap;
  margin: 18px 0 6px;
}
.qty-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
}
.qty-control .qty-btn {
  width: 42px;
  height: 100%;
  min-height: 48px;
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  transition: background .2s var(--ease);
}
.qty-control .qty-btn:hover { background: var(--surface-2); }
.qty-control .qty-input {
  width: 48px;
  height: 48px;
  border: 0;
  text-align: center;
  font: inherit;
  font-weight: 600;
  background: transparent;
  color: var(--ink);
  -moz-appearance: textfield;
}
.qty-control .qty-input::-webkit-outer-spin-button,
.qty-control .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.add-to-cart .btn { flex: 1 1 auto; }

/* ---------- shared summary rows ---------- */
.cart-summary-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
}
.cart-summary-row:last-of-type { border-bottom: 0; }
.cart-free { color: var(--accent-ink); font-weight: 600; }
.cart-summary-total {
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  border-bottom: 0;
  padding-top: 14px;
}

/* ---------- cart page ---------- */
.page-cart .section-head,
.page-checkout .section-head { margin-bottom: 22px; }

.cart-empty {
  text-align: center;
  padding: 48px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.cart-items { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.cart-item {
  display: grid;
  grid-template-columns: 72px 1fr auto auto auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.cart-item-media {
  width: 72px; height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
}
.cart-item-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cart-item-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cart-item-name { font-weight: 600; color: var(--ink); }
.cart-item-size, .cart-item-unit { font-size: 13px; }

.cart-item-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  overflow: hidden;
}
.cart-item-qty .qty-btn {
  width: 34px; height: 36px;
  border: 0; background: transparent;
  font-size: 18px; line-height: 1;
  color: var(--ink); cursor: pointer;
  transition: background .2s var(--ease);
}
.cart-item-qty .qty-btn:hover { background: var(--surface-2); }
.cart-item-qty .qty-value { min-width: 30px; text-align: center; font-weight: 600; font-size: 15px; }

.cart-item-line {
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
}
.cart-item-remove {
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 50%;
  font-size: 20px; line-height: 1;
  color: var(--muted); cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.cart-item-remove:hover { color: var(--sale); border-color: var(--sale); background: #fff; }

.cart-summary {
  margin-left: auto;
  max-width: 420px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.cart-checkout-btn { width: 100%; margin-top: 16px; }

/* ---------- checkout page ---------- */
.checkout-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 32px;
  align-items: start;
}
.checkout-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field .req { color: var(--sale); }
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  color: var(--ink);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 76px; }

.checkout-aside { position: sticky; top: 96px; }
.checkout-summary {
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.checkout-summary-title { font-size: 1.15rem; margin-bottom: 14px; }
.checkout-items { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.checkout-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}
.checkout-item-name { color: var(--ink-2); }
.checkout-item-line { font-weight: 600; white-space: nowrap; }

.checkout-error {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #fdecea;
  border: 1px solid #f5c6c0;
  color: var(--sale);
  font-size: 14px;
  font-weight: 600;
}
.checkout-submit { width: 100%; }
.checkout-submit:disabled { opacity: .65; cursor: progress; }

.checkout-done {
  text-align: center;
  max-width: 520px;
  margin: 0 auto;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.checkout-done-mark {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 30px;
  font-weight: 700;
}
.checkout-done p { margin: 0; }

/* ---------- header cart count badge (if header provides [data-cart-count]) ---------- */
[data-cart-count] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* ---------- toast ---------- */
.cart-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 24px);
  z-index: 200;
  max-width: calc(100vw - 32px);
  padding: 13px 20px;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.cart-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .checkout-grid { grid-template-columns: 1fr; }
  .checkout-aside { position: static; order: -1; }
}
@media (max-width: 640px) {
  .cart-item {
    grid-template-columns: 56px 1fr auto;
    grid-template-areas:
      "media info remove"
      "media qty  line";
    row-gap: 10px;
  }
  .cart-item-media { grid-area: media; width: 56px; height: 56px; }
  .cart-item-info { grid-area: info; }
  .cart-item-remove { grid-area: remove; justify-self: end; }
  .cart-item-qty { grid-area: qty; }
  .cart-item-line { grid-area: line; justify-self: end; }
  .cart-summary { max-width: none; }
  .field-row { grid-template-columns: 1fr; }
}
