/* Order basket (cart.js). Kept apart from style.css so the menu's own styles stay untouched. */

.cart-control { margin-top: 10px; }

.cart-add {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1.5px solid var(--orange);
  border-radius: 999px;
  background: var(--surface);
  color: var(--orange-dark);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 850;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cart-add:active { background: var(--sand); }

.cart-stepper {
  display: grid;
  grid-template-columns: 36px minmax(24px, 1fr) 36px;
  align-items: center;
  min-height: 36px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  overflow: hidden;
}
.cart-step {
  height: 36px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cart-step:active { background: var(--orange-dark); }
.cart-count { text-align: center; font-weight: 900; font-variant-numeric: tabular-nums; }

.cart-add:focus-visible,
.cart-step:focus-visible,
.cart-bar:focus-visible,
.cart-close:focus-visible,
.cart-send:focus-visible,
.cart-secondary:focus-visible { outline: 3px solid var(--brown); outline-offset: 2px; }

/* Floating basket button: bottom right, clear of the categories button on the left. */
.cart-bar {
  position: fixed;
  z-index: 42;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 24px);
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(158, 62, 0, 0.35);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cart-bar-icon { font-size: 1.05rem; }
.cart-bar-count {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* Narrow phones: icon, count and total only, so it stays clear of the categories button. */
@media (max-width: 420px) {
  .cart-bar-word { display: none; }
}
.cart-bar-total { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart-bar.is-raised { bottom: calc(16px + 46px + 10px + env(safe-area-inset-bottom)); }
body.image-viewer-open .cart-bar,
body.cart-open .cart-bar { display: none; }
/* Room below the last products so the button never covers a price. */
body.has-cart .page-content { padding-bottom: 84px; }

.cart-panel {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(28, 12, 4, 0.55);
}
/* display: flex above would otherwise keep a closed basket on screen. */
.cart-panel[hidden] { display: none; }
body.cart-open { overflow: hidden; }

.cart-card {
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: calc(100% - env(safe-area-inset-top) - 8px);
  overflow: hidden;
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(28, 12, 4, 0.35);
}
@media (min-width: 761px) {
  .cart-panel { align-items: center; }
}

/* The title and ✕ are a fixed row above the content, which scrolls on its own, so the
   basket can always be closed. (A sticky bar inside the scrolling area missed taps on phones.) */
.cart-head {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line);
}
.cart-body {
  display: grid;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px 18px calc(18px + env(safe-area-inset-bottom));
}
.cart-head h2 { margin: 0; font-size: 1.25rem; }
.cart-close {
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--sand);
  color: var(--brown);
  font: inherit;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
}

.cart-empty, .cart-sent { margin: 0; color: var(--muted); line-height: 1.5; }
.cart-sent { color: var(--ink); font-weight: 700; }

.cart-lines { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.cart-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.cart-line-info { display: grid; gap: 2px; min-width: 0; }
.cart-line-name { font-weight: 750; line-height: 1.3; overflow-wrap: anywhere; }
.cart-line-price { color: var(--orange-dark); font-weight: 850; font-variant-numeric: tabular-nums; }

.cart-total { display: flex; justify-content: space-between; align-items: baseline; margin: 0; font-size: 1.05rem; }
.cart-total strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }

.cart-types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; border: 0; }
.cart-payment { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cart-types legend { grid-column: 1 / -1; margin-bottom: 6px; padding: 0; font-weight: 800; }
.cart-type,
.cart-pay {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 46px;
  padding: 6px 8px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  text-align: center;
  font-size: 0.84rem;
  font-weight: 750;
  line-height: 1.2;
  cursor: pointer;
}
.cart-type input,
.cart-pay input { position: absolute; opacity: 0; pointer-events: none; }
.cart-type.is-active,
.cart-pay.is-active { border-color: var(--orange); background: #fff1e4; color: var(--orange-dark); }
.cart-type:focus-within,
.cart-pay:focus-within { outline: 3px solid var(--brown); outline-offset: 2px; }

.cart-field { display: grid; gap: 6px; font-weight: 750; font-size: 0.9rem; }
.cart-field input,
.cart-field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  /* 16px keeps iPhone Safari from zooming into the field. */
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  resize: vertical;
}
.cart-field input:focus,
.cart-field textarea:focus { border-color: var(--orange); outline: none; }

.cart-location { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.cart-location-ok { color: #2e7a57; font-weight: 800; }
.cart-location-error { color: #b3261e; font-size: 0.85rem; }
.cart-link { padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 0.85rem; text-decoration: underline; cursor: pointer; }

.cart-note { margin: -4px 0 0; color: var(--muted); font-size: 0.84rem; line-height: 1.45; }
.cart-error { margin: 0; color: #b3261e; font-weight: 750; font-size: 0.9rem; }

.cart-actions { display: grid; gap: 10px; }
.cart-send,
.cart-secondary {
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
  font: inherit;
  font-weight: 850;
  cursor: pointer;
}
.cart-send { border: 0; background: #1f8f4e; color: #fff; font-size: 1rem; }
.cart-send:active { background: #17733e; }
.cart-secondary { border: 1.5px solid var(--line); background: var(--surface); color: var(--brown); font-size: 0.92rem; }
.cart-location .cart-secondary { width: auto; min-height: 42px; padding: 0 14px; }
.cart-secondary:disabled { opacity: 0.6; cursor: wait; }

@media (max-width: 760px) {
  .cart-control { margin-top: 8px; }
  .cart-add { min-height: 34px; font-size: 0.74rem; padding: 0 6px; }
  .cart-stepper { grid-template-columns: 30px minmax(18px, 1fr) 30px; min-height: 34px; }
  .cart-step { height: 34px; font-size: 1.05rem; }
  .cart-bar { right: 10px; min-height: 46px; padding: 0 14px; font-size: 0.84rem; }
  .cart-panel { padding: 0; }
  /* Its own layer from the start, so a pull only moves it, with nothing to repaint. */
  .cart-card { width: 100%; border-radius: 22px 22px 0 0; max-height: 92%; will-change: transform; }
  /* Grab handle: shows the sheet can be pulled down; the whole top bar is the pull area. */
  .cart-head { padding-top: 22px; touch-action: none; }
  .cart-head::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    width: 40px;
    height: 5px;
    border-radius: 999px;
    background: var(--line);
    transform: translateX(-50%);
  }
  .cart-line { grid-template-columns: minmax(0, 1fr) 108px; }
}

/* Fields that belong to each order type. All are built once; the chosen one is unfolded
   (grid rows 0fr → 1fr), so switching types changes the height smoothly, frame by frame.
   The negative margin cancels the card gap when every section is folded (pick-up). */
.cart-sections { display: grid; margin-top: -14px; }
.cart-section {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
}
.cart-section.is-open { grid-template-rows: 1fr; opacity: 1; }
.cart-section-clip { min-height: 0; overflow: hidden; }
.cart-section-body { display: grid; gap: 14px; padding-top: 14px; }

/* The delivery fee is told on WhatsApp; this must be seen before the address is typed. */
.cart-fee-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border: 1.5px solid var(--orange);
  border-radius: 14px;
  background: #fff1e4;
  color: var(--brown);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.4;
}
.cart-fee-icon { flex: none; font-size: 1.15rem; line-height: 1.2; }
.cart-total-extra { color: var(--muted); font-size: 0.8rem; font-weight: 700; white-space: nowrap; }

/* Flat, entrance, floor, door code: two small fields per row, like a delivery app. */
.cart-address-extra { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cart-address-extra .cart-field { font-size: 0.82rem; }
.cart-address-extra .cart-field input { padding: 9px 10px; }

.cart-courier { display: grid; gap: 8px; }
.cart-courier-title { font-weight: 750; font-size: 0.9rem; }
.cart-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cart-chip {
  min-height: 38px;
  padding: 0 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cart-chip.is-active { border-color: var(--orange); background: #fff1e4; color: var(--orange-dark); }
.cart-chip:focus-visible { outline: 3px solid var(--brown); outline-offset: 2px; }

@media (prefers-reduced-motion: no-preference) {
  .cart-panel { transition: background-color 200ms ease; }
  .cart-add, .cart-step, .cart-bar, .cart-type { transition: background-color 120ms ease, border-color 120ms ease; }
  .cart-section { transition: grid-template-rows 300ms ease, opacity 220ms ease; }
  .cart-type, .cart-pay { transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease; }
}
