/* ════════════════════════════════════════════════════════════════
   سبد سفارش: ردیف‌های قابل کلیک، مودال آیتم، نوار سبد، فهرست سفارش‌ها
   از همان متغیرهای style.css استفاده می‌کند (--ink، --surface، ...).
   ════════════════════════════════════════════════════════════════ */

/* ── ردیف‌های منو قابل کلیک می‌شوند ── */
.row[data-id] {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s var(--ease-out-quart);
}

@media (hover: hover) {
  .row[data-id]:hover {
    background: var(--hover);
  }
}

.row[data-id]:active {
  background: var(--press);
}

.row[data-id]:focus-visible {
  outline-offset: -3px;
}

/* دکمهٔ + کوچک در انتهای ردیف؛ نشان می‌دهد ردیف قابل کلیک است */
.row[data-id]::after {
  content: "";
  flex: none;
  align-self: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235c0307' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M8 3v10M3 8h10'/%3E%3C/svg%3E") center / 14px no-repeat;
}

/* ── کارت‌های «ترکیبات خاص» قابل کلیک می‌شوند ── */
.card[data-id] {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s var(--ease-out-quart), box-shadow 0.2s var(--ease-out-quart);
}
@media (hover: hover) {
  .card[data-id]:hover { transform: translateY(-2px); box-shadow: var(--edge), var(--sh-lift); }
}
.card[data-id]:active { transform: scale(0.985); }
.card[data-id]:focus-visible { outline-offset: 2px; }

/* ── نوار سبد (پایین صفحه): قرص کوچک و جمع‌وجور، به اندازهٔ محتوا ── */
/* داک پایین صفحه: نوار وضعیت سفارش و نوار سبد، زیر هم و وسط */
.dock {
  position: fixed;
  z-index: 60;
  inset-inline: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.dock > * {
  pointer-events: auto;
}

.cartbar,
.orderbar {
  max-width: calc(100% - 2 * var(--pad-x));
}

.cartbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding-inline: 6px 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 6px 18px rgba(92, 3, 7, 0.28);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s var(--ease-out-quart), transform 0.1s ease-out;
}

.cartbar[hidden] {
  display: none;
}

.cartbar:hover {
  background: var(--accent-hover);
}

.cartbar:active {
  transform: scale(0.97);
}

.cartbar-badge {
  min-width: 32px;
  height: 32px;
  padding-inline: 8px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: rgba(254, 254, 254, 0.18);
  font-size: 14px;
}

.cartbar-label {
  text-align: start;
}

.cartbar-total:not(:empty) {
  padding-inline-start: 10px;
  border-inline-start: 1px solid rgba(254, 254, 254, 0.28);
}

.cartbar-total .money {
  font-weight: 600;
}

.cartbar-total .toman {
  opacity: 0.85;
}

.cartbar.is-bump {
  animation: cart-bump 0.45s var(--ease-spring);
}

@keyframes cart-bump {
  35% {
    transform: scale(1.06);
  }
}

body.has-cartbar {
  padding-bottom: 76px;
}

html.pano-lock .dock {
  display: none;
}

/* ── مودال‌ها (آیتم و سبد) ── */
html.sheet-lock {
  overflow: hidden;
}

.sheet {
  width: min(520px, 100%);
  max-height: min(88dvh, 760px);
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}

.sheet:modal {
  max-width: 100%;
  max-height: min(88dvh, 760px);
}

.sheet::backdrop {
  background: rgba(40, 2, 4, 0.4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.sheet[open] {
  animation: sheet-in 0.34s var(--ease-spring);
}

@keyframes sheet-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.sheet-body {
  position: relative;
  max-height: inherit;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 30px 22px 22px;
  border-radius: var(--r-panel);
  background: var(--paper);
  box-shadow: var(--sh-overlay);
}

@media (max-width: 640px) {
  .sheet:modal {
    width: 100%;
    margin: auto 0 0;
  }

  .sheet-body {
    border-radius: var(--r-panel) var(--r-panel) 0 0;
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }

  @keyframes sheet-in {
    from {
      opacity: 0.6;
      transform: translateY(100%);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }
}

.sheet-close {
  position: absolute;
  inset-block-start: 14px;
  inset-inline-end: 14px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text-2);
  cursor: pointer;
  transition: background-color 0.15s;
}

.sheet-close:hover {
  background: var(--fill-2);
}

.sheet-close svg {
  width: 18px;
  height: 18px;
}

/* ── مودال آیتم ── */
.item-art {
  display: grid;
  place-items: center;
  margin: 4px 0 12px;
}

.item-art[hidden] {
  display: none;
}
/* عکس آپلودشده در مودال؛ کمی پایین‌تر تا دکمهٔ بستن روی عکس نیفتد */
.item-art:has(.item-photo) { margin-top: 22px; }
.item-photo {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 280px;
  object-fit: cover;
  border-radius: var(--r-sheet);
  background: var(--surface-2);
}

.item-art .drink-art {
  width: auto;
  max-width: 100%;
  height: 124px;
}

.item-cat {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
}

.item-title {
  margin-top: 2px;
  padding-inline-end: 44px;
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 34px);
  font-weight: 700;
  line-height: 1.35;
}

.item-desc {
  margin-top: 6px;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text-body);
}

.item-price {
  margin-top: 12px;
  font-size: 22px;
  font-weight: 700;
}

.item-desc[hidden],
.item-price[hidden],
.item-incart[hidden] {
  display: none;
}

.item-incart {
  display: inline-block;
  margin-top: 12px;
  padding: 2px 12px;
  border-radius: var(--r-pill);
  background: var(--accent-tint);
  font-size: 13px;
  font-weight: 600;
}

.sheet-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.sheet-add {
  flex: 1;
  min-width: 0;
  padding-inline: 14px;
  gap: 6px;
  border: 0;
  font-family: inherit;
  font-size: 15px;
  white-space: nowrap;
  cursor: pointer;
}

.sheet-add .money {
  font-weight: 600;
}

.sheet-add .toman {
  opacity: 0.8;
}

.sheet-add .sep {
  opacity: 0.55;
}

/* ── شمارنده: − ۲ + ── */
.stepper {
  display: inline-flex;
  direction: ltr;
  /* همیشه − در چپ و + در راست، مثل بیشتر اپ‌ها */
  align-items: center;
  gap: 2px;
  height: 52px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: var(--edge);
}

.stepper-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 0.15s;
}

.stepper-btn:hover {
  background: var(--fill-2);
}

.stepper-btn:active {
  background: var(--press);
}

.stepper-btn:disabled {
  opacity: 0.32;
  cursor: default;
  background: transparent;
}

.stepper-btn svg {
  width: 18px;
  height: 18px;
}

.stepper-val {
  min-width: 34px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.stepper--sm {
  height: 42px;
  padding: 3px;
}

.stepper--sm .stepper-btn {
  width: 34px;
  height: 34px;
}

.stepper--sm .stepper-btn svg {
  width: 16px;
  height: 16px;
}

.stepper--sm .stepper-val {
  min-width: 28px;
  font-size: 16px;
}

/* ── فهرست سفارش‌ها ── */
.cart-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
  min-height: 1.4em;
}

.cart-list {
  margin-top: 12px;
}

.cart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 14px;
  padding: 14px 0;
  border-top: 1px solid var(--hairline);
}

.cart-row:first-child {
  border-top: 0;
}

.cart-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.4;
}

.cart-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  min-height: 1.2em;
  font-size: 14px;
  color: var(--text-2);
}

.cart-sub .money {
  font-weight: 700;
  color: var(--text);
}

.cart-row .stepper {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.cart-empty {
  margin-top: 18px;
  padding: 28px 0 12px;
  text-align: center;
  color: var(--text-2);
}

.cart-empty[hidden],
.cart-foot[hidden] {
  display: none;
}

.cart-foot {
  display: grid;
  gap: 12px;
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline-2);
}

.cart-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 700;
}

.cart-total[hidden] {
  display: none;
}

.cart-note {
  font-size: 13px;
  line-height: 1.9;
  color: var(--text-3);
}

.cart-foot .btn-ghost {
  height: 46px;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}

.btn-ghost.is-armed {
  border-color: rgba(92, 3, 7, 0.5);
  background: var(--fill-2);
}

@media (max-width: 420px) {
  .sheet-actions {
    gap: 8px;
  }

  .sheet-actions .stepper {
    height: 48px;
  }

  .sheet-actions .stepper-btn {
    width: 40px;
    height: 40px;
  }

  .sheet-actions .stepper-val {
    min-width: 26px;
  }

  .sheet-add {
    height: 48px;
    padding-inline: 10px;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {

  .sheet[open],
  .cartbar.is-bump {
    animation: none;
  }

  .cartbar,
  .stepper-btn,
  .row[data-id] {
    transition: none;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .sheet::backdrop {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ════════════════════════════════════════════════════════════════
   هدر دسته‌ها: قرص گرد شناور که همیشه بالای صفحه می‌چسبد
   این بخش ظاهر قدیمی .catbar در style.css را عوض می‌کند.
   ════════════════════════════════════════════════════════════════ */
:root {
  --catbar-h: 50px;
  /* ارتفاع قرص */
  --catbar-top: 10px;
  /* فاصله از بالای صفحه وقتی چسبیده است */
}

html {
  scroll-padding-top: calc(var(--catbar-top) + var(--catbar-h) + 16px);
}

/* خود .catbar فقط جای چسبیدن را نگه می‌دارد؛ ظاهر روی .seg-scroller است */
.catbar {
  top: max(var(--catbar-top), env(safe-area-inset-top));
  background: none;
  border: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  pointer-events: none;
  /* دور قرص، کلیک به محتوای زیر برسد */
}

.catbar-inner {
  height: auto;
  justify-content: center;
}

.seg-scroller {
  flex: 0 1 auto;
  /* به اندازهٔ محتوا؛ در موبایل داخلش اسکرول می‌شود */
  max-width: 100%;
  padding-block: 0;
  pointer-events: auto;
  border-radius: var(--r-pill);
  background: rgba(254, 254, 254, 0.94);
  border: 1px solid rgba(92, 3, 7, 0.09);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  box-shadow: 0 1px 3px rgba(92, 3, 7, 0.08), 0 8px 26px rgba(92, 3, 7, 0.13);
}

.seg {
  padding: 5px;
  background: none;
}

.seg-item {
  height: 38px;
}

@media (min-width: 900px) {
  .group-head {
    top: calc(var(--catbar-top) + var(--catbar-h) + 30px);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .seg-scroller {
    background: var(--paper);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (prefers-contrast: more) {
  .seg-scroller {
    border-color: rgba(92, 3, 7, 0.5);
  }
}

/* هایلایت دستهٔ فعال با اسکریپت (catbar.js)؛ جای :target-current بومی کروم که فقط در کروم جدید کار می‌کند */
.catbar.is-js .seg {
  scroll-target-group: none;
}

.seg-item[aria-current] {
  background: var(--accent-fill);
  color: var(--on-accent);
}


/* ════════════════ ثبت سفارش و پیگیری ════════════════ */
body.has-orderbar { padding-bottom: 76px; }
body.has-cartbar.has-orderbar { padding-bottom: 128px; }

/* ── نوار وضعیت سفارش ── */
.orderbar {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding-inline: 16px 18px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--paper);
  color: var(--text);
  box-shadow: 0 0 0 1px var(--hairline-2), 0 6px 18px rgba(92, 3, 7, 0.18);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.orderbar[hidden] { display: none; }
.orderbar:active { transform: scale(0.97); }
.orderbar-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: #b07010; }
.orderbar[data-state="new"] .orderbar-dot,
.orderbar[data-state="preparing"] .orderbar-dot { animation: dot-pulse 1.4s ease-in-out infinite; }
.orderbar[data-state="done"] .orderbar-dot { background: #2e6b3d; }
.orderbar[data-state="cancelled"] .orderbar-dot { background: #a4161a; }
.orderbar-text { overflow: hidden; text-overflow: ellipsis; }
.orderbar.is-bump { animation: cart-bump 0.45s var(--ease-spring); }
@keyframes dot-pulse { 50% { opacity: 0.3; } }

/* ── پیام کوتاه ── */
.toast {
  position: fixed;
  z-index: 70;
  inset-inline: 0;
  top: max(12px, env(safe-area-inset-top));
  margin-inline: auto;
  width: fit-content;
  max-width: calc(100% - 2 * var(--pad-x));
  padding: 10px 18px;
  border-radius: var(--r-pill);
  background: var(--accent-fill);
  color: var(--on-accent);
  box-shadow: var(--sh-lift);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.8;
  text-align: center;
  animation: toast-in 0.3s var(--ease-spring);
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } }

/* ── فرم ثبت سفارش ── */
.cart-checkout { width: 100%; border: 0; font-family: inherit; font-size: 16px; cursor: pointer; }
.field { display: grid; gap: 6px; margin-top: 16px; }
.field label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.field input {
  width: 100%;
  height: 52px;
  padding-inline: 16px;
  border: 1px solid var(--hairline-2);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 17px;
  text-align: start;
}
.field input::placeholder { color: var(--text-3); opacity: 0.7; }
.field input:focus-visible { outline: 2px solid var(--accent-fill); outline-offset: 1px; }
.field.has-error input { border-color: #a4161a; }
.field-hint { font-size: 13px; color: var(--text-3); }
.field-error { font-size: 13px; font-weight: 600; color: #a4161a; }
.form-error {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(164, 22, 26, 0.08);
  color: #a4161a;
  font-size: 14px;
  line-height: 1.9;
}
.field-hint[hidden], .field-error[hidden], .form-error[hidden] { display: none; }
#checkoutForm .sheet-actions { margin-top: 20px; }
#coBack { flex: none; height: 52px; padding-inline: 18px; font-family: inherit; font-size: 15px; cursor: pointer; }

/* ── کارت سفارش‌ها ── */
.o-list { display: grid; gap: 14px; margin-top: 14px; }
.o-card { padding: 16px; border-radius: 18px; background: var(--surface); box-shadow: var(--edge); }
.o-head { display: flex; align-items: baseline; gap: 8px; }
.o-title { font-family: var(--font-display); font-size: 21px; font-weight: 700; }
.o-meta { margin-inline-start: auto; font-size: 13px; color: var(--text-3); }
.o-status { margin-top: 8px; font-size: 15px; font-weight: 600; line-height: 1.8; }

.steps { display: flex; margin: 16px 0 6px; padding: 0; list-style: none; }
.steps li {
  position: relative;
  flex: 1;
  display: grid;
  justify-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  color: var(--text-3);
}
.steps li::before {
  content: "";
  position: absolute;
  top: 7px;
  inset-inline-end: 50%;
  width: 100%;
  height: 3px;
  background: var(--hairline-2);
}
.steps li:first-child::before { display: none; }
.steps-dot {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--hairline-2);
  box-shadow: 0 0 0 4px var(--surface);
}
.steps li.is-past, .steps li.is-now { color: var(--text); font-weight: 600; }
.steps li.is-past .steps-dot, .steps li.is-now .steps-dot { background: var(--accent-fill); }
.steps li.is-past::before, .steps li.is-now::before { background: var(--accent-fill); }
.steps li.is-now .steps-dot { box-shadow: 0 0 0 4px var(--surface), 0 0 0 7px var(--accent-tint); }
.steps li.is-now:not(.is-last) .steps-dot { animation: dot-pulse 1.4s ease-in-out infinite; }

.o-badge { display: inline-block; margin-top: 8px; padding: 2px 12px; border-radius: 99px; font-size: 13px; font-weight: 700; }
.o-badge.is-cancelled { background: rgba(164, 22, 26, 0.1); color: #a4161a; }
.o-badge.is-done { background: rgba(46, 107, 61, 0.12); color: #2e6b3d; }

.o-lines {
  display: grid;
  gap: 4px;
  margin: 12px 0 0;
  padding: 10px 0 0;
  list-style: none;
  border-top: 1px dashed var(--hairline-2);
  font-size: 15px;
}
.o-lines .qty { margin-inline-end: 6px; font-weight: 700; }
.o-total { display: flex; justify-content: space-between; margin-top: 8px; font-weight: 700; }
.o-discount {
  display: flex; justify-content: space-between; gap: 8px;
  margin-top: 6px; font-size: 13px; color: #2e6b3d;
}
.o-total.is-payable { padding-top: 6px; border-top: 1px dashed var(--hairline-2); }

/* ── کارت شطرنجی باشگاه مشتریان ── */
.loyalty-card {
  margin-top: 12px; padding: 12px;
  border: 1px solid var(--hairline-2); border-radius: 14px;
  background: var(--accent-tint);
}
.loyalty-head {
  display: flex; justify-content: space-between; gap: 8px;
  margin-bottom: 10px; font-size: 13px; font-weight: 700;
}
.loyalty-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin: 0; padding: 0; list-style: none;
}
.loyalty-cell {
  display: grid; place-items: center;
  aspect-ratio: 1.7;
  border: 1px dashed var(--hairline-2); border-radius: 10px;
  background: var(--surface);
}
.loyalty-cell.is-filled { border-style: solid; border-color: var(--accent-fill); }
.loyalty-stamp {
  width: 40%;                       /* بعد از چرخش، کادرِ مهر بزرگ‌تر می‌شود؛ ۴۰٪ تا از خانه بیرون نزند */
  height: auto;
  color: var(--accent-fill);
  display: block;
  transform: rotate(-45deg);        /* ۴۵ درجه به چپ (پادساعتگرد) */
}
.loyalty-cell.is-pending { animation: loyalty-blink 1.4s ease-in-out infinite; }
@keyframes loyalty-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
.loyalty-note { margin: 10px 0 0; font-size: 12px; color: var(--text-3); }
.o-note { margin-top: 10px; font-size: 13px; line-height: 1.9; color: var(--text-3); }
.o-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.o-actions button { flex: 1 1 auto; height: 44px; padding-inline: 14px; font-family: inherit; font-size: 14px; cursor: pointer; }
.o-actions .btn-pill { border: 0; }

@media (prefers-reduced-motion: reduce) {
  .toast, .orderbar.is-bump { animation: none; }
  .orderbar-dot, .steps-dot, .loyalty-cell.is-pending { animation: none !important; }
}
