/* ==========================================================================
   udi-theme — product archive (shop + category/tag): Figma 20:124 / 20:483
   Toolbar, active-filter chips, product grid, pagination and the off-canvas
   filter drawer with a dynamic price range. Roboto for UI text, Inter for the
   page heading and product-card names.
   ========================================================================== */

/* Roboto (self-hosted) — 400–700, needed globally on the archive */
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/roboto-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Roboto';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('../fonts/roboto-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.shop {
    --shop-font: 'Roboto', var(--font-sans);
    padding-block: 48px 96px;
}

/* --------------------------------------------------------------------------
   Header: title + description (left column, per design)
   -------------------------------------------------------------------------- */
/* Head shares the centered grid container (.u-wrap); only the title/description
   copy is capped so it reads well and starts flush with the product grid. */
.shop__head > * {
    max-width: 646px;
}

.shop__title {
    margin: 0;
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: clamp(30px, 3.2vw, 40px);
    line-height: 1.2;
    color: var(--c-black);
}

.shop__desc {
    margin-top: 40px;
    font-size: 16px;
    line-height: 1.5;
    color: var(--c-black);
}

.shop__desc p {
    margin: 0 0 12px;
}

.shop__desc p:last-child {
    margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Toolbar: filter button + sort, then chips + clear-all + result count
   -------------------------------------------------------------------------- */
.shop__bar {
    margin-top: 48px;
    font-family: var(--shop-font);
}

.shop__bar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.shop__filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--c-black);
    border: 1px solid var(--c-black);
    border-radius: 100px;
    color: var(--c-white);
    font-family: var(--shop-font);
    font-size: 16px;
    line-height: 1.5;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.shop__filter-toggle .udi-icon {
    width: 24px;
    height: 24px;
}

.shop__filter-toggle:hover,
.shop__filter-toggle:focus-visible {
    background: var(--c-white);
    color: var(--c-black);
}

/* Sort dropdown */
.shop__sort {
    position: relative;
    flex: 0 0 auto;
}

/* Tools group (column switcher + sort) on the right of the bar */
.shop__tools {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    flex: 0 0 auto;
}

.shop__cols {
    display: flex;
    align-items: center;
    gap: 6px;
}

.shop__cols-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--c-gray);
    border-radius: 8px;
    color: #969696;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.shop__cols-btn:hover,
.shop__cols-btn:focus-visible,
.shop__cols-btn.is-active {
    color: var(--c-ink);
    border-color: var(--c-ink);
}

/* Column options available per breakpoint: desktop 3/4/5 */
@media (min-width: 1024px) {
    .shop__cols-btn[data-cols="3"],
    .shop__cols-btn[data-cols="4"],
    .shop__cols-btn[data-cols="5"] {
        display: inline-flex;
    }
}

/* tablet 2/3/4 */
@media (min-width: 561px) and (max-width: 1023px) {
    .shop__cols-btn[data-cols="2"],
    .shop__cols-btn[data-cols="3"],
    .shop__cols-btn[data-cols="4"] {
        display: inline-flex;
    }
}

/* mobile 1/2 */
@media (max-width: 560px) {
    .shop__cols-btn[data-cols="1"],
    .shop__cols-btn[data-cols="2"] {
        display: inline-flex;
    }
}

.shop__sort-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    background: none;
    border: 0;
    color: var(--c-black);
    font-family: var(--shop-font);
    font-size: 16px;
    line-height: 1.5;
    cursor: pointer;
}

.shop__sort-toggle .udi-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
}

.shop__sort-toggle[aria-expanded='true'] .udi-icon {
    transform: rotate(180deg);
}

.shop__sort-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 20;
    min-width: 220px;
    margin: 0;
    padding: 8px;
    list-style: none;
    background: var(--c-white);
    border: 1px solid var(--c-gray);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgb(0 0 0 / 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.shop__sort.is-open .shop__sort-menu {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.shop__sort-menu a {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--c-black);
    font-size: 15px;
    line-height: 1.4;
    text-decoration: none;
}

.shop__sort-menu li[aria-selected='true'] a {
    font-weight: 600;
}

.shop__sort-menu a:hover,
.shop__sort-menu a:focus-visible {
    background: #feeff8;
    color: var(--c-primary);
}

/* Chips + clear-all + count row */
.shop__meta {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-top: 32px;
    min-height: 40px;
}

.shop__chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.shop__chips:empty {
    display: none;
}

.shop__chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 16px;
    background: #feeff8;
    border-radius: 100px;
    color: var(--c-black);
    font-size: 16px;
    line-height: 1.5;
    text-decoration: none;
    transition: background 0.15s ease;
}

.shop__chip:hover,
.shop__chip:focus-visible {
    background: #fcdcec;
}

.shop__chip-x {
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    color: var(--c-black);
}

.shop__chip-x .udi-icon {
    width: 16px;
    height: 16px;
}

.shop__resinfo {
    display: flex;
    align-items: center;
    gap: 40px;
    flex: 0 0 auto;
    margin-left: auto;
}

.shop__clear {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--c-black);
    font-size: 16px;
    line-height: 1.5;
    text-decoration: none;
}

.shop__clear span {
    text-decoration: underline;
    text-underline-position: from-font;
}

.shop__clear .udi-icon {
    width: 24px;
    height: 24px;
}

.shop__clear:hover span,
.shop__clear:focus-visible span {
    color: var(--c-primary);
}

.shop__count {
    color: #7f7f7f;
    font-size: 16px;
    line-height: 1.5;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Product grid
   -------------------------------------------------------------------------- */
.shop__body {
    margin-top: 40px;
}

.shop__grid {
    display: grid;
    grid-template-columns: repeat(var(--shop-cols-d, 3), minmax(0, 1fr));
    gap: 64px 40px;
}

.shop__empty {
    margin: 40px 0;
    font-size: 18px;
    color: var(--c-text);
}

/* Card CTA: "Dodaj do koszyka" / "Wybierz opcje" — pink outline (Figma).
   Specificity high enough to beat WooCommerce's default `.woocommerce a.button`. */
.shop .shop__grid a.pcard__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    margin-top: 16px;
    padding: 8px 20px;
    background: transparent;
    border: 1px solid var(--c-primary);
    border-radius: 100px;
    color: var(--c-primary);
    font-family: var(--shop-font);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.shop .shop__grid a.pcard__btn:hover,
.shop .shop__grid a.pcard__btn:focus-visible {
    background: var(--c-primary);
    color: var(--c-white);
}

.shop .shop__grid a.pcard__btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* WooCommerce appends a "Zobacz koszyk" link after an AJAX add — the mini
   cart opens instead, so hide it. */
.shop .shop__grid .added_to_cart {
    display: none;
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.shop__pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-top: 64px;
    font-family: var(--shop-font);
}

.shop__pagination:empty {
    display: none;
}

.shop__page,
.shop__page-arrow {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    color: var(--c-black);
    font-size: 16px;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.shop__page {
    border: 1px solid var(--c-black);
    background: var(--c-white);
}

.shop__page:hover,
.shop__page:focus-visible {
    background: #feeff8;
}

.shop__page.is-active {
    background: var(--c-black);
    border-color: var(--c-black);
    color: var(--c-white);
}

.shop__page-arrow {
    border: 1px solid var(--c-black);
}

.shop__page-arrow .udi-icon {
    width: 18px;
    height: 18px;
}

.shop__page-arrow:hover,
.shop__page-arrow:focus-visible {
    background: var(--c-black);
    color: var(--c-white);
}

.shop__page-arrow.is-disabled {
    opacity: 0.3;
    pointer-events: none;
}

.shop__page-dots {
    min-width: 24px;
    text-align: center;
    color: #7f7f7f;
}

/* ==========================================================================
   Off-canvas filter drawer (Figma 20:483)
   ========================================================================== */
.udi-filters {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    width: min(560px, 100vw);
    background: var(--c-white);
    font-family: var(--shop-font);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1), visibility 0s linear 0.32s;
}

.udi-filters.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1), visibility 0s;
}

.udi-filters__head {
    position: relative;
    flex: 0 0 auto;
    padding: 48px 48px 16px;
}

.udi-filters__title {
    margin: 0;
    font-family: var(--shop-font);
    font-weight: 700;
    font-size: 24px;
    line-height: 1.4;
    color: var(--c-black);
}

.udi-filters__close {
    position: absolute;
    top: 16px;
    right: 16px;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    background: none;
    border: 0;
    color: var(--c-black);
    cursor: pointer;
}

.udi-filters__close .udi-icon {
    width: 22px;
    height: 22px;
}

.udi-filters__body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 0 48px 20px;
}

.udi-filters__group {
    padding-bottom: 4px;
}

.udi-filters__grouphead {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
    border-top: 1px solid var(--c-black);
}

.udi-filters__grouptitle {
    flex: 1 0 0;
    min-width: 0;
    font-weight: 600;
    font-size: 18px;
    line-height: 1.5;
    color: var(--c-black);
}

.udi-filters__clear {
    flex: 0 0 auto;
    padding: 0;
    background: none;
    border: 0;
    color: var(--c-black);
    font-family: var(--shop-font);
    font-size: 16px;
    line-height: 1.5;
    cursor: pointer;
}

.udi-filters__clear:hover,
.udi-filters__clear:focus-visible {
    color: var(--c-primary);
}

.udi-filters__opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    cursor: pointer;
}

.udi-filters__opt.is-empty {
    opacity: 0.4;
    cursor: default;
}

.udi-filters__opt input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 0;
    display: grid;
    place-items: center;
    background: var(--c-white);
    border: 1px solid var(--c-black);
    border-radius: 0;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.udi-filters__opt input:checked {
    background: var(--c-black);
}

.udi-filters__opt input:checked::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid var(--c-white);
    border-width: 0 2px 2px 0;
    transform: translateY(-1px) rotate(45deg);
}

.udi-filters__opt input:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

.udi-filters__optlabel {
    font-size: 16px;
    line-height: 1.5;
    color: var(--c-black);
}

.udi-filters__count {
    color: #818181;
}

/* Price range (dual native sliders overlaid) */
.udi-filters__group--price .udi-range {
    margin: 16px 12px 0;
}

.udi-range {
    position: relative;
    height: 24px;
}

.udi-range__track {
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    height: 4px;
    background: #eee;
    border-radius: 2px;
}

.udi-range__fill {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--c-black);
    border-radius: 2px;
}

.udi-range__input {
    position: absolute;
    top: 10px;
    left: 0;
    width: 100%;
    height: 4px;
    margin: 0;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
}

.udi-range__input::-webkit-slider-runnable-track {
    height: 4px;
    background: transparent;
    border: 0;
}

.udi-range__input::-moz-range-track {
    height: 4px;
    background: transparent;
    border: 0;
}

.udi-range__input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    pointer-events: auto;
    width: 20px;
    height: 20px;
    margin-top: -8px;
    border-radius: 50%;
    background: var(--c-white);
    border: 2px solid var(--c-black);
    box-shadow: 0 0 10px rgb(0 0 0 / 0.1);
    cursor: pointer;
}

.udi-range__input::-moz-range-thumb {
    pointer-events: auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--c-white);
    border: 2px solid var(--c-black);
    box-shadow: 0 0 10px rgb(0 0 0 / 0.1);
    cursor: pointer;
}

.udi-range__input:focus-visible::-webkit-slider-thumb {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

.udi-filters__group--price .udi-range__label {
    margin: 24px 12px 0;
    font-size: 18px;
    line-height: 1.5;
    color: var(--c-black);
}

.udi-filters__foot {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 48px;
    border-top: 1px solid var(--c-gray);
}

.udi-filters__clearall {
    padding: 0;
    background: none;
    border: 0;
    color: var(--c-black);
    font-family: var(--shop-font);
    font-size: 16px;
    line-height: 1.5;
    text-decoration: underline;
    text-underline-position: from-font;
    cursor: pointer;
}

.udi-filters__clearall:hover,
.udi-filters__clearall:focus-visible {
    color: var(--c-primary);
}

.udi-filters__apply {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    padding: 12px 28px;
    background: var(--c-black);
    border: 1px solid var(--c-black);
    border-radius: 100px;
    color: var(--c-white);
    font-family: var(--shop-font);
    font-size: 16px;
    line-height: 1.5;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.udi-filters__apply:hover,
.udi-filters__apply:focus-visible {
    background: var(--c-white);
    color: var(--c-black);
}

.udi-filters-overlay {
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgb(0 0 0 / 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

body.udi-filters-open .udi-filters-overlay {
    opacity: 1;
    pointer-events: auto;
}

body.udi-filters-open {
    overflow: hidden;
}

/* Busy state while a fetch is in flight */
.shop.is-loading .shop__results,
.shop.is-loading .shop__pagination {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1023px) {
    .shop {
        padding-block: 32px 64px;
    }

    .shop__grid {
        grid-template-columns: repeat(var(--shop-cols-t, 2), minmax(0, 1fr));
        gap: 40px 24px;
    }

    /* Sort below the filter button so a long label never overflows the row */
    .shop__bar-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .shop__sort-menu {
        left: 0;
        right: auto;
    }

    .shop__meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .shop__resinfo {
        margin-left: 0;
        gap: 24px;
    }
}

@media (max-width: 560px) {
    .shop__grid {
        grid-template-columns: repeat(var(--shop-cols-m, 1), minmax(0, 1fr));
    }

    .udi-filters__head {
        padding: 32px 24px 16px;
    }

    .udi-filters__body {
        padding: 0 24px 20px;
    }

    .udi-filters__foot {
        padding: 12px 24px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .udi-filters,
    .udi-filters.is-open,
    .udi-filters-overlay,
    .shop__sort-menu {
        transition: none;
    }
}
