/* Global responsive baseline for all pages. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Полоса прокрутки не сужает вёрстку после загрузки — без горизонтального сдвига блоков */
  scrollbar-gutter: stable;
}

/* Основной контент не «схлопывается» до появления данных/стилей */
main {
  display: block;
  min-height: 28vh;
  min-height: 28svh;
}

main .main-content {
  min-height: 28vh;
  min-height: 28svh;
}

@keyframes horeca-skeleton-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* Prevent blink/jump animations during initial paint after refresh/navigation. */
html.page-preload *,
html.page-preload *::before,
html.page-preload *::after {
  animation: none !important;
  transition: none !important;
}

/* Скелетоны — исключение: без мерцания блока, но шиммер допустим */
html.page-preload .horeca-skeleton,
html.page-preload .horeca-skeleton-block,
html.page-preload .card-img:not(.card-img--loaded)::after,
html.page-preload .product-modal-img-slot.horeca-skeleton {
  animation: horeca-skeleton-shimmer 1.15s ease-in-out infinite !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* Минимальная высота страницы без скачков при появлении/скрытии UI браузера (моб.) */
body {
  min-height: 100vh;
  min-height: 100svh;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
  height: auto;
}

/* Карточки каталога: слот под картинку — на моб. 1:1; на десктопе высоту задаёт index (px) */
main .main-content .card .card-img {
  position: relative;
  overflow: hidden;
}

@media (max-width: 768px) {
  main .main-content .card .card-img {
    aspect-ratio: 1 / 1;
  }
}

main .main-content .card .card-img img {
  height: 100%;
  max-height: 100%;
  width: 100%;
  object-fit: contain;
  object-position: center 58%;
  vertical-align: middle;
}

/* Скелетон / заглушка для асинхронных блоков */
.horeca-skeleton,
.horeca-skeleton-block {
  background: linear-gradient(
    90deg,
    #e8ecf0 0%,
    #f1f4f8 45%,
    #e8ecf0 90%
  );
  background-size: 200% 100%;
  animation: horeca-skeleton-shimmer 1.15s ease-in-out infinite;
  border-radius: 6px;
}

.horeca-skeleton--text {
  display: block;
  height: 0.85em;
  min-height: 10px;
  margin: 0.35em 0;
  max-width: 100%;
}

.horeca-skeleton--media {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 220px;
  border-radius: 8px;
}

/* Модалка товара / корзина: зарезервированный блок под картинку */
.product-modal-img-slot {
  width: 100%;
  max-width: 280px;
  margin: 0 auto 12px;
  aspect-ratio: 1 / 1;
  max-height: min(220px, 40vh);
  background: #f3f4f6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.product-modal-img-slot img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.product-modal-img-slot.is-loaded {
  animation: none;
  background: #fff;
}

#cart-modal-body.cart-modal-body--loading {
  min-height: 140px;
}

.cart-loading-skeleton {
  padding: 8px 0 16px;
  min-height: 120px;
  box-sizing: border-box;
}

table {
  max-width: 100%;
}

input,
select,
textarea,
button {
  max-width: 100%;
  font: inherit;
}

@media (max-width: 768px) {
  .wrap {
    width: 100%;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Extra-compact profile for very small mobile screens (320-360px). */
@media (max-width: 360px) {
  html {
    font-size: 14px;
  }

  .wrap {
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
  }

  h1 { font-size: 1.12rem; }
  h2 { font-size: 1rem; }
  h3 { font-size: 0.92rem; }

  input,
  select,
  textarea,
  button {
    font-size: 0.9rem;
  }

  .btn,
  button,
  input[type="button"],
  input[type="submit"] {
    min-height: 34px;
    padding-top: 6px;
    padding-bottom: 6px;
  }

  table {
    font-size: 0.86rem;
  }
}
