/* ============================================================
   Гастроном Mini App — Soviet Retro Style
   Fonts: Playfair Display (display) + PT Sans (body)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700;900&family=PT+Sans:wght@400;700&display=swap');

/* ── Переменные ─────────────────────────────────────────── */
:root {
  --bg:          #F5F0E8;
  --bg-card:     #FFFFFF;
  --bg-dark:     #1C1C1C;
  --red:         #C0392B;
  --red-dark:    #962D22;
  --green:       #2C5F2E;
  --gold:        #B8860B;
  --text:        #2D2D2D;
  --text-muted:  #7A6E5F;
  --border:      #D4C5A9;
  --shadow:      rgba(0,0,0,0.12);
  --radius:      12px;
  --radius-sm:   8px;
  --tg-bg:       var(--tg-theme-bg-color, var(--bg));
  --tg-text:     var(--tg-theme-text-color, var(--text));
  --transition:  0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset + Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'PT Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Шапка ──────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-dark);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.header-logo {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.header-logo .logo-ru {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 900;
  color: #F5F0E8;
  letter-spacing: 0.04em;
}

.header-logo .logo-sub {
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Кнопка корзины */
.cart-btn {
  position: relative;
  background: var(--red);
  border: none;
  border-radius: 50px;
  padding: 8px 16px 8px 12px;
  color: white;
  font-family: 'PT Sans', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition), transform var(--transition);
}

.cart-btn:active { transform: scale(0.95); background: var(--red-dark); }

.cart-btn .cart-icon { font-size: 18px; }

.cart-badge {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--gold);
  color: #1C1C1C;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
}

.cart-badge.visible { display: flex; animation: pop 0.3s cubic-bezier(0.34,1.56,0.64,1); }

@keyframes pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* ── Категории ──────────────────────────────────────────── */
.categories {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.categories::-webkit-scrollbar { display: none; }

.cat-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 50px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: 'PT Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}

.cat-btn:hover { border-color: var(--red); color: var(--red); }

.cat-btn.active {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

/* ── Сетка товаров ──────────────────────────────────────── */
.products-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
  padding-bottom: 100px;
}

/* Анимация появления карточек */
.product-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px var(--shadow);
  opacity: 0;
  transform: translateY(16px);
  animation: fadeUp 0.4s forwards;
  transition: box-shadow var(--transition), transform var(--transition);
}

.product-card:active { transform: scale(0.98); }

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

/* Задержка для каждой карточки */
.product-card:nth-child(1)  { animation-delay: 0.02s; }
.product-card:nth-child(2)  { animation-delay: 0.05s; }
.product-card:nth-child(3)  { animation-delay: 0.08s; }
.product-card:nth-child(4)  { animation-delay: 0.11s; }
.product-card:nth-child(5)  { animation-delay: 0.14s; }
.product-card:nth-child(6)  { animation-delay: 0.17s; }
.product-card:nth-child(7)  { animation-delay: 0.20s; }
.product-card:nth-child(8)  { animation-delay: 0.23s; }
.product-card:nth-child(9)  { animation-delay: 0.26s; }
.product-card:nth-child(10) { animation-delay: 0.29s; }
.product-card:nth-child(11) { animation-delay: 0.32s; }
.product-card:nth-child(12) { animation-delay: 0.35s; }
.product-card:nth-child(13) { animation-delay: 0.38s; }
.product-card:nth-child(14) { animation-delay: 0.41s; }

/* Фото / эмодзи товара */
.product-image {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #F5F0E8 0%, #EDE4D3 100%);
  font-size: 52px;
  position: relative;
  overflow: hidden;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

/* Бейдж предзаказа */
.preorder-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--green);
  color: white;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 4px;
}

/* Декоративная линия под фото — советский стиль */
.product-stripe {
  height: 4px;
  background: repeating-linear-gradient(
    90deg,
    var(--red) 0px, var(--red) 8px,
    var(--bg-dark) 8px, var(--bg-dark) 12px
  );
}

.product-info {
  padding: 10px 10px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-name {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
}

.product-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  flex: 1;
  margin-bottom: 10px;
}

.product-price {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--red);
}

.product-price .price-preorder {
  font-size: 11px;
  color: var(--green);
  font-family: 'PT Sans', sans-serif;
  font-weight: 400;
}

/* Кнопка добавления в корзину / счётчик */
.add-btn {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-dark);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'PT Sans', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.add-btn:active { transform: scale(0.96); }
.add-btn:hover { background: var(--red); }

/* Счётчик в корзине (заменяет кнопку) */
.qty-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  background: #F5F0E8;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.qty-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-dark);
  color: white;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:hover { background: var(--red); }

.qty-num {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  min-width: 32px;
  text-align: center;
}

/* ── Боковая панель корзины ─────────────────────────────── */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  backdrop-filter: blur(2px);
}

.cart-overlay.open { opacity: 1; pointer-events: all; }

.cart-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 85vh;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cart-sheet.open { transform: translateY(0); }

.cart-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}

.cart-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cart-title {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  animation: fadeUp 0.25s forwards;
}

.cart-item-emoji {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #F5F0E8, #EDE4D3);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-name {
  font-family: 'Playfair Display', serif;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-price {
  font-size: 13px;
  color: var(--red);
  font-weight: 700;
  margin-top: 2px;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cart-item-qty .qty-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 15px;
}

.cart-item-qty .qty-num { font-size: 14px; }

.cart-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.cart-total-label {
  font-size: 14px;
  color: var(--text-muted);
}

.cart-total-sum {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  letter-spacing: 0.02em;
}

.btn-primary:active { transform: scale(0.98); background: var(--red-dark); }

.cart-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.cart-empty .empty-icon { font-size: 48px; margin-bottom: 12px; }
.cart-empty p { font-size: 15px; }

/* ── Экран оформления заказа ────────────────────────────── */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 300;
  overflow-y: auto;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active { display: block; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.screen-header {
  background: var(--bg-dark);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.screen-title {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 700;
  color: white;
}

.screen-body { padding: 20px 16px 100px; }

/* Форма */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: white;
  font-family: 'PT Sans', sans-serif;
  font-size: 16px;
  color: var(--text);
  transition: border-color var(--transition);
  -webkit-appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--red);
}

.form-input::placeholder { color: #B0A89A; }

textarea.form-input {
  resize: none;
  min-height: 100px;
}

/* Сводка заказа */
.order-summary {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.order-summary-header {
  background: var(--bg-dark);
  padding: 12px 16px;
}

.order-summary-header h3 {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  color: white;
  font-weight: 700;
}

.order-summary-items { padding: 12px 16px; }

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #F0EBE1;
  font-size: 14px;
}

.summary-item:last-child { border-bottom: none; }

.summary-item-name { color: var(--text); }
.summary-item-price { color: var(--red); font-weight: 700; }

.summary-total {
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
  background: #FFF8F0;
  border-top: 2px solid var(--border);
}

.summary-total-label {
  font-family: 'Playfair Display', serif;
  font-size: 16px;
  font-weight: 700;
}

.summary-total-sum {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 900;
  color: var(--red);
}

/* Подтверждение контактов */
.confirm-info {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.confirm-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid #F0EBE1;
  font-size: 14px;
}

.confirm-row:last-child { border-bottom: none; }

.confirm-icon { font-size: 16px; flex-shrink: 0; }
.confirm-value { color: var(--text); line-height: 1.4; }

/* Декоративный разделитель советский */
.soviet-divider {
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    var(--red) 0px, var(--red) 8px,
    var(--bg-dark) 8px, var(--bg-dark) 14px,
    var(--gold) 14px, var(--gold) 22px,
    var(--bg-dark) 22px, var(--bg-dark) 28px
  );
  margin: 20px 0;
  border-radius: 3px;
}

/* Успех */
.success-screen {
  text-align: center;
  padding: 60px 24px;
}

.success-icon {
  font-size: 72px;
  margin-bottom: 16px;
  animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bounceIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.success-title {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 12px;
}

.success-text {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 280px;
  margin: 0 auto;
}

/* ── Тост уведомление ───────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-dark);
  color: white;
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  z-index: 500;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Адаптив ────────────────────────────────────────────── */
@media (min-width: 400px) {
  .products-grid { grid-template-columns: repeat(2, 1fr); }
}
