/*
  Каталог Avelio: тёмное поле, как у витрины на главной (#101112),
  главные фото — студийные снимки мини-приложения бота на подложке #3e3e3d.
  Все плитки одной высоты: фото 4:3, название ровно в две строки,
  размер и код — по одной строке.
*/
:root {
  color-scheme: only dark;
  --bg: #101112;
  --surface: #17181a;
  --tile: #3e3e3d;
  --text: #eeeae5;
  --muted: #aaa7a2;
  --rule: rgb(238 234 229 / 16%);
  --rule-strong: rgb(238 234 229 / 34%);
  --brass: rgb(190 146 74);
  --ease: cubic-bezier(.16, 1, .3, 1);
  --gutter: 16px;
  --top-h: 56px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--top-h);
}
html.card-open { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.45 "Onest", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--text);
  color: var(--bg);
}
.skip:focus { top: 8px; }

:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }

.wrap {
  width: 100%;
  max-width: 1320px;
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px));
}

/* Шапка */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgb(16 17 18 / 92%);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
.top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--top-h);
}
.brand { display: inline-flex; align-items: center; min-height: 44px; color: var(--text); }
.brand svg { width: 104px; height: 28px; }
.brand-small svg { width: 84px; height: 22px; }
.top-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--rule-strong);
}

/* Заголовок и поиск */
.head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding-top: 28px;
}
h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 500;
  letter-spacing: -.01em;
}
.head-count { margin: 0; color: var(--muted); font-size: 14px; }

.search { margin-top: 18px; }
.search input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  background: var(--surface);
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.search input::placeholder { color: #8b8883; }
.search input:focus { outline: none; border-color: var(--text); }

/* Разделы и типы: на телефоне лента вбок, на компьютере переносится */
.chips {
  position: relative;
  display: flex;
  gap: 8px;
  margin-top: 16px;
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chips[hidden] { display: none; }
.chips-types { margin-top: 10px; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .2s, color .2s, border-color .2s;
}
.chip small { color: var(--muted); font-size: 12px; }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip[aria-pressed="true"] small { color: #55524d; }
.chips-types .chip { min-height: 36px; padding: 6px 12px; font-size: 13px; }
@media (hover: hover) {
  .chip:hover { border-color: var(--text); }
}

/* Ширина, порядок, только с размерами */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-top: 14px;
}
.select { position: relative; display: inline-flex; }
.select[hidden] { display: none; }
.select::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select select {
  min-height: 40px;
  padding: 8px 36px 8px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  background: var(--surface);
  font-size: 14px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.select select option { background: var(--surface); color: var(--text); }
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  font-size: 14px;
  cursor: pointer;
}
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--text); }

.result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  margin-top: 12px;
  border-bottom: 1px solid var(--rule);
}
.result p { margin: 0; color: var(--muted); font-size: 14px; }
.reset {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.reset[hidden] { display: none; }

.status { margin: 28px 0; color: var(--muted); }
.status:empty { display: none; }
.status button {
  margin-top: 12px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: none;
  cursor: pointer;
}

/* Сетка плиток */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px 12px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}
.grid > li { min-width: 0; }

.tile {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  touch-action: manipulation;
}
/* Подпись одной высоты у всех: место под две строки названия, размер и код
   идут сразу за названием, запас остаётся внизу плитки. */
.tile-text { height: 90px; overflow: hidden; }
.tile-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  max-height: calc(2 * 1.3em);
  margin: 10px 0 0;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.3;
  font-weight: 500;
}
.tile-size,
.tile-code {
  height: 1.4em;
  margin: 4px 0 0;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tile-code { margin-top: 0; font-size: 12px; letter-spacing: .02em; }
@media (hover: hover) {
  .tile:hover .thumb img { transform: scale(1.03); }
  .tile:hover .tile-name { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--rule-strong); }
}

/* Фото плитки — как в мини-приложении: 4:3, подложка #3e3e3d, широкие вписаны на цвет краёв */
.thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 14px;
  background: var(--tile);
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 60%;
  opacity: 0;
  transition: opacity .24s ease, transform .5s var(--ease);
}
.thumb.is-loaded img { opacity: 1; }
.thumb--wide::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    var(--thumb-edge-top, #d8d3cb) calc((100% - var(--thumb-wide-height)) / 2),
    var(--thumb-edge-bottom, #d8d3cb) calc((100% + var(--thumb-wide-height)) / 2)
  );
  filter: brightness(.86);
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease;
}
.thumb--wide.is-loaded::before { opacity: 1; }
.thumb--wide img {
  inset: 50% 0 auto;
  height: var(--thumb-wide-height);
  transform: translateY(-50%);
  object-fit: contain;
  object-position: center;
  filter: brightness(.86);
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 3%, #000 97%, transparent);
  mask-image: linear-gradient(to bottom, transparent, #000 3%, #000 97%, transparent);
}
@media (hover: hover) {
  .tile:hover .thumb--wide img { transform: translateY(-50%) scale(1.03); }
}
.thumb-missing {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.more-box { display: flex; justify-content: center; padding: 28px 0 56px; }
.more {
  min-height: 48px;
  padding: 12px 28px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: none;
  font-size: 15px;
  cursor: pointer;
}
.more[hidden] { display: none; }

/* Карточка товара — отдельный экран поверх списка; список под ней не двигается */
.card-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  animation: card-in .28s var(--ease);
}
.card-layer[hidden] { display: none; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.card-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgb(16 17 18 / 92%);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
}
.card-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--top-h);
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px 0 0;
  border: 0;
  background: none;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}

.card-body { padding-top: 16px; padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px)); }
.card-main { display: grid; gap: 22px; }

.gallery { position: relative; }
.gallery-track {
  display: flex;
  aspect-ratio: 4 / 3;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 16px;
  background: var(--tile);
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.gallery-track::-webkit-scrollbar { display: none; }
.gallery-slide {
  position: relative;
  flex: 0 0 100%;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}
.gallery-slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity .3s ease;
}
.gallery-slide.is-loaded img { opacity: 1; }
.gallery-slide::after {
  /* Тонкая полоска загрузки, пропадает с фото */
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  bottom: 14px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgb(238 234 229 / 55%), transparent);
  background-size: 200% 100%;
  animation: loading 1.2s linear infinite;
}
.gallery-slide.is-loaded::after,
.gallery-slide.has-error::after { display: none; }
@keyframes loading { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.gallery-count {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgb(16 17 18 / 70%);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.gallery-arrow {
  position: absolute;
  top: 50%;
  display: none;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: rgb(16 17 18 / 72%);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.gallery-prev { left: 12px; }
.gallery-next { right: 12px; }
.gallery-arrow:disabled { opacity: .35; cursor: default; }
@media (hover: hover) and (pointer: fine) {
  .gallery-arrow { display: block; }
}
.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.gallery-thumbs::-webkit-scrollbar { display: none; }
.gallery-thumbs button {
  flex: none;
  width: 64px;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--tile);
  opacity: .6;
  cursor: pointer;
}
.gallery-thumbs button[aria-current="true"] { border-color: var(--text); opacity: 1; }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }

.card-info { min-width: 0; }
.card-eyebrow { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.card-info h1 { margin-top: 8px; font-size: 30px; }
.card-facts { display: grid; gap: 0; margin: 20px 0 0; border-top: 1px solid var(--rule); }
.card-facts div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.card-facts dt { color: var(--muted); }
.card-facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.card-desc { margin: 18px 0 0; color: #d6d2cc; }
.card-actions { display: grid; gap: 10px; margin-top: 24px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 14px 22px;
  border: 1px solid var(--text);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  touch-action: manipulation;
}
.btn-main { background: var(--text); color: var(--bg); }
.btn-line { background: transparent; color: var(--text); border-color: var(--rule-strong); }
@media (hover: hover) {
  .btn-main:hover { background: #fff; }
  .btn-line:hover { border-color: var(--text); }
}

.related { margin-top: 44px; padding-top: 24px; border-top: 1px solid var(--rule); }
.related h2 { margin: 0; font-size: 20px; font-weight: 500; }
.related .grid { margin-top: 16px; }

@media (min-width: 720px) {
  :root { --gutter: 28px; --top-h: 64px; }
  .brand svg { width: 112px; height: 30px; }
  h1 { font-size: 44px; }
  .head { padding-top: 40px; }
  .search { max-width: 560px; }
  .chips { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding-inline: 0; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px 20px; }
  .card-info h1 { font-size: 36px; }
  .card-actions { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1080px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card-body { padding-top: 28px; }
  .card-main { grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr); gap: 44px; align-items: start; }
  .card-info { position: sticky; top: calc(var(--top-h) + 28px); }
  .card-actions { grid-template-columns: 1fr; }
  .related .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .card-layer { animation: none; }
  .thumb img, .gallery-slide img { transition: none; }
  .gallery-slide::after { animation: none; }
}
