/**
 * cards.css - the dish card and the order card, shared by the guest
 * client (`web/public`) and the new waiter PWA (`web-orders/`,
 * waiter.waitervoice.ai). The previous the old waiter host waiter
 * page (the previous waiter page) is archived as of waitervoice-nlex, phase 11.
 */

/* ---------- Карточка (§8.2) ---------- */

.card {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;              /* §3.2 — скроллится содержимое карточки */
  overscroll-behavior: contain;  /* и не «пробивает» в карусель/страницу  */
  background: var(--wv-white);
  border: 1px solid var(--wv-border);
  border-radius: var(--wv-r-card);
  box-shadow: var(--wv-shadow);
  animation: wv-card-in var(--wv-t-card) both;
}
/* The `hidden` attribute must win over the `display: flex` above — an
   author rule beats the browser's own `[hidden] { display: none }`. */
.card[hidden] { display: none; }
/* Список анимаций, а не замена: иначе при снятии класса wv-card-in
   стартует заново, и карточка «моргает» как после refresh (bcf.5). */
.card--flash { animation: wv-card-in var(--wv-t-card) both, wv-flash 600ms ease-out; }

/* Временная карточка (waitervoice-bcf.11): кнопка «назад» у левого верхнего
   угла, центр чуть внутри карточки по диагонали, часть кнопки снаружи. Карточка поэтому не обрезает
   содержимое (overflow: visible), а скроллится внутренний .card__scroll
   со скруглением карточки. */
.card--temp { position: relative; overflow: visible; }
/* waitervoice-bui6: у «Корзины» и «Заказа» угловые кнопки выходят за угол
   карточки — она их не обрезает, а прокрутка живёт во внутреннем слое. */
.card[data-card-id="cart"],
.card[data-card-id="orders"] { position: relative; overflow: visible; }
/* waitervoice-bui6: у этих двух карточек кнопки стоят друг напротив друга
   в зазоре 12px между карточками — поэтому они меньше и с центром глубже
   внутрь карточки: центр в 8px от её края, круг 26px. Расстояние между
   центрами соседних кнопок — 12 + 8 + 8 = 28px, больше диаметра, круги не
   пересекаются. Временные карточки (одна кнопка) не тронуты. */
.card[data-card-id="cart"] .card__back,
.card[data-card-id="orders"] .card__back {
  width: 26px; height: 26px;
  top: -5px;
  inset-inline-start: -5px;
  inset-inline-end: auto;
}
.card[data-card-id="cart"] .card__back--next,
.card[data-card-id="orders"] .card__back--next {
  inset-inline-start: auto;
  inset-inline-end: -5px;
}
.card__scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: inherit;
}
/* waitervoice-y8wv.11: на месте крестика — кнопка «назад» (шеврон ‹‹).
   Вид тот же, что у кнопки карточки раздела (`.catcard__nav`): акцентный круг.
   waitervoice-bui6: та же кнопка у «Корзины» и «Заказа», а «вперёд» (››) —
   у правого угла. */
.card__back {
  position: absolute;
  top: -10px;                    /* центр на 6px внутрь по диагонали от угла */
  inset-inline-start: -10px;
  z-index: 2;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  padding: 0;
  border: 1.5px solid var(--wv-accent);
  border-radius: 50%;
  background: var(--wv-white);
  box-shadow: 0 1px 4px rgba(17, 24, 39, 0.18);
  color: var(--wv-accent);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--wv-t-fast);
}
.card__back--next { inset-inline-start: auto; inset-inline-end: -10px; }
/* Кнопки без цели (заказа ещё не было) не показываются вовсе. */
.card__back[hidden] { display: none; }
.card__back:active { background: var(--wv-accent-50); }
.card__back:focus-visible { outline: 2px solid var(--wv-accent); outline-offset: 2px; }

@keyframes wv-card-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes wv-flash {
  0%   { box-shadow: var(--wv-shadow), 0 0 0 0 rgba(0, 198, 248, 0.7); }
  40%  { box-shadow: var(--wv-shadow), 0 0 0 4px rgba(0, 198, 248, 0.45); }
  100% { box-shadow: var(--wv-shadow), 0 0 0 0 rgba(0, 198, 248, 0); }
}

/* ---------- Карточка блюда (§8.6.2) ---------- */

/* ---------- Карточка блюда (§8.6.2) ---------- */

/* waitervoice-bcf.15: фото + корзина в левом нижнем углу (верхний левый
   занят кнопкой «назад»). waitervoice-km3f: над фото лежит тот же
   контрол корзины, что в подвале карточки — круглая кнопка при qty 0 и
   счётчик при qty > 0. */
.dish__media { position: relative; }
.dish__media .dish__photo { display: block; }
.dish__photo-cart {
  position: absolute;
  inset-inline-start: 12px;
  bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
/* Кнопка «в корзину» поверх фото: светлый круг, как раньше. */
.dish__photo-cart .basket__add,
.dish__photo-cart .basket__cart {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 1px solid var(--wv-accent-line);
  border-radius: 50%;
  background: #fff;
  color: var(--wv-accent);
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.22);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  cursor: pointer;
  transition: transform var(--wv-t-fast), background var(--wv-t-fast);
}
.dish__photo-cart .basket__add:active,
.dish__photo-cart .basket__cart:active { transform: scale(0.92); background: #fff; }
.dish__photo-cart .basket__add:focus-visible,
.dish__photo-cart .basket__cart:focus-visible { outline: 2px solid var(--wv-accent); outline-offset: 2px; }
/* Счётчик поверх фото: белая подложка — иначе цифры не читаются на
   любом снимке. */
.dish__photo-cart .basket__step {
  background: #fff;
  border: 1px solid var(--wv-border);
}
/* waitervoice-km3f: едва заметное дыхание циана вокруг круга «в корзину» (qty 0).
   У иконки рядом со счётчиком (.basket__cart) свечения нет. */
@keyframes wv-photo-cart-glow {
  0%, 100% { box-shadow: 0 2px 8px rgba(17, 24, 39, 0.22), 0 0 0 0 rgba(0, 198, 248, 0); }
  50%      { box-shadow: 0 2px 8px rgba(17, 24, 39, 0.22), 0 0 14px 4px rgba(0, 170, 255, 0.95), 0 0 0 1.5px rgba(0, 170, 255, 0.85); }
}
.dish__photo-cart .basket__add { animation: wv-photo-cart-glow 2.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .dish__photo-cart .basket__add {
    animation: none;
    box-shadow: 0 2px 8px rgba(17, 24, 39, 0.22), 0 0 10px 3px rgba(0, 170, 255, 0.8), 0 0 0 1.5px rgba(0, 170, 255, 0.7);
  }
}
.dish__photo {
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  border-radius: calc(var(--wv-r-card) - 1px) calc(var(--wv-r-card) - 1px) 0 0;
  background: var(--wv-skeleton);
}
.dish__body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.dish__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dish__name { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
/* Плашка «ккал / вес» справа в шапке (waitervoice-bcf.7, вариант C):
   компактные шрифты, чтобы имя блюда получило максимум ширины. */
.dish__stat {
  flex-shrink: 0;
  min-width: 62px;
  border: 0;
  background: var(--wv-chip);
  color: var(--wv-text);
  border-radius: 10px;
  padding: 4px 8px;
  font-variant-numeric: tabular-nums;
}
.dish__stat-row { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; line-height: 1.25; }
.dish__stat-row + .dish__stat-row { border-top: 1px solid var(--wv-border); margin-top: 3px; padding-top: 3px; }
.dish__stat-row b { font-size: 14px; font-weight: 800; }
.dish__stat-row span { font-size: 9px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--wv-text-muted); }
.dish__stat-row + .dish__stat-row b { font-size: 13px; font-weight: 700; }
.dish__desc { font-size: 15px; font-weight: 450; line-height: 1.5; color: var(--wv-text-muted); }
/* waitervoice-jv4p.2: the name in the menu's language — the description's
   font, under the translated name. */
.dish__orig { font-size: 15px; font-weight: 450; line-height: 1.5; color: var(--wv-text-muted); margin-top: 2px; overflow-wrap: anywhere; }

/* The label column is as wide as the LONGEST label (waitervoice-idqr): a
   fixed width let a long word (Georgian «ნახშირწყლები») run over the bar.
   `subgrid` keeps the three bars aligned across the rows. */
.macros {
  display: grid;
  grid-template-columns: minmax(4.2rem, max-content) minmax(2rem, 1fr) auto;
  column-gap: 10px;
  row-gap: 6px;
}
.macros li {
  display: grid;
  grid-template-columns: subgrid;
  grid-column: 1 / -1;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}
.macros span:first-child { color: var(--wv-text-muted); overflow-wrap: anywhere; }
.macros b { height: 6px; border-radius: 999px; background: var(--wv-skeleton); overflow: hidden; }
.macros b i { display: block; height: 100%; border-radius: inherit; }
.macros .m-p i { background: var(--wv-cyan); }
.macros .m-f i { background: var(--wv-amber); }
.macros .m-c i { background: var(--wv-carb); }
.macros u { text-decoration: none; font-variant-numeric: tabular-nums; }

.sect__title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--wv-text-muted);
  margin-bottom: 8px;
}
/* Компактные чипы (waitervoice-bcf.8): мельче и плотнее, идут в поток по
   ширине карточки. Бейджи — отдельным блоком под ингредиентами (bcf.12). */
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chips span {
  background: var(--wv-chip);
  border: 0;
  color: var(--wv-text);
  border-radius: var(--wv-r-chip);
  padding: 3px 9px;
  font-size: 11.5px;
  line-height: 1.3;
  font-weight: 700;
}
.chips span.badge { background: var(--wv-skeleton); }
.dish__ings { font-size: 15px; font-weight: 450; line-height: 1.5; }
/* Футер карточки: цена слева, «в корзину» справа (waitervoice-bcf.9). */
.dish__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dish__price { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Общие строки корзины и заказа (§8.6.3) ---------- */

/* Строка корзины (waitervoice-bcf.14): N × [миниатюра] имя … сумма. */
.cart__pick,
.orders__pick {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 4px 0; border: 0; background: none; text-align: start;
  font: inherit; font-size: 17px; color: inherit; cursor: pointer;
}
.cart__qty { flex-shrink: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.cart__thumb,
.orders__thumb {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: var(--wv-r-tag);
  object-fit: cover;
  background: var(--wv-skeleton);
}
.cart__name,
.orders__name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.cart__sum,
.orders__sum { flex-shrink: 0; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cart__pick:active,
.orders__pick:active { opacity: 0.6; }
.cart__pick:focus-visible,
.orders__pick:focus-visible { outline: 2px solid var(--wv-accent); outline-offset: 2px; border-radius: var(--wv-r-tag); }
.cart__note,
.orders__note { font-size: 15px; color: var(--wv-text-muted); margin-top: 2px; }
.cart__sep { height: 1px; background: var(--wv-border); }
/* waitervoice-ybb7.4 (`docs/feature-service-charge.md` §7): the two
   muted rows that break the total down — `Subtotal` and
   `Service charge 10%`. Same pair in the cart and on the order card, so
   one rule for both. `.orders__line` lines its text up with the text
   inside the dark `.orders__total` bar (16px), and pulls the pair
   together against the card's 14px gap. */
.cart__line,
.orders__line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 15px; font-weight: 500; color: var(--wv-text-muted);
  font-variant-numeric: tabular-nums;
}
.cart__line b,
.orders__line b { font-weight: 600; }
.cart__total,
.orders__total { display: flex; justify-content: space-between; align-items: baseline; font-size: 17px; font-weight: 700; }
.cart__total b,
.orders__total b { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Карточка истории заказов (§8.6.3a) ---------- */

/* ---------- Карточка истории заказов (§8.6.3a, waitervoice-xc1) ---------- */

.orders { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
/* waitervoice-b5cb.12: title on the left, Mine / Whole table on the
   right of the same row. The title may shrink and wrap; the switcher
   never does. */
.orders__head-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.orders__title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; min-width: 0; }
/* waitervoice-bui6: в шапке карточки — только заголовок по центру; кнопок
   навигации в шапке больше нет (навигация — в угловых кнопках карточки). */
.card-head { position: relative; min-height: 36px; display: flex; align-items: center; justify-content: center; }
.card-head__title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; text-align: center; }
.orders__view-row { display: flex; justify-content: center; }
/* Шапка и подпись — одна шапка: без отрицательного отступа между ними
   зиял бы пробел в 14px, заданный карточке. */
.orders > .card-head + .orders__table { text-align: center; margin-top: -10px; }
/* waitervoice-b5cb.13: the title (in the head) and this line are siblings
   in `.orders`, so the card's 14px gap fell between them and read as a
   hole. The negative margin leaves 4px: they are one header. */
.orders__table { font-size: 15px; color: var(--wv-text-muted); margin-top: -10px; }
.orders__items { display: flex; flex-direction: column; gap: 10px; }
.orders__block { display: flex; flex-direction: column; gap: 8px; }
.orders__head { display: flex; justify-content: space-between; align-items: center; }

/* waitervoice-b5cb.10: four money levels, four different weights. A dish
   sum is quiet, an order subtotal is small and labelled, a guest's total
   closes that guest's box, and the card total is the one filled bar.
   Before this they were all bold 15-17px and read as one column. These
   rules come after the shared `.cart__*, .orders__*` ones on purpose:
   the basket keeps its own look. */
.orders__sum { font-weight: 500; color: var(--wv-text-muted); }

/* waitervoice-nyp.2.3: segmented Mine / Whole-table control. Sits
   flush with the title row, same chip tokens as the existing
   `.orders__status`. Tabs are 32px tall (≥ 44px touch zone with
   padding), the active tab gets the accent color. */
.orders__view {
  display: inline-flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 2px;
  border-radius: var(--wv-r-chip);
  background: var(--wv-bg-soft);
  border: 1px solid var(--wv-border);
}
.orders__view button {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 6px 14px;
  min-height: 32px;
  border-radius: calc(var(--wv-r-chip) - 4px);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.orders__view button[aria-selected="true"] {
  background: var(--wv-accent);
  color: #fff;
}
.orders__view button:focus-visible {
  outline: 2px solid var(--wv-accent);
  outline-offset: 2px;
}

/* waitervoice-b5cb.10: one box per guest in the Whole-table view (and
   always for the waiter). The head names the guest; the guest's sum is
   the box's last row, under a stronger rule than the one between orders. */
.orders__part {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px;
  border: 1px solid var(--wv-border);
  border-radius: var(--wv-r-bubble);
  background: var(--wv-bg-soft);
}
.orders__guest {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 800;
}
.orders__guest-no {
  width: 26px; height: 26px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--wv-navy);
  color: var(--wv-white);
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.orders__part-total {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-top: 8px;
  border-top: 1px solid var(--wv-border-strong);
  font-size: 15px; font-weight: 700;
}
.orders__part-total b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.orders__no {
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--wv-text-muted);
}
.orders__status {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 2px 10px;
  border-radius: var(--wv-r-chip);
  background: var(--wv-accent-50);
  color: var(--wv-accent);
  font-size: 13px; font-weight: 700;
}
.orders__subtotal {
  display: flex; justify-content: flex-end; align-items: baseline; gap: 6px;
  font-size: 13px; font-weight: 600;
  color: var(--wv-text-muted);
  font-variant-numeric: tabular-nums;
}

/* waitervoice-rk0x.4 — one block per order
   (`web/docs/feature-guest-order-cancel.md` §1.3, the approved mockups in
   `web/docs/mockups/guest-orders/`). Each order is a bordered white block
   with a radius of 16; the count stands at the end of the dish name; the
   status chip turns green once the waiter accepted the order; the totals
   live in a block of their own instead of the dark navy plate.

   These rules come AFTER the shared ones on purpose: `.orders__status`,
   `.orders__part` and `.orders__subtotal` are single-class selectors, so
   the LAST rule of the same specificity is the one that applies. Pasting
   this block above them left the chip blue, the subtotal jammed to the
   right and the viewer's box without its outline — the overrides were
   never applied at all. `web/shared/cards-css-cascade.test.js` guards the
   order. */
.orders__block { gap: 0; border: 1px solid var(--wv-border); border-radius: var(--wv-r-bubble); background: var(--wv-white); overflow: hidden; }
.orders__head { padding: 11px 14px; border-bottom: 1px solid var(--wv-border); }
.orders__status--accepted { background: #e8f7ee; color: #116a3a; }   /* the pair .bill__done uses */
.orders__items { gap: 0; }
.orders__items > div + div { border-top: 1px solid var(--wv-border); }
.orders__pick { padding: 10px 14px; }
.orders__note { padding: 0 14px 10px; margin-top: -4px; }
.orders__mult { font-weight: 800; }
.orders__subtotal { justify-content: space-between; padding: 10px 14px; border-top: 1px solid var(--wv-border); font-size: 15px; font-weight: 500; }
.orders__subtotal b { font-weight: 700; color: var(--wv-text); }
/* the viewer's own guest box */
.orders__part--mine { border-color: var(--wv-accent-line); }
/* totals: one separate block (it replaces the navy plate of `.orders__total`
   and the loose `.orders__line` rows of the order card) */
.orders__sums { border: 1px solid var(--wv-border); border-radius: var(--wv-r-bubble); background: var(--wv-white); overflow: hidden; }
.orders__sums > div { padding: 10px 14px; margin: 0; }
.orders__sums > div + div { border-top: 1px solid var(--wv-border); }
.orders__sums .orders__line { font-size: 15px; font-weight: 500; color: var(--wv-text-muted); }
.orders__sums .orders__total { background: none; color: var(--wv-text); border-radius: 0; font-size: 17px; font-weight: 700; }
.orders__sums .orders__total b { font-size: 20px; font-weight: 800; }

.orders__empty {
  font-size: 15px; font-weight: 450; line-height: 1.5;
  color: var(--wv-text-muted);
}

.cart__done {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px;
  border-radius: var(--wv-r-chip);
  background: var(--wv-accent-50);
  color: var(--wv-accent);
  font-size: 17px; font-weight: 700;
}

/* waitervoice-b5cb.4/.5: QR for the waiter under the order total. */
.orders__qr {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding-top: 14px; border-top: 1px solid var(--wv-border);
}
/* waitervoice-6b0r: when the host can copy, the block is a <button>.
   Reset it to the plain div it used to be, so the card looks identical
   and only the affordance changes. `cursor: pointer` is the visible
   half of "this does something"; the focus ring comes from the global
   :focus-visible rule. */
button.orders__qr {
  width: 100%;
  border: 0; border-top: 1px solid var(--wv-border);
  background: none; font: inherit; color: inherit;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button.orders__qr:active { opacity: 0.7; }
.orders__qr-img { width: 168px; height: 168px; }
.orders__qr-cap { font-size: 13px; font-weight: 600; color: var(--wv-text-muted); text-align: center; }
/* waitervoice-xwzc.4: the Bill block under the guest's total. */
.bill { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.bill__btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; border: 0; border-radius: 16px; background: var(--wv-accent); color: #fff; font: inherit; font-size: 17px; font-weight: 700; cursor: pointer; }
.bill__btn svg { width: 20px; height: 20px; }
.bill__btn[disabled] { opacity: 0.55; cursor: default; }
.bill__done { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px; background: #e8f7ee; color: #116a3a; font-size: 16px; font-weight: 600; line-height: 1.3; }
.bill__done svg { width: 22px; height: 22px; flex: none; }
.bill__done small { display: block; font-size: 13px; font-weight: 500; opacity: 0.8; }
.bill__err { font-size: 14px; font-weight: 500; color: #b3261e; text-align: center; margin: 0; }
.bill__spin { width: 18px; height: 18px; border: 3px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; border-radius: 50%; animation: wv-bill-spin 1s linear infinite; }
@keyframes wv-bill-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bill__spin { animation: none; } }

/* waitervoice-rk0x.5 (`web/docs/feature-guest-order-cancel.md` §1.1): the
   cancel zone under the guest's own unaccepted order — a muted centred
   line and the button.

   The button is the app's own `.bill__btn` (the "Bill" button's style:
   radius 16px, 52px tall, the accent fill, white text) — it is NOT
   redefined here, and `.bill__btn[disabled]` already dims the state
   while the request is in flight.

   The rules stand AFTER the base orders rules on purpose: an override
   declared before the rule it overrides loses the cascade (same
   specificity, later wins) — see `cards-css-cascade.test.js`. */
.orders__cancel {
  border-top: 1px solid var(--wv-border);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.orders__cancel p {
  margin: 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.35;
  color: var(--wv-text-muted);
}
