/* WIM FOTO Filter — frontend styles v0.1.0 */

/* ── Wrapper ── */
.wimfoto-filter-wrap {
    font-family: inherit;
}

/* ── Tuotelistan sivupadding ── */
.woocommerce ul.products,
.woocommerce-page ul.products {
    padding-left: 40px !important;
    padding-right: 40px !important;
}

/* ── Filter bar ── */
.wff-bar {
    display: flex;
    align-items: stretch;
    background: #F8F7F6;
    border: none;
    margin: 0;
    z-index: 400;
    padding-left: 40px;
    padding-right: 40px;
}

/* Kun JS lisää is-stuck-luokan, filtteri kiinnittyy fixed-positiolla */
.wff-bar.is-stuck {
    position: fixed;
    top: 71px;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 400;
    border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* Placeholder pitää layoutin paikallaan kun filtteri irtoaa virrasta */
.wff-bar-placeholder {
    display: none;
}
.wff-bar-placeholder.is-visible {
    display: block;
}

@media (max-width: 1200px) {
    .wff-bar.is-stuck { top: 60px; }
}
@media (max-width: 650px) {
    .wff-bar.is-stuck { top: 50px; }
}

/* Tag-wrap sticky — top asetetaan JS:llä dynaamisesti */
.wff-tags-wrap.is-stuck {
    position: fixed;
    top: 120px; /* fallback — JS ylikirjoittaa tämän */
    left: 0;
    right: 0;
    z-index: 399;
}

.wff-group {
    position: relative;
    border: none;
}

.wff-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 18px;
    height: 46px;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: #111;
    background: none;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s;
    font-family: inherit;
}

.wff-btn:hover {
    color: #888;
    background: none;
}
.wff-btn[aria-expanded="true"] {
    color: #111;
    background: none;
}

/* active dot */
.wff-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #111;
    display: none;
    flex-shrink: 0;
}
.wff-btn.has-selection .wff-dot { display: block; }

/* chevron */
.wff-chev {
    width: 9px;
    height: 9px;
    opacity: 0.4;
    transition: transform 0.15s;
    flex-shrink: 0;
}
.wff-btn[aria-expanded="true"] .wff-chev { transform: rotate(180deg); }

/* ── Dropdown ── */
.wff-dd {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #F8F7F6;
    border: 0.5px solid #e0ddd8;
    border-top: none;
    z-index: 500;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.wff-dd.is-open { display: block; }

/* ── Category grid — images (styles moved to thumb section) ── */

.wff-cat-thumb {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    overflow: hidden;
    border: 0.5px solid #e0ddd8;
    background: #f5f4f1;
    flex-shrink: 0;
    /* Kiinteä korkeus — kaikki thumbnailit saman kokoisia kuvasuhteesta riippumatta */
    display: flex;
    align-items: center;
    justify-content: center;
}
.wff-cat-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;   /* cover täyttää alueen, crop jos tarpeen */
    display: block;
}
.wff-cat-thumb-placeholder {
    width: 100%;
    height: 100%;
    background: #eeecea;
}

/* Kuva-grid: kaikki rivit saman korkuisia */
.wff-cat-grid--images {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 14px;
    width: 320px;
    /* align-items: start jotta lyhyemmät itemit ei veny */
    align-items: start;
}

/* Thumbnail-version cat-item */
.wff-cat-grid--images .wff-cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 7px 3px;
    border-radius: 6px;
    border: 0.5px solid transparent;
    transition: all 0.12s;
    min-height: 80px;
    justify-content: flex-start;
}

.wff-cat-lbl {
    font-size: 9.5px;
    letter-spacing: 0.03em;
    color: #888;
    text-align: center;
    line-height: 1.3;
}
.wff-cat-item.is-selected .wff-cat-lbl {
    color: #111;
    font-weight: 500;
}

/* ── Category grid — text, vaakasuora grid ── */
.wff-cat-grid--text {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    padding: 4px 8px 8px;
    width: 300px;
}

.wff-cat-grid--text .wff-cat-item {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    min-height: 0 !important;
    gap: 6px;
    cursor: pointer;
    padding: 5px 6px;
    border-radius: 3px;
    font-size: 11px;
    color: #111;
    letter-spacing: 0.02em;
    border: none !important;
    transition: color 0.1s;
}
.wff-cat-grid--text .wff-cat-item:hover {
    background: none !important;
    color: #888;
}
.wff-cat-grid--text .wff-cat-item.is-selected {
    font-weight: 500;
    color: #111;
}
.wff-cat-grid--text .wff-cat-item .wff-chk {
    flex-shrink: 0;
    display: flex !important;
}
/* Piilotetaan .wff-cat-lbl tekstiversiossa — teksti on suoraan span:ssa */
.wff-cat-grid--text .wff-cat-item .wff-cat-lbl {
    display: none;
}

/* ── Shared checkbox ── */
.wff-chk {
    width: 13px;
    height: 13px;
    border: 0.5px solid #ccc;
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
}
.is-selected .wff-chk {
    background: #111;
    border-color: #111;
}
.is-selected .wff-chk::after {
    content: '';
    display: block;
    width: 7px;
    height: 4px;
    border-left: 1.5px solid #fff;
    border-bottom: 1.5px solid #fff;
    transform: rotate(-45deg) translate(1px, -1px);
}

/* ── Toggle button (Lisää/Piilota kuvat) — piilotettu toistaiseksi ── */
.wff-img-toggle {
    display: none !important;
}

/* ── Attribute list ── */
.wff-attr-list { padding: 8px; }

.wff-attr-opt {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    font-size: 12px;
    color: #888;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.1s, color 0.1s;
}
.wff-attr-opt:hover { background: #f5f4f1; color: #111; }
.wff-attr-opt.is-selected { color: #111; }

/* ── Tag-wrap: istuu filtteripalkki alapuolella ── */
.wff-tags-wrap {
    background: #F8F7F6;
    border: none;
    padding-left: 40px;
    padding-right: 40px;
}

/* ── Active filter tags ── */
.wff-tags {
    display: none;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    margin: 0 0 4px;
}
.wff-tags.has-tags { display: flex; }

.wff-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: transparent;
    border: 0.5px solid #999;
    border-radius: 20px;
    font-size: 10px;
    letter-spacing: 0.04em;
    color: #111;
}
.wff-tag-remove {
    background: none !important;
    border: none !important;
    cursor: pointer;
    color: #ccc !important;
    font-size: 14px;
    line-height: 1;
    padding: 0 0 0 2px;
    font-family: inherit;
    transition: color 0.1s;
}
.wff-tag-remove:hover { color: #bbb !important; background: none !important; }

.wff-clear-all {
    font-size: 11px;
    color: #aaa !important;
    cursor: pointer;
    margin-left: 6px;
    text-decoration: none !important;
    background: none !important;
    border: none !important;
    font-family: inherit;
    letter-spacing: 0.03em;
    transition: color 0.1s;
}
.wff-clear-all:hover { color: #bbb !important; background: none !important; }






/* ══════════════════════════════════════════════
   MOBIILI — alle 768px
   Filtteripalkki tiivistyy "FILTERS"-nappiin
   joka avaa full-screen drawerin
══════════════════════════════════════════════ */

@media (max-width: 768px) {

    /* Piilotetaan desktop-filtterit mutta ei mobiili-toggle-ryhmää */
    .wff-bar .wff-group:not(.wff-mobile-group) {
        display: none;
    }

    /* Piilotetaan kategoriakuvat mobiilissa */
    .wff-cat-grid--images {
        display: none !important;
    }
    .wff-cat-grid--text {
        display: grid !important;
    }
    /* Drawer kategoriat tekstinä */
    .wff-drawer-cat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .wff-drawer-cat-thumb {
        display: none;
    }
    .wff-drawer-cat-item {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 8px 4px;
    }
    .wff-drawer-cat-lbl {
        font-size: 12px;
        text-align: left;
    }

    /* Näytetään mobiili-toggle-nappi — tummempi, selkeämpi */
    .wff-mobile-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0 20px;
        height: 46px;
        font-size: 11px;
        letter-spacing: 0.08em;
        color: #111;
        font-weight: 500;
        background: none;
        border: none;
        cursor: pointer;
        font-family: inherit;
        border-right: 0.5px solid #e0ddd8;
    }
    .wff-mobile-toggle:hover { color: #555; }
    .wff-mobile-toggle.is-active {
        background: #111 !important;
        color: #fff !important;
    }
    .wff-mobile-toggle-count {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: #111;
        color: #fff;
        font-size: 10px;
        display: none;
    }
    .wff-mobile-toggle-count.has-count {
        display: inline-flex;
    }

    /* Tag-wrap mobiilissa ei sticky — näkyy normaalisti */
    .wff-tags-wrap.is-stuck {
        position: static;
    }
}

@media (min-width: 769px) {
    .wff-mobile-toggle { display: none; }
}

/* ── Drawer ── */
.wff-drawer {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
}
.wff-drawer.is-open {
    display: block;
}

.wff-drawer-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.3);
}

.wff-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 400px;
    background: #fff;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.25s ease;
}
.wff-drawer.is-open .wff-drawer-panel {
    transform: translateX(0);
}

/* Mobiilissa: drawer kiinni filtteripalkissa */
@media (max-width: 768px) {
    /* Drawer fixed filtteripalkin alle */
    .wff-drawer {
        display: none;
        position: fixed;
        top: auto; /* asetetaan JS:llä */
        left: 0;
        right: 0;
        bottom: auto;
        z-index: 401;
        inset: unset;
        width: 100%;
    }
    .wff-drawer.is-open {
        display: block;
    }
    .wff-drawer-overlay {
        display: none;
    }
    .wff-drawer-panel {
        position: static;
        transform: none !important;
        max-width: 100%;
        width: 100%;
        background: #fff;
        border-bottom: 0.5px solid #e0ddd8;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
        max-height: 70vh;
        overflow-y: auto;
    }
    .wff-drawer-header {
        display: none;
    }
    .wff-drawer-footer {
        position: static;
        max-width: 100%;
    }
    .wff-drawer-body {
        padding: 8px 0;
    }
}

.wff-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 0.5px solid #e0ddd8;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}
.wff-drawer-title {
    font-size: 12px;
    letter-spacing: 0.06em;
    color: #111;
    font-weight: 500;
}
.wff-drawer-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: #888;
    line-height: 1;
    padding: 0;
    font-family: inherit;
}

/* Drawer-sisältö: filtterit pystylistana */
.wff-drawer-body {
    padding: 8px 0 80px;
}

.wff-drawer-group {
    border-bottom: 0.5px solid #f0eeeb;
}

.wff-drawer-group-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 20px;
    font-size: 12px;
    letter-spacing: 0.06em;
    color: #888;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}
.wff-drawer-group-btn.has-selection {
    color: #111;
}
.wff-drawer-group-btn svg {
    width: 10px;
    height: 10px;
    opacity: 0.4;
    transition: transform 0.15s;
    flex-shrink: 0;
}
.wff-drawer-group-btn.is-open svg {
    transform: rotate(180deg);
}

.wff-drawer-options {
    display: none;
    padding: 4px 20px 16px;
}
.wff-drawer-options.is-open {
    display: block;
}

/* Kategoriat drawerissa — 3-sarakkeinen grid thumbnailin kanssa */
.wff-drawer-cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.wff-drawer-cat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 8px 4px;
    border-radius: 6px;
    border: 0.5px solid transparent;
    transition: all 0.12s;
}
.wff-drawer-cat-item:hover,
.wff-drawer-cat-item.is-selected {
    background: #f5f4f1;
    border-color: #e0ddd8;
}
.wff-drawer-cat-item.is-selected {
    border-color: #888;
}
.wff-drawer-cat-thumb {
    width: 64px;
    height: 64px;
    border-radius: 4px;
    overflow: hidden;
    background: #f0ede8;
    border: 0.5px solid #e0ddd8;
}
.wff-drawer-cat-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.wff-drawer-cat-thumb-placeholder {
    width: 100%;
    height: 100%;
    background: #eeecea;
}
.wff-drawer-cat-lbl {
    font-size: 9px;
    letter-spacing: 0.03em;
    color: #888;
    text-align: center;
    line-height: 1.3;
}
.wff-drawer-cat-item.is-selected .wff-drawer-cat-lbl {
    color: #111;
    font-weight: 500;
}

/* Attribuutit drawerissa */
.wff-drawer-attr-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    font-size: 13px;
    color: #888;
    cursor: pointer;
    border-bottom: 0.5px solid #f8f7f5;
}
.wff-drawer-attr-opt:last-child { border-bottom: none; }
.wff-drawer-attr-opt.is-selected { color: #111; }

/* Drawer footer: näytä tulokset -nappi */
.wff-drawer-footer {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 400px;
    padding: 16px 20px;
    background: #fff;
    border-top: 0.5px solid #e0ddd8;
}
.wff-drawer-apply {
    display: block;
    width: 100%;
    padding: 12px;
    background: #111;
    color: #fff;
    border: none;
    font-size: 12px;
    letter-spacing: 0.06em;
    cursor: pointer;
    font-family: inherit;
    border-radius: 4px;
    transition: opacity 0.15s;
}
.wff-drawer-apply:hover { opacity: 0.8; }

/* Termi ei saatavilla valitussa kategoriassa — piilotetaan */
.wff-attr-opt.is-unavailable {
    display: none;
}


/* ══════════════════════════════════════════════
   TUOTEKORTTI — kaikki kortit saman korkuisia
   otsikko/hinta pysyy aina alhaalla
══════════════════════════════════════════════ */
.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
    display: flex !important;
    flex-direction: column !important;
}
.woocommerce ul.products li.product .astra-shop-thumbnail-wrap,
.woocommerce-page ul.products li.product .astra-shop-thumbnail-wrap {
    flex: 1 1 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    /* Kiinteä minimikorkeus — vaakakuvat eivät litistä korttia */
    min-height: 280px !important;
}
.woocommerce ul.products li.product .astra-shop-summary-wrap,
.woocommerce-page ul.products li.product .astra-shop-summary-wrap {
    flex-shrink: 0 !important;
    margin-top: 0 !important;
    width: 100% !important;
}

/* attr hover override */
.wff-attr-opt:hover { background: none !important; color: #bbb !important; }
