/* Catalog-only refinements; preserve the theme's native drawer and queries. */
body.peniel-catalog {
    --catalog-radius: var(--peniel-control-radius, 5px);
    --catalog-accent: #ba462e;
    --catalog-ink: #222;
    --catalog-border: #ddd;
}

body.peniel-catalog #shop-sidebar {
    background: #fff;
    border: 1px solid var(--catalog-border);
    border-radius: var(--catalog-radius);
    padding: 16px;
}

body.peniel-catalog #shop-sidebar .widget {
    margin-bottom: 24px;
}

body.peniel-catalog #shop-sidebar .widget:last-child {
    margin-bottom: 0;
}

body.peniel-catalog #shop-sidebar .widget_product_categories {
    padding-top: 20px;
    border-top: 1px solid var(--catalog-border);
}

body.peniel-catalog #shop-sidebar .widget-title {
    display: block;
    font-size: 16px;
    line-height: 24px;
    text-transform: none;
    letter-spacing: normal;
}

body.peniel-catalog #shop-sidebar .is-divider {
    display: none;
}

body.peniel-catalog #shop-sidebar .product-categories {
    margin-top: 12px;
}

body.peniel-catalog .peniel-catalog-description {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--catalog-border);
}

body.peniel-catalog #shop-sidebar .peniel-catalog-filter {
    margin: 0;
}

body.peniel-catalog .peniel-filter-heading {
    margin-bottom: 20px;
}

body.peniel-catalog #peniel-filter-title {
    margin: 0 0 6px;
    font-size: 18px;
    line-height: 24px;
    text-transform: none;
}

body.peniel-catalog .peniel-filter-heading p {
    margin: 0;
    color: #595959;
    font-size: 14px;
    line-height: 20px;
}

body.peniel-catalog .peniel-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

body.peniel-catalog .peniel-active-filters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 20px;
}

body.peniel-catalog :is(.peniel-filter-chip, .peniel-filter-clear) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 14px;
    line-height: 20px;
    border-radius: var(--catalog-radius);
}

body.peniel-catalog .peniel-filter-chip {
    border: 1px solid #d8bbb0;
    background: #f8eee9;
    color: #6f291c;
    max-width: 100%;
    overflow-wrap: anywhere;
}

body.peniel-catalog .peniel-filter-clear {
    color: #6f291c;
    text-decoration: underline;
    text-underline-offset: 3px;
}

body.peniel-catalog #shop-sidebar .peniel-catalog-filter .peniel-filter-field {
    margin-bottom: 16px !important;
}

/* Remove the redundant line break, not the accessible label. */
body.peniel-catalog #shop-sidebar .peniel-catalog-filter label + br {
    display: none;
}

body.peniel-catalog #shop-sidebar .peniel-catalog-filter label {
    display: block;
    margin: 0 0 6px;
    font-size: 14px;
    line-height: 20px;
    color: var(--catalog-ink);
}

body.peniel-catalog #shop-sidebar select,
body.peniel-catalog .woocommerce-ordering .orderby {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 48px;
    height: auto;
    margin: 0;
    padding: 10px 32px 10px 12px;
    border: 1px solid var(--catalog-border);
    border-radius: var(--catalog-radius);
    background-color: #fff;
    color: var(--catalog-ink);
    font-size: 16px;
    line-height: 24px;
    box-shadow: none;
}

body.peniel-catalog #shop-sidebar .peniel-catalog-filter button[type="submit"] {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    margin: 4px 0 0;
    padding: 12px 16px !important;
    border: 1px solid var(--catalog-accent);
    border-radius: var(--catalog-radius);
    background: var(--catalog-accent);
    color: #fff;
    font-size: 14px;
    line-height: 20px;
    text-transform: none;
    letter-spacing: normal;
}

body.peniel-catalog #shop-sidebar .product-categories li {
    position: relative;
}

body.peniel-catalog #shop-sidebar .product-categories li > a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    max-width: calc(100% - 42px);
    padding-block: 8px;
    font-size: 14px;
    line-height: 20px;
}

body.peniel-catalog #shop-sidebar .product-categories li.has-child > a {
    max-width: calc(100% - 76px);
}

body.peniel-catalog #shop-sidebar .product-categories .toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: 44px;
    height: 44px;
    min-height: 44px;
    margin: 0;
    padding: 0;
}

body.peniel-catalog .filter-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 10px 16px;
    border: 1px solid #aaa;
    border-radius: var(--catalog-radius);
    background: #fff;
    color: var(--catalog-ink);
    font-size: 16px;
    line-height: 24px;
    text-transform: none;
}

body.peniel-catalog .filter-button[aria-expanded="true"] {
    border-color: var(--catalog-accent);
    background: #f8eee9;
}

body.peniel-catalog :is(#shop-sidebar, .shop-page-title, .products) :is(a, button, select):focus-visible,
body.peniel-catalog :is(.peniel-filter-chip, .peniel-filter-clear):focus-visible,
body.peniel-catalog .mfp-wrap:has(#shop-sidebar) .mfp-close:focus-visible {
    outline: 2px solid #222;
    outline-offset: 2px;
}

body.peniel-catalog .products .product-small .add_to_cart_button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    max-width: 100%;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 16px;
    white-space: normal;
}

@media (min-width: 850px) {
    /* Keep the native desktop breakpoint, but give the sidebar usable width. */
    body.peniel-catalog .category-page-row {
        display: grid;
        grid-template-columns: 272px minmax(0, 1fr);
        column-gap: 0;
    }

    body.peniel-catalog .category-page-row > :is(:has(#shop-sidebar), :has(.shop-container)) {
        width: auto;
        max-width: none;
        min-width: 0;
        flex-basis: auto;
    }

    body.peniel-catalog .woocommerce-ordering {
        min-width: 260px;
        margin-bottom: 0;
    }
}

@media (min-width: 850px) and (max-width: 1023px) {
    body.peniel-catalog .products > .product {
        flex-basis: 50%;
        max-width: 50%;
    }
}

@media (max-width: 849px) {
    /* Flatten only non-semantic wrappers to align the native controls. */
    body.peniel-catalog .shop-page-title .page-title-inner {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.45fr);
        gap: 12px 8px;
        padding: 16px 16px 0;
    }

    body.peniel-catalog .shop-page-title .page-title-inner > .flex-col {
        display: contents;
        text-align: left;
    }

    body.peniel-catalog .shop-page-title .flex-col > .is-small {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    body.peniel-catalog .shop-page-title .breadcrumbs {
        text-align: left;
    }

    body.peniel-catalog .category-filtering {
        grid-column: 1;
        grid-row: 2;
        display: flex !important;
        flex-direction: column;
        padding: 0;
    }

    body.peniel-catalog .filter-button,
    body.peniel-catalog .woocommerce-ordering {
        width: 100%;
        margin: 0;
    }

    body.peniel-catalog .filter-button {
        padding-inline: 8px;
        font-size: 14px;
    }

    body.peniel-catalog .woocommerce-ordering {
        grid-column: 2;
        grid-row: 2;
        min-width: 0;
    }

    body.peniel-catalog .woocommerce-result-count.hide-for-medium {
        grid-column: 1 / -1;
        grid-row: 3;
        display: block !important;
        margin: 0;
        font-size: 14px;
        line-height: 20px;
    }

    body.peniel-catalog .category-page-row {
        padding-top: 20px;
    }

    /* Only the filters modal; leave cart/login/location overlays untouched. */
    body.peniel-catalog .mfp-wrap:has(#shop-sidebar) .mfp-content {
        width: min(360px, 100vw);
        background: #fff;
        opacity: 1;
    }

    body.peniel-catalog .mfp-wrap #shop-sidebar {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        padding: 64px 16px 24px;
        border: 0;
        border-radius: 0;
        background: #fff;
    }

    body.peniel-catalog .mfp-wrap:has(#shop-sidebar) .mfp-close {
        position: fixed;
        top: 8px;
        right: auto;
        left: calc(min(360px, 100vw) - 52px);
        width: 44px;
        height: 44px;
        min-height: 44px;
        padding: 8px;
        border-radius: var(--catalog-radius);
        color: #222;
        background: #fff;
        opacity: 1;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.peniel-catalog .mfp-wrap:has(#shop-sidebar),
    body.peniel-catalog .mfp-wrap:has(#shop-sidebar) .mfp-content {
        transition: none;
    }
}
