/* Category listings page. Builds on tokens.css and styles.css (header, cards, buttons, footer). */

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
body.no-scroll { overflow: hidden; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line-strong); }
.btn-secondary:hover { background: var(--pale-2); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel { background: linear-gradient(110deg, #E9EEF4 8%, #F4F7FA 18%, #E9EEF4 33%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

/* ---------- breadcrumbs ---------- */
.crumbs { margin: 18px 0 10px; }
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13.5px; color: var(--muted); font-weight: 500; margin: 0; padding: 0; list-style: none; }
.crumbs li { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs li + li::before { content: ''; width: 5px; height: 5px; border-top: 1.5px solid #9AA8B8; border-right: 1.5px solid #9AA8B8; transform: rotate(45deg); margin-right: 2px; }
.crumbs a { padding: 6px 0; border-radius: 4px; }
.crumbs a:hover { color: var(--primary); text-decoration: underline; }
.crumbs [aria-current="page"] { color: var(--ink); white-space: nowrap; }

/* ---------- heading + search ---------- */
.cat-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 16px; }
.cat-head h1 { font-size: clamp(26px, 2.6vw, 34px); font-weight: 800; letter-spacing: -.025em; line-height: 1.15; }
.cat-count { font-size: 16px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-desc { margin-top: 8px; max-width: 80ch; font-size: 15px; line-height: 1.55; color: var(--muted); }
.cat-search { margin-top: 18px; max-width: 760px; }
.cat-search-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 16px; box-shadow: 0 6px 20px rgba(16, 44, 74, .06); }
.cat-search-row:focus-within { border-color: #9DB8D6; box-shadow: 0 6px 20px rgba(16, 44, 74, .1), 0 0 0 3px rgba(29, 93, 166, .12); }
.cat-search-row input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: inherit; font-size: 16px; font-weight: 500; color: var(--ink); height: 44px; }
.cat-search-row input::placeholder { color: #6B7A8A; }
.cat-search-row input::-webkit-search-cancel-button { display: none; }
.scope { display: inline-flex; align-items: center; gap: 8px; margin: 10px 0 0 4px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; min-height: 28px; }
.scope input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }

/* ---------- subcategories ---------- */
.subcats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.schip { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; transition: border-color .15s, background .15s; }
.schip small { font-size: 12px; font-weight: 600; color: var(--muted); }
.schip:hover { border-color: var(--line-strong); background: var(--pale-2); }
.schip[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.schip[aria-current="true"]::before { content: ''; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); margin-right: 2px; }
.schip[aria-current="true"] small { color: #C9D8E8; }
.schip.more { color: var(--primary); border-style: dashed; background: transparent; }

/* ---------- layout ---------- */
.cat-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 22px; }

/* ---------- filter sidebar ---------- */
.filters { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100vh - var(--header-h) - 32px); overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; }
.filters-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 6px; }
.filters-top h2 { font-size: 17px; font-weight: 800; }
.icon-x { display: none; width: 44px; height: 44px; border: 0; background: transparent; border-radius: 50%; place-items: center; color: var(--ink); }
.icon-x:hover { background: var(--pale-2); }
.filters-body { padding: 0 18px; }
.filters-foot { display: flex; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line); margin-top: 4px; }
.filters-foot .btn { height: 42px; flex: 1; }
#filters-apply { display: none; }
.fgroup { border-bottom: 1px solid var(--line); }
.fgroup:last-child { border-bottom: 0; }
.fgroup summary { list-style: none; display: flex; align-items: center; gap: 8px; min-height: 48px; font-size: 14.5px; font-weight: 700; cursor: pointer; border-radius: 8px; }
.fgroup summary::-webkit-details-marker { display: none; }
.fgroup summary span { flex: 1; }
.fgroup summary .chev { color: var(--muted); transition: transform .15s; }
.fgroup[open] summary .chev { transform: rotate(180deg); }
.fbadge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--primary); color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.fbody { padding: 2px 0 14px; }
.fopts { display: grid; gap: 2px; }
.fopts.scroll { max-height: 224px; overflow: auto; margin-right: -6px; padding-right: 6px; }
.fopt { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 14px; font-weight: 500; cursor: pointer; border-radius: 8px; }
.fopt:hover { color: var(--primary); }
.fopt input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--primary); }
.fsearch { width: 100%; height: 38px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 14px; background: var(--bg); }
.fsearch:focus { outline: 2px solid var(--primary); outline-offset: 1px; background: #fff; }
.fhint { font-size: 13px; color: var(--muted); padding: 4px 0 2px; }
.frange { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.frange label { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 10px; height: 42px; background: #fff; min-width: 0; }
.frange label:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 93, 166, .14); }
.frange span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.frange input { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; font: inherit; font-size: 14.5px; font-weight: 600; background: transparent; color: var(--ink); }
.frange input::placeholder { color: #8A98A8; font-weight: 500; }
.fpills { display: flex; flex-wrap: wrap; gap: 8px; }
.fpill { position: relative; cursor: pointer; }
.fpill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.fpill span { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 14px; font-weight: 700; background: #fff; }
.fpill input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.fpill input:checked + span::before { content: ''; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); margin-right: 7px; }
.fpill input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.sw { width: 18px; height: 18px; border-radius: 50%; border: 1px solid #B9C5D2; flex: none; }
.ftoggle { padding: 4px 0; }
.ftoggle .fopt { min-height: 44px; font-weight: 600; font-size: 14.5px; }

/* ---------- results toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.tb-filters { display: none; height: 44px; padding: 0 16px; flex: none; }
.tb-range { flex: 1; font-size: 14px; color: var(--muted); font-weight: 500; min-width: 0; font-variant-numeric: tabular-nums; }
.tb-sort { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); margin-left: auto; }
.tb-sort select { height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 34px 0 12px; font: inherit; font-size: 14.5px; font-weight: 600; color: var(--ink); background: #fff
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23556677' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center / 16px; appearance: none; -webkit-appearance: none; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.chip-x { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px 0 14px; border-radius: 999px; border: 1px solid #C5D6E8; background: var(--pale-2); font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.chip-x:hover { background: var(--pale); }
.chip-x .ic { width: 15px; height: 15px; color: var(--muted); }
.chip-reset { border: 0; background: transparent; color: var(--primary); font-size: 13.5px; font-weight: 700; padding: 0 6px; height: 36px; border-radius: 8px; }
.chip-reset:hover { text-decoration: underline; }
.results { min-width: 0; }
#results-body { margin-top: 14px; min-height: 320px; }

/* ---------- listing grid (reuses the shared card) ---------- */
.cat-grid { grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 20px 16px; }
.top.promo { background: #E4ECF4; color: #25384D; }
.price small { font-size: 12px; font-weight: 600; color: var(--muted); }
.skel-card { pointer-events: none; }
.skel-card .thumb { display: block; }
.skel-card .sl { height: 13px; border-radius: 6px; margin-top: 10px; }
.w90 { width: 90%; } .w60 { width: 60%; } .w40 { width: 40%; }

/* ---------- pagination ---------- */
.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 32px 0 8px; }
.pg { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 44px; height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 15px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
a.pg:hover { background: var(--pale-2); border-color: var(--line-strong); }
.pg[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.pg.gap { border: 0; background: transparent; min-width: 24px; padding: 0; color: var(--muted); }
.pg .ic { width: 16px; height: 16px; }

/* ---------- states ---------- */
.cat-state { max-width: 520px; margin: 48px auto; text-align: center; }
.cat-state .state-ic { width: 76px; height: 76px; border-radius: 50%; background: var(--pale-2); color: var(--accent); display: grid; place-items: center; margin: 0 auto 18px; }
.cat-state .state-ic .ic { width: 36px; height: 36px; stroke-width: 1.4; }
.cat-state h2 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.cat-state p { margin-top: 8px; color: var(--muted); line-height: 1.55; }
.state-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

/* ---------- tablet and phone: filters become a bottom sheet ---------- */
.filters-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(16, 44, 74, .45); }
@media (max-width: 999px) {
  .cat-layout { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 16px; }
  .filters { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 70; max-height: 88vh; max-height: 88dvh; border-radius: 20px 20px 0 0; border: 0;
    box-shadow: 0 -12px 40px rgba(16, 44, 74, .25); transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; overflow: hidden; }
  .filters.is-open { transform: none; visibility: visible; transition: transform .25s ease; }
  .filters-top { padding: 12px 8px 4px 20px; flex: none; }
  .filters-top h2 { font-size: 19px; }
  .icon-x { display: grid; }
  .filters-body { overflow: auto; flex: 1; padding: 0 20px; overscroll-behavior: contain; }
  .filters-foot { flex: none; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); background: #fff; }
  #filters-apply { display: inline-flex; flex: 2; }
  .filters-foot .btn-secondary { flex: 1; }
  .toolbar { position: sticky; top: var(--header-h); z-index: 20; background: var(--bg); padding: 8px 0; margin: 0; border-bottom: 1px solid transparent; }
  .tb-filters { display: inline-flex; }
  .tb-sort span { display: none; }
  .tb-range { display: none; }
  .tb-sort { margin-left: auto; }
}
@media (max-width: 719px) {
  .crumbs { margin: 12px 0 8px; }
  .crumbs ol { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .crumbs ol::-webkit-scrollbar { display: none; }
  .crumbs li { flex: none; }
  .cat-head { gap: 2px 12px; }
  .cat-desc { font-size: 14px; }
  .cat-search { margin-top: 12px; }
  .subcats { flex-wrap: nowrap; overflow-x: auto; margin: 14px calc(var(--gutter) * -1) 0; padding: 2px var(--gutter); scrollbar-width: none; scroll-snap-type: x proximity; }
  .subcats::-webkit-scrollbar { display: none; }
  .schip { flex: none; scroll-snap-align: start; height: 40px; }
  .schip.more { display: none; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 12px; }
  .tb-sort select { max-width: 52vw; }
  .pg-txt { display: none; }
  .pager { gap: 4px; }
  .pg { min-width: 40px; padding: 0 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .filters, .filters.is-open { transition: none; }
  .skel { animation: none; }
}

/* slim scrollbars inside the filter panel */
.filters, .fopts.scroll { scrollbar-width: thin; scrollbar-color: #C9D6E4 transparent; }
.filters::-webkit-scrollbar, .fopts.scroll::-webkit-scrollbar { width: 6px; }
.filters::-webkit-scrollbar-thumb, .fopts.scroll::-webkit-scrollbar-thumb { background: #C9D6E4; border-radius: 3px; }

/* search field and the "whole platform" switch share one row on wider screens */
@media (min-width: 720px) {
  .cat-search { max-width: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; }
  .cat-search-row { flex: 1 1 420px; max-width: 640px; }
  .scope { margin: 0; }
}
@media (max-width: 719px) { .page-cat .seg button { min-height: 44px; min-width: 48px; } }

/* =====================================================================
   Search page + shared engine additions
   ===================================================================== */
.cat-search-row { position: relative; z-index: 10; }
.search-page .cat-search { margin-top: 14px; max-width: none; display: block; }
.search-page .cat-search-row { max-width: none; padding: 8px 8px 8px 18px; border-radius: 16px; box-shadow: 0 8px 28px rgba(16, 44, 74, .08); }
.search-page .cat-search-row input { height: 48px; font-size: 17px; }
.search-page .cat-search-row .btn { height: 48px; padding: 0 30px; border-radius: 12px; font-size: 16px; }
.clear-q { width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%; background: var(--pale-2); color: var(--muted); display: grid; place-items: center; }
.clear-q:hover { background: var(--pale); color: var(--ink); }
.sep { width: 1px; height: 28px; background: var(--line); flex: none; }
.loc-pill-wrap { position: relative; display: flex; }
.loc-pill-btn { height: 48px; min-width: 190px; max-width: 260px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; font-weight: 600; font-size: 15.5px; }
.loc-pill-btn:hover { background: var(--pale-2); }
.loc-pill-btn span { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-pop { top: calc(100% + 12px); right: 0; width: 340px; padding: 12px; left: auto; }
.loc-pop .fopts.scroll { max-height: 300px; }
.sugg { top: calc(100% + 8px); left: 0; right: 0; }
.opt small { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); }
.cat-search.is-loading .cat-search-row::after { content: ''; position: absolute; right: 150px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border: 2px solid #C5D6E8; border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-context { margin-top: 6px; font-size: 15.5px; color: var(--ink-2); font-weight: 600; }
.search-page .cat-head { margin-top: 22px; }
.search-page .cat-head h1 { font-size: clamp(24px, 2.4vw, 32px); overflow-wrap: anywhere; }
.notice { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 10px 14px; background: #FFF6DD; border: 1px solid #F0DDA4; border-radius: 12px; font-size: 14px; font-weight: 600; color: #5A4300; }
.notice span { flex: 1; }
.notice button { width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; }
.notice button:hover { background: rgba(0, 0, 0, .06); }

/* category facet (search page) */
.facet .fgroup { border-bottom: 1px solid var(--line); }
.catlist { display: grid; gap: 2px; }
.catlist li.d1 { padding-left: 14px; }
.catopt { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; min-height: 38px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; font-size: 14px; font-weight: 500; }
.catopt small { font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.catopt:hover { background: var(--pale-2); }
.catopt[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 700; }
.catopt[aria-pressed="true"] small { color: #C9D8E8; }
.gocat { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 4px; font-size: 13.5px; font-weight: 700; color: var(--primary); }
.gocat:hover { text-decoration: underline; }
.lvl-region > .fopt { font-weight: 700; }
.lvl-city, .lvl-district { padding-left: 18px; }
.lvl-country > .fopt { font-weight: 700; }

/* toolbar: view toggle + sort */
.tb-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.tb-right .tb-sort { margin-left: 0; }
.view-toggle { padding: 3px; }
.view-toggle button { width: 40px; height: 36px; display: grid; place-items: center; padding: 0; }
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.state-note { margin-top: -28px; text-align: center; font-size: 13px; color: var(--muted); }

/* grid / list view: the same cards, laid out as rows with the one-line summary */
.blurb { display: none; }
.cat-grid.is-list { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.is-list .card { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.is-list .thumb { height: auto; aspect-ratio: 4 / 3; } /* the 4:3 image is kept in the list view too */
.is-list .card-body { display: flex; flex-direction: column; justify-content: center; padding: 14px 64px 14px 20px; }
.is-list .ttl { font-size: 17px; min-height: 0; }
.is-list .price { font-size: 21px; margin-top: 6px; }
.is-list .blurb { display: block; margin-top: 8px; font-size: 14px; color: var(--ink-2); font-weight: 500; }
.is-list .meta { flex-direction: row; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.is-list .fav { top: 12px; right: 12px; }

@media (max-width: 999px) {
  .search-page .cat-search-row { flex-wrap: wrap; row-gap: 6px; }
  .tb-right { gap: 8px; }
  .view-toggle { display: none; }          /* phones and tablets browse as a grid; the toggle is for wide screens */
  .is-list { /* a list preference saved on desktop falls back to the grid layout here */ }
  .cat-grid.is-list { grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 20px 16px; }
  .is-list .card { display: block; }
  .is-list .thumb { height: auto; }
  .is-list .card-body { display: block; padding: 12px 14px 14px; }
  .is-list .ttl { font-size: 14px; min-height: 2.7em; }
  .is-list .price { font-size: 17px; }
  .is-list .blurb { display: none; }
  .is-list .meta { flex-direction: column; gap: 2px; margin-top: 8px; }
}
@media (max-width: 719px) {
  .search-page .cat-search-row { padding: 8px; }
  .search-page .cat-search-row > .ic { margin-left: 8px; }
  .search-page .cat-search-row input { flex: 1 1 0; min-width: 0; height: 46px; }
  .sep { display: block; flex: 0 0 100%; height: 0; width: auto; background: none; } /* line break: field on row one, region + button on row two */
  .loc-pill-wrap { flex: 1 1 0; min-width: 0; order: 5; }
  .loc-pill-btn { min-width: 0; width: 100%; max-width: none; height: 46px; border: 1px solid var(--line); }
  .search-page .cat-search-row .btn { order: 6; height: 46px; padding: 0 22px; }
  .loc-pop { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 75vh; border-radius: 20px 20px 0 0; z-index: 80; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
  .loc-pop .fopts.scroll { max-height: 50vh; }
  .cat-search.is-loading .cat-search-row::after { right: 12px; top: 28px; }
  .search-context { font-size: 14px; }
  .cat-state + .state-note { margin-top: -20px; }
}
