/*
  The product list, part 3: the comparison table (1IT.my's). One box that scrolls both ways under the header, a sticky
  header row, the product column frozen on the left and Buy frozen on the right. Row height is the density's
  (list-3.css: --row-h, --row-photo).
*/
:root[data-view="table"] .table-scroll {
    display: block;
}
.table-scroll {
    position: relative;
    max-height: calc(100dvh - var(--header-h, 0px) - 32px);
    overflow: auto;
    overscroll-behavior-x: contain;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--list-shadow);
    scrollbar-width: thin;
}
.table-scroll:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.product-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text);
    font-size: 14px;
}

/* ---------- head */
.product-table th {
    position: sticky;
    top: var(--head-offset, 0px);
    z-index: 3;
    height: var(--head-h);
    padding: 0 12px;
    border-bottom: 1px solid var(--border);
    background: var(--page);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}
.product-table th a {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: inherit;
}
.product-table th a:hover {
    color: var(--accent);
}
.product-table th a svg {
    width: 13px;
    height: 13px;
    opacity: 0.45;
}
.product-table th[aria-sort] {
    color: var(--accent);
}
.product-table th[aria-sort] svg {
    opacity: 1;
}
.product-table th[aria-sort="ascending"] svg {
    transform: rotate(180deg);
}
.th-rank {
    display: inline-block;
    width: 22px;
    margin-right: calc(var(--row-photo) + 20px);
    text-align: right;
}

/* ---------- cells */
.product-table td {
    height: var(--row-h);
    padding: var(--cell-pad) 12px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    white-space: nowrap;
    vertical-align: middle;
}
.product-table tbody tr:last-child td {
    border-bottom: 0;
}
.product-table tbody tr:hover td {
    background: color-mix(in srgb, var(--page) 75%, var(--surface));
}
.product-table .is-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.product-table td small {
    color: var(--muted);
    font-size: 12px;
}
/* Price beside the name while the panel takes the room; after the specs (1IT.my's order) when the table has the
   full width. list-3.css keeps it beside the name on narrower screens. */
.product-table .is-late,
:root[data-panel="hidden"] .product-table .is-early {
    display: none;
}
:root[data-panel="hidden"] .product-table .is-late {
    display: table-cell;
}
.cell-none {
    color: var(--muted);
}
[data-column-hidden] {
    display: none !important;
}

/* ---------- the frozen product column: rank, photo, brand in small caps above the name */
.product-table .col-id {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 300px;
    min-width: 300px;
    max-width: 300px;
    border-right: 1px solid var(--border);
}
.product-table th.col-id {
    z-index: 5;
}
.row-id {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.row-rank {
    flex: none;
    width: 22px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.row-photo {
    display: grid;
    flex: none;
    place-items: center;
    width: var(--row-photo);
    height: var(--row-photo);
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--photo);
}
.row-photo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.row-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}
.row-brand {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    line-height: 14px;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}
.row-brand a {
    color: inherit;
}
.row-brand a:hover {
    color: var(--accent);
}
.row-brand a + a {
    margin-left: 6px;
}
.row-name {
    overflow: hidden;
    color: var(--ink);
    font-size: 14px;
    font-weight: 650;
    line-height: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.row-name:hover {
    color: var(--accent);
}
.row-keys,
.row-open {
    display: none;
}

/* ---------- rating, stock, price */
.row-star {
    margin-right: 3px;
    color: var(--accent);
}
.stock-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 9px;
    border-radius: var(--radius-pill);
    background: var(--page);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
.stock-tag::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}
.stock-tag.is-instock {
    background: var(--primary-soft);
    color: var(--ink);
}
.stock-tag.is-instock::before {
    background: var(--primary);
}
:root[data-theme="dark"] .stock-tag.is-instock {
    background: var(--page);
}
.row-price {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
}
.row-price ins {
    order: 1;
    text-decoration: none;
}
.row-price del {
    order: 2;
    color: var(--muted);
    font-size: 12px;
}
.row-price .amount {
    color: var(--ink);
    font-size: 15px;
    font-weight: 800;
}
.row-price del .amount {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}
/* A sale on one price: the price now on the first line, the price it was and the saving below. */
.row-pricebox.is-sale {
    display: inline-grid;
    grid-template-columns: auto auto;
    justify-items: end;
    align-items: center;
    column-gap: 6px;
    line-height: 17px;
}
.row-pricebox.is-sale .row-price {
    display: contents;
}
.row-pricebox.is-sale ins {
    grid-row: 1;
    grid-column: 1 / -1;
}
.row-pricebox.is-sale del {
    grid-row: 2;
    grid-column: 1;
    line-height: 14px;
}
.row-off {
    grid-row: 2;
    grid-column: 2;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 12px;
    font-weight: 750;
    line-height: 15px;
}

/* ---------- the frozen Buy column */
.product-table .col-buy {
    position: sticky;
    right: 0;
    z-index: 2;
    width: 1%;
    padding-inline: 10px;
    border-left: 1px solid var(--border);
    text-align: center;
    box-shadow: -10px 0 12px -10px color-mix(in srgb, var(--deep) 30%, var(--clear));
}
.product-table th.col-buy {
    z-index: 5;
    text-align: center;
}
.col-buy .button {
    height: var(--buy-h);
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    white-space: nowrap;
}
/* Only a real Add is green: Read more (out of stock) and Choose options open the product, outlined in blue. */
.product-table .col-buy .button:not(.add_to_cart_button),
.product-table .col-buy .button.product_type_variable {
    border-color: var(--accent);
    background: var(--surface);
    color: var(--accent);
}
.product-table .col-buy .button:not(.add_to_cart_button):hover,
.product-table .col-buy .button.product_type_variable:hover {
    background: var(--accent);
    color: var(--accent-ink);
}
.col-buy .button.loading {
    opacity: 0.7;
}
.col-buy .button.added::before {
    content: "✓";
}
.col-buy .added_to_cart {
    display: none;
}
