/*
  The product list, part 5, loaded last so it overrides the rest: tablet and phone. Up to 900 px the filter panel
  is a bottom sheet opened by All filters; up to 640 px the table is 1IT.my's rows that open (look pref `phone` =
  rows, the default) or the table itself.
*/
.filter-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: color-mix(in srgb, var(--deep) 55%, var(--clear));
}
@media (min-width: 901px) and (max-width: 1180px) {
    :root {
        --list-panel-w: 252px;
    }
    .list-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
    .count-word {
        display: none;
    }
}
/* Narrower than the specs allow: the price moves beside the name (1IT.my does the same) */
@media (max-width: 1180px) {
    :root[data-panel] .product-table .is-late {
        display: none;
    }
    :root[data-panel] .product-table .is-early {
        display: table-cell;
    }
    .product-table .col-id {
        width: 260px;
        min-width: 260px;
        max-width: 260px;
    }
}
@media (max-width: 900px) {
    .catalog-work.with-filters,
    :root[data-panel="hidden"] .catalog-work.with-filters {
        display: block;
    }
    .filter-panel,
    :root[data-panel="hidden"] .filter-panel {
        display: none;
    }
    .filter-panel.is-open,
    :root[data-panel="hidden"] .filter-panel.is-open {
        display: block;
        position: fixed;
        inset: auto 0 0;
        z-index: 210;
        max-height: 88dvh;
        border: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        box-shadow: var(--list-shadow-lift);
        animation: list-sheet-up 0.22s ease-out;
    }
    .filter-panel.is-open .filter-head {
        padding: 18px 12px 12px 20px;
    }
    .filter-panel.is-open .filter-head::before {
        content: "";
        position: absolute;
        top: 6px;
        left: calc(50% - 20px);
        width: 40px;
        height: 4px;
        border-radius: var(--radius-pill);
        background: var(--border);
    }
    .filter-panel.is-open .filter-head h2 {
        font-size: 17px;
    }
    .filter-panel.is-open .filter-section {
        padding-inline: 20px;
    }
    .filter-panel.is-open .facet-chip {
        min-height: 36px;
        padding-inline: 13px;
        font-size: 14px;
    }
    .filter-panel.is-open .sort-option {
        min-height: 40px;
        font-size: 14px;
    }
    .filter-foot {
        position: sticky;
        bottom: 0;
        justify-content: space-between;
        padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--border);
        background: var(--surface);
    }
    .filter-panel .filter-foot .filter-done {
        display: inline-flex;
        height: 42px;
        padding: 0 20px;
        border-radius: var(--radius-sm);
        font-size: 14px;
    }
    :root.sheet-open,
    :root.sheet-open body {
        overflow: hidden;
    }
    .list-toolbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px;
    }
    .filter-toggle {
        border-color: var(--accent);
        background: var(--accent);
        color: var(--accent-ink);
    }
    .filter-toggle b {
        background: var(--accent-ink);
        color: var(--accent);
    }
    .facet-area {
        flex-basis: 100%;
        order: 3;
    }
    .list-head h1 {
        font-size: 24px;
    }
    .list-grid {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    }
}
@media (max-width: 640px) {
    .list-head {
        margin-bottom: 10px;
    }
    .list-head h1 {
        font-size: 22px;
    }
    .strip-area {
        margin-bottom: 12px;
    }
    .strip-chip {
        height: 36px;
        font-size: 13px;
    }
    .strip-photo {
        width: 26px;
        height: 26px;
    }
    :root[data-strip="tiles"] .strip-chip {
        width: 96px;
        height: 96px;
        font-size: 12px;
    }
    :root[data-strip="tiles"] .strip-photo {
        width: 44px;
        height: 36px;
    }
    .scroll-arrow {
        display: none;
    }
    .view-switch span,
    .count-word {
        display: none;
    }
    .view-switch button {
        padding: 0 9px;
    }
    .list-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    .catalog-results .empty-store {
        flex-direction: column;
        gap: 12px;
        padding: 20px;
    }

    /* The table on a phone, by choice: a narrower frozen product column, the name on two lines */
    :root[data-phone="table"] .product-table .col-id {
        width: 210px;
        min-width: 210px;
        max-width: 210px;
    }
    :root[data-phone="table"] .row-rank,
    :root[data-phone="table"] .th-rank {
        display: none;
    }
    :root[data-phone="table"] .row-name {
        display: -webkit-box;
        white-space: normal;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    :root[data-phone="table"] .table-scroll {
        max-height: 75dvh;
    }
    :root[data-phone="table"] .product-table .col-buy {
        position: static;
        box-shadow: none;
    }
    .columns-word {
        display: none;
    }

    /* Rows that open: photo, brand, name and three key facts; price on the right; the rest once opened */
    :root:not([data-phone="table"]) .table-scroll {
        max-height: none;
        overflow: visible;
    }
    :root:not([data-phone="table"]) .product-table,
    :root:not([data-phone="table"]) .product-table tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }
    :root:not([data-phone="table"]) .product-table thead,
    :root:not([data-phone="table"]) .columns-menu {
        display: none;
    }
    :root:not([data-phone="table"]) .product-row {
        position: relative;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 10px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }
    :root:not([data-phone="table"]) .product-row:last-child {
        border-bottom: 0;
    }
    :root:not([data-phone="table"]) .product-row td {
        display: none;
        position: static;
        width: auto;
        min-width: 0;
        max-width: none;
        height: auto;
        padding: 0;
        border: 0;
        background: var(--clear);
        box-shadow: none;
        white-space: normal;
    }
    /* The product cell spans the row; the price sits over its top right, beside the brand and the name. */
    :root:not([data-phone="table"]) .product-row .col-id,
    :root:not([data-phone="table"]) .product-row .col-price.is-early {
        display: block;
        grid-row: 1;
    }
    :root:not([data-phone="table"]) .product-row .col-id {
        grid-column: 1 / -1;
    }
    :root:not([data-phone="table"]) .product-row .col-price {
        grid-column: 2;
        align-self: start;
    }
    :root:not([data-phone="table"]) .row-brand,
    :root:not([data-phone="table"]) .row-name {
        margin-right: 66px;
    }
    :root:not([data-phone="table"]) .row-rank {
        display: none;
    }
    :root:not([data-phone="table"]) .row-id {
        align-items: flex-start;
    }
    :root:not([data-phone="table"]) .row-photo {
        width: 48px;
        height: 48px;
    }
    :root:not([data-phone="table"]) .row-keys {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        min-width: 0;
        margin-top: 6px;
    }
    :root:not([data-phone="table"]) .row-keys i {
        flex: none;
        max-width: 100%;
        overflow: hidden;
        padding: 1px 7px;
        border-radius: 5px;
        background: var(--page);
        color: var(--text);
        font-size: 12px;
        font-style: normal;
        font-weight: 650;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    :root:not([data-phone="table"]) .row-keys i.row-stock {
        flex: none;
        color: var(--muted);
    }
    :root:not([data-phone="table"]) .row-keys i.row-stock.is-ok {
        background: var(--primary-soft);
        color: var(--ink);
    }
    :root[data-theme="dark"]:not([data-phone="table"]) .row-keys i.row-stock.is-ok {
        background: var(--page);
        color: var(--primary);
    }
    :root:not([data-phone="table"]) .row-price {
        flex-direction: column;
        align-items: flex-end;
        gap: 0;
    }
    :root:not([data-phone="table"]) .row-pricebox.is-sale del {
        grid-column: 1 / -1;
    }
    :root:not([data-phone="table"]) .row-off {
        display: none;
    }
    :root:not([data-phone="table"]) .row-open {
        display: grid;
        flex: none;
        align-self: flex-end;
        place-items: center;
        width: 30px;
        height: 30px;
        padding: 0;
        border: 1px solid var(--border);
        border-radius: var(--radius-pill);
        background: var(--surface);
        color: var(--ink);
    }
    :root:not([data-phone="table"]) .row-open svg {
        width: 16px;
        height: 16px;
        transition: transform 0.15s;
    }
    :root:not([data-phone="table"]) .product-row.is-open .row-open svg {
        transform: rotate(180deg);
    }
    :root:not([data-phone="table"]) .product-row.is-open {
        background: color-mix(in srgb, var(--page) 60%, var(--surface));
    }
    :root:not([data-phone="table"]) .product-row.is-open td[data-column] {
        display: flex;
        grid-column: 1 / -1;
        align-items: baseline;
        justify-content: flex-end;
        gap: 4px;
        padding: 7px 0;
        border-top: 1px solid var(--border);
        font-size: 14px;
    }
    :root:not([data-phone="table"]) .product-row.is-open td[data-column]::before {
        content: attr(data-label);
        margin-right: auto;
        color: var(--muted);
        font-size: 13px;
    }
    :root:not([data-phone="table"]) .product-row.is-open td[data-column-hidden] {
        display: flex !important;
    }
    :root:not([data-phone="table"]) .product-row.is-open .col-buy {
        display: block;
        grid-column: 1 / -1;
        margin-top: 8px;
        text-align: left;
    }
    :root:not([data-phone="table"]) .product-row.is-open .col-buy .button {
        width: 100%;
        height: 42px;
        font-size: 14px;
    }
}
@keyframes list-sheet-up {
    from {
        transform: translateY(40px);
        opacity: 0.4;
    }
}
@media (prefers-reduced-motion: reduce) {
    .filter-panel.is-open {
        animation: none;
    }
}
