/* ============================================================
   ASSETS/CSS/STORE.CSS — Store, category & deal pages (Phase 3)
   ============================================================
   Loaded only on store pages ($page_css = ['css/store.css']).
   Uses the tokens from style.css (--primary, --border ...).
   Lives in the "components" layer like style.css, so Tailwind
   utilities can still override it.
   ============================================================ */
@layer theme, base, components, utilities;

@layer components {

    /* ---------- Page heading ---------- */
    .store-hero {
        padding: clamp(24px, 4vw, 40px) 0 clamp(20px, 3vw, 32px);
        background: var(--gradient-soft);
        border-bottom: 1px solid var(--border);
    }
    .store-hero__row { display: flex; align-items: flex-start; gap: 18px; margin-top: 18px; }
    .store-hero__icon, .store-hero__image {
        flex-shrink: 0; width: 64px; height: 64px; border-radius: 18px;
        display: flex; align-items: center; justify-content: center;
        background: var(--gradient); color: #fff; box-shadow: var(--shadow-brand); object-fit: cover;
    }
    @media (max-width: 479px) { .store-hero__icon, .store-hero__image { width: 48px; height: 48px; border-radius: 14px; } }
    .store-hero .eyebrow { margin-bottom: 6px; }
    .store-hero__desc { margin-top: 8px; max-width: 680px; }
    .store-hero__count { margin-top: 10px; font-size: .9375rem; color: var(--text-soft); }

    /* ---------- Breadcrumb ---------- */
    .breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 0; font-size: .875rem; color: var(--muted); }
    .breadcrumb li { display: inline-flex; align-items: center; min-width: 0; }
    .breadcrumb li + li::before { content: "/"; margin: 0 8px; color: #cbd5e1; }
    .breadcrumb a { color: var(--muted); }
    .breadcrumb a:hover { color: var(--primary); }
    .breadcrumb [aria-current] { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }

    /* ---------- Controls: search, sort, filters ---------- */
    .store-body { padding: 24px 0 clamp(48px, 6vw, 80px); }
    .store-controls { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 14px; }
    .store-controls__top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
    .store-search { position: relative; flex: 1 1 260px; min-width: 0; }
    .store-search .form-input { padding-left: 42px; }
    .store-search__icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
    .store-sort { display: flex; align-items: center; gap: 8px; flex: 1 1 200px; }
    .store-sort label { font-size: .875rem; color: var(--muted); white-space: nowrap; }
    .store-sort .form-input { min-width: 0; }
    .store-filter-toggle { position: relative; }
    .filter-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--primary); color: #fff; font-size: .6875rem; display: inline-flex; align-items: center; justify-content: center; }
    @media (max-width: 479px) {
        .store-sort, .store-filter-toggle, .store-search-btn { flex: 1 1 100%; }
    }

    .store-filters { display: none; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); gap: 16px 20px; }
    .store-filters.is-open { display: grid; }
    @media (min-width: 640px) { .store-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
    @media (min-width: 1024px) {
        .store-filters { display: grid; grid-template-columns: 1fr 1fr 2fr auto; align-items: end; }
        .store-filter-toggle { display: none; }
    }
    .store-filter { min-width: 0; margin: 0; padding: 0; border: 0; }
    .store-filter .form-label { margin-bottom: 6px; }
    .price-inputs { display: flex; align-items: center; gap: 8px; }
    .price-inputs .form-input { min-width: 0; }
    .store-filter--checks { display: flex; flex-wrap: wrap; gap: 8px; }
    .store-filter--checks legend { width: 100%; float: left; }
    .check {
        display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 12px;
        border: 1px solid var(--border); border-radius: 999px; font-size: .875rem; cursor: pointer; background: var(--surface);
    }
    .check:has(input:checked) { border-color: var(--primary); background: var(--primary-50); color: var(--primary-dark); }
    .check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
    .store-filter--actions { display: flex; gap: 8px; flex-wrap: wrap; }

    /* ---------- Category chips (scroll sideways inside, never the page) ---------- */
    .chips {
        display: flex; gap: 8px; margin-top: 18px; padding: 2px 2px 8px;
        overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch;
    }
    .chip {
        flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px;
        min-height: 40px; padding: 8px 16px; border-radius: 999px; white-space: nowrap;
        background: var(--surface); border: 1px solid var(--border); color: var(--text-soft);
        font-size: .875rem; font-weight: 500; transition: border-color .18s, color .18s, background .18s;
    }
    .chip:hover { border-color: var(--primary); color: var(--primary); }
    .chip.is-active { background: var(--gradient); border-color: transparent; color: #fff; box-shadow: var(--shadow-brand); }
    .chip__count { font-size: .75rem; padding: 1px 7px; border-radius: 99px; background: var(--surface-alt); color: var(--muted); }
    .chip.is-active .chip__count { background: rgba(255, 255, 255, .2); color: #fff; }

    /* ---------- Results bar + active filter pills ---------- */
    .results-bar { margin-top: 18px; display: grid; gap: 10px; }
    .results-bar__title { font-size: .9375rem; color: var(--text-soft); }
    .filter-pills { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
    .filter-pill {
        display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
        background: var(--primary-50); color: var(--primary-dark); font-size: .8125rem; font-weight: 500; max-width: 100%;
    }
    .filter-pill:hover { background: var(--primary-100); color: var(--primary-dark); }
    .filter-pill--clear { background: transparent; color: var(--muted); text-decoration: underline; }

    .store-results { margin-top: 24px; transition: opacity .2s; }
    .store-results.is-loading { opacity: .45; pointer-events: none; }

    /* ---------- Pagination ---------- */
    .pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; margin-top: 40px; }
    .pagination__pages { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
    .pagination__link {
        display: inline-flex; align-items: center; justify-content: center; gap: 6px;
        min-width: 42px; height: 42px; padding: 0 12px; border-radius: 12px;
        border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); font-weight: 600; font-size: .875rem;
    }
    a.pagination__link:hover { border-color: var(--primary); color: var(--primary); }
    .pagination__link.is-current { background: var(--gradient); border-color: transparent; color: #fff; }
    .pagination__link.is-disabled { opacity: .45; cursor: not-allowed; }
    .pagination__gap { display: inline-flex; align-items: center; height: 42px; padding: 0 4px; color: var(--muted); }
    @media (max-width: 479px) { .pagination__step span { display: none; } }

    /* ---------- Empty state ---------- */
    .empty-state {
        text-align: center; padding: clamp(40px, 6vw, 72px) 20px; border-radius: var(--radius-lg);
        background: var(--surface); border: 1px dashed #cbd5e1;
        display: flex; flex-direction: column; align-items: center; gap: 10px;
    }
    .empty-state p { color: var(--muted); max-width: 440px; }
    .empty-state__icon { width: 68px; height: 68px; border-radius: 20px; display: flex; align-items: center; justify-content: center; background: var(--primary-50); color: var(--primary); margin-bottom: 6px; }
    .empty-state .btn-row { margin-top: 14px; }

    /* ---------- /categories page ---------- */
    .category-block { display: flex; flex-direction: column; gap: 10px; }
    .category-block__children { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px; }
    .category-block__children a { display: inline-block; font-size: .8125rem; padding: 4px 10px; border-radius: 99px; background: var(--surface-alt); color: var(--text-soft); }
    .category-block__children a:hover { color: var(--primary); }
    .category-block__children span { color: var(--muted); }

    /* ---------- Product page foundation (full page in Phase 4) ---------- */
    .product-foundation { display: grid; gap: 28px; margin-top: 22px; align-items: start; }
    @media (min-width: 900px) { .product-foundation { grid-template-columns: 1.1fr 1fr; gap: 48px; } }
    .product-foundation__media { aspect-ratio: 16 / 10; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
    .product-foundation__media img { width: 100%; height: 100%; object-fit: cover; }
    .product-foundation__info { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
    .product-foundation__badges { display: flex; flex-wrap: wrap; gap: 8px; }
    .price--large .price__current { font-size: 1.75rem; }
    .price--large .price__old { font-size: 1.0625rem; }
}
