/* R8 semantic readability: catalog primary/secondary/state roles remain distinct. */
.dh-catalog {
    --catalog-line: color-mix(in srgb, var(--text-primary) 18%, transparent);
    --catalog-muted: var(--text-dim);
    --catalog-font: "Source Code Pro", Consolas, Menlo, "Noto Sans CJK SC", monospace;
    font-family: var(--catalog-font);
    width: min(100%, 1600px);
    margin: 0 auto;
    padding: 1.25rem clamp(1rem, 3vw, 3rem) 1.5rem;
}
/* 09:53 fix: wrapping flex masthead - a long single-line title ("> Б/У ПОЗИЦИИ")
   pushes the toolbar onto its own line instead of running under the search
   input; short titles keep the previous side-by-side arrangement. */
.dh-catalog__masthead { display:flex; flex-wrap:wrap; align-items:end; gap:clamp(1rem,2vw,2rem); margin-bottom:1.5rem; }
.dh-catalog__heading { display:flex; align-items:center; flex:0 0 auto; max-width:100%; min-height:3.5rem; margin:0; }
.dh-catalog__title { margin:0; font-family:'Arial Narrow','Nimbus Sans Narrow','DejaVu Sans Condensed',Arial,sans-serif; font-size:clamp(1.9rem,2.8vw,2.75rem); font-weight:700; line-height:1; letter-spacing:.055em; text-transform:uppercase; white-space:normal; overflow-wrap:anywhere; }
.dh-catalog__toolbar { display:grid; grid-template-columns:minmax(0,1fr) minmax(13rem,17rem); gap:.75rem; margin-bottom:0; flex:1 1 24rem; min-width:0; }
.dh-catalog__search { position:relative; min-width:0; }
.dh-catalog__search svg { position:absolute; left:1rem; top:50%; width:1rem; height:1rem; transform:translateY(-50%); color:var(--catalog-muted); pointer-events:none; }
.dh-catalog__search input, .dh-catalog__sort {
    width:100%; min-height:3.5rem; border:1px solid var(--catalog-line); background:color-mix(in srgb,var(--bg-primary) 94%,var(--text-primary) 6%); color:var(--text-primary); font:500 .82rem/1.2 var(--catalog-font); letter-spacing:.09em; text-transform:uppercase; outline:none;
}
.dh-catalog__search input { padding:0 1rem 0 3rem; }
.dh-catalog__sort { position:relative; }
.dh-catalog__sort .sort-select-btn { display:flex!important; align-items:center; justify-content:space-between; gap:.75rem; min-height:3.5rem; padding:0 1rem; border:0!important; width:100%!important; text-align:left; }
.dh-catalog__mobile-filter { display:none; }
.dh-catalog__workspace { display:grid; grid-template-columns:minmax(14.5rem,18rem) minmax(0,1fr); gap:clamp(1rem,2vw,2rem); align-items:start; }
.dh-catalog__sidebar { position:sticky; top:8.5rem; border:1px solid var(--catalog-line); background:color-mix(in srgb,var(--bg-primary) 97%,var(--text-primary) 3%); }
@media (min-width:1024px) {
    /* R17 independent catalog sidebar scroll: desktop keeps the sticky panel
       bounded to the visible window; the existing <=1023px fixed drawer remains
       the tablet/mobile scroll owner. */
    .dh-catalog__sidebar {
        max-height: calc(100dvh - 15.5rem);
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
    }
}

.dh-catalog__sidebar-head { display:flex; align-items:center; justify-content:space-between; padding:1rem 1.1rem; border-bottom:1px solid var(--catalog-line); font-size:.78rem; letter-spacing:.13em; }
.dh-catalog__mobile-close { display:none; }
.dh-facet { border-bottom:1px solid var(--catalog-line); }
.dh-facet__heading { width:100%; display:flex; justify-content:space-between; align-items:center; padding:1rem 1.1rem; border:0; background:transparent; color:var(--text-primary); font:600 .8125rem/1.2 var(--catalog-font); letter-spacing:.14em; text-align:left; cursor:pointer; }
.dh-facet__heading span:last-child { transition:transform .18s ease; }
.dh-facet.is-open .dh-facet__heading span:last-child { transform:rotate(180deg); }
.dh-facet__options { display:none; max-height:16rem; overflow:auto; padding:0 .7rem .9rem; }
.dh-facet.is-open .dh-facet__options { display:grid; }
.dh-facet__option { display:grid; grid-template-columns:1rem minmax(0,1fr) auto; align-items:center; gap:.65rem; width:100%; min-height:2rem; padding:.25rem .35rem; border:0; background:transparent; color:var(--catalog-muted); font:400 .8125rem/1.35 var(--catalog-font); letter-spacing:.045em; text-align:left; cursor:pointer; }
.dh-facet__option:hover, .dh-facet__option.is-selected { color:var(--text-primary); }
.dh-facet__check { width:.85rem; height:.85rem; border:1px solid var(--catalog-muted); position:relative; }
.dh-facet__color { width:.85rem; height:.85rem; border:1px solid var(--catalog-muted); border-radius:50%; background:var(--facet-color); box-shadow:0 0 0 1px var(--bg-primary) inset; }
.dh-facet__group { padding:.55rem .35rem .25rem 1.85rem; color:var(--catalog-muted); font-size:.7rem; letter-spacing:.12em; text-transform:uppercase; }
.dh-facet__option.is-selected .dh-facet__check::after { content:''; position:absolute; inset:2px; background:var(--text-primary); }
.dh-facet__label { overflow:hidden; text-overflow:ellipsis; }
.dh-facet__count { color:var(--catalog-muted); font-variant-numeric:tabular-nums; }
.dh-catalog__legacy-filters { display:none!important; }
.dh-catalog__price { padding:1rem 1.1rem; border-bottom:1px solid var(--catalog-line); }
.dh-catalog__price-title { margin:0 0 .9rem; color:var(--text-primary); font-size:.76rem; letter-spacing:.14em; }
.dh-catalog__reset { width:calc(100% - 2rem); min-height:3.25rem; margin:1rem; border:1px solid var(--text-primary); background:transparent; color:var(--text-primary); font:500 .75rem/1 var(--catalog-font); letter-spacing:.12em; cursor:pointer; }
.dh-catalog__reset:hover { background:var(--text-primary); color:var(--bg-primary); }
.dh-catalog__results { min-width:0; }
.dh-catalog__results-head { display:flex; align-items:center; justify-content:space-between; gap:1rem; min-height:2.75rem; margin-bottom:.7rem; border-bottom:1px solid var(--catalog-line); }
.dh-catalog__count { margin:0; color:var(--catalog-muted); font-size:.8125rem; letter-spacing:.12em; text-transform:uppercase; }
.dh-catalog__view-toggle { display:flex; gap:.35rem; }
.dh-catalog__view-toggle button { display:grid; place-items:center; width:2rem; height:2rem; border:1px solid transparent; background:transparent; color:var(--catalog-muted); cursor:pointer; }
.dh-catalog__view-toggle button.is-active { border-color:var(--catalog-line); color:var(--text-primary); }
.dh-catalog #products-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:clamp(.75rem,1vw,1.15rem); }
.dh-product-card { position:relative; min-width:0; background:var(--bg-primary); overflow:hidden; border:1px solid var(--catalog-line); }
.dh-product-card__media-link, .dh-product-card__details-link { display:block; min-width:0; }
.dh-product-card__media-link { position:absolute; inset:0; }
.dh-product-card__media { touch-action:pan-y; position:relative; aspect-ratio:1/1; overflow:hidden; background:color-mix(in srgb,var(--bg-primary) 88%,var(--text-primary) 12%); border-bottom:1px solid var(--catalog-line); }
.dh-product-card__image { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; opacity:0; transition:opacity .22s ease,transform .35s ease; }
.dh-product-card__image.is-active { opacity:1; }
.dh-product-card:hover .dh-product-card__image.is-active { transform:scale(1.015); }
.dh-product-card__badges { position:absolute; z-index:3; top:.65rem; left:.65rem; right:.65rem; display:flex; flex-wrap:wrap; gap:.35rem; pointer-events:none; }
.dh-product-card__badge { display:inline-flex; align-items:center; min-height:1.5rem; padding:.15rem .42rem; border:1px solid currentColor; background:#0a0a0a; color:#fff; font:500 .61rem/1 var(--catalog-font); letter-spacing:.09em; }
.dh-product-card__badge--sale, .dh-product-card__badge--discount { background:#d52525; border-color:#d52525; }
.dh-product-card__badge--discount { margin-left:auto; }
.dh-product-card__badge--exclusive { background:#39224e; border-color:#9e77bd; }
.dh-product-card__oos { bottom:0!important; top:auto!important; }
.dh-product-card__gallery-arrow { position:absolute; z-index:4; top:50%; transform:translateY(-50%); display:grid; place-items:center; width:2rem; height:2rem; padding:0; border:0; background:transparent; color:#fff; isolation:isolate; opacity:0; cursor:pointer; transition:opacity .18s ease; }
.dh-product-card__gallery-arrow::before { content:''; position:absolute; z-index:-1; inset:calc(50% - .75rem); background:rgba(0,0,0,.48); border:1px solid rgba(255,255,255,.45); }
.dh-product-card:hover .dh-product-card__gallery-arrow, .dh-product-card:focus-within .dh-product-card__gallery-arrow { opacity:1; }
.dh-product-card__gallery-arrow--prev { left:.5rem; }
.dh-product-card__gallery-arrow--next { right:.5rem; }
.dh-product-card__gallery-dots { position:absolute; z-index:4; left:50%; bottom:.15rem; transform:translateX(-50%); display:flex; gap:0; padding:0; background:transparent; }
.dh-product-card__gallery-dot { position:relative; width:2.75rem; height:2.75rem; padding:0; border:0; background:transparent; cursor:pointer; }
.dh-product-card__gallery-dot::after { content:''; position:absolute; left:50%; top:50%; width:.42rem; height:.42rem; transform:translate(-50%,-50%); border:1px solid #fff; border-radius:50%; background:rgba(0,0,0,.25); box-shadow:0 0 0 1px rgba(0,0,0,.55); }
.dh-product-card__gallery-dot.is-active::after { background:#fff; }
.dh-product-card__details { min-height:8.25rem; padding:.75rem .8rem .9rem; }
.dh-product-card__brand { margin:0 0 .32rem; color:var(--catalog-muted); font-size:.8rem; letter-spacing:.09em; text-transform:uppercase; white-space:normal; overflow-wrap:anywhere; overflow:hidden; text-overflow:ellipsis; }
.dh-product-card__name { display:-webkit-box; min-height:2.4rem; margin:0 0 .55rem; overflow:hidden; color:var(--text-primary); font:500 .875rem/1.35 var(--catalog-font); letter-spacing:.025em; -webkit-line-clamp:2; -webkit-box-orient:vertical; }
.dh-product-card__price { display:flex; flex-wrap:wrap; align-items:baseline; gap:.6rem; color:var(--text-primary); font:600 1rem/1.2 var(--catalog-font); }
.dh-product-card__old-price { color:var(--catalog-muted); font-size:.8rem; font-weight:500; text-decoration:line-through; }
.dh-catalog__actions { display:flex; flex-wrap:wrap; justify-content:flex-end; align-items:center; gap:1rem; min-height:3.5rem; margin-top:1rem; }
.dh-pagination { display:flex; justify-content:flex-end; align-items:center; gap:.35rem; min-height:3.5rem; margin:0; }
.dh-pagination button { min-width:2.2rem; height:2.2rem; border:1px solid transparent; background:transparent; color:var(--catalog-muted); font:500 .75rem/1 var(--catalog-font); cursor:pointer; }
.dh-pagination button:hover, .dh-pagination button.is-current { border-color:var(--catalog-line); color:var(--text-primary); }
.dh-pagination button:disabled { opacity:.25; cursor:not-allowed; }
.dh-catalog[data-view="list"] #products-grid { grid-template-columns:1fr; }
.dh-catalog[data-view="list"] .dh-product-card { display:grid; grid-template-columns:minmax(10rem,24rem) minmax(0,1fr); }
.dh-catalog[data-view="list"] .dh-product-card__media { aspect-ratio:4/3; }
.dh-catalog[data-view="list"] .dh-product-card__details-link { align-self:center; }
.dh-catalog[data-view="list"] .dh-product-card__details { padding:1.5rem; }
.dh-catalog__ticker { margin-top:1.5rem; }
@media (max-width:1279px) {
    .dh-catalog #products-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media (max-width:1023px) {
    .dh-catalog { padding-top:.8rem!important; }
    .dh-catalog__masthead { flex-direction:column; align-items:stretch; gap:.8rem; }
    .dh-catalog__toolbar { grid-template-columns:minmax(0,1fr) minmax(10rem,14rem) auto; flex:none; width:100%; }
    .dh-catalog__mobile-filter { display:grid; place-items:center; width:3.5rem; min-height:3.5rem; border:1px solid var(--catalog-line); background:transparent; color:var(--text-primary); }
    .dh-catalog__workspace { display:block; }
    .dh-catalog__sidebar { position:fixed; z-index:70; top:0; bottom:0; left:0; width:min(22rem,88vw); overflow:auto; transform:translateX(-105%); transition:transform .2s ease; }
    .dh-catalog__sidebar.is-open, .dh-catalog__sidebar.translate-x-0 { transform:translateX(0); }
    .dh-catalog__mobile-close { display:grid; place-items:center; border:0; background:transparent; color:var(--text-primary); }
    .dh-catalog #products-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
}
@media (max-width:767px) {
    .dh-catalog { padding-inline:.75rem; }
    .dh-catalog__heading { min-height:2.5rem; margin-bottom:0; }
    .dh-catalog__masthead { margin-bottom:1rem; gap:.75rem; }
    .dh-catalog__toolbar { grid-template-columns:minmax(0,1fr) 2.75rem; gap:.5rem; }
    .dh-catalog__search input, .dh-catalog__sort, .dh-catalog__sort .sort-select-btn { min-height:2.75rem; }
    .dh-catalog__mobile-filter { width:2.75rem; min-height:2.75rem; }
    .dh-catalog__search { grid-column:1/-1; }
    .dh-catalog__sort { grid-column:auto; }
    .dh-catalog #products-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
    .dh-product-card__media { aspect-ratio:1/1; }
    .dh-product-card__details { min-height:7.7rem; padding:.65rem; }
    .dh-product-card__gallery-arrow { display:grid; min-width:2.75rem; width:2.75rem; height:2.75rem; opacity:1; }
    .dh-product-card__gallery-dots { bottom:0; }
    .dh-catalog__view-toggle { display:none; }
    .dh-catalog__actions, .dh-pagination { justify-content:center; }
    .dh-catalog[data-view="list"] #products-grid { grid-template-columns:1fr; }
    .dh-catalog[data-view="list"] .dh-product-card { grid-template-columns:8.5rem minmax(0,1fr); }
}

/* Mobile global section spacing must not inflate the catalog facet drawer. */
@media (max-width: 640px) {
    .dh-catalog__sidebar .dh-facet { padding: 0 !important; }
}

/* Text has its own contrast tier; facet borders and icons retain their colors. */
.dh-catalog { --catalog-muted-text:var(--text-muted-readable); }
.dh-facet__option, .dh-facet__group, .dh-facet__count, .dh-catalog__count,
.dh-product-card__brand, .dh-product-card__old-price, .dh-pagination button {
    color:var(--catalog-muted-text);
    font-weight:600;
}
