/* Токены: поверхности берём у Telegram, акценты — свои.
   Палитра: уголь, фольга, янтарь, перец, дым, укроп. */
:root {
  --bg: var(--tg-theme-bg-color, #E9E9E6);
  --surface: var(--tg-theme-secondary-bg-color, #FFFFFF);
  --text: var(--tg-theme-text-color, #1A1714);
  --hint: var(--tg-theme-hint-color, #6F6A63);
  --separator: color-mix(in srgb, var(--hint) 22%, transparent);

  --amber: #F0A22E;
  --amber-ink: #2A1B05;
  --pepper: #C4392A;
  --dill: #3F7A4E;

  /* Мягкий янтарный градиент для акцентных кнопок и активного раздела. */
  --coals: linear-gradient(160deg, #F7B44A, #E8921F);

  /* Едва заметный блик сверху на карточках — объём без пестроты. */
  --sheen: linear-gradient(180deg, color-mix(in srgb, #fff 5%, var(--surface)), var(--surface));

  --radius: 14px;
  --radius-sm: 10px;
  --gap: 12px;
  --pad: 16px;
  --tap: 44px;

  --safe-top: var(--tg-safe-area-inset-top, 0px);
  --safe-bottom: var(--tg-safe-area-inset-bottom, 0px);

  --fast: 160ms;
  --slow: 240ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--tg-theme-bg-color, #17151A);
    --surface: var(--tg-theme-secondary-bg-color, #221F26);
    --text: var(--tg-theme-text-color, #F2F0EC);
    --hint: var(--tg-theme-hint-color, #9A948C);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Свой display в классе перебивает браузерный [hidden] — возвращаем атрибуту силу,
   иначе скелет и чипсы остаются на экране после загрузки. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: calc(var(--safe-top) + 8px) 0 calc(var(--safe-bottom) + 24px);
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ── шапка ───────────────────────────────────────────── */
.bar { padding: 4px var(--pad) 12px; }
.bar__title { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; }
.bar__note { margin-top: 6px; font-size: 13px; color: var(--hint); }
.bar__note--closed { color: var(--pepper); font-weight: 600; }

/* ── разделы ─────────────────────────────────────────── */
.chips {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  padding: 0 var(--pad) 10px; scroll-snap-type: x proximity;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 72%, transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 36px; padding: 7px 15px; scroll-snap-align: start;
  border: 1px solid var(--separator); border-radius: 999px; background: var(--surface);
  font-size: 14px; font-weight: 500;
  white-space: nowrap; transition: color var(--fast), border-color var(--fast);
}
.chip[aria-current="true"] {
  background: var(--coals); color: var(--amber-ink);
  border-color: transparent; font-weight: 600;
}

/* ── экраны ──────────────────────────────────────────── */
.screen { display: none; padding: 0 var(--pad); }
.screen--active { display: block; animation: fade var(--slow) ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-title {
  display: flex; align-items: center; gap: 12px; margin: 22px 0 10px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--hint);
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--separator); }

/* ── карточка блюда ──────────────────────────────────────
   Раздел, где у блюд есть фото или описание, показываем карточками.
   Фото нет — колонка под него не резервируется: пустой квадрат читался бы
   как непрогрузившаяся картинка, а не как сознательный выбор. */
.card {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  width: 100%; margin-bottom: var(--gap); padding: 14px; text-align: left;
  background: var(--sheen); border: 1px solid var(--separator); border-radius: var(--radius);
}
.card--photo { grid-template-columns: 96px 1fr; gap: 14px; align-items: center; padding: 10px; }
.card:active { transform: scale(0.99); }
.card__photo {
  width: 96px; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--hint) 14%, transparent);
}
.card__title { font-size: 17px; font-weight: 600; line-height: 1.25; }
.card--photo .card__title { font-size: 16px; }
.card__sub {
  margin-top: 3px; font-size: 13px; color: var(--hint);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Короткое описание — это не текст, а признак: основа, размер, вид.
   Показываем меткой, чтобы разница между «Лаваш» и «Пита» читалась с одного взгляда. */
.card__tag {
  display: inline-block; margin-top: 6px; padding: 2px 9px;
  border: 1px solid var(--separator); border-radius: 999px;
  font-size: 12px; letter-spacing: 0.02em; color: var(--hint);
}
.card__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__price { font-size: 19px; font-weight: 700; line-height: 1; }
.rub { margin-left: 2px; font-size: 0.78em; font-weight: 500; color: var(--hint); }

/* ── строка дозаказа ─────────────────────────────────────
   Соусы, добавки, напитки берут вдогонку к основному, поэтому раздел
   без единого фото и описания сжимается в список: цена и «плюс» на месте,
   лишнего веса нет. */
.row {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px;
  width: 100%; margin-bottom: 8px; padding: 10px 12px 10px 14px; text-align: left;
  background: var(--sheen); border: 1px solid var(--separator); border-radius: var(--radius-sm);
}
.row:active { transform: scale(0.995); }
.row__title { font-size: 15px; font-weight: 500; }
.row__price { font-size: 16px; font-weight: 700; line-height: 1; white-space: nowrap; }

/* ── счётчик ─────────────────────────────────────────── */
.stepper { display: inline-flex; align-items: center; gap: 2px; background: color-mix(in srgb, var(--amber) 14%, transparent); border-radius: 999px; }
.stepper__btn { min-width: var(--tap); min-height: 36px; border: 0; background: none; font-size: 20px; line-height: 1; border-radius: 999px; }
.stepper__btn:active { background: color-mix(in srgb, var(--amber) 28%, transparent); }
.stepper__qty { min-width: 28px; text-align: center; font-weight: 700; }
.add { min-height: 36px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--amber); color: var(--amber-ink); font-weight: 600; }
/* В списке дозаказа подпись не нужна — действие очевидно из контекста строки. */
.add--compact { min-width: 38px; padding: 0; font-size: 22px; line-height: 1; }

/* ── большое фото в карточке товара ──────────────────── */
.hero { width: calc(100% + var(--pad) * 2); margin-left: calc(var(--pad) * -1); aspect-ratio: 4 / 3; object-fit: cover; background: color-mix(in srgb, var(--hint) 14%, transparent); }
.product__title { margin: 14px 0 6px; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.product__price { font-size: 21px; font-weight: 700; line-height: 1; }
.product__text { margin: 10px 0 0; color: var(--hint); }
.product__label {
  margin-top: 16px; font-size: 13px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--hint);
}

/* ── корзина ─────────────────────────────────────────── */
.line { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--separator); }
.line:last-of-type { border-bottom: 0; }
.line__title { font-weight: 500; }
.line__sum { font-weight: 700; white-space: nowrap; }
.total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--separator);
  font-size: 18px; font-weight: 700;
}

/* ── добавки к блюду ─────────────────────────────────── */
.addon {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  width: 100%; margin-bottom: 8px; padding: 9px 12px; text-align: left;
  background: var(--sheen); border: 1px solid var(--separator); border-radius: var(--radius-sm);
  transition: border-color var(--fast);
}
.addon--on { border-color: var(--amber); }
.addon__mark {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 999px;
  background: color-mix(in srgb, var(--hint) 16%, transparent);
  font-size: 15px; line-height: 1;
}
.addon--on .addon__mark { background: var(--amber); color: var(--amber-ink); font-weight: 700; }
.addon__title { font-size: 15px; }
.addon__price { font-size: 15px; font-weight: 700; white-space: nowrap; }

/* ── когда заказ будет готов ─────────────────────────────
   Время выдачи не выбирают — заказ встаёт в ближайший свободный слот,
   и экрану остаётся сообщить результат, а не просить решение. */
.ready {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-top: 10px; padding: 14px;
  background: var(--sheen); border: 1px solid var(--separator); border-radius: var(--radius);
}
.ready__label { font-size: 14px; color: var(--hint); }
.ready__time { font-size: 19px; font-weight: 700; }

/* ── формы ───────────────────────────────────────────── */
.field { margin-top: 16px; }
.field__label { display: block; margin-bottom: 6px; font-size: 14px; color: var(--hint); }
.input {
  width: 100%; min-height: var(--tap); padding: 11px 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--separator); border-radius: var(--radius-sm);
  font: inherit;
}
.input:focus { border-color: var(--amber); outline: none; }
.input--error { border-color: var(--pepper); }
.error { margin-top: 6px; font-size: 13px; color: var(--pepper); }

.btn { min-height: var(--tap); padding: 12px 18px; border: 0; border-radius: var(--radius-sm); background: var(--coals); color: var(--amber-ink); font-weight: 600; }
.btn--quiet { background: var(--surface); color: var(--text); border: 1px solid var(--separator); }
.btn--wide { display: block; width: 100%; margin-top: 12px; }

/* ── статусы заказа ──────────────────────────────────── */
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: color-mix(in srgb, var(--hint) 16%, transparent); }
.status--paid, .status--cooking { background: color-mix(in srgb, var(--amber) 22%, transparent); }
.status--ready, .status--done { background: color-mix(in srgb, var(--dill) 20%, transparent); color: var(--dill); }
.status--pending { background: color-mix(in srgb, var(--pepper) 16%, transparent); color: var(--pepper); }

.order-card { display: block; width: 100%; margin-bottom: var(--gap); padding: 14px; text-align: left; background: var(--sheen); border: 1px solid var(--separator); border-radius: var(--radius); }
.order-card__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.order-num { font-weight: 700; }
.muted { color: var(--hint); font-size: 14px; }

/* ── пустые состояния, скелетоны, тосты ──────────────── */
.empty { padding: 48px 0; text-align: center; }
.empty__title { font-size: 18px; font-weight: 700; }
.empty__text { margin-top: 6px; color: var(--hint); }

.skeleton-list { display: grid; gap: var(--gap); }
.skeleton-card { height: 116px; border-radius: var(--radius); background: color-mix(in srgb, var(--hint) 12%, transparent); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

.toast {
  position: fixed; left: var(--pad); right: var(--pad); bottom: calc(var(--safe-bottom) + 16px);
  z-index: 20; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--pepper); color: #fff; font-size: 14px; animation: rise var(--slow) ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.fallback { padding: 64px var(--pad); text-align: center; }
.fallback__text { margin-bottom: 16px; color: var(--hint); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
