/* FAICHAK SPORT STORE - catalog filters and sorting (assets/js/catalog.js). Loaded after shop.css.
   The design has no filters: they take the site's own look - cream outlines on the dark page, yellow for
   what is chosen. Desktop: one row above the design's 3-column grid, each group a button with a panel,
   the count and the sort on the right. Phones: the form is a side sheet like the cart, opened from the
   bar; the sort stays in the bar. Desktop sizes are design pixels: calc(N * var(--u)). */

/* Subcategories: links under the title (on desktop right after it, in its row, sharing it out to the filter
   bar's right edge - Milush 30.10: "на всю ширину", "сейчас ужато"), shaped like the filter buttons, the
   chosen one yellow. One row: on the narrowest phones it scrolls sideways */
.subcats { display: flex; justify-content: safe center; gap: 6px; margin: -12px 0 24px; overflow-x: auto; scrollbar-width: none; }
.subcats::-webkit-scrollbar { display: none; }
.subcats__link {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 14px;
  border: 2px solid rgba(253, 248, 238, .28);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.subcats__link:hover { border-color: var(--yellow); }
.subcats__link[aria-current] { border-color: var(--yellow); background: var(--yellow); color: #000; }
@media (min-width: 1152px) {
  .subcats { justify-self: stretch; gap: calc(14 * var(--u)); margin: 0 0 calc(26 * var(--u)); }
  .subcats__link { flex: 1 1 auto; justify-content: center; height: calc(54 * var(--u)); padding: 0 calc(24 * var(--u)); border-radius: calc(12 * var(--u)); font-size: calc(20 * var(--u)); }
}

/* The whole catalog: its sections as photo tiles under the title, like the home page's category cards
   (phones two a row, desktop one row), the name on a shade so it reads on a light photo */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: -8px 0 24px; }
.tile { position: relative; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden; background: var(--night); }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile::after { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgba(0, 0, 0, .55)); }
.tile span { position: absolute; z-index: 1; left: 12px; bottom: 8px; font-size: 18px; font-weight: 800; }
.tile:hover span { color: var(--yellow); }
@media (min-width: 1152px) {
  .tiles { grid-column: 1 / -1; grid-template-columns: repeat(auto-fit, minmax(calc(240 * var(--u)), 1fr));  /* six departments in a row */ gap: calc(20 * var(--u)); margin: 0 0 calc(30 * var(--u)); }
  .tile { aspect-ratio: auto; height: calc(180 * var(--u)); border-radius: calc(14 * var(--u)); }
  .tile span { left: calc(22 * var(--u)); bottom: calc(14 * var(--u)); font-size: calc(32 * var(--u)); }
}

/* Options: a tick box, the name and how many cards it leaves */
.filters__panel > label, .filters__toggle, .sorter__panel label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}
.filters__count { font-weight: 500; }
.filters input[type="checkbox"], .sorter input {
  appearance: none;
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 2px solid var(--cream);
  border-radius: 5px;
  background: none;
  cursor: pointer;
}
.filters input[type="checkbox"]:checked {
  border-color: var(--yellow);
  background: var(--yellow) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.sorter input { border-radius: 50%; }
.sorter input:checked { border-color: var(--yellow); background: var(--yellow); box-shadow: inset 0 0 0 4px var(--night); }
label:has(> input:disabled) { cursor: not-allowed; opacity: .4; }
label:has(> input:disabled) input { cursor: not-allowed; }
.filters__panel > label:hover, .filters__toggle:hover, .sorter__panel label:hover { color: var(--yellow); }

/* Shoe sizes: a grid of numbers like the product page's size chips, the ticked ones yellow (the panel itself
   is shown per screen below) */
.filters__group[data-filter="size"] .filters__panel > label {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  min-height: 44px;
  border: 2px solid rgba(253, 248, 238, .28);
  border-radius: 10px;
  font-weight: 700;
}
.filters__group[data-filter="size"] input[type="checkbox"] { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; }
.filters__group[data-filter="size"] .filters__count { display: none; }
.filters__group[data-filter="size"] .filters__panel > label:hover { color: inherit; }
@media (hover: hover) {
  .filters__group[data-filter="size"] .filters__panel > label:hover { border-color: var(--yellow); }
}
.filters__group[data-filter="size"] .filters__panel > label:has(:checked) { border-color: var(--yellow); background: var(--yellow); color: #000; }
.filters__group[data-filter="size"] .filters__panel > label:has(:focus-visible) { outline: 2px solid var(--yellow); outline-offset: 2px; }
@media (max-width: 1151.98px) {
  .filters__group[data-filter="size"] .filters__panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 8px; padding-bottom: 10px; }
}

/* Price: two thumbs on one track, and the two numbers to type */
.range { --a: 0; --b: 1; --t: 22px; position: relative; height: 32px; }
.range__track { position: absolute; inset: 50% calc(var(--t) / 2) auto; height: 4px; margin-top: -2px; border-radius: 2px; background: rgba(253, 248, 238, .22); }
.range__fill { position: absolute; inset: 0 calc((1 - var(--b)) * 100%) 0 calc(var(--a) * 100%); border-radius: 2px; background: var(--yellow); }
.range input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  appearance: none;
  background: none;
  pointer-events: none;
}
.range input::-webkit-slider-runnable-track { height: 100%; background: none; }
.range input::-webkit-slider-thumb {
  appearance: none;
  width: var(--t);
  height: var(--t);
  margin-top: calc((32px - var(--t)) / 2);
  border: 0;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
  cursor: grab;
  pointer-events: auto;
}
.range input::-moz-range-track { background: none; }
.range input::-moz-range-thumb {
  width: var(--t);
  height: var(--t);
  border: 0;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
  cursor: grab;
  pointer-events: auto;
}
.range input:active::-webkit-slider-thumb { cursor: grabbing; }
.range input:focus-visible { outline: none; }
.range input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--cream); outline-offset: 2px; }
.range input:focus-visible::-moz-range-thumb { outline: 2px solid var(--cream); outline-offset: 2px; }
.range__nums { display: flex; gap: 14px; margin-top: 14px; }
.range__nums label { display: flex; flex: 1; align-items: center; gap: 8px; font-weight: 600; }
.range__num {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 10px;
  border: 2px solid rgba(253, 248, 238, .28);
  border-radius: 8px;
  background: none;
  color: inherit;
  font: 600 15px var(--text);
  -moz-appearance: textfield;
}
.range__num::-webkit-inner-spin-button, .range__num::-webkit-outer-spin-button { appearance: none; margin: 0; }
.range__num:focus { border-color: var(--yellow); outline: none; }

/* Group and sort buttons */
.filters__head {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.filters__head svg { flex: none; width: 18px; height: 18px; }
.filters__picked:empty { display: none; }

/* Phone bar: the Filters and Sort buttons side by side, the count under them */
.catalog__bar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; }
.catalog__bar > * { min-width: 0; }  /* two buttons share a 280px row on a 320px phone */
.catalog__filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 44px;
  padding: 0 clamp(8px, 2.5vw, 18px);
  border: 0;
  border-radius: 10px;
  background: var(--yellow);
  color: #000;
  font: 800 clamp(12px, 3.6vw, 14px)/1 var(--text);
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 4px 5px 16px rgba(0, 0, 0, .28);
}
.catalog__filter svg { width: 20px; height: 20px; }
.catalog__count { order: 2; grid-column: 1 / -1; }
.sorter { position: relative; }
.sorter__head {
  justify-content: center;
  width: 100%;
  height: 44px;
  padding: 0 clamp(8px, 2.5vw, 14px);
  border: 2px solid rgba(253, 248, 238, .28);
  border-radius: 10px;
  font: 800 clamp(12px, 3.6vw, 14px)/1 var(--text);
  text-transform: uppercase;
}
.sorter__value { display: none; }
.sorter__head:hover, .sorter.is-open .sorter__head, .sorter.is-set .sorter__head { border-color: var(--yellow); }
.sorter__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: none;
  width: max-content;
  padding: 8px 18px;
  border: 1px solid rgba(253, 248, 238, .12);
  border-radius: 14px;
  background: #160b07;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
}
.sorter.is-open .sorter__panel { display: block; }
.filters__head svg, .sorter__head svg { transition: rotate .2s; }
.is-open > legend .filters__head svg, .sorter.is-open .sorter__head svg { rotate: 180deg; }

/* Phones: the sheet */
@media (max-width: 1151.98px) {
  .filters {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 55;
    display: flex;
    flex-direction: column;
    width: min(100%, 420px);
    padding: 22px 20px 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #000 linear-gradient(rgba(36, 21, 15, .78), var(--night) 60%);
    box-shadow: 10px 0 40px rgba(0, 0, 0, .5);
    translate: -100% 0;
    visibility: hidden;
  }
  .filters.is-open { translate: 0 0; visibility: visible; }
  .filters__veil { position: fixed; inset: 0; z-index: 54; background: rgba(0, 0, 0, .6); opacity: 0; visibility: hidden; }
  .filters.is-open + .filters__veil { opacity: 1; visibility: visible; }
  .filters__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
  .filters__title { font-size: 30px; text-transform: uppercase; }
  .filters__close { display: grid; place-items: center; width: 40px; height: 40px; margin-right: -8px; padding: 0; border: 0; background: none; color: var(--cream); cursor: pointer; }
  .filters__close:hover { color: var(--yellow); }
  .filters__close svg { width: 24px; height: 24px; }
  .filters__group { min-width: 0; margin: 0; padding: 18px 0 8px; border: 0; border-top: 1px solid rgba(253, 248, 238, .16); }
  .filters__group legend { float: left; width: 100%; margin-bottom: 8px; padding: 0; }
  .filters__group legend + * { clear: both; }
  .filters .filters__head { font-size: 14px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; cursor: default; }
  .filters .filters__head svg { display: none; }
  .filters__range { margin: 6px 0 4px; }
  .filters__toggle { padding: 10px 0; border-top: 1px solid rgba(253, 248, 238, .16); }
  /* Show N (main) over Reset, the cart's pair of buttons */
  .filters__foot {
    position: sticky;
    bottom: 0;
    display: flex;
    margin: auto -20px 0;
    padding: 18px 20px 22px;
    background: var(--night);
  }
  .filters__foot button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 54px;
    border: 0;
    border-radius: 10px;
    font: 800 15px/1.1 var(--text);
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 4px 5px 16px rgba(0, 0, 0, .28);
  }
  .filters__show { position: relative; z-index: 1; flex: 0 0 64%; padding: 0 12px; background: var(--yellow); color: #000; }
  .filters__reset { flex: 1; margin-left: -28px; padding: 0 8px 0 36px; background: rgba(255, 241, 113, .72); color: #000; }
  .filters__reset:disabled { cursor: default; opacity: .55; }
  /* Scrolling the list, the Filters and Sort buttons stay under the header (Milush 29.10), on its black once
     they hold; catalog.js moves the count out of the bar, so the count scrolls away */
  .catalog__bar { position: sticky; top: var(--head); z-index: 5; margin: -8px -20px 4px; padding: 8px 20px; }
  .is-stuck .catalog__bar { background: #000; }
  .catalog__main > .catalog__count { margin-bottom: 24px; }
}

@media (max-width: 1151.98px) and (prefers-reduced-motion: no-preference) {
  .filters { transition: translate .45s var(--ease), visibility 0s .45s; }
  .filters.is-open { transition: translate .45s var(--ease); }
  .filters__veil { transition: opacity .45s var(--ease), visibility 0s .45s; }
  .filters.is-open + .filters__veil { transition: opacity .45s var(--ease); }
}

/* Desktop: the filters in one row over the grid, the count and the sort at its right end */
@media (min-width: 1152px) {
  .catalog__layout { display: grid; grid-template-columns: 1fr auto; column-gap: calc(40 * var(--u)); align-items: start; }
  .catalog__main { display: contents; }
  .catalog__grid, .catalog__empty { grid-column: 1 / -1; }
  .filters, .catalog__bar { grid-row: 1; margin-bottom: calc(56 * var(--u)); }
  .filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: calc(14 * var(--u));
    font-size: calc(20 * var(--u));
  }
  .catalog__bar { grid-column: 2; display: flex; gap: calc(28 * var(--u)); }
  .catalog__count { order: 0; white-space: nowrap; }
  /* Scrolling the list, the row stays under the slim header (80 tall), on the header's ground once it holds:
     the ground runs from the screen's left edge to its right one (main clips it) */
  .filters, .catalog__bar { position: sticky; top: calc(80 * var(--u)); z-index: 5; }
  .filters::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 0 -100vw calc(-16 * var(--u)) calc((1666 * var(--u) - 100vw) / 2);
    background: rgba(0, 0, 0, .55);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
  }
  .is-stuck .filters::before { opacity: 1; }
  .filters__top, .filters__veil, .filters__show, .catalog__filter { display: none; }
  .filters__foot { display: contents; }

  .filters__group { position: relative; min-width: 0; margin: 0; padding: 0; border: 0; }
  .filters__group legend { padding: 0; }
  /* before the script turns them into panels the options stay out of the row */
  .filters__group > :not(legend) { display: none; }
  .filters__head, .filters__toggle {
    height: calc(54 * var(--u));
    padding: 0 calc(20 * var(--u));
    border: 2px solid rgba(253, 248, 238, .28);
    border-radius: calc(12 * var(--u));
    font-weight: 700;
    white-space: nowrap;
  }
  .filters__head { gap: calc(10 * var(--u)); }
  .filters__head svg { width: calc(20 * var(--u)); height: calc(20 * var(--u)); }
  .filters__head:hover, .is-open > legend .filters__head, .filters__toggle:hover { border-color: var(--yellow); color: inherit; }
  .is-set > legend .filters__head { border-color: var(--yellow); background: var(--yellow); color: #000; }
  .filters__toggle { display: inline-flex; gap: calc(12 * var(--u)); min-height: 0; }
  .filters__toggle:has(:checked) { border-color: var(--yellow); background: var(--yellow); color: #000; }
  .filters__toggle:has(:checked) input { border-color: #000; background-color: #000; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23fff171' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
  .filters__reset {
    height: calc(54 * var(--u));
    padding: 0 calc(10 * var(--u));
    border: 0;
    background: none;
    color: var(--cream);
    font: 700 calc(20 * var(--u)) var(--text);
    text-decoration: underline;
    text-underline-offset: .25em;
    cursor: pointer;
    visibility: hidden;
  }
  .filters.is-active .filters__reset { visibility: visible; }
  .filters__reset:hover { color: var(--yellow); }

  .filters__panel, .sorter__panel {
    position: absolute;
    top: calc(100% + 10 * var(--u));
    left: 0;
    z-index: 20;
    width: max-content;
    min-width: calc(260 * var(--u));
    padding: calc(10 * var(--u)) calc(22 * var(--u));
    border: 1px solid rgba(253, 248, 238, .12);
    border-radius: calc(16 * var(--u));
    background: #160b07;
    box-shadow: 0 calc(18 * var(--u)) calc(44 * var(--u)) rgba(0, 0, 0, .55);
    font-size: calc(20 * var(--u));
  }
  .filters__group.is-open > .filters__panel { display: block; }
  .sorter__panel { right: 0; left: auto; }
  .filters__panel > label, .sorter__panel label { gap: calc(14 * var(--u)); min-height: calc(54 * var(--u)); }
  .filters__panel > label .filters__count { padding-left: calc(18 * var(--u)); }
  .filters input[type="checkbox"], .sorter input { width: calc(24 * var(--u)); height: calc(24 * var(--u)); border-radius: calc(6 * var(--u)); }
  .sorter input { border-radius: 50%; }
  .filters input[type="checkbox"]:checked { background-size: calc(17 * var(--u)); }
  .sorter input:checked { box-shadow: inset 0 0 0 calc(5 * var(--u)) var(--night); }
  .filters__group[data-filter="price"] > .filters__panel { width: calc(380 * var(--u)); padding: calc(22 * var(--u)) calc(24 * var(--u)) calc(24 * var(--u)); }
  .filters__group[data-filter="size"].is-open > .filters__panel {
    display: grid;
    grid-template-columns: repeat(6, calc(76 * var(--u)));
    gap: calc(10 * var(--u));
    padding: calc(22 * var(--u));
  }
  .filters__group[data-filter="size"] .filters__panel > label { min-height: calc(54 * var(--u)); border-radius: calc(12 * var(--u)); }
  .range { --t: calc(26 * var(--u)); height: calc(36 * var(--u)); }
  .range input::-webkit-slider-thumb { margin-top: calc((36 * var(--u) - var(--t)) / 2); }
  .range__nums { gap: calc(16 * var(--u)); margin-top: calc(16 * var(--u)); }
  .range__nums label { gap: calc(10 * var(--u)); }
  .range__num { height: calc(48 * var(--u)); padding: 0 calc(12 * var(--u)); border-radius: calc(10 * var(--u)); font-size: calc(20 * var(--u)); }

  .sorter__head { width: auto; height: calc(54 * var(--u)); padding: 0 calc(20 * var(--u)); border-radius: calc(12 * var(--u)); gap: calc(10 * var(--u)); font: 700 calc(20 * var(--u)) var(--text); text-transform: none; }
  .sorter__name { display: none; }
  .sorter__value { display: inline; }
  .sorter.is-set .sorter__head { border-color: rgba(253, 248, 238, .28); }
  .sorter__head:hover, .sorter.is-open .sorter__head { border-color: var(--yellow); }
}
