/* Базовые переменные — тёплая ресторанная палитра */
:root {
  --header-height: 7vh;
  --gap: clamp(1rem, 2.2vw, 2rem);
  --card-min-w: 270px;
  --card-max-w: 380px;
  --content-max: 2400px;
  --font-title: clamp(1.4rem, 3.5vw, 3rem);
  --font-body: clamp(1.05rem, 2.2vw, 1.6rem);
  --font-badge: clamp(1.35rem, 3.5vw, 2.25rem);
  --font-badge-label: clamp(1.05rem, 2.5vw, 1.5rem);
  --font-small: clamp(0.8rem, 1.6vw, 1.1rem);
  --radius: clamp(12px, 2vw, 24px);
  --radius-badge: clamp(8px, 1.2vw, 14px);
  --bg: #0c0b0a;
  --bg-subtle: #121110;
  --surface: #1c1a18;
  --surface-card: #1a1816;
  --accent: #d4a84b;
  --accent-dim: rgba(212, 168, 75, 0.85);
  --text: #f2efe9;
  --text-muted: #9a958c;
  --border: rgba(212, 168, 75, 0.15);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg);
  background-image: radial-gradient(ellipse 120% 80% at 50% -20%, rgba(212, 168, 75, 0.06), transparent 50%);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Анимации при обновлении данных */
@keyframes headerUpdate {
  0% { box-shadow: 0 0 0 0 rgba(212, 168, 75, 0); }
  35% { box-shadow: 0 0 0 10px rgba(212, 168, 75, 0.2); }
  70% { box-shadow: 0 0 0 4px rgba(212, 168, 75, 0.12); }
  100% { box-shadow: 0 0 0 0 rgba(212, 168, 75, 0); }
}

.header-updated {
  animation: headerUpdate 0.7s ease;
}

.header-celebrate {
  animation: headerCelebrate 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes headerCelebrate {
  0% { filter: blur(0); box-shadow: 0 0 0 0 rgba(212, 168, 75, 0); }
  15% { filter: blur(4px); box-shadow: 0 0 20px 4px rgba(212, 168, 75, 0.35); }
  50% { filter: blur(2px); box-shadow: 0 0 24px 6px rgba(212, 168, 75, 0.3); }
  100% { filter: blur(0); box-shadow: 0 0 0 0 rgba(212, 168, 75, 0); }
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.menu-grid.menu-updated .dish-card {
  animation: cardEnter 0.5s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.dish-card-celebrate {
  animation: cardCelebrate 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cardCelebrate {
  0% { filter: blur(0); box-shadow: var(--shadow); }
  15% { filter: blur(4px); box-shadow: 0 0 28px 6px rgba(212, 168, 75, 0.35); transform: scale(1.02); }
  50% { filter: blur(2px); box-shadow: 0 0 32px 8px rgba(212, 168, 75, 0.3); transform: scale(1.02); }
  100% { filter: blur(0); box-shadow: var(--shadow); transform: scale(1); }
}

.confetti-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confetti-fly 1.2s ease-out forwards;
}

@keyframes confetti-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0.3) rotate(720deg); }
}

/* Шапка */
.header {
  height: var(--header-height);
  min-height: 44px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 1.25rem;
}

.header-inner {
  width: 100%;
  max-width: 1600px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.header-inner .logo { justify-self: start; }
.header-address-wrap { justify-self: center; text-align: center; }
.header-inner .header-phone-wrap { justify-self: end; }

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-img {
  max-height: calc(var(--header-height) - 1rem);
  max-width: 110px;
  object-fit: contain;
}

.logo-img[hidden] {
  display: none;
}

.logo-text {
  font-size: var(--font-title);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.header-phone-wrap {
  display: flex;
  align-items: center;
}

.header-phone-badge {
  display: inline-block;
  padding: 0.45rem 1rem;
  background: #fff;
  color: #1a1816;
  font-size: var(--font-small);
  font-weight: 600;
  font-family: 'Segoe UI', system-ui, sans-serif;
  border-radius: var(--radius-badge);
  white-space: nowrap;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-phone-badge:empty {
  display: none;
}

.header-address {
  font-size: clamp(1.1rem, 2.8vw, 1.75rem);
  color: #fff;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.header-address:empty {
  display: none;
}

/* Основная область — строго в экран, без скролла */
.main {
  flex: 1 1 0;
  padding: var(--gap);
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
  max-height: 100%;
}

@media (min-width: 1400px) {
  .main { padding: clamp(1rem, 1.5vw, 1.5rem); }
}

#menuContainer {
  width: 100%;
  max-width: var(--content-max);
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Постраничный показ — сетка заполняет экран, без скролла */
.menu-pagination-wrap {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
  overflow: hidden;
}

.menu-viewport {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  width: 100%;
}

.menu-pages {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.menu-page {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  padding: 0 var(--gap);
  box-sizing: border-box;
}

.menu-page .menu-grid {
  flex: 1;
  min-height: 0;
  height: 100%;
  max-width: var(--content-max);
  width: 100%;
  align-content: stretch;
  justify-content: center;
}

/* Сетка подстраивается под высоту: равные строки, карточки заполняют ячейки */
.menu-page .menu-grid {
  grid-auto-rows: 1fr;
}

.menu-page .menu-grid .dish-card {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.menu-page .menu-grid .dish-card .dish-image-wrap {
  flex: 1;
  min-height: 0;
  aspect-ratio: unset;
}

.menu-page .menu-grid .dish-card .dish-name-banner {
  flex-shrink: 0;
}

.menu-page-indicator {
  flex-shrink: 0;
  padding: 0.75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.menu-progress-track {
  width: 100%;
  max-width: 320px;
  height: 5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.menu-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #e8c04a 100%);
  border-radius: 999px;
  transition: width 0.15s linear;
}

.menu-page-dots {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  justify-content: center;
}

.menu-page-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.3s ease, transform 0.2s ease;
}

.menu-page-dot.active {
  background: var(--accent);
  transform: scale(1.2);
  box-shadow: 0 0 0 2px rgba(212, 168, 75, 0.4);
}

.menu-page-dot {
  cursor: pointer;
}

.menu-page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.menu-page-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.menu-page-btn:hover {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.menu-grid {
  display: grid;
  gap: var(--gap);
  justify-content: center;
  align-content: stretch;
  width: 100%;
  max-width: var(--content-max);
}

/* Динамическая сетка по настройке «блюд на странице» — заполняет экран без скролла */
#menuContainer .menu-page .menu-grid,
#menuContainer > .menu-grid {
  grid-template-columns: repeat(var(--grid-cols, 4), 1fr);
  grid-template-rows: repeat(var(--grid-rows, 3), 1fr);
  grid-auto-rows: 1fr;
  align-content: stretch;
  min-height: 0;
  max-width: 100%;
}

/* Одна страница без пагинации — тоже заполняем экран без скролла */
#menuContainer > .menu-grid {
  flex: 1;
  min-height: 0;
  height: 100%;
  align-content: stretch;
  grid-auto-rows: 1fr;
}

#menuContainer > .menu-grid .dish-card {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

#menuContainer > .menu-grid .dish-card .dish-image-wrap {
  flex: 1;
  min-height: 0;
  aspect-ratio: unset;
}

#menuContainer > .menu-grid .dish-card .dish-name-banner {
  flex-shrink: 0;
}

/* Шаблоны по количеству блюд */
.menu-grid.count-1 {
  grid-template-columns: 1fr;
  max-width: 520px;
  margin: 0 auto;
  gap: 0;
}
.menu-grid.count-1 .dish-card {
  max-width: 100%;
}
.menu-grid.count-1 .dish-image-wrap { aspect-ratio: 16/10; }
.menu-grid.count-1 .dish-name { font-size: clamp(1.2rem, 3vw, 1.75rem); }
.menu-grid.count-1 .dish-name-banner { padding: 1rem 1.25rem 1.25rem; }

.menu-grid.count-2 {
  grid-template-columns: repeat(2, 1fr);
  max-width: 1200px;
  margin: 0 auto;
  gap: clamp(1rem, 2.5vw, 2rem);
}
.menu-grid.count-2 .dish-image-wrap { aspect-ratio: 4/3; }

.menu-grid.count-3 {
  grid-template-columns: repeat(3, 1fr);
  max-width: 1400px;
  margin: 0 auto;
  gap: clamp(1rem, 2.2vw, 1.75rem);
}
@media (min-width: 1600px) {
  .menu-grid.count-3 { max-width: var(--content-max); }
}

.menu-grid.count-4 {
  grid-template-columns: repeat(2, 1fr);
  max-width: 1200px;
  margin: 0 auto;
  gap: clamp(1rem, 2.2vw, 1.75rem);
}
@media (min-width: 900px) {
  .menu-grid.count-4 {
    grid-template-columns: repeat(4, 1fr);
    max-width: 1600px;
  }
}
@media (min-width: 1600px) {
  .menu-grid.count-4 { max-width: var(--content-max); }
}

.menu-grid.count-5-6 {
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(1rem, 2vw, 1.5rem);
}
@media (min-width: 720px) {
  .menu-grid.count-5-6 {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 1200px) {
  .menu-grid.count-5-6 {
    grid-template-columns: repeat(4, 1fr);
    max-width: var(--content-max);
    margin: 0 auto;
  }
}

.menu-grid.count-7-9 {
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(0.9rem, 1.8vw, 1.25rem);
}
@media (min-width: 640px) {
  .menu-grid.count-7-9 {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 1100px) {
  .menu-grid.count-7-9 {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (min-width: 1600px) {
  .menu-grid.count-7-9 {
    grid-template-columns: repeat(5, 1fr);
    max-width: var(--content-max);
  }
}
.menu-grid.count-7-9 .dish-name-banner { padding: 0.5rem 0.65rem 0.65rem; }
.menu-grid.count-7-9 .dish-card .dish-name { font-size: clamp(0.95rem, 1.8vw, 1.2rem); }
.menu-grid.count-7-9 .dish-price-tag .price-full-val,
.menu-grid.count-7-9 .dish-price-tag .price-half-val { font-size: clamp(1rem, 2.2vw, 1.5rem); }
.menu-grid.count-7-9 .dish-price-tag .badge-label { font-size: clamp(0.8rem, 1.6vw, 1.1rem); }
.menu-grid.count-7-9 .dish-price-tag .dish-badge { padding: 0.5rem 0.7rem; }

/* 12 блюд на странице — карточки чуть меньше, макс. 4 колонки */
.menu-grid.count-10-plus {
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(0.9rem, 1.8vw, 1.35rem);
  --card-min-w: 250px;
  --card-max-w: 400px;
}
@media (min-width: 720px) {
  .menu-grid.count-10-plus {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (min-width: 1100px) {
  .menu-grid.count-10-plus {
    grid-template-columns: repeat(4, 1fr);
    max-width: var(--content-max);
  }
}
.menu-grid.count-10-plus .dish-image-wrap { aspect-ratio: 4/3; }
.menu-grid.count-10-plus .dish-name-banner { padding: 0.55rem 0.75rem 0.7rem; }
.menu-grid.count-10-plus .dish-card .dish-name { font-size: clamp(1rem, 2vw, 1.35rem); }
.menu-grid.count-10-plus .dish-price-tag .dish-badge { padding: 0.6rem 0.85rem; }
.menu-grid.count-10-plus .dish-price-tag .badge-label { font-size: clamp(0.95rem, 2vw, 1.25rem); }
.menu-grid.count-10-plus .dish-price-tag .price-full-val,
.menu-grid.count-10-plus .dish-price-tag .price-half-val { font-size: clamp(1.2rem, 2.5vw, 1.7rem); }

/* Карточка блюда — скругления сильнее внизу, ценник справа, название в баннере внизу */
.dish-card {
  background: var(--surface-card);
  border-radius: 16px 16px 24px 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.2s ease;
}

.dish-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(212, 168, 75, 0.25);
}

.dish-card .dish-image-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-subtle);
  overflow: hidden;
  border-radius: inherit;
}

.dish-card .dish-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dish-image-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #252220 0%, #1a1816 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: var(--font-small);
}

/* Ценник в правом верхнем углу: белая часть (зелёная цена + 1/2) + тёмная часть (белая цена) */
.dish-price-tag {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  align-items: stretch;
  border-radius: 0 16px 0 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.dish-price-tag .dish-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 1rem;
  font-family: 'Segoe UI', system-ui, sans-serif;
  white-space: nowrap;
}

.dish-price-tag .dish-badge-full {
  background: rgba(255, 255, 255, 0.98);
  color: #2d6a2d;
}

.dish-price-tag .dish-badge-full .price-full-val {
  font-size: var(--font-badge);
  font-weight: 800;
  color: #2d6a2d;
  line-height: 1.2;
}

.dish-price-tag .dish-badge-full .badge-label {
  font-size: var(--font-badge-label);
  color: #2d6a2d;
  opacity: 0.9;
  font-weight: 600;
}

.dish-price-tag .dish-badge-half {
  background: #1a1816;
  color: #fff;
}

.dish-price-tag .dish-badge-half .price-half-val {
  font-size: var(--font-badge);
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

/* Только полная порция — без блока 1/2 */
.dish-price-tag.no-half .dish-badge-full {
  border-radius: 0 12px 0 12px;
}
.dish-price-tag.no-half .dish-badge-full .price-full-val {
  color: #1a1816;
}
.dish-price-tag.no-half .dish-badge-full {
  background: rgba(255, 255, 255, 0.98);
  color: #1a1816;
}

/* Текстовый блок — карточка с произвольным текстом (мелкие блюда, примечания) */
.dish-card-text {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
}
.dish-card-text .dish-text-inner {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  width: 100%;
  height: 100%;
}
.dish-card-text .dish-text-image {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
  background: var(--bg-subtle);
  overflow: hidden;
}
.dish-card-text .dish-text-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.dish-card-text .dish-text-block {
  width: 100%;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.96);
  color: #1a1816;
  border-radius: 16px 16px 24px 24px;
  font-size: var(--font-body);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Баннер с названием внизу карточки поверх картинки */
.dish-name-banner {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 0 0 24px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.dish-card .dish-name {
  font-size: var(--font-body);
  font-weight: 600;
  line-height: 1.3;
  color: #1a1816;
  letter-spacing: 0.01em;
  margin: 0;
}

.loading {
  text-align: center;
  padding: 3rem;
  font-size: var(--font-body);
  color: var(--text-muted);
}

@media (min-width: 1920px) {
  .menu-grid:not([class*="count-"]) {
    grid-template-columns: repeat(auto-fill, minmax(280px, 360px));
    max-width: var(--content-max);
  }
}

@media (max-width: 600px) {
  .header-inner {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .header-inner .logo,
  .header-address-wrap,
  .header-inner .header-phone-wrap {
    justify-self: center;
  }
}
