:root {
  --cream: #d3c0b5;
  --dark:  #000000;
  --ink:   #0a0a0a;
  --paper: #ffffff;
}

/* Тёмная тема (мужской каталог) */
.theme-dark {
  --bg: var(--dark);
  --fg: var(--cream);
  --card-bg: #0d0d0d;
  --card-bg-hover: #141414;
  --border: #2a2a2a;
  --muted: #8a7e72;
  --cta-bg: var(--cream);
  --cta-fg: var(--dark);
}

/* Светлая тема (женский каталог) */
.theme-light {
  --bg: var(--cream);
  --fg: var(--ink);
  --card-bg: #c9b6aa;
  --card-bg-hover: #c2afa3;
  --border: #b3a094;
  --muted: #6c5f53;
  --cta-bg: var(--dark);
  --cta-fg: var(--cream);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { min-height: 100%; }

body {
  font-family: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Фейд-ин не на body (иначе вспышка дефолтного белого фона), а на внутренних элементах.
   Цвет фона страницы появляется мгновенно и совпадает с цветом залитой половинки. */
@keyframes catalog-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
body > * { animation: catalog-enter 520ms ease-out; }

a { color: inherit; text-decoration: none; }
button { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; }
img { display: block; max-width: 100%; }

/* ===== Topbar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 24px clamp(24px, 5vw, 80px);
  background: var(--bg);
}

.topbar__nav {
  display: flex;
  gap: clamp(20px, 2.6vw, 40px);
}

.nav-link {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding-bottom: 4px;
  border-bottom: 1px solid transparent;
  transition: opacity .2s ease, border-color .2s ease;
}
.nav-link:not(.is-active) { opacity: 0.7; }
.nav-link.is-active { border-color: currentColor; }
.nav-link:hover { opacity: 1; }

.nav-link--back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  opacity: 0.9;
}
.nav-link--back svg {
  flex-shrink: 0;
  transition: transform .25s ease;
}
.nav-link--back:hover svg { transform: translateX(-4px); }

.topbar__logo {
  justify-self: center;
  display: block;
}

.logo-mini {
  height: clamp(72px, 9vh, 108px);
  width: auto;
  user-select: none;
}

.topbar__actions {
  display: flex;
  justify-self: end;
  gap: clamp(20px, 3vw, 48px);
}

.action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: opacity .2s ease;
}
.action:hover { opacity: 0.7; }

.action__icon {
  width: 24px;
  height: 26px;
  flex-shrink: 0;
}

/* ===== Catalog ===== */
.catalog {
  padding: 0 clamp(24px, 5vw, 80px) 0;
  max-width: 1600px;
  margin: 0 auto;
}

.catalog__title {
  font-family: "Saira Extra Condensed", "Inter", sans-serif;
  font-weight: 900;
  font-size: clamp(32px, 3.9vw, 62px);
  line-height: 0.95;
  letter-spacing: -0.005em;
  word-spacing: 0.2em;
  text-transform: uppercase;
  margin: clamp(8px, 1vh, 20px) 0 clamp(40px, 5vh, 64px);
}

/* ===== Категории ===== */
.categories {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(20px, 2.6vw, 44px);
  margin-bottom: clamp(32px, 4vh, 48px);
}

.categories__item {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding-bottom: 6px;
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, opacity .2s ease;
}
.categories__item.is-active { border-color: currentColor; }
.categories__item:not(.is-active) { opacity: 0.7; }
.categories__item:hover { opacity: 1; }
button.categories__item { padding: 0 0 6px; background: none; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: clamp(28px, 4vh, 44px);
}

.control {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-width: 200px;
  padding: 14px 22px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: border-color .2s ease;
}
.control:hover { border-color: currentColor; }
.control svg { transition: transform .2s ease; }
.control[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Sort dropdown */
.control-wrap { position: relative; display: inline-flex; }
.control-wrap .control { min-width: 200px; }

.control__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  z-index: 20;
}
.control__menu li { list-style: none; }
.control__menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 22px;
  background: none;
  border: 0;
  color: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0.75;
  transition: background-color .15s ease, opacity .15s ease;
}
.control__menu-item:hover { background: var(--card-bg); opacity: 1; }
.control__menu-item.is-active { opacity: 1; font-weight: 600; }

.toolbar__count {
  margin-left: auto;
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ===== Баннер активного фильтра по бренду ===== */
.brand-filter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: clamp(20px, 3vh, 32px);
  padding: 14px 22px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.brand-filter strong { font-weight: 700; color: currentColor; }
.brand-filter__label { flex: 1; }
.brand-filter__clear {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 0 6px;
  opacity: 0.7;
  transition: opacity .2s ease;
}
.brand-filter__clear:hover { opacity: 1; }

/* ===== Products ===== */
[hidden] { display: none !important; }

.products {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(16px, 1.6vw, 28px);
  margin-bottom: clamp(40px, 5vh, 64px);
}

.product {
  display: flex;
  flex-direction: column;
  background: transparent;
  padding: 0;
}
.product__link {
  display: contents;
  color: inherit;
  text-decoration: none;
}

.product__media {
  aspect-ratio: 1 / 1;
  margin-bottom: clamp(16px, 1.6vw, 24px);
  border-radius: 12px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.product__name {
  font-size: clamp(11px, 0.8vw, 13px);
  font-weight: 500;
  letter-spacing: 0.18em;
  line-height: 1.4;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: clamp(10px, 1.2vh, 16px);
}

.product__price {
  font-size: clamp(14px, 1vw, 17px);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-align: center;
  margin-bottom: clamp(14px, 1.6vh, 22px);
}

.product__buy {
  margin-top: auto;
  padding: 13px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: var(--cta-bg);
  color: var(--cta-fg);
  border: 1px solid var(--cta-bg);
  transition: background-color .25s ease, color .25s ease;
}

.product__buy:hover {
  background: transparent;
  color: var(--cta-bg);
}

/* ===== Сетка брендов (тот же размер карточек, что у товаров) ===== */
.brands {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(16px, 1.6vw, 28px);
  margin-bottom: clamp(40px, 5vh, 64px);
}

.brand {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  padding: clamp(20px, 1.8vw, 32px);
  transition: background-color .2s ease;
  cursor: pointer;
}
.brand:hover { background: var(--card-bg-hover); }

/* Картинка занимает квадратную область — как у .product__media */
.brand__media {
  position: relative;
  aspect-ratio: 1 / 1;
  margin-bottom: clamp(20px, 2vw, 32px);
}

.brand__media img {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 65%;
  max-height: 55%;
  width: auto;
  height: auto;
  object-fit: contain;
  /* Принудительно делаем все лого одного цвета (тема перебивает оригинальные цвета SVG) */
  filter: brightness(0);
}

/* На тёмной теме инвертируем чёрный в кремовый */
.theme-dark .brand__media img {
  filter: brightness(0) invert(1);
}

.brand__name {
  font-size: clamp(11px, 0.8vw, 13px);
  font-weight: 500;
  letter-spacing: 0.18em;
  line-height: 1.4;
  text-transform: uppercase;
  text-align: center;
  /* Фиксированная высота под 2 строки чтобы все карточки одной высоты,
     текст (одно- или двухстрочный) центрируется в этой зоне */
  height: 3em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== Show more ===== */
.load-more {
  display: block;
  width: 100%;
  padding: 22px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  margin-bottom: 64px;
  transition: background-color .25s ease, color .25s ease;
}
.load-more:hover {
  background: currentColor;
}
.load-more:hover { color: var(--bg); }

/* Инвертированный вариант (тёмная кнопка на светлом фоне) */
.load-more--inverted {
  background: var(--cta-bg);
  color: var(--cta-fg);
  border-color: var(--cta-bg);
  margin-left: calc(-1 * clamp(24px, 5vw, 80px));
  margin-right: calc(-1 * clamp(24px, 5vw, 80px));
  margin-bottom: 0;
  width: auto;
}
.load-more--inverted:hover {
  background: transparent;
  color: var(--cta-bg);
}

/* ===== Подвал ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: clamp(40px, 5vh, 64px) clamp(24px, 5vw, 80px) clamp(28px, 3.6vh, 44px);
  max-width: 1600px;
  margin: 0 auto;
}
.footer__grid {
  display: grid;
  grid-template-columns: minmax(140px, auto) repeat(3, 1fr) auto;
  gap: clamp(24px, 4vw, 56px);
  align-items: start;
}
.footer__brand img { height: 80px; width: auto; user-select: none; }
.footer__brand-text {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 14px;
  line-height: 1.6;
}
.footer__col-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 14px;
}
.footer__col ul { list-style: none; padding: 0; margin: 0; }
.footer__col li { margin-bottom: 10px; }
.footer__col a {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--fg);
  opacity: 0.7;
  transition: opacity .2s ease;
}
.footer__col a:hover { opacity: 1; }
.footer__social { display: flex; gap: 14px; align-items: center; }
.footer__social a {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
  transition: opacity .2s ease;
}
.footer__social a:hover { opacity: 1; }
.footer__social img { width: 22px; height: 22px; filter: brightness(0); }
.theme-dark .footer__social img { filter: brightness(0) invert(1); }

/* ===== Адаптив ===== */
@media (max-width: 1100px) {
  .products { grid-template-columns: repeat(3, 1fr); }
  .footer__grid { grid-template-columns: 1fr 1fr; }
  .footer__brand, .footer__social { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr auto 1fr;
    grid-template-rows: auto auto;
    padding: 14px 18px;
    gap: 10px;
  }
  /* Лого по центру */
  .topbar__logo { grid-column: 2; grid-row: 1; justify-self: center; }
  /* Корзина абсолютно справа, симметрично с «На главную» */
  .topbar__actions {
    position: absolute;
    top: 14px;
    right: calc(18px - 3vw);
    gap: 18px;
  }
  /* «На главную» вынесена из nav и закреплена слева в первой строке */
  .nav-link--back {
    position: absolute;
    top: calc(14px + 1vh);
    left: calc(18px - 3vw);
    font-size: 12.3px;
    letter-spacing: 0.12em;
    gap: 8px;
  }
  .nav-link--back svg { width: 22.5px; height: 10.2px; }
  /* Остальные ссылки (О нас, Доставка и оплата) — по центру во второй строке (+15%, сдвинуты вправо на 3vw) */
  .topbar__nav {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
  }
  .topbar__nav .nav-link:not(.nav-link--back) {
    font-size: 10.5px;
    letter-spacing: 0.12em;
    padding-bottom: 2px;
    transform: translateX(3vw);
  }
  .logo-mini { height: 36px; }
  .action { font-size: 12.3px; letter-spacing: 0.12em; gap: 8px; }
  .action__icon { width: 22.5px; height: 23.5px; transform: translateY(-1px); }

  .catalog { padding: 0 18px; }
  .catalog__title { font-size: 26px; margin-bottom: 28px; }

  .categories { gap: 16px; }
  .categories__item { font-size: 11px; letter-spacing: 0.14em; }

  .toolbar { flex-wrap: wrap; }
  .control { min-width: 0; flex: 1; padding: 12px 16px; font-size: 11px; }
  .toolbar__count { width: 100%; text-align: right; margin: 4px 0 0; }

  .products { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .product { padding: 14px; }
  .product__name { font-size: 10px; letter-spacing: 0.14em; }
  .product__price { font-size: 13px; }

  /* Бренды: 2 колонки и одинаковая компоновка с увеличенными лого */
  .brands { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .brand { padding: 16px; }
  .brand__media img { max-width: 70%; max-height: 55%; }
  .brand__name { font-size: 11px; letter-spacing: 0.14em; height: 2.6em; }

  /* Подвал на мобилке */
  .footer { padding: 32px 18px 24px; }
  .footer__grid { grid-template-columns: 1fr 1fr; gap: 22px; }
  .footer__brand { grid-column: 1 / -1; }
  .footer__brand img { height: 56px; }
  .footer__social { grid-column: 1 / -1; justify-content: flex-end; }

  .load-more { padding: 18px; font-size: 11px; }
  .load-more--inverted {
    margin-left: -18px;
    margin-right: -18px;
  }
}

/* ===== Пустое состояние каталога ===== */
.products-empty {
  padding: clamp(40px, 6vh, 72px) 24px;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--card-bg);
  margin-top: 8px;
}
