/* ---------------------------------------------------------------------------
   Cart, checkout and confirmation.

   The first version put the lines in a table inside a narrow panel: names
   wrapped mid-word, the columns fought each other and it grew a horizontal
   scrollbar. This is a two-column layout instead — the lines get the room,
   and the totals sit in a summary card that follows you down the page.

   Uses site.css tokens only, so it follows the light/dark toggle for free.
   Logical properties throughout so RTL mirrors itself.
--------------------------------------------------------------------------- */

.cart-page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 120px 24px 88px;
}

.cart-head { margin-bottom: 30px; }

.cart-title {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.cart-sub { color: var(--text-dim); margin: 0; }

.cart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 344px;
  gap: 30px;
  align-items: start;
}

/* ------------------------------------------------------------- the lines --- */

.cart-lines {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
}

.cart-line {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 20px 22px;
}

.cart-line + .cart-line { border-top: 1px solid var(--border); }

.cart-line-shot {
  width: 92px;
  height: 74px;
  border-radius: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  overflow: hidden;
}

.cart-line-shot img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* These are <p> elements, and site.css paints every paragraph --text-dim.
   The product name is the strongest thing in the row, so it takes --text back
   explicitly rather than inheriting the muted body colour. */
.cart-line-name {
  font-weight: 700;
  font-size: 1.04rem;
  margin: 0 0 3px;
  line-height: 1.25;
  color: var(--text);
}

.cart-line-meta {
  font-size: 0.84rem;
  color: var(--text-dim);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.cart-line-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

/* Stepper. Each button is its own tiny form posting the new quantity, so the
   total can never disagree with the number on screen — the old "type a number,
   then press Update" arrangement let those two drift apart. */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.qty-stepper button {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.qty-stepper button:hover:not(:disabled) { background: var(--accent); color: #04222e; }
.qty-stepper button:disabled { opacity: 0.35; cursor: default; }

.qty-stepper .qty-value {
  min-width: 34px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.cart-line-total {
  min-width: 116px;
  text-align: end;
  font-weight: 800;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cart-remove {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  padding: 6px;
  border-radius: 50%;
  transition: color 0.18s, background 0.18s;
}

.cart-remove:hover { color: #d1495b; background: color-mix(in srgb, #d1495b 12%, transparent); }

/* ----------------------------------------------------------- the summary --- */

.cart-summary {
  position: sticky;
  top: calc(var(--header-h) + 18px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
}

.cart-summary h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 16px;
}

.cart-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 0;
  font-size: 0.94rem;
  color: var(--text-dim);
}

.cart-row span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
  padding-top: 16px;
}

.cart-total .label { font-weight: 650; }

.cart-total .value {
  font-size: 1.6rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cart-summary .btn { width: 100%; margin-top: 18px; }
.cart-note { font-size: 0.84rem; color: var(--text-dim); margin: 14px 0 0; line-height: 1.5; }

.cart-trust {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 18px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--border);
  list-style: none;
}

.cart-trust li {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.86rem;
  color: var(--text-dim);
}

.cart-trust svg { width: 15px; height: 15px; flex: none; color: var(--accent); }

/* ---------------------------------------------------------------- empty --- */

.cart-empty {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 72px 28px;
  text-align: center;
}

.cart-empty-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--bg-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.cart-empty-icon svg { width: 26px; height: 26px; }
.cart-empty p { color: var(--text-dim); margin: 0 0 20px; }

.cart-alert {
  background: var(--bg-card);
  border: 1px solid color-mix(in srgb, #e0a458 45%, transparent);
  border-inline-start: 3px solid #e0a458;
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 0.93rem;
}

/* ------------------------------------------------------------- checkout --- */

.checkout-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
}

.checkout-panel + .checkout-panel { margin-top: 22px; }

.checkout-legend {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 18px;
}

.checkout-step {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: #04222e;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.is-wide { grid-column: 1 / -1; }

.field > span {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-dim);
}

.field input,
.field select,
.field textarea {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 11px 14px;
  width: 100%;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field textarea { resize: vertical; min-height: 84px; }

/* Payment choice as selectable cards rather than bare radios. */
.pay-options { display: grid; gap: 12px; }

.pay-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 15px 17px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.pay-option:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.pay-option input { margin-top: 3px; accent-color: var(--accent); flex: none; }

.pay-option:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.pay-option .pay-name { font-weight: 650; display: block; }
.pay-option .pay-hint { font-size: 0.85rem; color: var(--text-dim); }

.form-errors {
  border: 1px solid color-mix(in srgb, #d1495b 50%, transparent);
  background: color-mix(in srgb, #d1495b 8%, transparent);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.form-errors ul { margin: 0; padding-inline-start: 18px; }
.form-errors:empty { display: none; }

/* ---------------------------------------------------------- confirmation --- */

.order-done { max-width: 680px; margin: 0 auto; text-align: center; }

.order-tick {
  width: 72px;
  height: 72px;
  margin: 0 auto 22px;
  border-radius: 50%;
  background: color-mix(in srgb, #12a37a 15%, transparent);
  color: #12a37a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  animation: order-pop 0.55s cubic-bezier(0.3, 1.5, 0.5, 1);
}

@keyframes order-pop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.order-ref {
  display: inline-block;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--bg-raised);
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px 22px;
  margin: 6px 0 24px;
}

.order-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  text-align: start;
}

/* ------------------------------------------------------------ responsive --- */

@media (max-width: 940px) {
  .cart-layout { grid-template-columns: 1fr; }
  .cart-summary { position: static; }
}

@media (max-width: 620px) {
  .cart-page { padding-inline: 18px; padding-top: 100px; }
  .cart-line { grid-template-columns: 66px minmax(0, 1fr); gap: 14px; }
  .cart-line-shot { width: 66px; height: 58px; }
  .cart-line-right { grid-column: 1 / -1; justify-content: space-between; }
  .cart-line-total { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .order-tick { animation: none; }
  .qty-stepper button,
  .cart-remove,
  .pay-option { transition: none; }
}

/* ------------------------------------------------------------- tracking --- */

.order-track { margin-top: 26px; text-align: start; }

.track-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

/* The spine runs behind the dots and is drawn once, not per-step. */
.track-steps::before {
  content: "";
  position: absolute;
  inset-inline-start: 7px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--border);
}

.track-step {
  position: relative;
  display: flex;
  gap: 16px;
  padding: 0 0 20px;
}

.track-step:last-child { padding-bottom: 0; }

.track-dot {
  position: relative;
  z-index: 1;
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
}

.track-step.is-done .track-dot { background: var(--accent); border-color: var(--accent); }

.track-step.is-current .track-dot {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}

.track-label { display: block; font-weight: 650; color: var(--text-dim); }
.track-step.is-done .track-label { color: var(--text); }

.track-when {
  display: block;
  font-size: 0.84rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.track-note { display: block; font-size: 0.88rem; color: var(--text-dim); margin-top: 3px; }

.order-cancelled {
  color: #d1495b;
  font-weight: 650;
  margin: 0;
}

.track-consignment {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.track-consignment span { color: var(--text-dim); }
.track-consignment strong { font-variant-numeric: tabular-nums; }

.order-keep {
  font-size: 0.86rem;
  color: var(--text-dim);
  margin: 0 0 22px;
}
