/* Listing bar: a sticky strip above the grid with two tabs, "Filtry" and "Sortowanie". Filters open as
   a dropdown with the groups in columns from 1000px and as a full-screen sheet (JS) below; sorting is
   a small dropdown list of links. Plain content without JS. Active filter chips sit under the bar.
   Tokens only, mobile first. Markup: template-parts/shop/filters.php, loop/orderby.php,
   filters-active.php. Behaviour: filters.js. */

/* ---------- Listing layout: bar, then the products ---------- */
.nz-shop__layout:has(> .nz-shop__filters) { row-gap: 20px; }
.nz-shop__filters { position: sticky; top: calc(var(--nz-admin-bar, 0px) + var(--nz-header-offset, 0px)); z-index: 25; background: var(--nz-bg); border-bottom: 1px solid var(--nz-line); transition: top 250ms ease; }
/* The sheet below 1000px must sit above the header and the cookie bar; a sticky parent would trap its z-index. */
.nz-shop__filters:has(.nz-filters__panel[aria-modal="true"]) { z-index: 9100; }

/* ---------- Bar ---------- */
.nz-filters { position: relative; display: block; }
.nz-filters__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding-block: 10px; }
.nz-filters__bar .nz-shop__count { margin: 0 0 0 auto; }
.nz-filters__open { display: none; }
.js .nz-filters__open { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 16px; border: 1px solid var(--nz-text); border-radius: var(--nz-radius); background: var(--nz-bg-light); color: var(--nz-text); font-size: 1rem; font-weight: 700; line-height: 1; cursor: pointer; transition: background-color 150ms, color 150ms; }
.js .nz-filters__open:hover,
.js .nz-filters__open[aria-expanded="true"] { background: var(--nz-text); color: var(--nz-bg-light); }
.js .nz-filters__open-count { font-weight: 400; }
.nz-filters__chevron { flex: 0 0 auto; width: 7px; height: 7px; margin: 0 2px 3px 4px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform 150ms; }
.nz-filters__open[aria-expanded="true"] .nz-filters__chevron { transform: rotate(-135deg); margin-bottom: -3px; }
@media (max-width: 699px) {
  .js .nz-filters__open { flex: 1 1 0; padding: 0 12px; }
  /* Two tabs fill the bar; the count would only push them apart (the status region still announces results). */
  .nz-filters__bar .nz-shop__count { display: none; }
}

/* Without JS both panels are plain content under the bar (the form ends with "Filtruj", sorting is a list of links). */
.nz-filters__panel,
.nz-sort__panel { flex: 1 1 100%; }
.nz-filters__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.nz-filters__title { margin: 0; font-size: 1.75rem; line-height: 1; }
.nz-filters__close { display: none; }
.nz-filters__form { display: flex; flex-direction: column; }
/* Skip target (woocommerce/archive-product.php, tabindex=-1): it takes focus only to move the reading position, so no outline around the whole column. */
.nz-shop__main:focus { outline: none; }

/* Dropdown panels (JS): closed until opened. Hidden only once <nz-filters> is defined, so a module
   that never starts leaves the plain form and list; until then they stay collapsed for up to 3s
   (no flash or shift while the module loads) and come back after that. */
.js nz-filters:defined .nz-filters__panel:not(.is-open),
.js nz-filters:defined .nz-sort__panel:not(.is-open) { display: none; }
.js nz-filters:not(:defined) :is(.nz-filters__panel, .nz-sort__panel) { animation: nz-filters-pending 0s linear 3s both; }
.js nz-filters:defined .nz-sort__panel { position: absolute; top: 100%; left: 0; right: 0; z-index: 2; padding: 8px; background: var(--nz-bg-light); border: 1px solid var(--nz-line-linen); border-radius: var(--nz-radius); box-shadow: var(--nz-shadow-panel); }
@media (min-width: 700px) {
  .js nz-filters:defined .nz-sort__panel { right: auto; width: 320px; }
}

/* Sorting list: one link per option, the current one marked */
.nz-sort__list { margin: 0; padding: 0; list-style: none; }
.nz-sort__link { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: var(--nz-radius); color: var(--nz-text); font-size: 1rem; line-height: 1.3; }
.nz-sort__link:hover { background: var(--nz-bg); color: var(--nz-accent-dark); }
.nz-sort__link.is-current { font-weight: 700; }
.nz-sort__link.is-current::after { content: ""; flex: 0 0 auto; width: 6px; height: 11px; margin-right: 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }

/* Group: <details> with the summary as the row, chevron at the right */
.nz-filters__group { border-top: 1px solid var(--nz-line); }
.nz-filters__summary { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0; list-style: none; cursor: pointer; font-size: 1rem; font-weight: 700; line-height: 1.3; }
.nz-filters__summary::-webkit-details-marker { display: none; }
.nz-filters__summary::after { content: ""; flex: 0 0 auto; width: 8px; height: 8px; margin: 0 6px 4px auto; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform 150ms; }
.nz-filters__group[open] > .nz-filters__summary::after { transform: rotate(-135deg); margin-bottom: -4px; }
.nz-filters__summary-text { flex: 0 1 auto; min-width: 0; }
.nz-filters__summary-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--nz-radius); background: var(--nz-text); color: var(--nz-bg-light); font-size: 0.75rem; font-weight: 700; line-height: 1; }
.nz-filters__fieldset { min-width: 0; margin: 0; padding: 0 0 14px; border: 0; }
.nz-filters__list { display: flex; flex-direction: column; }

/* Option row: the label wraps the whole 44px row */
.nz-filters__option { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 2px 0; cursor: pointer; font-size: 1rem; line-height: 1.3; }
.nz-filters__checkbox { appearance: none; -webkit-appearance: none; flex: 0 0 auto; display: grid; place-content: center; width: 22px; height: 22px; margin: 0; border: 1.5px solid var(--nz-text); border-radius: var(--nz-radius); background: var(--nz-bg-light); cursor: pointer; transition: background-color 120ms; }
.nz-filters__checkbox::before { content: ""; width: 12px; height: 12px; background: var(--nz-bg-light); clip-path: polygon(14% 44%, 0 65%, 40% 100%, 100% 22%, 86% 8%, 40% 70%); transform: scale(0); transition: transform 120ms; }
.nz-filters__checkbox:checked { background: var(--nz-text); }
.nz-filters__checkbox:checked::before { transform: scale(1); }
.nz-filters__checkbox:focus-visible { outline: var(--nz-focus); outline-offset: 2px; }
.nz-filters__option:hover .nz-filters__checkbox { border-color: var(--nz-accent-dark); }
.nz-filters__option-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.nz-filters__option-count { flex: 0 0 auto; font-size: 0.875rem; font-variant-numeric: tabular-nums; color: var(--nz-muted); }

/* "Pokaż więcej": the options past the first eight are hidden until expanded (JS only) */
.js .nz-filters__group:not(.is-expanded) .nz-filters__item--extra { display: none; }
.nz-filters__more { display: inline-flex; align-items: center; min-height: 44px; padding: 0; border: 0; background: none; color: var(--nz-text); font-size: 0.9375rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.nz-filters__more:hover { color: var(--nz-accent-dark); }
html:not(.js) .nz-filters__more { display: none; }

/* Price: two 44px inputs with the listing's min and max as placeholders */
.nz-filters__price { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.nz-filters__price-field { display: flex; flex: 1 1 88px; flex-direction: column; gap: 4px; min-width: 0; font-size: 0.875rem; font-weight: 600; }
.nz-filters__price-input { width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--nz-text); border-radius: var(--nz-radius); background: var(--nz-bg-light); color: var(--nz-text); font: inherit; font-size: 1rem; appearance: textfield; -moz-appearance: textfield; }
.nz-filters__price-input::-webkit-outer-spin-button,
.nz-filters__price-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.nz-filters__price-input::placeholder { color: var(--nz-muted); opacity: 1; }
.nz-filters__price-sep { padding-bottom: 12px; color: var(--nz-muted); }
.nz-filters__price-unit { padding-bottom: 12px; font-size: 0.9375rem; font-weight: 600; }

/* "Tylko promocje" */
.nz-filters__option--sale { min-height: 52px; border-top: 1px solid var(--nz-line); border-bottom: 1px solid var(--nz-line); font-weight: 700; }

/* Actions */
.nz-filters__actions { display: flex; flex-direction: column; align-items: stretch; gap: 12px; margin-top: 20px; }
.nz-filters__submit { width: 100%; min-height: 50px; padding: 0 20px; }
.nz-filters__clear { display: inline-flex; align-items: center; justify-content: center; align-self: center; min-height: 44px; font-size: 0.9375rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.nz-filters__clear:hover { color: var(--nz-accent-dark); }

/* ---------- Desktop (JS): filters as a dropdown, the groups side by side ---------- */
@media (min-width: 1000px) {
  .js nz-filters:defined .nz-filters__panel { position: absolute; top: 100%; left: 0; right: 0; z-index: 2; max-height: calc(100dvh - var(--nz-admin-bar, 0px) - var(--nz-header-offset, 0px) - 140px); overflow-y: auto; overscroll-behavior: contain; padding: 8px 28px 0; background: var(--nz-bg-light); border: 1px solid var(--nz-line-linen); border-radius: var(--nz-radius); box-shadow: var(--nz-shadow-panel); }
  .js nz-filters:defined .nz-filters__panel:focus { outline: none; }
  .js nz-filters:defined .nz-filters__head { display: none; }
  .js nz-filters:defined .nz-filters__fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); align-items: start; gap: 4px 36px; }
  /* Every group is open and its heading is a label, not a toggle (filters.js opens them and swallows the click). */
  .js nz-filters:defined .nz-filters__group { border-top: 0; }
  .js nz-filters:defined .nz-filters__summary { min-height: 44px; cursor: default; font-size: 0.8125rem; letter-spacing: 0.1em; text-transform: uppercase; }
  .js nz-filters:defined .nz-filters__summary::after { display: none; }
  .js nz-filters:defined .nz-filters__option--sale { align-self: end; border: 0; }
  /* The apply bar sticks to the bottom of the scrolling panel (the panel's bottom padding moved into the bar). */
  .js nz-filters:defined .nz-filters__actions { position: sticky; bottom: 0; z-index: 1; flex-direction: row-reverse; align-items: center; justify-content: space-between; margin: 8px -28px 0; padding: 16px 28px 24px; border-top: 1px solid var(--nz-line); background: var(--nz-bg-light); }
  .js nz-filters:defined .nz-filters__submit { width: auto; min-width: 240px; }
}
@media (min-width: 1200px) {
  /* The five groups in one row; price and "Tylko promocje" start the second. */
  .js nz-filters:defined .nz-filters__fields { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* ---------- Mobile (JS): the form as a full-screen sheet ---------- */
@media (max-width: 999px) {
  .js .nz-filters__panel.is-open { position: fixed; inset: 0; z-index: 9100; /* above the cookie bar of the core plugin (9000), which is inert while the sheet is open */ display: flex; flex-direction: column; padding: 0 16px max(16px, env(safe-area-inset-bottom)); background: var(--nz-bg-light); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .js .nz-filters__panel.is-open:focus { outline: none; }
  .js .nz-filters__panel.is-open .nz-filters__head { position: sticky; top: 0; z-index: 1; margin: 0 -16px 8px; padding: 10px 16px; background: var(--nz-bg-light); border-bottom: 1px solid var(--nz-line); }
  .js .nz-filters__panel.is-open .nz-filters__title { font-size: 1.5rem; }
  .js .nz-filters__panel.is-open .nz-filters__close { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; padding: 0 14px; border: 1px solid var(--nz-text); border-radius: var(--nz-radius); background: none; color: var(--nz-text); font-size: 1rem; font-weight: 700; line-height: 1; cursor: pointer; }
  .js .nz-filters__panel.is-open .nz-filters__form { flex: 1 0 auto; }
  .js .nz-filters__panel.is-open .nz-filters__actions { position: sticky; bottom: 0; z-index: 1; margin: auto -16px 0; padding: 12px 16px max(12px, env(safe-area-inset-bottom)); background: var(--nz-bg-light); border-top: 1px solid var(--nz-line); box-shadow: 0 -12px 24px -16px rgba(46, 38, 34, 0.25); }
  .js .nz-filters__panel.is-open .nz-filters__option--sale { margin-bottom: 20px; }
  .js .nz-filters__panel.is-open .nz-filters__group:first-of-type { border-top: 0; }
  /* A field that takes focus scrolls clear of the sticky head and apply bar, never under them (WCAG 2.4.11). */
  .js .nz-filters__panel.is-open { scroll-padding-block: 72px 96px; }
}
/* Short viewports (landscape phones, 200-400% zoom): head and apply bar scroll with the form, so they
   never cover most of the sheet; the apply button waits at the end of the form. */
@media (max-width: 999px) and (max-height: 480px) {
  .js .nz-filters__panel.is-open { scroll-padding-block: 0; }
  .js .nz-filters__panel.is-open :is(.nz-filters__head, .nz-filters__actions) { position: static; box-shadow: none; }
}

/* ---------- Active filter chips (under the bar) ---------- */
.nz-filters-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 20px; }
.nz-filters-active__list { display: flex; flex-wrap: wrap; gap: 8px; }
.nz-filters-active__chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px 0 14px; border: 1px solid var(--nz-line-linen); border-radius: var(--nz-radius); background: var(--nz-bg-light); color: var(--nz-text); font-size: 0.9375rem; font-weight: 600; line-height: 1.2; transition: border-color 150ms, color 150ms; }
.nz-filters-active__chip:hover { border-color: var(--nz-text); color: var(--nz-text); }
.nz-filters-active__group { font-weight: 400; color: var(--nz-text-2); }
.nz-filters-active__remove { font-size: 1.25rem; line-height: 1; color: var(--nz-text-2); }
.nz-filters-active__chip:hover .nz-filters-active__remove { color: var(--nz-accent-dark); }
.nz-filters-active__clear { display: inline-flex; align-items: center; min-height: 44px; font-size: 0.9375rem; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.nz-filters-active__clear:hover { color: var(--nz-accent-dark); }

@keyframes nz-filters-pending {
  from { visibility: hidden; height: 0; overflow: hidden; }
  to { visibility: visible; height: auto; overflow: visible; }
}

@media (prefers-reduced-motion: reduce) {
  .nz-filters__summary::after,
  .nz-filters__checkbox,
  .nz-filters__checkbox::before,
  .nz-filters-active__chip { transition: none; }
}
