/* Catalog page — contacts-style hero + milky paper stage. Mobile-first / iOS. */

.catalog-hero__bg {
  background:
    linear-gradient(165deg, rgba(233, 246, 252, 0.55) 0%, transparent 42%),
    url("../img/contacts-hero.png") center 42% / cover no-repeat;
}

.catalog-hero .contacts-hero__lead {
  max-width: 46ch;
}

/* Soft atmospheric stage under hero */
.catalog-stage {
  --catalog-overlap: clamp(28px, 4vw, 40px);
  position: relative;
  /* Top padding offsets negative wrap margin so overflow:hidden won't clip chips */
  padding: var(--catalog-overlap) 0 clamp(28px, 4vw, 48px);
  background:
    linear-gradient(180deg, #ffffff 0%, #f7f4ee 28%, #ffffff 100%);
  overflow: hidden;
}

.catalog-stage__glow {
  position: absolute;
  left: 50%;
  top: 0;
  width: min(920px, 120%);
  height: 220px;
  transform: translateX(-50%);
  background: radial-gradient(
    ellipse at center,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 255, 255, 0.35) 45%,
    transparent 72%
  );
  pointer-events: none;
}

.catalog-stage__wrap {
  position: relative;
  z-index: 1;
  margin-top: calc(var(--catalog-overlap) * -1);
}

.catalog-panel {
  position: relative;
  border-radius: clamp(20px, 3vw, 28px);
  background-color: #fcfcfa;
  border: 1px solid rgba(30, 36, 48, 0.08);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 28px 60px -36px rgba(20, 36, 64, 0.35),
    0 4px 16px rgba(20, 36, 64, 0.06);
  /* visible: fixed filter drawer must not be trapped by overflow */
  overflow: visible;
  isolation: isolate;
}

.catalog-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.22;
  border-radius: inherit;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.92 0 0 0 0 0.92 0 0 0 0 0.9 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  mix-blend-mode: multiply;
}

.catalog-panel__tools,
.catalog-panel__results {
  position: relative;
  z-index: 1;
}

.catalog-panel__tools {
  padding: clamp(16px, 2.5vw, 24px) clamp(14px, 2.4vw, 28px) 8px;
  border-bottom: 1px solid rgba(30, 36, 48, 0.06);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, transparent 100%);
}

.catalog-filters {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.catalog-filter-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(30, 36, 48, 0.12);
  background: rgba(255, 255, 255, 0.88);
  color: #1b2430;
  font-weight: 700;
  font-size: 0.9375rem;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.catalog-filter-btn:active {
  background: #f3f1ec;
}

.catalog-filters__backdrop {
  display: none;
}

.catalog-filters__head {
  display: none;
}

.catalog-filters__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: rgba(30, 36, 48, 0.06);
  color: #1b2430;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.catalog-filters__title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.25rem;
  color: #1b2430;
}

.catalog-chips {
  margin-bottom: 0;
  gap: 10px;
  padding-block: 2px;
}

.catalog-chips--sub {
  margin: 10px 0 14px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(30, 36, 48, 0.04);
  flex-wrap: wrap;
}

.catalog-stage .chip--sub {
  min-height: 36px;
  font-size: 0.75rem;
  font-weight: 650;
  padding: 6px 12px;
  border-radius: 10px;
}

.catalog-stage .chip {
  border-radius: 12px;
  border: 1px solid rgba(30, 36, 48, 0.1);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: -0.01em;
  min-height: 42px;
  padding: 8px 16px;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.catalog-stage .chip:active {
  transform: scale(0.98);
}

.catalog-stage .chip.is-active {
  background: linear-gradient(145deg, #2a4f8f 0%, #163a72 55%, #0e1b33 100%);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.catalog-stage .chip:hover {
  border-color: rgba(42, 79, 143, 0.45);
  color: #163a72;
}

.catalog-stage .chip.is-active:hover {
  background: linear-gradient(145deg, #2a4f8f 0%, #163a72 55%, #0e1b33 100%);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.catalog-filter-btn__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #163a72;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.catalog-filter-btn__count.is-empty {
  display: none;
}

.catalog-filter-btn.has-filters {
  border-color: rgba(22, 58, 114, 0.35);
  background: rgba(22, 58, 114, 0.06);
}

/* Mobile: Filter button + right drawer (no horizontal chip scroll) */
@media (max-width: 767px) {
  .catalog-filter-btn {
    display: inline-flex;
    width: auto;
    flex: 0 0 auto;
    min-width: 108px;
    padding-inline: 14px;
  }

  .catalog-filters__backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 80;
    margin: 0;
    background: rgba(13, 22, 48, 0.42);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0.28s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  .catalog-filters__backdrop.is-open,
  body.is-catalog-filters-open .catalog-filters__backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .catalog-filters__panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    z-index: 81;
    width: min(86vw, 320px);
    max-width: 320px;
    margin: 0;
    padding:
      max(16px, env(safe-area-inset-top, 0px))
      max(16px, env(safe-area-inset-right, 0px))
      max(20px, env(safe-area-inset-bottom, 0px))
      16px;
    background: #fcfcfa;
    box-shadow: -18px 0 48px -24px rgba(20, 36, 64, 0.45);
    transform: translate3d(100%, 0, 0);
    visibility: hidden;
    pointer-events: none;
    transition:
      transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
      visibility 0.3s;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .catalog-filters__panel.is-open,
  body.is-catalog-filters-open .catalog-filters__panel {
    transform: translate3d(0, 0, 0);
    visibility: visible;
    pointer-events: auto;
  }

  .catalog-filters__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
  }

  .catalog-chips {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    overflow: visible;
    gap: 8px;
    padding: 0;
    margin: 0;
  }

  .catalog-stage .chip,
  .catalog-filters__panel .chip {
    width: 100%;
    justify-content: flex-start;
    border-radius: 12px;
    min-height: 46px;
  }

  body.is-catalog-filters-open {
    overflow: hidden;
    touch-action: none;
  }
}

@media (min-width: 768px) {
  .catalog-filter-btn,
  .catalog-filters__head,
  .catalog-filters__backdrop {
    display: none;
  }

  .catalog-filters__panel {
    position: static;
    width: auto;
    flex: 0 1 auto;
    min-width: 0;
    max-width: calc(100% - 196px);
    padding: 0;
    background: transparent;
    box-shadow: none;
    transform: none;
    overflow: visible;
  }

  .catalog-chips {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-block: 2px;
  }

  .catalog-chips::-webkit-scrollbar {
    display: none;
  }
}

.catalog-stage .catalog-search {
  flex: 1 1 180px;
  min-width: 0;
  margin-bottom: 0;
}

.catalog-stage .catalog-search input {
  min-height: 50px;
  border-radius: 14px;
  border: 1px solid rgba(30, 36, 48, 0.1);
  background: rgba(255, 255, 255, 0.78);
  padding-left: 46px;
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
}

.catalog-stage .catalog-search input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--c-green) 45%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-green) 16%, transparent);
}

.catalog-stage .catalog-search__icon {
  left: 16px;
  display: inline-flex;
  color: #6b7380;
}

.catalog-panel__results {
  padding: clamp(14px, 2.2vw, 24px) clamp(14px, 2.4vw, 28px) clamp(20px, 3vw, 32px);
}

.catalog-stage .pagination__meta {
  margin: 0 0 18px;
  font-size: 0.8125rem;
  color: #6b7380;
  font-weight: 600;
}

.catalog-stage .product-group {
  margin-bottom: clamp(28px, 4vw, 44px);
}

.catalog-stage .product-group:last-child {
  margin-bottom: 8px;
}

.catalog-stage .product-group__title {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2.35rem, 4.6vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0;
  padding: 0.14em 0.06em 0.14em 0;
  border-bottom: none;
  color: #1b2430;
  font-style: normal;
  font-synthesis: none;
}

@media (max-width: 767px) {
  .catalog-stage .product-group {
    margin-top: 22px;
    margin-bottom: 32px;
  }

  .catalog-stage .product-group:first-child {
    margin-top: 18px;
  }

  .catalog-stage .product-group__title {
    font-size: clamp(2.2rem, 8.5vw, 2.55rem);
    line-height: 1.12;
    padding: 0.2em 0.1em 0.2em 0;
  }
}

.catalog-stage .product-grid {
  gap: 14px;
}

.catalog-stage .product-card {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  border: 1px solid rgba(30, 36, 48, 0.07);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 28px -22px rgba(20, 36, 64, 0.28);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

.catalog-stage .product-card:hover,
.catalog-stage .product-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 18px 36px -24px rgba(20, 36, 64, 0.4);
}

.catalog-stage .product-card:focus-visible {
  outline: 2px solid var(--c-green);
  outline-offset: 3px;
}

.catalog-stage .product-card__media {
  background:
    linear-gradient(180deg, #f3f1ec 0%, #e8e6e1 100%);
}

.catalog-stage .product-card__brand {
  color: var(--c-green);
}

@media (max-width: 767px) {
  .catalog-stage .product-card__brand {
    font-size: 0.82rem;
    margin-bottom: 6px;
  }
}

.catalog-stage .empty-state {
  padding: 28px 8px;
  text-align: center;
}

@media (min-width: 768px) {
  .catalog-stage .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }

  .catalog-filters {
    gap: 12px 16px;
  }

  .catalog-stage .catalog-search {
    flex: 1 1 200px;
    max-width: 360px;
  }
}

@media (min-width: 1100px) {
  .catalog-stage .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .catalog-stage .product-card,
  .catalog-stage .chip {
    transition: none;
  }

  .catalog-stage .product-card:hover {
    transform: none;
  }

  .catalog-filters__backdrop,
  .catalog-filters__panel {
    transition: none;
  }
}

@supports (-webkit-touch-callout: none) {
  .catalog-stage .catalog-search input {
    font-size: 16px;
  }
}
