/* Baylan listing layer (R1.5)

   product/category, product/search, product/manufacturer/info and
   product/special. Loaded after baylan-shell.css, so everything here may rely
   on the foundation tokens and on .bl-card already being styled.

   Legacy Yoga rules still ship in bundle.min.css and are more specific than a
   bare element selector in several places (.pagination, ul, label), which is
   why a few blocks below re-state properties that look like resets. */

/* --------------------------------------------------------------------------
   1. Page head
   -------------------------------------------------------------------------- */

.bl-page-head {
  padding: var(--bl-space-3) 0 var(--bl-space-4);
  border-bottom: var(--bl-hairline);
  background: var(--bl-color-bg);
}

.bl-breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--bl-space-1) var(--bl-space-2);
  margin: 0 0 var(--bl-space-2);
  padding: 0;
  list-style: none;
  font-size: 13px;
  line-height: 1.4;
}

.bl-breadcrumb li {
  display: flex;
  align-items: center;
  color: var(--bl-alpha-text-55);
}

/* The separator is decorative, so it is drawn rather than written into the
   markup where a screen reader would announce it between every crumb. */
.bl-breadcrumb li + li::before {
  content: '';
  width: 5px;
  height: 5px;
  margin-right: var(--bl-space-2);
  border-right: 1px solid var(--bl-alpha-text-45);
  border-bottom: 1px solid var(--bl-alpha-text-45);
  transform: rotate(-45deg);
  flex: 0 0 auto;
}

.bl-breadcrumb a {
  color: var(--bl-alpha-text-70);
  text-decoration: none;
}

.bl-breadcrumb a:hover { color: var(--bl-color-accent); text-decoration: underline; }

.bl-breadcrumb li[aria-current] span { color: var(--bl-color-text); }

.bl-page-head-main {
  display: flex;
  align-items: center;
  gap: var(--bl-space-3);
}

.bl-page-head-image {
  width: auto;
  height: 48px;
  max-width: 120px;
  object-fit: contain;
  background: var(--bl-color-photo-bg);
  border: var(--bl-hairline);
  padding: var(--bl-space-1);
  flex: 0 0 auto;
}

/* `.bl-root h1` in the foundation layer is (0,1,1) and outranks a bare class,
   so without the element in the selector the title keeps --bl-h1 at every
   width - wide enough on a phone to break a Ukrainian category name mid-word. */
.bl-root h1.bl-page-title {
  margin: 0;
  font-family: var(--bl-font-heading);
  font-weight: var(--bl-font-heading-weight);
  font-size: var(--bl-h3);
  line-height: var(--bl-heading-lh);
  letter-spacing: var(--bl-heading-ls);
  color: var(--bl-color-text);
  /* A brand or a search phrase can be one long unbroken token. */
  overflow-wrap: anywhere;
}

@media (min-width: 768px) {
  .bl-page-head { padding: var(--bl-space-4) 0; }
  .bl-root h1.bl-page-title { font-size: var(--bl-h2); }
  .bl-page-head-image { height: 64px; }
}

/* --------------------------------------------------------------------------
   2. Body
   -------------------------------------------------------------------------- */

.bl-listing-body {
  padding-top: var(--bl-space-4);
  padding-bottom: calc(var(--bl-space-4) * 3);
}

/* Admin-authored copy: keep the shop's own formatting readable without
   imposing a redesign typography on markup nobody is allowed to touch. */
.bl-listing-intro {
  margin-bottom: var(--bl-space-4);
  max-width: 78ch;
  color: var(--bl-alpha-text-70);
}

.bl-listing-intro > :first-child { margin-top: 0; }
.bl-listing-intro > :last-child { margin-bottom: 0; }
.bl-listing-intro img { max-width: 100%; height: auto; }

/* The brand and category copy written for these pages uses headings, lists and
   comparison tables, which this block had never carried before — it was styled
   for one short plain paragraph. Rendered unstyled, the tables were the real
   casualty: no cell borders and 1px of padding, so a three-column model table
   read as one run-on block and a wrapped first column made it impossible to see
   which figure belonged to which row.

   Scoped to .bl-listing-intro so it only reaches admin-authored copy. */
.bl-listing-intro h2 { margin: var(--bl-space-4) 0 var(--bl-space-2); }
.bl-listing-intro h3 { margin: var(--bl-space-3) 0 var(--bl-space-2); }
.bl-listing-intro p,
.bl-listing-intro ul,
.bl-listing-intro ol { margin: 0 0 var(--bl-space-2); }
.bl-listing-intro ul,
.bl-listing-intro ol { padding-left: 1.35em; }
.bl-listing-intro li { margin-bottom: 4px; }

.bl-listing-intro table {
  width: 100%;
  margin: 0 0 var(--bl-space-3);
  border-collapse: collapse;
  font-size: 14px;
}
.bl-listing-intro th,
.bl-listing-intro td {
  padding: 8px 12px 8px 0;
  text-align: left;
  vertical-align: top;
  border-bottom: var(--bl-hairline);
}
.bl-listing-intro th {
  font-weight: 600;
  color: var(--bl-color-text);
  border-bottom-width: 2px;
}
.bl-listing-intro tr:last-child td { border-bottom: none; }

@media (max-width: 640px) {
  /* Losing the table's own column algorithm is the lesser evil: the alternative
     is the page scrolling sideways, and these tables carry no colspans. */
  .bl-listing-intro table { display: block; overflow-x: auto; }
  .bl-listing-intro th,
  .bl-listing-intro td { padding-right: 16px; white-space: nowrap; }
}

.bl-listing-intro-bottom {
  margin: calc(var(--bl-space-4) * 2) 0 0;
  padding-top: var(--bl-space-4);
  border-top: var(--bl-hairline);
  /* Full page width. The 78ch measure above is right for one short paragraph
     beside a product grid, but this copy closes the page under both columns
     and carries model tables that a 78ch column squeezes into a narrow strip. */
  max-width: none;
}

/* --------------------------------------------------------------------------
   3. Subcategories
   -------------------------------------------------------------------------- */

.bl-subcats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bl-space-2);
  margin: 0 0 var(--bl-space-4);
  padding: 0;
  list-style: none;
}

.bl-subcat {
  display: flex;
  align-items: center;
  gap: var(--bl-space-2);
  min-height: 44px;
  padding: var(--bl-space-2) var(--bl-space-3);
  border: var(--bl-hairline);
  background: var(--bl-color-surface);
  color: var(--bl-color-text);
  font-size: 14px;
  line-height: 1.3;
  text-decoration: none;
}

.bl-subcat:hover {
  border-color: var(--bl-color-accent);
  color: var(--bl-color-accent);
}

.bl-subcat img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: var(--bl-color-photo-bg);
  flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   4. Search refine form
   -------------------------------------------------------------------------- */

.bl-search-refine {
  margin-bottom: var(--bl-space-4);
  padding: var(--bl-space-3);
  border: var(--bl-hairline);
  background: var(--bl-color-surface);
}

.bl-search-refine-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--bl-space-2);
}

.bl-search-refine-row > .bl-input,
.bl-search-refine-row > .bl-btn { min-height: 44px; }

.bl-search-refine-flags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--bl-space-2) var(--bl-space-4);
  margin-top: var(--bl-space-3);
}

@media (min-width: 768px) {
  .bl-search-refine-row {
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
    align-items: center;
  }
}

.bl-check {
  display: inline-flex;
  align-items: center;
  gap: var(--bl-space-2);
  min-height: 44px;
  margin: 0;
  font-size: 14px;
  cursor: pointer;
}

.bl-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--bl-color-accent);
  flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   5. Select
   The chevron is a background image so the control keeps one box and one
   focus ring; `appearance: none` alone would leave the native arrow behind
   in the browsers that still draw it inside the padding box.
   -------------------------------------------------------------------------- */

.bl-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: calc(var(--bl-space-3) * 2 + 10px);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none' stroke='%231d1f20' stroke-width='1.5'%3E%3Cpath d='m1 1 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--bl-space-3) center;
  cursor: pointer;
}

.bl-select::-ms-expand { display: none; }

/* --------------------------------------------------------------------------
   6. Toolbar
   -------------------------------------------------------------------------- */

.bl-listing-toolbar {
  position: sticky;
  /* .bl-header wraps to two rows below 992px, so its height is measured at
     runtime by baylan-shell.js; the literal is only the first-paint value. */
  top: var(--bl-header-height, 56px);
  z-index: var(--bl-z-sticky-bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bl-space-3);
  min-height: 48px;
  margin-bottom: var(--bl-space-3);
  padding: var(--bl-space-2) 0;
  background: var(--bl-color-bg);
  border-bottom: var(--bl-hairline);
}

.bl-listing-total {
  margin: 0;
  font-size: 14px;
  color: var(--bl-alpha-text-60);
}

.bl-listing-sort { display: flex; align-items: center; }

/* 44px, not the foundation's 40px default: these are the only controls on a
   listing page and both are reached by thumb. */
.bl-listing-sort-trigger {
  gap: var(--bl-space-2);
  min-height: 44px;
}

/* One control per viewport: the sheet is the mobile affordance, the inline
   select the desktop one. Both point at the same controller-generated URLs. */
.bl-listing-sort-select { display: none; }

@media (min-width: 768px) {
  .bl-listing-sort-trigger { display: none; }
  .bl-listing-sort-select { display: block; width: auto; min-width: 200px; min-height: 44px; }
}

/* --------------------------------------------------------------------------
   7. Grid
   2 columns up to 767px, 3 to 991px, 4 above - the density the approved
   prototype uses at each stop.
   -------------------------------------------------------------------------- */

.bl-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--bl-space-3);
  align-items: stretch;
}

.bl-grid > * { min-width: 0; }

@media (min-width: 768px) {
  /* 20px is the prototype's gutter between cards; --bl-space-4 resolves to
     13.6px, which read as a legacy edge-to-edge table rather than a grid. */
  .bl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
}

@media (min-width: 992px) {
  .bl-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* --------------------------------------------------------------------------
   8. Pagination
   system/library/pagination.php emits <ul class="pagination"> with a bare
   <li> per page and <li class="active"><span>. Bootstrap styles that class in
   bundle.min.css, so every property it sets has to be answered here.
   -------------------------------------------------------------------------- */

.bl-pagination {
  margin-top: calc(var(--bl-space-4) * 2);
  padding-top: var(--bl-space-4);
  border-top: var(--bl-hairline);
}

.bl-pagination .pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--bl-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.bl-pagination .pagination li { display: block; }

.bl-pagination .pagination li a,
.bl-pagination .pagination li span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--bl-space-2);
  border: var(--bl-hairline);
  border-radius: var(--bl-radius);
  background: var(--bl-color-surface);
  color: var(--bl-color-text);
  font-size: 14px;
  text-decoration: none;
}

.bl-pagination .pagination li a:hover {
  border-color: var(--bl-color-accent);
  color: var(--bl-color-accent);
}

.bl-pagination .pagination li.active span {
  background: var(--bl-color-accent);
  border-color: var(--bl-color-accent);
  color: #fff;
}

/* --------------------------------------------------------------------------
   9. Mobile sort sheet
   Bottom sheet rather than the drawer's side panel, but the same scrim,
   the same z-layers and the same open/close contract as .bl-drawer.
   -------------------------------------------------------------------------- */

.bl-sheet {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: var(--bl-z-sheet);
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  background: var(--bl-color-bg);
  border-top: var(--bl-hairline);
  box-shadow: var(--bl-shadow-lg);
  transform: translateY(100%);
  transition: transform 0.2s ease;
  padding-bottom: var(--bl-safe-bottom);
}

.bl-sheet.is-open { transform: translateY(0); }

.bl-sheet[hidden] { display: none; }

.bl-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 var(--bl-space-3) 0 var(--bl-space-4);
  border-bottom: var(--bl-hairline);
}

.bl-sheet-title {
  margin: 0;
  font-family: var(--bl-font-heading);
  font-weight: var(--bl-font-heading-weight);
  font-size: var(--bl-h5);
  line-height: var(--bl-heading-lh);
}

.bl-sheet-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bl-sheet-option {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: var(--bl-space-2) var(--bl-space-4);
  border-bottom: var(--bl-hairline);
  color: var(--bl-color-text);
  font-size: 15px;
  text-decoration: none;
}

.bl-sheet-option:hover { background: var(--bl-alpha-text-04); color: var(--bl-color-text); }

.bl-sheet-option.is-current {
  color: var(--bl-color-accent);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .bl-sheet { transition: none; }
}

/* --------------------------------------------------------------------------
   10. Empty state
   -------------------------------------------------------------------------- */

.bl-listing .bl-empty { margin-top: var(--bl-space-4); }

/* --------------------------------------------------------------------------
   11. Facet layout (R1.8)
   One column below 992px, where the rail sits above the results; the
   prototype's 272px sidebar from there up.
   -------------------------------------------------------------------------- */

.bl-listing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--bl-space-4);
}

.bl-listing-main { min-width: 0; }

@media (min-width: 992px) {
  .bl-listing-layout {
    grid-template-columns: 272px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
  }

  /* The rail takes a quarter of the row, so the grid drops from the four
     across it uses full-width to the prototype's three. */
  .bl-listing-layout .bl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .bl-facets {
    position: sticky;
    top: calc(var(--bl-header-height, 56px) + var(--bl-space-3));
  }
}

/* The prototype's rail sits on the page ground inside a hairline frame, not on
   a filled grey slab; .bl-blueprint on the panel already supplies the border and
   the corner ticks. */
.bl-facets-panel {
  padding: 18px;
  background: transparent;
}

.bl-facets-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--bl-space-2);
  margin-bottom: var(--bl-space-3);
}

.bl-facets-title {
  margin: 0;
  font-family: var(--bl-font-heading);
  font-weight: var(--bl-font-heading-weight);
  font-size: var(--bl-h5);
  line-height: var(--bl-heading-lh);
}

.bl-facets-reset {
  font-size: 13px;
  white-space: nowrap;
}

.bl-facets-group + .bl-facets-group {
  margin-top: var(--bl-space-3);
  padding-top: var(--bl-space-3);
  border-top: var(--bl-hairline);
}

.bl-facets-group-title {
  margin: 0 0 var(--bl-space-2);
  font-family: var(--bl-font-heading);
  font-weight: var(--bl-font-heading-weight);
  font-size: var(--bl-h6);
  line-height: var(--bl-heading-lh);
  color: var(--bl-alpha-text-70);
}

/* `.bl-root ul` in the shell layer is (0,1,1) and outranks a single class, so
   the reset is scoped through the panel. */
.bl-facets-panel .bl-facets-list {
  margin: 0;
  padding: 0;
  list-style: none;
  /* Nominal diameter has a dozen values; past that the rail would push the
     price control off a laptop screen. */
  max-height: 264px;
  overflow-y: auto;
}

/* `.bl-root a` is (0,1,1) as well - the option would otherwise be accent blue
   on every row instead of only where it is checked. */
.bl-root a.bl-facets-opt {
  display: flex;
  align-items: center;
  gap: var(--bl-space-2);
  min-height: 32px;
  padding: 2px 0;
  color: var(--bl-color-text);
  font-size: 14px;
  line-height: 1.3;
  text-decoration: none;
}

.bl-root a.bl-facets-opt:hover { color: var(--bl-color-accent); }

.bl-facets-box {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border: 1px solid var(--bl-alpha-text-45);
  background: var(--bl-color-bg);
  color: transparent;
}

.bl-facets-opt.is-checked .bl-facets-box {
  border-color: var(--bl-color-accent);
  background: var(--bl-color-accent);
  color: #fff;
}

.bl-facets-box .bl-icon { width: 11px; height: 11px; }

.bl-facets-label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.bl-facets-count {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--bl-alpha-text-45);
}

.bl-facets-price-row {
  display: flex;
  align-items: center;
  gap: var(--bl-space-1);
}

.bl-facets-price-input {
  min-width: 0;
  min-height: 32px;
  padding: 0 var(--bl-space-2);
  font-size: 13px;
}

.bl-facets-price-dash {
  flex: 0 0 auto;
  color: var(--bl-alpha-text-45);
}

.bl-facets-price-go {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 var(--bl-space-2);
}

/* --------------------------------------------------------------------------
   12. Active filter chips
   -------------------------------------------------------------------------- */

.bl-listing-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--bl-space-2);
  margin: 0 0 var(--bl-space-3);
  padding: 0;
  list-style: none;
}

.bl-root a.bl-listing-chip {
  gap: var(--bl-space-1);
  text-decoration: none;
}

.bl-root a.bl-listing-chip:hover {
  background: var(--bl-color-accent-200);
  color: var(--bl-color-accent-800);
}

.bl-listing-chip .bl-icon { width: 12px; height: 12px; }

.bl-listing-chip-reset {
  font-size: 13px;
  color: var(--bl-alpha-text-60);
}

/* --------------------------------------------------------------------------
   13. Mobile filter sheet
   The rail is the same panel at both widths; below 992px it is lifted out of
   the flow and slid up from the bottom by :target. No script, so it keeps the
   rest of the rail's promise of working with JavaScript off.
   -------------------------------------------------------------------------- */

.bl-listing-controls {
  display: flex;
  align-items: center;
  gap: var(--bl-space-2);
}

.bl-root a.bl-listing-facets-trigger {
  gap: var(--bl-space-2);
  min-height: 44px;
  text-decoration: none;
}

.bl-listing-facets-trigger .bl-tag { min-width: 20px; justify-content: center; }

@media (max-width: 991px) {
  .bl-facets {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: var(--bl-z-sheet);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    visibility: hidden;
  }

  .bl-facets:target { visibility: visible; }

  .bl-facets-scrim {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: var(--bl-alpha-scrim);
  }

  .bl-facets .bl-facets-panel {
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
    /* The head is the sheet's title bar and supplies its own top padding, so
       the panel gives up its own or the sticky offset would not be zero. */
    padding-top: 0;
    padding-bottom: calc(18px + var(--bl-safe-bottom));
    background: var(--bl-color-bg);
    box-shadow: var(--bl-shadow-lg);
    transform: translateY(100%);
    transition: transform 0.2s ease;
  }

  .bl-facets:target .bl-facets-panel { transform: translateY(0); }

  /* The head is the sheet's own title bar here, so it has to survive the
     panel scrolling under it. */
  .bl-facets .bl-facets-head {
    position: sticky;
    top: 0;
    align-items: center;
    margin: 0 -18px var(--bl-space-3);
    padding: var(--bl-space-3) 18px;
    background: var(--bl-color-bg);
    border-bottom: var(--bl-hairline);
  }

  .bl-facets .bl-facets-panel .bl-facets-list { max-height: none; }

  .bl-root a.bl-facets-opt { min-height: 44px; }
}

@media (min-width: 992px) {
  .bl-facets-scrim,
  .bl-facets-close,
  .bl-listing-facets-trigger { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bl-facets .bl-facets-panel { transition: none; }
}
