/**
 * The archive's filters.
 *
 * Sizes are in px because 1rem is 10px on this site (Automatic.css), so a
 * value in rem here would read as a tenth of what it looks like.
 */

.innowine-facets {
  display: flex;
  flex-direction: column;
  gap: var(--space-s, 2rem);
  inline-size: 100%;
}

.innowine-facet {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.innowine-facet__title {
  margin: 0 0 2px;
  color: var(--black, #000);
  font-size: 17px;
  font-weight: 700;
}

.innowine-facet__list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.innowine-choice {
  margin: 0;
  padding: 0;
  line-height: 0;
}

/*
 * `.woocommerce-page label` puts 0.7em under every label in the shop, which
 * down a list of filters is eleven empty pixels between each row. Two classes
 * deep, because one does not outrank it.
 */
.innowine-choice .innowine-check,
.innowine-facet--search .innowine-search {
  margin-block-end: 0;
}

/* The regions under a country the reader has already picked. */
.innowine-facet__list--child {
  margin-block-start: 2px;
  padding-inline-start: 26px;
}

/* ------------------------------------------------------------- the search */

.innowine-search {
  position: relative;
  display: flex;
  align-items: center;
  inline-size: 100%;
}

.innowine-search__icon {
  position: absolute;
  inset-inline-start: 12px;
  inline-size: 16px;
  block-size: 16px;
  color: #8a8a8a;
  pointer-events: none;
}

.innowine-search__input {
  inline-size: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background-color: var(--white, #fff);
  color: var(--black, #000);
  font-family: inherit;
  font-size: 15px;
}

.innowine-search__input::placeholder {
  color: #707070; /* 4.9:1 (WCAG AA); #9a9a9a was 2.8:1 */
}

.innowine-search__input:focus-visible {
  border-color: var(--black, #000);
  outline: none;
}

/* ----------------------------------------------------------- the checkbox */

.innowine-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline: -6px;
  padding: 5px 6px;
  border-radius: 5px;
  line-height: 1.3;
  cursor: pointer;
}

.innowine-check:hover {
  background-color: #f6f6f6;
}

/* Off-screen rather than hidden: it still has to take focus and a click. */
.innowine-check__input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.innowine-check__box {
  position: relative;
  flex: none;
  inline-size: 18px;
  block-size: 18px;
  border: 1px solid #c7c7c7;
  border-radius: 3px;
  background-color: var(--white, #fff);
}

.innowine-check__input:checked + .innowine-check__box {
  border-color: var(--black, #000);
  background-color: var(--black, #000);
}

.innowine-check__input:checked + .innowine-check__box::after {
  content: "";
  position: absolute;
  inset-block-start: 2px;
  inset-inline-start: 5px;
  inline-size: 4px;
  block-size: 8px;
  border: solid var(--white, #fff);
  border-width: 0 2px 2px 0;
  rotate: 45deg;
}

.innowine-check__input:focus-visible + .innowine-check__box {
  outline: 2px solid var(--black, #000);
  outline-offset: 2px;
}

.innowine-check__label {
  color: var(--black, #000);
  font-size: 15px;
  line-height: 1.3;
}

.innowine-check__count {
  color: #6b6a66; /* 5.4:1; #8a8a8a was 3.5:1 */
  font-size: 14px;
}

/*
 * The Selection category, in the gold the cards give the same wines: the
 * badge's text colour for the words, its border colour for the ticked box.
 */
.innowine-choice--selection .innowine-check__label {
  color: #8a6a12;
  font-weight: 600;
}

.innowine-choice--selection .innowine-check__box {
  border-color: #b08d2e;
}

.innowine-choice--selection .innowine-check__input:checked + .innowine-check__box {
  border-color: #b08d2e;
  background-color: #b08d2e;
}

.innowine-choice--selection .innowine-check:hover {
  background-color: #f8f3e3;
}

/* On sale, in the red of the cards' "Akció" badge (8:1 on white). */
.innowine-choice--sale .innowine-check__label {
  color: #9e191a;
  font-weight: 600;
}

.innowine-choice--sale .innowine-check__box {
  border-color: #9e191a;
}

.innowine-choice--sale .innowine-check__input:checked + .innowine-check__box {
  border-color: #9e191a;
  background-color: #9e191a;
}

.innowine-choice--sale .innowine-check:hover {
  background-color: #fbeeee;
}
/* --------------------------------------------------------- more and reset */

/* Beyond the first few choices, until the reader asks for the rest. */
.innowine-choice.is-extra {
  display: none;
}

.innowine-facet.is-expanded .innowine-choice.is-extra {
  display: block;
}

.innowine-facet__more,
.innowine-facet__clear {
  align-self: flex-start;
  margin-block-start: 4px;
  padding: 6px 10px;
  border: 0;
  border-radius: 5px;
  background-color: #f2f2f2;
  color: #4a4a4a;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.innowine-facet__more:hover,
.innowine-facet__clear:hover {
  background-color: #e8e8e8;
}

.innowine-facets__apply,
.innowine-facets__reset {
  display: block;
  padding: 11px 14px;
  border: 0;
  border-radius: 5px;
  background-color: #f2f2f2;
  color: #4a4a4a;
  font-family: inherit;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.innowine-facets__reset:hover {
  background-color: #e8e8e8;
  color: var(--black, #000);
}

/* Nothing is filtered, so there is nothing to clear. */
.innowine-facets__reset.is-disabled {
  color: #b5b5b5;
  cursor: default;
  pointer-events: none;
}

/* ------------------------------------------------------------ the slider */

.innowine-facet--price {
  gap: 8px;
}

.innowine-range {
  position: relative;
  block-size: 24px;
  margin-block-start: 4px;
  /* A click on the track moves the nearer handle (innowine-facets.js). */
  cursor: pointer;
}

.innowine-range__track {
  position: absolute;
  inset-block-start: 10px;
  inset-inline: 2px;
  block-size: 4px;
  border-radius: 2px;
  background-color: #e6e6e6;
}

.innowine-range__fill {
  position: absolute;
  inset-block: 0;
  inset-inline: 0;
  border-radius: 2px;
  background-color: var(--wpgb-accent-scheme-1, #e65953);
}

/*
 * Two inputs over one track. The input itself takes no pointer, or the one on
 * top would swallow every grab meant for the other; only the handles do.
 */
.innowine-range__input {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  inline-size: 100%;
  block-size: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  appearance: none;
  pointer-events: none;
}

.innowine-range__input::-webkit-slider-thumb {
  appearance: none;
  inline-size: 18px;
  block-size: 18px;
  border: 2px solid var(--wpgb-accent-scheme-1, #e65953);
  border-radius: 50%;
  background-color: var(--white, #fff);
  box-shadow: 0 1px 3px rgb(0 0 0 / 20%);
  cursor: grab;
  pointer-events: auto;
}

.innowine-range__input::-moz-range-thumb {
  inline-size: 18px;
  block-size: 18px;
  border: 2px solid var(--wpgb-accent-scheme-1, #e65953);
  border-radius: 50%;
  background-color: var(--white, #fff);
  box-shadow: 0 1px 3px rgb(0 0 0 / 20%);
  cursor: grab;
  pointer-events: auto;
}

.innowine-range__input:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--black, #000);
  outline-offset: 2px;
}

.innowine-range__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.innowine-range__text {
  color: var(--black, #000);
  font-size: 14px;
}

.innowine-range__foot .innowine-facet__clear {
  margin-block-start: 0;
}

/* ------------------------------------------------------- while it fetches */

/*
 * The grid is a page out of date until the answer lands, so it says so and
 * stops taking clicks. The sidebar stays live: ticking a second box while the
 * first is still in flight is normal, and the older request is dropped.
 */
.archive-body.is-filtering .archive-main {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 120ms ease-out;
}

/* --------------------------------------------------- phone: search + toggle */

/*
 * On a wide screen the two wrappers are not there as far as layout goes, and
 * the sidebar reads as it always did: one column of every filter. The toggle
 * and the "Keresés" heading belong to the narrow layout only.
 */
.innowine-facets__more,
.innowine-facets__actions {
  display: contents;
}

.innowine-facets__toggle,
.archive-sidebar__title-narrow {
  display: none;
}

/*
 * Narrow: a box with the search in it, and on its bottom edge a black
 * "Szűrők törlése" button and a "További szűrők" toggle. The row sits across
 * the border line on a white ground, so the line runs up to it from both
 * sides; the toggle drops the other filters open inside the box.
 */
@media (width <= 991px) {
  .archive-sidebar {
    --_facets-pad: 24px;
    /* The row shrinks with the screen: 44px on a tablet, 36px on a phone. */
    --_facets-actions: clamp(36px, 10vw, 44px);
    margin-block-end: calc(var(--_facets-actions) / 2);
    padding: var(--_facets-pad) var(--_facets-pad) calc(var(--_facets-actions) / 2 + 8px);
    border-color: var(--black, #000);
    border-radius: 8px;
  }

  .archive-sidebar__title {
    font-size: 20px;
    text-align: start;
  }

  .archive-sidebar__title-wide {
    display: none;
  }

  .archive-sidebar__title-narrow {
    display: inline;
  }

  .innowine-facet--search .innowine-search__input {
    border-color: var(--black, #000);
    border-radius: 0;
    font-size: 16px;
  }

  .innowine-facets__more {
    display: flex;
    flex-direction: column;
    gap: var(--space-s, 2rem);
  }

  /* `html.iw-js`: a <head> elején kerül fel (innowine-kereso-ikon.php), így a
     szűrők már az első rajzoláskor csukva vannak, nem a lábléci JS után
     (az az egész terméklistát felugrasztotta: mobil CLS 0.3-0.4). */
  .innowine-facets:has(.innowine-facets__toggle:not([hidden])[aria-expanded="false"]) .innowine-facets__more,
  html.iw-js .innowine-facets:has(.innowine-facets__toggle[aria-expanded="false"]) .innowine-facets__more {
    display: none;
  }

  .innowine-facets__actions {
    display: flex;
    align-items: center;
    align-self: center;
    gap: clamp(14px, 5vw, 32px);
    min-block-size: var(--_facets-actions);
    /* Its middle on the box's bottom border: the box's own bottom padding,
       half the row, and the border itself. */
    margin-block-end: calc(-1 * (var(--_facets-actions) + 8px + 1px));
    padding-inline: clamp(8px, 3vw, 16px);
    background-color: var(--white, #fff);
  }

  /* Exactly the row's height, so the row's middle stays on the border line. */
  .innowine-facets__reset {
    display: flex;
    align-items: center;
    min-block-size: var(--_facets-actions);
    padding: 0 clamp(14px, 5vw, 36px);
    border-radius: 4px;
    background-color: var(--black, #000);
    color: var(--white, #fff);
    font-size: clamp(13px, 3.5vw, 15px);
    font-weight: 600;
    white-space: nowrap;
  }

  /* Nothing is filtered yet: grey, the way the wide sidebar shows it. */
  .innowine-facets__reset.is-disabled {
    background-color: #f2f2f2;
    color: #b5b5b5;
  }

  .innowine-facets__reset:hover {
    background-color: #B3161E;
    color: var(--white, #fff);
  }

  .innowine-facets__toggle:not([hidden]),
  html.iw-js .innowine-facets__toggle {
    display: flex;
    align-items: center;
    gap: clamp(8px, 2.5vw, 14px);
    margin: 0;
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--black, #000);
    font-family: inherit;
    font-size: clamp(12px, 3.2vw, 13px);
    font-weight: 600;
    line-height: 1.15;
    text-align: start;
    cursor: pointer;
  }

  .innowine-facets__toggle:focus-visible {
    outline: 2px solid var(--black, #000);
    outline-offset: 4px;
  }

  /* Three bars, shortening downwards; open, they cross into an X. */
  .innowine-facets__toggle-icon {
    display: flex;
    flex-direction: column;
    gap: 5px;
    inline-size: clamp(22px, 6vw, 28px);
  }

  .innowine-facets__toggle-icon > span {
    display: block;
    block-size: 2px;
    border-radius: 1px;
    background-color: currentColor;
    transition: transform 0.2s ease, opacity 0.2s ease, inline-size 0.2s ease;
  }

  .innowine-facets__toggle-icon > span:nth-child(1) { inline-size: 100%; }
  .innowine-facets__toggle-icon > span:nth-child(2) { inline-size: 75%; }
  .innowine-facets__toggle-icon > span:nth-child(3) { inline-size: 50%; }

  .innowine-facets__toggle[aria-expanded="true"] .innowine-facets__toggle-icon > span {
    inline-size: 100%;
  }

  .innowine-facets__toggle[aria-expanded="true"] .innowine-facets__toggle-icon > span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .innowine-facets__toggle[aria-expanded="true"] .innowine-facets__toggle-icon > span:nth-child(2) {
    opacity: 0;
  }

  .innowine-facets__toggle[aria-expanded="true"] .innowine-facets__toggle-icon > span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}

@media (width <= 991px) and (prefers-reduced-motion: reduce) {
  .innowine-facets__toggle-icon > span {
    transition: none;
  }
}
