/*******************************************************

    polo.gr product category / shop pages (inc/functions/polo-category.php):
    header, filters sidebar, toolbar, product cards. Loaded only on those
    pages, after the legacy CSS, so .polo-cat-page wins over Storefront's
    float grid without !important.

 *******************************************************/



    .polo-cat-page {
        --polo-cat-soft:   #f5f5f4;
        --polo-cat-gap:    28px;
        --polo-cat-side:   250px;
    }



    /* Header */

    .polo-cat-head,
    .polo-cat {
        max-width: 1360px;
        margin-right: auto;
        margin-left: auto;
    }

    .polo-cat-head {
        margin-top: 8px;
        margin-bottom: 28px;
    }

    .polo-cat-head__crumbs {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 8px;
        margin: 0 0 14px;
        color: var( --polo-grey );
        font-family: var( --polo-font-roboto );
        font-size: 13px;
    }

    .polo-cat-head__crumbs a {
        color: var( --polo-grey );
        text-decoration: none;
    }

    .polo-cat-head__crumbs a:hover,
    .polo-cat-head__crumbs a:focus-visible {
        color: var( --polo-black );
        text-decoration: underline;
    }

    .polo-cat-head__sep {
        color: #b9bcbf;
    }

    .polo-cat-page .polo-cat-head__title {
        margin: 0;
        color: var( --polo-black );
        font-family: var( --polo-font-zona );
        font-size: clamp( 30px, 3.4vw, 48px );
        font-weight: 800;
        letter-spacing: 0;
        line-height: 1.05;
        text-align: left;
        text-transform: uppercase;
    }

    .polo-cat-head__desc {
        max-width: 760px;
        margin: 12px 0 0;
        color: #45494d;
        font-family: var( --polo-font-roboto );
        font-size: 15px;
        line-height: 1.6;
    }

    .polo-cat-head__desc p:last-child {
        margin-bottom: 0;
    }



    /* Layout: filters | products */

    .polo-cat {
        display: grid;
        grid-template-columns: var( --polo-cat-side ) minmax( 0, 1fr );
        gap: 0 40px;
        align-items: start;
        font-family: var( --polo-font-roboto );
    }

    .polo-cat__main {
        min-width: 0;
    }



    /* Filters sidebar */

    .polo-cat__filters {
        position: sticky;
        top: 110px;
        max-height: calc( 100vh - 130px );
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-right: 6px;
        scrollbar-width: thin;
    }

    .polo-cat__filters-head {
        display: none;
    }

    .polo-cat__facet {
        border-top: 1px solid var( --polo-line );
    }

    .polo-cat__facet:last-child {
        border-bottom: 1px solid var( --polo-line );
    }

    .polo-cat-page .polo-cat__facet-title {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0;
        padding: 14px 0;
        color: var( --polo-black );
        font-family: var( --polo-font-roboto );
        font-size: 14px;
        font-weight: 700;
        letter-spacing: 0.04em;
        line-height: 1.3;
        text-transform: uppercase;
        cursor: pointer;
        list-style: none;
    }

    .polo-cat__facet-title::-webkit-details-marker {
        display: none;
    }

    summary.polo-cat__facet-title::after {
        content: "+";
        font-size: 18px;
        font-weight: 400;
    }

    details[open] > summary.polo-cat__facet-title::after {
        content: "\2212";
    }

    .polo-cat__facet ul {
        margin: 0 0 14px;
        padding: 0;
        list-style: none;
    }

    .polo-cat__facet li {
        margin: 0;
    }

    .polo-cat__facet--cats ul {
        margin-top: -4px;
    }

    .polo-cat__cat,
    .polo-cat__opt {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 6px 0;
        color: #33373d;
        font-size: 14px;
        line-height: 1.35;
        text-decoration: none;
    }

    .polo-cat__cat:hover,
    .polo-cat__opt:hover,
    .polo-cat__cat:focus-visible,
    .polo-cat__opt:focus-visible {
        color: var( --polo-black );
    }

    .polo-cat__cat.is-current {
        color: var( --polo-black );
        font-weight: 700;
    }

    .polo-cat__cat.is-current::before {
        content: "";
        width: 3px;
        height: 16px;
        margin-left: -12px;
        margin-right: -1px;
        background-color: var( --polo-red );
    }

    .polo-cat__cat--all {
        color: var( --polo-grey );
    }

    .polo-cat__n {
        margin-left: auto;
        color: #9a9ea2;
        font-size: 12px;
    }

    .polo-cat__box {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        width: 18px;
        height: 18px;
        border: 1.5px solid #b9bcbf;
        border-radius: 3px;
        background-color: var( --polo-white );
        color: transparent;
        transition: background-color 0.15s, border-color 0.15s;
    }

    .polo-cat__opt:hover .polo-cat__box {
        border-color: var( --polo-black );
    }

    .polo-cat__opt.is-on .polo-cat__box {
        border-color: var( --polo-black );
        background-color: var( --polo-black );
        color: var( --polo-white );
    }

    /* Colour facet: a swatch instead of the checkbox; chosen = ringed with a check. */
    .polo-cat__swatch {
        display: inline-flex;
        flex: 0 0 auto;
        align-items: center;
        justify-content: center;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        box-shadow: inset 0 0 0 1px rgba( 0, 0, 0, 0.12 );
        color: transparent;
    }

    .polo-cat__swatch.is-light {
        box-shadow: inset 0 0 0 1px #c9ccd0;
    }

    .polo-cat__opt--colour:hover .polo-cat__swatch {
        box-shadow: 0 0 0 2px var( --polo-white ), 0 0 0 3px #b9bcbf;
    }

    .polo-cat__opt--colour.is-on .polo-cat__swatch {
        box-shadow: 0 0 0 2px var( --polo-white ), 0 0 0 3.5px var( --polo-black );
        color: var( --polo-white );
    }

    .polo-cat__opt--colour.is-on .polo-cat__swatch.is-light,
    .polo-cat__opt--colour.is-on .polo-cat__swatch[style*="#f0a81c"] {
        color: var( --polo-black );
    }

    .polo-cat__swatch .polo-cat-icon {
        width: 12px;
        height: 12px;
    }

    .polo-cat-icon {
        display: block;
        width: 1em;
        height: 1em;
    }

    .polo-cat__box .polo-cat-icon {
        width: 13px;
        height: 13px;
    }



    /* Toolbar: filters button (mobile), count, sorting */

    .polo-cat__bar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px 16px;
        margin: 0 0 18px;
        padding: 0 0 14px;
        border-bottom: 1px solid var( --polo-line );
    }

    .polo-cat-page .polo-cat__count {
        margin: 0 auto 0 0;
        color: var( --polo-grey );
        font-size: 14px;
    }

    .polo-cat__sort {
        margin: 0;
    }

    .polo-cat__sort select {
        height: 40px;
        margin: 0;
        padding: 0 34px 0 12px;
        border: 1px solid #d6d8da;
        border-radius: 4px;
        background: var( --polo-white ) url( "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%23101212' stroke-width='2' fill='none'/%3E%3C/svg%3E" ) no-repeat right 10px center / 14px;
        color: var( --polo-black );
        font-family: var( --polo-font-roboto );
        font-size: 14px;
        -webkit-appearance: none;
        appearance: none;
        cursor: pointer;
    }

    .polo-cat__filters-btn {
        display: none;
    }

    .polo-cat__chips {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin: -4px 0 20px;
        padding: 0;
        list-style: none;
    }

    .polo-cat__chips a {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 6px 10px 6px 12px;
        border-radius: 999px;
        background-color: var( --polo-cat-soft );
        color: var( --polo-black );
        font-size: 13px;
        text-decoration: none;
    }

    .polo-cat__chips a:hover,
    .polo-cat__chips a:focus-visible {
        background-color: #e8e8e6;
    }

    .polo-cat__chips .polo-cat-icon {
        width: 14px;
        height: 14px;
    }

    .polo-cat__chips .polo-cat__chips-clear a {
        background: none;
        color: var( --polo-grey );
        text-decoration: underline;
    }



    /* Product grid and cards */

    .polo-cat-page .site-main ul.products {
        display: grid;
        grid-template-columns: repeat( 4, minmax( 0, 1fr ) );
        gap: 36px var( --polo-cat-gap );
        margin: 0 0 40px;
        padding: 0;
    }

    .polo-cat-page .site-main ul.products::before,
    .polo-cat-page .site-main ul.products::after {
        display: none;
    }

    /* !important: the legacy grid sets width and margin-right with !important (css/legacy/child.css). */
    .polo-cat-page .site-main ul.products li.product {
        float: none;
        clear: none;
        width: auto !important;
        margin: 0 !important;
        padding: 0;
        text-align: left;
    }

    .polo-cat-page ul.products li.product .woocommerce-LoopProduct-link {
        display: block;
        color: var( --polo-black );
        text-decoration: none;
    }

    .polo-card__media {
        position: relative;
        display: block;
        aspect-ratio: 1 / 1;
        margin: 0 0 14px;
        overflow: hidden;
        border-radius: 6px;
        background-color: var( --polo-cat-soft );
    }

    /* Product photos are on white: multiply melts the white into the soft tile. Width/height fixed = no layout shift. */
    .polo-cat-page ul.products li.product .polo-card__media img {
        position: absolute;
        inset: 0;
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: none;
        margin: 0;
        padding: 9%;
        object-fit: contain;
        mix-blend-mode: multiply;
        border-radius: 0;
        box-shadow: none;
        transition: opacity 0.35s var( --polo-ease ), transform 0.5s var( --polo-ease );
    }

    .polo-cat-page ul.products li.product .polo-card__media img.polo-card__alt {
        opacity: 0;
    }

    @media ( hover: hover ) {

        .polo-cat-page ul.products li.product:hover .polo-card__media img {
            transform: scale( 1.03 );
        }

        .polo-cat-page ul.products li.product:hover .polo-card__media.has-alt img:not( .polo-card__alt ) {
            opacity: 0;
        }

        .polo-cat-page ul.products li.product:hover .polo-card__media.has-alt img.polo-card__alt {
            opacity: 1;
        }

    }

    .polo-cat-page .storefront-sorting:not( :has( .woocommerce-message, .woocommerce-info, .woocommerce-error ) ) {
        display: none;
    }

    .polo-cat-page ul.products li.product .woocommerce-loop-product__title,
    .polo-cat-page .polo-card__colour {
        text-align: left;
    }

    .polo-cat-page ul.products li.product .woocommerce-loop-product__title {
        margin: 0;
        padding: 0;
        color: var( --polo-black );
        font-family: var( --polo-font-roboto );
        font-size: 15px;
        font-weight: 500;
        letter-spacing: 0;
        line-height: 1.35;
        text-transform: none;
    }

    .polo-cat-page ul.products li.product .woocommerce-LoopProduct-link:hover .woocommerce-loop-product__title {
        text-decoration: underline;
        text-underline-offset: 3px;
    }

    .polo-cat-page .polo-card__colour {
        margin: 3px 0 0;
        color: var( --polo-grey );
        font-size: 13px;
        line-height: 1.35;
    }

    .polo-card__swatches {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 6px;
        margin: 10px 0 0;
        padding: 0;
        list-style: none;
    }

    .polo-card__swatches li {
        margin: 0;
    }

    .polo-card__swatches a {
        display: block;
        width: 30px;
        height: 30px;
        overflow: hidden;
        padding: 1px;
        border: 1px solid #dcdee0;
        border-radius: 50%;
        background-color: var( --polo-white );
        transition: border-color 0.15s;
    }

    .polo-card__swatches a:hover,
    .polo-card__swatches a:focus-visible {
        border-color: var( --polo-black );
    }

    .polo-cat-page ul.products li.product .polo-card__swatches img {
        display: block;
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: none;
        margin: 0;
        border-radius: 50%;
        object-fit: cover;
        transform: scale( 1.55 ); /* product photos have wide white margins: fill the circle with the bag */
    }

    .polo-card__more a {
        display: flex;
        align-items: center;
        justify-content: center;
        border-color: transparent;
        color: var( --polo-grey );
        font-size: 12px;
        text-decoration: none;
    }

    /* The old "glow" style image of some products stays inside the tile. */
    .polo-cat-page ul.products li.product .polo-card__media .style-image {
        z-index: 1;
    }

    .polo-cat-page .woocommerce-pagination {
        text-align: center;
    }



    /* Tablet: 3 per row, narrower sidebar */

    @media ( max-width: 1199px ) {

        .polo-cat-page {
            --polo-cat-side: 210px;
            --polo-cat-gap:  20px;
        }

        .polo-cat {
            gap: 0 28px;
        }

        .polo-cat-page .site-main ul.products {
            grid-template-columns: repeat( 3, minmax( 0, 1fr ) );
        }

    }



    /* Mobile and small tablets: filters become a drawer, 2 per row */

    @media ( max-width: 900px ) {

        .polo-cat {
            display: block;
        }

        .polo-cat__filters {
            position: fixed;
            top: 0;
            bottom: 0;
            left: 0;
            z-index: 2147483001;
            width: min( 360px, 88vw );
            max-height: none;
            padding: 0 20px 24px;
            background-color: var( --polo-white );
            box-shadow: 0 0 40px rgba( 0, 0, 0, 0.18 );
            transform: translateX( -105% );
            visibility: hidden;
            transition: transform 0.3s var( --polo-ease ), visibility 0s linear 0.3s;
        }

        .polo-cat.is-open .polo-cat__filters {
            transform: none;
            visibility: visible;
            transition: transform 0.3s var( --polo-ease );
        }

        .polo-cat.is-open::before {
            content: "";
            position: fixed;
            inset: 0;
            z-index: 2147483000;
            background-color: rgba( 16, 18, 18, 0.45 );
        }

        .polo-cat__filters-head {
            position: sticky;
            top: 0;
            z-index: 1;
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin: 0 -20px 6px;
            padding: 16px 20px;
            border-bottom: 1px solid var( --polo-line );
            background-color: var( --polo-white );
        }

        .polo-cat__filters-head p {
            margin: 0;
            color: var( --polo-black );
            font-size: 18px;
            font-weight: 700;
        }

        .polo-cat__filters-close {
            display: flex;
            margin: 0;
            padding: 6px;
            border: 0;
            background: none;
            color: var( --polo-black );
            font-size: 22px;
            cursor: pointer;
        }

        .polo-cat__filters-btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            height: 40px;
            margin: 0;
            padding: 0 14px;
            border: 1px solid var( --polo-black );
            border-radius: 4px;
            background-color: var( --polo-white );
            color: var( --polo-black );
            font-family: var( --polo-font-roboto );
            font-size: 14px;
            font-weight: 500;
            cursor: pointer;
        }

        .polo-cat__filters-btn .polo-cat-icon {
            width: 18px;
            height: 18px;
        }

        .polo-cat__badge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 20px;
            height: 20px;
            padding: 0 6px;
            border-radius: 999px;
            background-color: var( --polo-black );
            color: var( --polo-white );
            font-size: 12px;
        }

        .polo-cat__bar {
            gap: 10px;
        }

        .polo-cat-page .polo-cat__count {
            order: 3;
            width: 100%;
            margin: 0;
            font-size: 13px;
        }

        .polo-cat__sort {
            margin-left: auto;
        }

        .polo-cat-page .site-main ul.products {
            grid-template-columns: repeat( 2, minmax( 0, 1fr ) );
            gap: 28px 14px;
        }

        .polo-cat-page ul.products li.product .woocommerce-loop-product__title {
            font-size: 14px;
        }

        .polo-card__swatches a {
            width: 26px;
            height: 26px;
        }

        .polo-cat-head {
            margin-bottom: 20px;
        }

        /* Clamped by CSS from the first paint (no shift); the script adds the toggle when the text is longer. */
        .polo-cat-head__desc:not( .is-open ) {
            display: -webkit-box;
            overflow: hidden;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 3;
        }

        .polo-cat-head__more {
            margin: 6px 0 0;
            padding: 0;
            border: 0;
            background: none;
            color: var( --polo-black );
            font-family: var( --polo-font-roboto );
            font-size: 14px;
            font-weight: 500;
            text-decoration: underline;
            cursor: pointer;
        }

    }

    @media ( prefers-reduced-motion: reduce ) {

        .polo-cat-page ul.products li.product .polo-card__media img,
        .polo-cat__filters {
            transition: none;
        }

    }
