/* ==========================================================================
   Catalog page head
   ========================================================================== */
.catalog-head {
  padding-block: 0 40px;
  text-align: left;
}

.catalog-head__text {
  font-size: 13px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  max-width: 560px;
}

@media (min-width: 1200px) {
  .catalog-head {
    padding-block: 0 60px;
  }

  .catalog-head__text {
    font-size: 14px;
  }
}

/* ==========================================================================
   Catalog toolbar: filters button, result count, sort dropdown, active chips
   ========================================================================== */
.catalog-toolbar {
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

/* phone: the two buttons share the row, "Найдено" goes under them */
.catalog-toolbar__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 10px;
}

.catalog-toolbar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  padding-inline: 16px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-light);
  white-space: nowrap;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease;
}

.catalog-toolbar__btn:hover,
.catalog-toolbar__btn[aria-expanded="true"] {
  border-color: var(--color-text-light);
}

.catalog-toolbar__btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.catalog-toolbar__btn svg {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.catalog-toolbar__badge {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding-inline: 6px;
  border-radius: 999px;
  background: var(--color-accent);
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-white);
}

.catalog-toolbar__badge[hidden] {
  display: none;
}

/* search inside the catalog: phone — own row under the buttons */
.catalog-find {
  position: relative;
  grid-column: 1 / -1;
  grid-row: 2;
}

.catalog-find__icon {
  position: absolute;
  top: 50%;
  left: 16px;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.catalog-find input {
  width: 100%;
  height: 44px;
  padding: 0 16px 0 44px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: none;
  font-size: 14px;
  color: var(--color-text-light);
  transition: border-color 0.2s ease, width 0.3s ease;
}

.catalog-find input::placeholder {
  color: var(--color-text-muted);
}

.catalog-find input:hover {
  border-color: var(--color-text-muted);
}

.catalog-find input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.catalog-toolbar__found {
  grid-column: 1 / -1;
  grid-row: 3;
  font-size: 13px;
  color: var(--color-text-muted);
}

.catalog-toolbar__found b {
  font-weight: 600;
  color: var(--color-text-light);
}

/* ---- sort dropdown ---- */
.catalog-sort {
  position: relative;
}

.catalog-sort__prefix {
  display: none;
  color: var(--color-text-muted);
  font-weight: 400;
}

.catalog-sort__current {
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalog-sort__chevron {
  transition: transform 0.25s ease;
}

.catalog-sort__toggle[aria-expanded="true"] .catalog-sort__chevron {
  transform: rotate(180deg);
}

.catalog-sort__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: max(100%, 250px);
  padding: 6px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-bg-elevated);
  box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.5);
  animation: catalog-pop 0.2s ease both;
}

.catalog-sort__menu[hidden] {
  display: none;
}

@keyframes catalog-pop {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.catalog-sort__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 9px;
  font-size: 14px;
  text-align: left;
  color: var(--color-text-light);
  transition: background-color 0.15s ease;
}

.catalog-sort__option:hover,
.catalog-sort__option:focus-visible {
  background: var(--color-card-bg);
  outline: none;
}

.catalog-sort__option:focus-visible {
  box-shadow: inset 0 0 0 1px var(--color-accent);
}

.catalog-sort__check {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--color-accent);
  opacity: 0;
}

.catalog-sort__option.is-active {
  color: var(--color-accent);
  font-weight: 600;
}

.catalog-sort__option.is-active .catalog-sort__check {
  opacity: 1;
}

/* ---- active filter chips ---- */
.catalog-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  /* phone: one scrolling line */
  overflow-x: auto;
  scrollbar-width: none;
}

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

.catalog-chips[hidden] {
  display: none;
}

.catalog-chip {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px 0 14px;
  border: 1px solid rgba(233, 105, 18, 0.45);
  border-radius: 999px;
  background: rgba(233, 105, 18, 0.1);
  font-size: 13px;
  color: var(--color-text-light);
  white-space: nowrap;
  animation: catalog-pop 0.2s ease both;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.catalog-chip svg {
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
  transition: color 0.2s ease;
}

.catalog-chip:hover {
  border-color: var(--color-accent);
  background: rgba(233, 105, 18, 0.2);
}

.catalog-chip:hover svg {
  color: var(--color-text-light);
}

.catalog-chips__reset {
  flex-shrink: 0;
  margin-left: 4px;
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

.catalog-chips__reset:hover {
  color: var(--color-text-light);
}

@media (min-width: 768px) {
  .catalog-toolbar__row {
    display: flex;
    gap: 16px;
  }

  .catalog-toolbar__btn {
    width: auto;
  }

  .catalog-find {
    flex: 0 1 320px;
  }

  .catalog-toolbar__found {
    margin-left: auto;
  }

  .catalog-sort__prefix {
    display: inline;
  }

  .catalog-chips {
    flex-wrap: wrap;
    overflow: visible;
  }
}

/* ==========================================================================
   Filters side panel
   ========================================================================== */
.side-panel {
  position: fixed;
  inset: 0;
  z-index: 300;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 0.35s;
}

.side-panel.is-open {
  visibility: visible;
  pointer-events: auto;
  transition: none;
}

.side-panel__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.side-panel.is-open .side-panel__overlay {
  opacity: 1;
}

.side-panel__panel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  max-width: 440px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  box-shadow: 30px 0 60px -30px rgba(0, 0, 0, 0.6);
  padding: 24px 24px 0;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.side-panel.is-open .side-panel__panel {
  transform: translateX(0);
}

.side-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--color-border);
}

.side-panel__title {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 22px;
}

.side-panel__head-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.side-panel__reset {
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

.side-panel__reset:hover {
  color: var(--color-text-light);
}

.side-panel__close {
  width: 16px;
  height: 16px;
  position: relative;
  flex-shrink: 0;
}

.side-panel__close::before,
.side-panel__close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: var(--color-text-light);
}

.side-panel__close::before {
  transform: rotate(45deg);
}

.side-panel__close::after {
  transform: rotate(-45deg);
}

.side-panel__body {
  flex: 1;
  overflow-y: auto;
  margin-inline: -24px;
  padding-inline: 24px;
}

.side-panel__foot {
  flex-shrink: 0;
  padding-block: 16px 20px;
  border-top: 1px solid var(--color-border);
}

.side-panel__apply {
  width: 100%;
  height: 52px;
  font-size: 15px;
}

/* ---- groups ---- */
.filter-group {
  border-bottom: 1px solid var(--color-border);
}

.filter-group summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-block: 18px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.filter-group summary::-webkit-details-marker {
  display: none;
}

.filter-group__title {
  flex: 1;
}

.filter-group__count {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding-inline: 6px;
  border-radius: 999px;
  background: var(--color-accent);
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-white);
}

.filter-group__count[hidden] {
  display: none;
}

.filter-group__icon {
  position: relative;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.filter-group__icon::before,
.filter-group__icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  background: var(--color-text-muted);
  transform: translate(-50%, -50%);
}

.filter-group__icon::before {
  width: 14px;
  height: 1.3px;
}

.filter-group__icon::after {
  width: 1.3px;
  height: 14px;
  transition: transform 0.2s ease;
}

.filter-group[open] .filter-group__icon::after {
  transform: translate(-50%, -50%) scaleY(0);
}

.filter-group__options {
  display: grid;
  gap: 4px;
  padding-bottom: 16px;
}

/* ---- options: custom checkbox + label + count ---- */
.filter-option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-inline: -8px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.filter-option:hover {
  background: var(--color-card-bg);
}

.filter-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.filter-option__box {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--color-border-light);
  border-radius: 6px;
  color: var(--color-text-white);
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.filter-option__box svg {
  width: 13px;
  height: 13px;
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset 0.25s ease 0.05s;
}

.filter-option input:checked + .filter-option__box {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.filter-option input:checked + .filter-option__box svg {
  stroke-dashoffset: 0;
}

.filter-option input:focus-visible + .filter-option__box {
  box-shadow: 0 0 0 3px rgba(233, 105, 18, 0.35);
}

.filter-option__swatch {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.filter-option__text {
  flex: 1;
  font-size: 14px;
  color: var(--color-text-light);
}

.filter-option__count {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Product grid / tiles
   ========================================================================== */
.catalog-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding-bottom: 60px;
}

@media (min-width: 640px) {
  .catalog-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1200px) {
  .catalog-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding-bottom: 100px;
  }
}

/* Relative so the whole-tile link below still covers the photo as well. */
/* --tile-radius / --tile-pad drive the button radius below: an inner
   corner = outer corner − padding, so the button follows the card's curve */
.product-tile {
  --tile-radius: var(--radius-lg);
  --tile-pad: 20px;

  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--tile-radius);
  overflow: hidden;
  background: var(--color-bg-elevated);
}

.product-tile__media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--color-card-bg-strong);
}

.product-tile__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
}

@media (hover: hover) {
  .product-tile:hover .product-tile__media img {
    transform: scale(1.04);
  }
}

.product-tile__link {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.product-tile__top {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-badge-bg);
  border: 1px solid var(--color-badge-border);
  backdrop-filter: blur(3.5px);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--color-text-white);
}

.status-badge span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-badge--in span {
  background: #4caf50;
}

.status-badge--out span {
  background: #e34848;
}

.status-badge--soon span {
  background: #e9b512;
}

/* Colour choice: "Цвет: …" on the left, swatches on the right. A picked
   swatch gets a light ring with a gap, visible on any colour. */
.product-tile__colors {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.product-tile__color {
  font-size: 13px;
  color: var(--color-text-muted);
}

.product-tile__color span {
  color: var(--color-text-light);
}

.product-tile__swatches {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Same look as the product page (.color-swatch in product.css): the picked
   colour gets a ring in its own colour, set off by a gap in the card
   colour, and a white tick inside. */
.product-tile__swatch {
  position: relative;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
  transition:
    transform 0.2s ease,
    border-color 0.2s ease;
}

.product-tile__swatch:hover {
  transform: scale(1.08);
}

.product-tile__swatch.is-active {
  box-shadow:
    0 0 0 2px var(--color-bg-elevated),
    0 0 0 4px var(--swatch);
}

.product-tile__swatch.is-active::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
  filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.6));
}

.product-tile__swatch:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}

.product-tile__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: var(--tile-pad);
}

.product-tile__sku {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.product-tile__title {
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 8px;
}

.product-tile__desc {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 20px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Sits above the whole-tile link so the order action stays clickable. */
.product-tile__btn {
  position: relative;
  z-index: 2;
  margin-top: auto;
  align-self: stretch;
  text-align: center;
  border-radius: max(var(--radius-sm), calc(var(--tile-radius) - var(--tile-pad)));
}

/* Brief confirmation state after the item lands in the order list. */
.product-tile__btn.is-added {
  background: var(--color-bg-elevated);
  color: var(--color-text-light);
  box-shadow: inset 0 0 0 1px var(--color-border);
}
