/* ============================================================
   Пекарня, Кумертау — mobile-first стили
   Палитра: молочный / кремовый / бежевый / карамель / графит
   ============================================================ */

:root {
  --bg: #faf6ef;            /* молочный */
  --bg-soft: #f4ece0;       /* кремовый */
  --card: #fffdf8;
  --beige: #e9dcc6;         /* тёплый бежевый */
  --caramel: #c08a4d;       /* карамельный */
  --caramel-dark: #a56f36;
  --dough: #d9b98a;         /* цвет теста */
  --ink: #38302a;           /* тёмный графит */
  --muted: #8a7d70;
  --line: #e6dccb;
  --ok: #4f7a4f;
  --err: #a45c44;

  --radius: 18px;
  --radius-s: 12px;
  --shadow: 0 6px 24px rgba(90, 70, 40, .08);
  --shadow-soft: 0 2px 10px rgba(90, 70, 40, .06);

  --tabbar-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  /* НЕ используем overflow-x:hidden — переполнение устраняется по источнику */
  min-height: 100vh;
}

img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ---------- Шапка ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;                    /* не даёт шапке вылезать за экран */
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  padding: calc(6px + var(--safe-top)) 14px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__logo { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.logo-mark { font-size: 26px; }
.logo-text { font-weight: 800; font-size: 17px; letter-spacing: .2px; display: flex; flex-direction: column; line-height: 1.1; }
.logo-city { font-size: 11px; font-weight: 500; color: var(--caramel-dark); }
.topbar__badge { font-size: 11px; color: var(--muted); white-space: nowrap; }
/* На очень узких экранах надпись не помещается — скрываем, чтобы не было
   горизонтального скролла (реальная причина, а не маскировка) */
@media (max-width: 400px) {
  .topbar__badge { display: none; }
}

/* ---------- Экран/секции ---------- */
.screen { padding: 16px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px); animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Главная ---------- */
.hero { display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.hero__media {}
.hero__img {
  aspect-ratio: 16 / 9;   /* пропорции исходного фото 1672×941 ≈ 16:9 */
  border-radius: var(--radius);
  background: linear-gradient(140deg, var(--dough), var(--caramel));
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.hero__photo { width: 100%; height: 100%; object-fit: contain; display: block; }
.hero__cap {
  position: absolute; left: 10px; bottom: 10px;
  font-size: 10px; color: rgba(255, 255, 255, .85);
  background: rgba(60, 40, 20, .35);
  padding: 4px 8px; border-radius: 999px;
}
.hero__title { font-size: 30px; line-height: 1.12; font-weight: 800; letter-spacing: -.3px; }
.hero__text { color: var(--muted); font-size: 15px; }
.hero__actions { display: flex; flex-direction: column; gap: 10px; }
.hero__features { list-style: none; display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 4px; }
.hero__features li { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.feat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--caramel); flex: none; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 50px;                       /* крупные touch-цели */
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 700; font-size: 15px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--caramel); color: #fffdf8; box-shadow: var(--shadow); }
.btn--primary:hover { background: var(--caramel-dark); }
.btn--ghost { border: 1.5px solid var(--caramel); color: var(--caramel-dark); background: transparent; }
.btn--large { min-height: 54px; font-size: 16px; }
.btn--add { min-height: 42px; padding: 0 16px; font-size: 14px; }

/* ---------- Меню ---------- */
.menu-head { margin-bottom: 12px; }
.menu-head h2 { font-size: 24px; font-weight: 800; }
.muted { color: var(--muted); font-size: 13px; }

.cats {
  display: flex; gap: 8px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 2px 10px;
  margin: 0 -16px 4px;
  padding-left: 16px; padding-right: 16px;
  scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cat-chip {
  flex: none; padding: 10px 18px;
  border-radius: 999px; background: var(--card);
  border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; color: var(--muted);
  transition: background .15s ease, color .15s ease;
}
.cat-chip.is-active { background: var(--caramel); color: #fff; border-color: var(--caramel); }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.card {
  background: var(--card); border-radius: var(--radius-s);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
}
.card__img {
  aspect-ratio: 1 / 1; background: linear-gradient(150deg, #f0e6d4, var(--beige));
  display: grid; place-items: center; font-size: 52px;
  overflow: hidden;
}
.card__photo {
  width: 100%; height: 100%;
  object-fit: cover;               /* аккуратная обрезка, ничего не растягивается */
  display: block;
}
.card__photo--contain { object-fit: contain; }  /* панорамные фото — целиком и по центру */
.card__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card__name { font-weight: 700; font-size: 15px; }
.card__desc { font-size: 12px; color: var(--muted); line-height: 1.35; }
.card__row { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card__price { font-weight: 800; font-size: 16px; color: var(--ink); }
.card__price small { font-size: 11px; color: var(--muted); font-weight: 500; }

/* счётчик количества */
.qty { display: inline-flex; align-items: center; gap: 2px; background: var(--bg-soft); border-radius: 999px; }
.qty button { width: 34px; height: 34px; font-size: 18px; font-weight: 700; color: var(--caramel-dark); border-radius: 50%; }
.qty button:active { background: var(--beige); }
.qty span { min-width: 22px; text-align: center; font-weight: 700; }

/* ---------- Корзина ---------- */
.cart-list { display: flex; flex-direction: column; gap: 10px; }
.cart-item {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 10px 12px; box-shadow: var(--shadow-soft);
}
.cart-item__img { width: 52px; height: 52px; border-radius: 10px; background: linear-gradient(150deg, #f0e6d4, var(--beige)); display: grid; place-items: center; font-size: 28px; flex: none; overflow: hidden; }
.cart-item__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cart-item__info { flex: 1; min-width: 0; }
.cart-item__name { font-weight: 700; font-size: 14px; }
.cart-item__price { font-size: 12px; color: var(--muted); }
.cart-item__del { width: 36px; height: 36px; color: var(--err); font-size: 18px; border-radius: 50%; }
.cart-item__del:active { background: var(--bg-soft); }
.cart-empty { text-align: center; padding: 40px 0; display: flex; flex-direction: column; gap: 14px; color: var(--muted); }
.cart-total { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px; box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.cart-total__row { display: flex; flex-direction: column; }
.cart-total__row span { font-size: 12px; color: var(--muted); }
.cart-total__row strong { font-size: 20px; }

/* ---------- Форма ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 13px; font-weight: 600; color: var(--ink); }
.field input, .field textarea {
  font: inherit; width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--line); border-radius: var(--radius-s);
  background: var(--card); color: var(--ink);
  font-size: 16px;                       /* >=16px: Safari не зумит при фокусе */
  -webkit-appearance: none; appearance: none;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--caramel); }
.field input.is-invalid { border-color: var(--err); }
.agree { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 16px 0; }
.agree input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--caramel); }
.form-err { color: var(--err); font-size: 14px; margin-top: 10px; min-height: 20px; }
.order-summary {
  background: var(--bg-soft); border-radius: var(--radius-s); padding: 6px 14px;
  font-size: 14px; margin-bottom: 10px;
}
.order-item { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.order-item:last-child { border-bottom: none; }
.order-item--total { justify-content: space-between; font-weight: 800; padding-top: 11px; }
.order-item--total span { font-weight: 600; color: var(--muted); font-size: 13px; }
.order-item--total b { font-size: 17px; }
.order-item__img {
  width: 48px; height: 48px; flex: none; border-radius: 10px; overflow: hidden;
  background: linear-gradient(150deg, #f0e6d4, var(--beige));
  display: grid; place-items: center; font-size: 26px;
}
.order-item__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.order-item__info { flex: 1; min-width: 0; }
.order-item__name { font-weight: 700; font-size: 14px; }
.order-item__calc { font-size: 12px; color: var(--muted); }
.order-item__calc b { color: var(--ink); }

/* ---------- Подтверждение ---------- */
.done { text-align: center; padding: 48px 16px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.done__icon { width: 72px; height: 72px; border-radius: 50%; background: var(--caramel); color: #fff; font-size: 34px; display: grid; place-items: center; box-shadow: var(--shadow); }
.done h2 { font-size: 22px; }

/* ---------- Нижняя навигация ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  position: relative; touch-action: manipulation;
}
.tabbar__item.is-active { color: var(--caramel-dark); }
.tabbar__icon { font-size: 21px; line-height: 1; }
.tabbar__count {
  position: absolute; top: 7px; right: 50%;

  transform: translateX(16px);
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--caramel); color: #fff;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}

/* ---------- Блоки главной ---------- */
.home-block { margin-top: 26px; }
.home-block h2 { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.home-block__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.home-block__head h2 { margin-bottom: 0; }
.link-btn { color: var(--caramel-dark); font-weight: 700; font-size: 14px; padding: 6px 0; }

/* «Популярное» — горизонтальная лента */
.pop-list {
  display: flex; gap: 12px; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px; padding: 2px 16px 10px;
  scrollbar-width: none;
}
.pop-list::-webkit-scrollbar { display: none; }
.pop-list .card { flex: 0 0 150px; }

/* Шаги «Как заказать» */
.steps { list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 12px; }
.steps li {
  counter-increment: step; position: relative;
  padding: 14px 14px 14px 52px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-s); font-size: 14px;
}
.steps li::before {
  content: counter(step);
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--caramel); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
}

/* «Почему мы» */
.reasons { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.reasons li {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 12px 14px; font-size: 14px;
}

/* Адрес и контакты */
.contacts { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }

/* ---------- Планшет/десктоп ---------- */
@media (min-width: 720px) {
  .screen { max-width: 1080px; margin: 0 auto; padding: 28px 32px calc(var(--tabbar-h) + 40px); }
  .hero { flex-direction: row; align-items: center; gap: 28px; padding-top: 24px; }
  .hero__media { flex: 1; }
  .hero__content { flex: 1; }
  .hero__title { font-size: 40px; }
  .hero__actions { flex-direction: row; }
  .topbar { padding-left: 32px; padding-right: 32px; }
  .tabbar { max-width: 620px; left: 50%; right: auto; transform: translateX(-50%); border-radius: 20px 20px 0 0; }
  .cart-item__img { width: 64px; height: 64px; font-size: 34px; }
}

@media (min-width: 1000px) {
  .hero__title { font-size: 46px; }
  .grid { gap: 16px; }
  .card__img { font-size: 64px; }
}

/* ---------- PWA-заготовка ---------- */
@media (display-mode: standalone) {
  body { padding-top: var(--safe-top); }
}

/* Уменьшенные движения — доступность */
@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  * { transition: none !important; }
}