/* 03-commerce.css: product cards, grids, facet rail, shop toolbar, pagination,
   category tiles. Mobile-first; the facet rail becomes a slide-in sheet below 900px. */

/* ---------- section headings (shared by home + shop) ---------- */

.section-title {
    margin-bottom: 20px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.section-head .section-title {
    margin-bottom: 0;
}

.section-more {
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
}

/* ---------- category tiles ---------- */

.category-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

.category-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 18px;
    color: var(--text);
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.category-tile:hover {
    text-decoration: none;
    border-color: var(--brand-200);
    box-shadow: 0 4px 18px rgba(11, 60, 93, 0.14);
    transform: translateY(-2px);
}

.category-tile i {
    font-size: 1.6rem;
    color: var(--brand-600);
}

.category-tile-name {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--brand-900);
}

.category-tile-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- product grid + cards ---------- */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}

.product-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    color: var(--text);
    transition: box-shadow 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.product-card:hover {
    text-decoration: none;
    color: var(--text);
    border-color: var(--brand-200);
    box-shadow: 0 6px 22px rgba(11, 60, 93, 0.16);
    transform: translateY(-2px);
}

.product-card:hover .product-card-name {
    color: var(--brand-600);
}

.product-card-media {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-card-media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
}

.product-card-placeholder {
    color: var(--brand-200);
    font-size: 3.2rem;
}

.product-card-sourcing {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
}

.product-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px 16px;
    flex: 1;
}

.product-card-brand {
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.product-card-name {
    font-size: 1rem;
    line-height: 1.35;
    color: var(--brand-900);
    transition: color 0.15s ease;
}

.product-card-certs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.product-card-conditions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.product-card-pricing {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.price {
    font-weight: 700;
    color: var(--brand-900);
}

.price-was {
    color: var(--text-muted);
    text-decoration: line-through;
    font-size: 0.85em;
    font-weight: 500;
    margin-left: 6px;
}

.price-context {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 4px;
}

.product-card-price .price {
    font-size: 1.08rem;
}

.product-card-used {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.product-card-used-count {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-left: 6px;
}

.product-card-quote {
    font-weight: 600;
    color: var(--brand-600);
    font-size: 0.95rem;
}

/* ---------- shop page layout ---------- */

.shop-page {
    padding-top: 24px;
    padding-bottom: 48px;
}

.shop-header {
    margin-bottom: 20px;
}

.shop-subcategories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.subcategory-chip {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.subcategory-chip:hover {
    background: var(--brand-200);
    text-decoration: none;
}

.shop-layout {
    display: block;
}

.shop-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.shop-result-count {
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 500;
}

.shop-sort {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.shop-sort select {
    min-height: 44px;
    width: auto;
}

/* ---------- facet rail ---------- */

.filter-toggle {
    margin-bottom: 16px;
}

.filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--brand-500);
    color: var(--text-on-brand);
    font-size: 0.75rem;
}

.facet-rail {
    display: none;
}

.facet-rail-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.facet-rail-title {
    font-weight: 700;
    color: var(--brand-900);
    font-size: 1.05rem;
}

.facet-rail-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.facet-rail-close:hover {
    background: var(--bg-subtle);
}

.facet-clear {
    margin-bottom: 8px;
    justify-content: flex-start;
    padding-left: 0;
}

.facet-group {
    border-bottom: 1px solid var(--border);
    padding: 4px 0;
}

.facet-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 44px;
    padding: 0;
    border: none;
    background: transparent;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--brand-900);
    cursor: pointer;
}

.facet-group-toggle i {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.facet-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 12px;
}

.facet-option {
    min-height: 36px;
    border-radius: var(--radius-sm);
    padding: 4px 6px;
}

.facet-option:hover {
    background: var(--bg-subtle);
}

.facet-option .facet-count {
    margin-left: auto;
}

.facet-count {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.facet-sublabel {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 8px 0 2px 6px;
}

.facet-category-list,
.facet-subcategory-list {
    list-style: none;
    margin: 0;
    padding: 0 0 12px;
}

.facet-subcategory-list {
    padding: 0 0 0 14px;
}

.facet-category-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 36px;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.facet-category-link:hover {
    background: var(--bg-subtle);
    text-decoration: none;
    color: var(--brand-700);
}

.facet-category-link.active {
    color: var(--brand-600);
    font-weight: 600;
    background: var(--brand-50);
}

.facet-price {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 14px;
}

.facet-price-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.facet-price-sep {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.facet-apply-mobile {
    margin-top: 16px;
}

/* mobile: slide-in filter sheet */
.facet-rail-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-card);
    padding: 16px 20px calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
}

.facet-rail-open .facet-rail-head {
    display: flex;
}

/* ---------- empty state ---------- */

.shop-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    padding: 48px 24px;
}

.shop-empty i {
    font-size: 2.2rem;
    color: var(--brand-200);
}

.shop-empty p {
    color: var(--text-muted);
}

/* ---------- pagination ---------- */

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 28px;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--brand-600);
    font-weight: 600;
    font-size: 0.92rem;
}

.pagination-link:hover {
    border-color: var(--brand-600);
    text-decoration: none;
}

.pagination-link.active {
    background: var(--brand-500);
    border-color: var(--brand-500);
    color: var(--text-on-brand);
}

/* ---------- desktop layout ---------- */

@media (min-width: 900px) {
    .shop-layout {
        display: grid;
        grid-template-columns: 260px 1fr;
        gap: 32px;
        align-items: start;
    }

    .filter-toggle {
        display: none;
    }

    .facet-rail {
        display: block;
        position: sticky;
        top: 88px;
        max-height: calc(100vh - 104px);
        overflow-y: auto;
        padding-right: 8px;
    }

    .facet-apply-mobile {
        display: none;
    }
}
