/* cart.css - cart and checkout (index.html only). Load last.
   Cart badge/toast, cart panel, wizard, upsells, checkout form,
   date/time picker, confirmation, phone cart bar.

   Contents - search for the marker, e.g. "== CART: feedback ==":
     == CART: feedback ==  cart count badge, restore banner, toast, fly-to-cart dot
     == CART: panel ==  slide-in cart panel
     == CART: wizard ==  checkout steps and their buttons
     == CART: upsell ==  suggested add-on cards
     == CART: lines ==  cart lines and total
     == CART: checkout form ==  details form, delivery address, honeypot, notes, errors
     == CART: date and time ==  date picker + time selects
     == CART: confirmation ==  order sent screen, WhatsApp fallback link
     == CART: summary ==  last-step order summary
     == CART: cart bar ==  phone cart bar between the floating buttons
*/

/* == CART: feedback == */
#cart-count {
  background: var(--accent-warm);
  color: #2a1d08;
  font-size: 0.72rem;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

#cart-restore-banner {
  position: fixed;
  top: 66px;
  right: 14px;
  left: 14px;
  z-index: 45;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  font-size: 0.9rem;
}
#cart-restore-banner.hidden { display: none; }
#cart-restore-banner span { flex: 1; }
#restore-cart-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}
#dismiss-cart-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
}

#cart-toast {
  position: fixed;
  top: 66px;
  left: 14px;
  background: var(--ink);
  color: var(--card); /* not #fff: --ink turns light in dark mode */
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  z-index: 55;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  max-width: 70vw;
  box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}
#cart-toast.show { opacity: 1; transform: translateY(0); }

.fly-dot {
  position: fixed;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  background: var(--accent-warm);
  border-radius: 50%;
  z-index: 60;
  pointer-events: none;
  transition: transform 0.55s cubic-bezier(.3,.6,.4,1), opacity 0.55s ease;
}

.topbar-cart.bump { animation: cart-bump 0.3s ease; }
@keyframes cart-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* == CART: panel == */
/* Opens from the cart button's side: left in Hebrew, right in English
   (inset-inline-end follows dir). */
#cart-panel {
  position: fixed;
  top: 0;
  inset-inline-end: 0;
  width: min(400px, 100%);
  height: 100%;
  background: var(--card);
  box-shadow: 6px 0 20px rgba(0,0,0,0.15);
  /* Top: starts under the fixed 58px top bar (z-index 50), like #side-menu. */
  padding: 74px 22px 22px;
  overflow-y: auto;
  z-index: 30;
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1);
}

#cart-panel.hidden { transform: translateX(-105%); }
html[dir="ltr"] #cart-panel { box-shadow: -6px 0 20px rgba(0,0,0,0.15); }
html[dir="ltr"] #cart-panel.hidden { transform: translateX(105%); }
#cart-panel h2 { margin-top: 0; }
#cart-close {
  position: absolute;
  top: 70px;
  inset-inline-end: 16px;
  background: var(--bg);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
}
/* The cart heading gets focus when the cart opens - no ring unless via keyboard. */
#cart-panel h2:focus:not(:focus-visible) { outline: none; }

/* == CART: wizard == */
.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 6px 0 20px;
}
.wizard-step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}
.wizard-step-dot.active {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}
.wizard-step-label { font-size: 0.75rem; color: var(--muted); margin-inline-start: -4px; }
.wizard-step-dot.active + .wizard-step-label { color: var(--ink); font-weight: 600; }
.wizard-panel.hidden { display: none; }
.wizard-nav {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
/* Every step's buttons (including step 1's lone "next") sit in .wizard-nav. */
.wizard-nav button {
  flex: 1;
  padding: 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}
.wizard-nav .wizard-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--ink);
}
.wizard-nav .wizard-next {
  background: var(--accent-warm);
  color: #2a1d08;
  border: none;
}
.wizard-nav #send-order {
  background: #25d366;
  color: #0a2e16;
  border: none;
}

/* == CART: upsell == */
/* One compact row per suggested add-on: in RTL the first column (photo) sits
   on the right, the text in the middle and the checkbox on the left.
   (#details-form prefix: the form's generic label/input rules would
   otherwise force display:block and a full-width input.) */
#details-form .upsell-card {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  min-height: 72px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 10px 0;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.upsell-card:has(input:checked) { border-color: var(--accent); }
/* A ticked extra opens "כמות − n +" under it (renderUpsellList): card and row
   share one frame. The − / + are the cart lines' (.qty-stepper). */
.upsell-item { margin: 10px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); overflow: hidden; transition: border-color 0.15s ease; }
.upsell-item:has(input:checked) { border-color: var(--accent); }
#details-form .upsell-item .upsell-card { margin: 0; border: none; border-radius: 0; }
.upsell-qty { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px dashed var(--border); background: #fffaf4; font-size: 0.88rem; font-weight: 600; }
.upsell-qty[hidden] { display: none; }
.upsell-qty .qty-btn { width: 32px; height: 32px; }
.upsell-qty-total { margin-inline-start: auto; font-weight: 700; color: var(--accent-dark); }
.upsell-card-image {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 72px;
  object-fit: cover;
}
.upsell-card-image-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tan);
  background: radial-gradient(circle at 50% 40%, var(--bg) 0%, var(--border) 100%);
}
.upsell-card-image-placeholder svg { width: 26px; height: 26px; }
.upsell-card-text { padding: 8px 4px; font-size: 0.85rem; font-weight: 600; text-align: center; }
.upsell-card-checkbox { display: flex; justify-content: center; }
#details-form .upsell-card-checkbox input {
  appearance: none;
  width: 22px;
  height: 22px;
  padding: 0;
  background: var(--card);
  border: 2px solid var(--muted);
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-content: center;
}
.upsell-card-checkbox input::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--accent);
  transform: scale(0);
  transition: transform 0.12s ease;
}
.upsell-card-checkbox input:checked { border-color: var(--accent); }
.upsell-card-checkbox input:checked::before { transform: scale(1); }
#details-form .upsell-card-checkbox input[type="radio"],
.upsell-card-checkbox input[type="radio"]::before { border-radius: 50%; }

/* == CART: lines == */
.cart-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
  font-size: 0.9rem;
}
.cart-line-name { flex: 1; }
/* "+ עוד אחת עם בחירה אחרת" (anotherChoiceHtml): opens the dish's window. */
.cart-line-another { display: block; margin-top: 4px; padding: 0; border: none; background: none; color: var(--accent-dark); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; text-align: start; }
.cart-line-another:hover { text-decoration: underline; }
.cart-line-qty { min-width: 24px; text-align: center; font-weight: 700; }
.cart-line .qty-btn { width: 32px; height: 32px; }
.cart-line-remove {
  background: none;
  border: none;
  color: #c0392b;
  cursor: pointer;
  font-family: inherit;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 12px 0;
  border-top: 2px solid var(--ink);
  margin-top: 4px;
}

.cart-line-thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.cart-line-price { display: block; font-weight: 700; color: var(--accent-dark); margin-top: 2px; }
.cart-pieces { margin: 0 0 4px; font-size: 0.85rem; color: var(--muted); }

/* == CART: checkout form == */
.fulfillment-choice { margin: 14px 0; }
#delivery-fields { margin-bottom: 10px; }
#delivery-fields.hidden { display: none; }
.address-field { position: relative; }
.address-suggestions {
  position: absolute;
  z-index: 20;
  top: 100%;
  right: 0;
  left: 0;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}
.address-suggestions.hidden { display: none; }
.address-suggestion {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.9rem;
  text-align: start;
  cursor: pointer;
}
.address-suggestion:last-child { border-bottom: none; }
.address-suggestion:hover, .address-suggestion:focus-visible { background: var(--bg); outline: none; }
.delivery-zone-status { font-size: 0.8rem; color: var(--muted); margin: 2px 0 0; }
.date-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 6px 0 14px;
}
.inline-error {
  color: #c0392b;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 6px 0;
}

#details-form label {
  display: block;
  margin: 12px 0 4px;
  font-size: 0.9rem;
  font-weight: 600;
}

#details-form input, #details-form textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--card);
  color: var(--ink);
}
#details-form input:focus, #details-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.note { font-size: 0.8rem; color: var(--muted); margin-top: 12px; }

/* Clipped in place, not pushed off-screen: left:-9999px widens an RTL page. */
.hp-field {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* == CART: date and time == */
/* Dates the admin closed for orders */
.date-picker-day.blocked {
  text-decoration: line-through;
  color: var(--muted);
  opacity: 0.6;
}

.date-field { position: relative; margin: 12px 0 4px; }
.date-field > span { display: block; margin-bottom: 4px; font-size: 0.9rem; font-weight: 600; }
.time-field { margin: 12px 0 4px; }
.time-field > span { display: block; margin-bottom: 4px; font-size: 0.9rem; font-weight: 600; }
/* Two scroll wheels (setupTimePicker), clock order HH:MM even in RTL. The
   band is where the chosen item stops; 65px = (inner height - item) / 2. */
.time-wheel { position: relative; display: flex; justify-content: center; align-items: center; gap: 6px; height: 176px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); direction: ltr; overflow: hidden; }
.time-wheel::before { content: ""; position: absolute; inset: 65px 10px auto; height: 44px; border-radius: 10px; background: var(--bg); border: 1px solid var(--accent); pointer-events: none; }
.time-wheel::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; background: linear-gradient(var(--card), transparent 32%, transparent 68%, var(--card)); }
.time-wheel-col { position: relative; width: 72px; height: 100%; padding: 65px 0; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; border-radius: 10px; outline: none; }
.time-wheel-col::-webkit-scrollbar { display: none; }
.time-wheel-col:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.time-wheel-col > div { height: 44px; display: grid; place-items: center; scroll-snap-align: center; font-size: 1.3rem; color: var(--muted); cursor: pointer; user-select: none; -webkit-user-select: none; }
.time-wheel-col > .on { color: var(--ink); font-weight: 700; }
.time-wheel-col > .off { color: var(--border); }
.time-colon { position: relative; z-index: 2; font-size: 1.3rem; font-weight: 700; color: var(--muted); }
.date-picker-trigger {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--card);
  color: var(--muted);
  text-align: start;
  cursor: pointer;
}
.date-picker-trigger:hover, .date-picker-trigger:focus-visible { outline: none; border-color: var(--accent); }
.date-picker-trigger.has-value { color: var(--ink); }

.date-picker-popup {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  padding: 14px;
}
.date-picker-popup.hidden { display: none; }

.date-picker-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.date-picker-nav button {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 44px;
  height: 44px;
  font-size: 1.1rem;
  color: var(--ink);
  cursor: pointer;
}
.date-picker-nav button:hover { border-color: var(--accent); color: var(--accent-dark); }
.date-picker-nav button:disabled { opacity: 0.4; cursor: default; }
.date-picker-nav button:disabled:hover { border-color: var(--border); color: var(--ink); }
.date-picker-nav h3 { margin: 0; font-size: 1rem; font-weight: 400; font-family: "Bellefair", serif; font-size-adjust: 0.492; }

.date-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.date-picker-day {
  aspect-ratio: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
}
.date-picker-day:hover { border-color: var(--accent); }
.date-picker-day.empty { visibility: hidden; cursor: default; }
.date-picker-day.disabled { color: var(--muted); opacity: 0.4; cursor: not-allowed; }
.date-picker-day.disabled:hover { border-color: var(--border); }
.date-picker-day.today { border-color: var(--accent); border-width: 2px; }
.date-picker-day.selected { background: var(--accent); border-color: var(--accent); color: #2a1505; font-weight: 700; }

/* == CART: confirmation == */
#order-confirmation {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 60px;
}
#order-confirmation.hidden { display: none; }
#cart-main.hidden { display: none; }
#order-confirmation .confirmation-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 18px;
}
#order-confirmation p { color: var(--muted); margin-bottom: 24px; }
#order-confirmation button { align-self: center; }
#order-confirmation .order-save-warning {
  color: var(--ink);
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
}
#order-confirmation .hidden { display: none; }
#wa-fallback-link { display: inline-block; margin-bottom: 12px; }
#wa-fallback-link.hidden { display: none; }
#order-page-link { display: block; margin: 0 0 14px; color: var(--accent-dark); font-weight: 600; }
#order-number-line { font-size: 1.15em; margin: 0 0 8px; }

/* == CART: summary == */
/* Last checkout step: what's being ordered */
.checkout-summary { margin-top: 16px; font-size: 0.85rem; }
.checkout-summary ul { list-style: none; margin: 6px 0 0; padding: 0; }
.checkout-summary li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.checkout-summary li span:last-child { white-space: nowrap; }

/* == CART: cart bar == */
/* Phone cart bar, next to the WhatsApp button */
.cart-bar { display: none; }
@media (max-width: 639.98px) {
  .cart-bar {
    display: block;
    position: fixed;
    bottom: 22px;
    left: 88px;   /* WhatsApp button: 20px + 56px + gap */
    right: 20px;
    height: 52px;
    z-index: 20;
    border: none;
    border-radius: 26px;
    padding: 0 12px;
    background: var(--accent-warm);
    color: #2a1d08;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    cursor: pointer;
  }
  .cart-bar.hidden, body.panel-open .cart-bar { display: none; }
}
