/* ТОВАРИ ОПТОМ — вітрина каталогу.
   Палітра: фіолетовий, зелений, жовтий і білий. */

:root {
  --purple:      #6c2bd9;
  --purple-dark: #571fb4;
  --purple-soft: #f1ecfc;
  --neutral:     #f6f6f7;
  --green:       #17a672;
  --green-soft:  #e6f6ef;
  --yellow:      #ffc42e;
  --yellow-dark: #eeb000;

  --ink:      #1c1330;
  --ink-2:    #6e6a78;
  --bg:       #ffffff;
  --bg-soft:  #f6f6f7;
  --line:     #e5e5ea;
  --dark:     #221a33;

  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(28, 19, 48, .05), 0 10px 26px rgba(28, 19, 48, .06);
}

* { box-sizing: border-box; }

/* Скрытый элемент прячется всегда — даже если у него задан свой display. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg-soft);
  color: var(--ink);
  font: 400 15px/1.5 "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}

img { max-width: 100%; display: block; }

a { color: inherit; }

.wrap {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: 16px;
}

/* ── Шапка ─────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 30;
  background: var(--dark);
  color: #fff;
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand__cart {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--ink);
}

.brand__logo {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .35);
}

.brand__text { display: grid; gap: 1px; min-width: 0; }

.brand__title {
  font-family: "Oswald", "Manrope", sans-serif;
  font-weight: 700;
  font-size: clamp(17px, 4.6vw, 24px);
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1.1;
}

.brand__sub {
  font-size: 12px;
  color: rgba(255, 255, 255, .78);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__cta { margin-left: auto; flex: 0 0 auto; }

/* ── Кнопки ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--yellow);
  color: var(--ink);
  font: 600 14px/1 "Manrope", sans-serif;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease;
}

.btn:hover { background: var(--yellow-dark); }

.btn--small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

/* Жовта кнопка — для головної дії в шапці. */
.btn--accent { white-space: nowrap; }

:where(a, button, input, select):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ── Пошук і сортування ────────────────────────────────────────────────── */

.searchbar {
  position: sticky;
  top: calc(62px + env(safe-area-inset-top, 0px));
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.searchbar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-block: 10px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.search__icon {
  position: absolute;
  left: 12px;
  color: var(--ink-2);
  pointer-events: none;
}

.search__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 42px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink);
  font: 400 15px/1 "Manrope", sans-serif;
}

.search__input::placeholder { color: #9b94ad; }

.search__submit {
  flex: 0 0 auto;
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--yellow);
  color: var(--ink);
  font: 600 14px/1 "Manrope", sans-serif;
  cursor: pointer;
}

.search__submit:hover { background: var(--yellow-dark); }

.searchbar__count {
  margin: 0;
  flex: 0 0 auto;
  font-size: 13px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.sortbox {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.sortbox__label {
  font-size: 12px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.sortbox__select {
  height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink);
  font: 500 13px/1 "Manrope", sans-serif;
  max-width: 190px;
}

/* ── Підказка «як замовити» ────────────────────────────────────────────── */

.howto {
  margin: 0;
  padding: 9px 16px;
  background: var(--neutral);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
  text-align: center;
}

.howto b { color: var(--ink); }

/* ── Категорії ─────────────────────────────────────────────────────────── */

.cats {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.cats__inner {
  display: flex;
  gap: 8px;
  padding-block: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink);
  font: 600 13px/1 "Manrope", sans-serif;
  text-decoration: none;
  white-space: nowrap;
}

.chip:hover { border-color: var(--ink-2); }

.chip.is-active {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

.chip__count {
  font-weight: 500;
  font-size: 11.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.chip.is-active .chip__count { color: rgba(255, 255, 255, .75); }

/* ── Сітка товарів ─────────────────────────────────────────────────────── */

.main { padding-block: 18px 32px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 12px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card__media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #f4f4f6;
}

.card__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 8px;
  cursor: zoom-in;
  /* У части фото белый фон «вшит» в картинку — умножение подмешивает его
     к подложке, и все карточки выглядят одинаково. */
  mix-blend-mode: multiply;
}

.card__img--empty {
  display: grid;
  place-items: center;
  color: #c3bcd6;
  cursor: default;
}

.card__sku {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(36, 25, 67, .88);
  color: #fff;
  font: 600 11px/1.4 "Manrope", sans-serif;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}

/* ── Мітки: NEW, ХІТ, ПОПУЛЯРНЕ ────────────────────────────────────────── */

.card__marks {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.mark {
  padding: 3px 8px;
  border-radius: 999px;
  font: 700 10.5px/1.5 "Manrope", sans-serif;
  letter-spacing: .05em;
  white-space: nowrap;
}

.mark--new     { background: var(--yellow); color: var(--ink); }
.mark--hit     { background: var(--dark);   color: var(--yellow); }
.mark--popular { background: var(--green);  color: #fff; }

.card__photos {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(36, 25, 67, .78);
  color: #fff;
  font: 500 11px/1.5 "Manrope", sans-serif;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 12px;
  flex: 1 1 auto;
}

.card__name {
  margin: 0;
  font: 600 14px/1.35 "Manrope", sans-serif;
  text-wrap: pretty;
}

.card__desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-2);
}

.variants {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.variant {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-soft);
  font-size: 11.5px;
  color: var(--ink-2);
}

.variant__title { color: var(--ink); }

.variant__price {
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ── Наявність ─────────────────────────────────────────────────────────── */

.stock {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.stock__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.stock--in_stock     { color: var(--green); }
.stock--on_order     { color: var(--yellow-dark); }
.stock--out_of_stock { color: #9b94ad; }

/* ── Ціна і дії ────────────────────────────────────────────────────────── */

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.price {
  margin: 0;
  font-family: "Oswald", "Manrope", sans-serif;
  font-weight: 600;
  font-size: 22px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.price__from {
  font-family: "Manrope", sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-2);
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.price__cur { color: inherit; margin-left: 2px; }

.price__uah {
  display: block;
  margin-top: 2px;
  font-family: "Manrope", sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}

.price__ask {
  font-family: "Manrope", sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}

.card__more {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--purple);
  text-decoration: none;
  text-underline-offset: 3px;
}

.card__more:hover { text-decoration: underline; }

/* ── Кнопка «Додати» ───────────────────────────────────────────────────── */

.btn--pick { min-width: 96px; }
.btn--pick .btn__added { display: none; }

.btn--pick.is-picked {
  background: var(--green);
  color: #fff;
}

.btn--pick.is-picked:hover { background: #128a5e; }
.btn--pick.is-picked .btn__add { display: none; }
.btn--pick.is-picked .btn__added { display: inline; }

.card.is-picked {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green) inset, var(--shadow);
}

/* ── Порожній результат ────────────────────────────────────────────────── */

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--ink-2);
}

.empty--state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 56px 16px;
  color: #b3abc7;
}

.empty__title {
  margin: 0;
  font-family: "Oswald", "Manrope", sans-serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink);
  text-wrap: balance;
}

.empty__hint {
  margin: 0;
  max-width: 44ch;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-2);
}

.empty--state .btn { margin-top: 6px; }

/* ── Підвал ────────────────────────────────────────────────────────────── */

.footer {
  background: var(--dark);
  color: rgba(255, 255, 255, .78);
  margin-top: 24px;
  padding-bottom: 76px;
}

.footer__inner {
  display: grid;
  gap: 16px;
  padding-block: 28px 34px;
}

.footer__h {
  margin: 0 0 10px;
  font-family: "Oswald", "Manrope", sans-serif;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--yellow);
}

.footer__line { margin: 0 0 6px; font-size: 14px; }

.footer__line a { color: #fff; text-underline-offset: 3px; }

.footer__rate { color: #fff; font-weight: 600; }

.footer__note {
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .12);
  font-size: 12.5px;
  color: rgba(255, 255, 255, .6);
  max-width: 60ch;
}

/* ── Перегляд фото ─────────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(28, 19, 48, .93);
}

.lightbox__img {
  max-width: min(94vw, 900px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

.lightbox__close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.lightbox__nav--prev { left: 14px; }
.lightbox__nav--next { right: 14px; }

/* ── Панель обраних позицій ────────────────────────────────────────────── */

.picked {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--dark);
  color: #fff;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -6px 24px rgba(28, 19, 48, .24);
}

.picked__inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-block: 10px;
  flex-wrap: wrap;
}

.picked__summary {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: auto;
  padding: 6px 0;
  border: 0;
  background: none;
  color: #fff;
  font: 600 14px/1 "Manrope", sans-serif;
  cursor: pointer;
}

.picked__summary span:first-of-type { color: var(--yellow); }

.picked__chevron {
  font-size: 11px;
  color: rgba(255, 255, 255, .7);
  transition: transform .15s ease;
}

.picked.is-open .picked__chevron { transform: rotate(180deg); }

.picked__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn--ghost-light {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .3);
}

.btn--ghost-light:hover { background: rgba(255, 255, 255, .12); }

.picked__actions .btn:not(.btn--ghost-light) {
  background: var(--yellow);
  color: var(--ink);
}

.picked__actions .btn:not(.btn--ghost-light):hover { background: var(--yellow-dark); }

.picked__clear {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.picked__list {
  list-style: none;
  margin: 0;
  padding: 0 16px 12px;
  max-width: 1200px;
  margin-inline: auto;
  max-height: 46vh;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.picked__item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  font-size: 13.5px;
  line-height: 1.4;
  color: rgba(255, 255, 255, .85);
}

.picked__item:last-child { border-bottom: 0; }

.picked__remove {
  margin-left: auto;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

/* ── Повідомлення ──────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(92vw, 520px);
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.4;
  box-shadow: 0 8px 28px rgba(28, 19, 48, .3);
}

/* Фільтри-мітки: хіт, популярне, новинки */
.chip--mark { font-size: 12px; letter-spacing: .02em; }

.chip--hit.is-active     { background: var(--dark);   border-color: var(--dark);   color: var(--yellow); }
.chip--popular.is-active { background: var(--green);  border-color: var(--green);  color: #fff; }
.chip--new.is-active     { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }

.cats--categories { border-top: 0; }

/* Підказка й натяк на прокрутку категорій */
.cats { position: relative; }

.cats::after,
.cats::before {
  content: "";
  position: absolute;
  top: 0;
  width: 42px;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s ease;
  z-index: 2;
}

.cats::after {
  right: 0;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), var(--bg) 72%);
}

.cats::before {
  left: 0;
  background: linear-gradient(to left, rgba(255, 255, 255, 0), var(--bg) 72%);
}

/* Класи вмикає скрипт: видно, що стрічку можна гортати. */
.cats.has-next::after { opacity: 1; }
.cats.has-prev::before { opacity: 1; }

.only-narrow { display: none; }

/* Посилання в картці та підвалі — зручні для пальця */
.card__more {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
}

.footer__line a { display: inline-block; padding-block: 6px; }

/* ── Адаптив ───────────────────────────────────────────────────────────── */

@media (max-width: 559px) {
  .only-wide { display: none; }
  .only-narrow { display: inline; }

  /* Шапка в один рядок: менший логотип, коротша кнопка, без підзаголовка. */
  .topbar__inner { gap: 8px; padding-block: 9px; }
  .brand { gap: 8px; }
  .brand__logo { width: 40px; height: 40px; flex-basis: 40px; }
  .brand__cart { width: 34px; height: 34px; flex-basis: 34px; }
  .brand__title { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand__sub { display: none; }
  .topbar__cta { padding: 0 12px; min-height: 36px; font-size: 13px; }

  .howto { padding-block: 8px; line-height: 1.45; }

  /* Стрічка категорій: наступний чіп виглядає з-під градієнта. */
  .cats__inner { padding-right: 0; scroll-padding-inline: 16px; }
  .cats.has-next .cats__inner { padding-right: 6px; }

  /* Панель обраного: підсумок і хрестик у рядок, кнопки — на всю ширину. */
  .picked__inner { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding-block: 9px; }
  .picked__summary { grid-column: 1; grid-row: 1; margin-right: 0; }
  .picked__actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }
  .picked__actions .btn { width: 100%; padding: 0 10px; font-size: 13px; }
  .picked__clear { grid-column: 2; grid-row: 1; width: 32px; height: 32px; font-size: 18px; }
  .picked__list { max-height: 38vh; }
  .searchbar { top: calc(54px + env(safe-area-inset-top, 0px)); }

  /* На телефоні пошук працює миттєво — кнопка зайва, Enter теж шукає. */
  .search__submit { display: none; }
  .searchbar__count { font-size: 12px; }
  .searchbar__inner { flex-wrap: wrap; row-gap: 8px; }
  .search { flex: 1 1 100%; }
  .sortbox { flex: 1 1 auto; }
  .sortbox__label { display: none; }
  .sortbox__select { width: 100%; max-width: none; }
}

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
  .card__name { font-size: 15px; }
  .footer__inner { grid-template-columns: 1fr 1fr; align-items: start; }
  .footer__note { padding-top: 0; border-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
