/* ============================================================
   SABLE — Collection & search page
   Loaded on the collection/search templates only.

   Mobile is the design target (90% of traffic): the grid must be
   visible almost immediately, so the header + toolbar are compact
   and the sheets (Sort / Filter / Quick add) are custom-built here
   rather than reusing Dawn's `facets` drawer.
   ============================================================ */

.sbl-collection {
  background: var(--sbl-ink);
  padding-block: var(--sbl-s-4) var(--sbl-s-9);
}

/* ---------------- Header (compact) ---------------- */
.sbl-collection__header {
  margin-bottom: var(--sbl-s-3);
}
.sbl-collection__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sbl-s-2) var(--sbl-s-4);
  margin-top: 0.4rem;
}
.sbl-collection__title {
  font-size: var(--sbl-t-h1);
  margin: 0;
}
.sbl-collection__count {
  margin: 0;
  font-size: var(--sbl-t-small);
  color: var(--sbl-mute);
  white-space: nowrap;
}

/* Clamped on mobile so the grid never sits below the fold behind
   three lines of prose; full text once there's room for it. */
.sbl-collection__desc {
  max-width: var(--sbl-maxw-text);
  color: var(--sbl-mute);
  font-size: var(--sbl-t-small);
  line-height: var(--sbl-lh-body);
  margin-top: var(--sbl-s-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (min-width: 750px) {
  .sbl-collection__desc {
    -webkit-line-clamp: unset;
    display: block;
    overflow: visible;
  }
}

/* ---------------- Sticky toolbar ---------------- */
/* Position: sticky handles the actual pinning (never overlaps the
   grid — a stuck element simply stops scrolling with the page, it
   doesn't remove itself from flow). `--sbl-toolbar-top` is written
   by a scroll listener in sbl-collection.js, not an
   IntersectionObserver: the header's rendered height changes when
   it condenses, and an IO only fires on a threshold *crossing* — a
   fast scroll can jump straight past that crossing and never fire. */
.sbl-collection__toolbar {
  position: sticky;
  top: var(--sbl-toolbar-top, 6.4rem);
  z-index: var(--sbl-z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sbl-s-3);
  min-height: 5.2rem;
  background: var(--sbl-ink);
  border-top: var(--sbl-border);
  border-bottom: var(--sbl-border);
  margin-bottom: var(--sbl-s-4);
}
.sbl-collection__toolbar.is-stuck {
  box-shadow: var(--sbl-shadow);
}
.sbl-collection__toolbar-count {
  margin: 0;
  font-size: var(--sbl-t-small);
  color: var(--sbl-mute);
}
.sbl-collection__toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sbl-s-2);
}
.sbl-collection__toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sbl-s-1);
  min-height: 4.4rem;
  padding: 0 var(--sbl-s-3);
  background: none;
  border: 1px solid transparent;
  font: inherit;
  font-size: var(--sbl-t-small);
  letter-spacing: var(--sbl-ls-label);
  text-transform: uppercase;
  color: var(--sbl-paper);
  cursor: pointer;
  position: relative;
}
.sbl-collection__toolbar-btn:hover {
  border-color: var(--sbl-line);
}
.sbl-collection__toolbar-btn svg {
  width: 1.4rem;
  height: 1.4rem;
  fill: currentColor;
}
.sbl-collection__toolbar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.8rem;
  height: 1.8rem;
  padding: 0 0.4rem;
  background: var(--sbl-signal);
  color: var(--sbl-ink);
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: var(--sbl-radius-pill);
}
.sbl-collection__toolbar-badge[hidden] {
  display: none;
}

/* ---------------- Empty state ---------------- */
.sbl-collection__empty {
  padding-block: var(--sbl-s-7);
  max-width: 52rem;
}
.sbl-collection__empty h2 {
  font-size: var(--sbl-t-h2);
  margin: 0 0 var(--sbl-s-3);
}
.sbl-collection__empty p {
  color: var(--sbl-mute);
  margin: 0 0 var(--sbl-s-4);
}
.sbl-collection__empty-fallback {
  margin-top: var(--sbl-s-7);
  border-top: var(--sbl-border);
  padding-top: var(--sbl-s-6);
}
.sbl-collection__empty-fallback h3 {
  font-size: var(--sbl-t-h3);
  margin: 0 0 var(--sbl-s-4);
}

/* ---------------- Grid ---------------- */
/* 2-up mobile with tight gutters so the images stay large; 3-up
   tablet; 4-up desktop with more air between cards. */
.sbl-collection__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sbl-s-3) var(--sbl-s-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 750px) {
  .sbl-collection__grid { grid-template-columns: repeat(3, 1fr); gap: var(--sbl-s-5); }
}
@media (min-width: 990px) {
  .sbl-collection__grid { grid-template-columns: repeat(4, 1fr); gap: var(--sbl-s-5) var(--sbl-s-4); }
}

/* ---------------- Load more ---------------- */
.sbl-collection__load-more {
  display: flex;
  justify-content: center;
  margin-top: var(--sbl-s-6);
}
.sbl-collection__load-more[hidden] { display: none; }
.sbl-collection__load-more-btn {
  width: 100%;
}
@media (min-width: 750px) {
  .sbl-collection__load-more-btn {
    width: auto;
    min-width: 24rem;
  }
}

/* ============================================================
   Quick add (card-level)
   ============================================================ */
.sbl-card-qa-wrap {
  position: relative;
}
/* Anchored to the TOP of the card, i.e. over the image — NOT the bottom.
   Bottom-anchoring measured from the wrapper, whose height includes the text
   block, so the button landed on top of the title and truncated it ("B-Court
   Low-Top S…r"), and it moved whenever a title wrapped to two lines. Top
   anchoring is deterministic and can never collide with the copy. */
.sbl-card__quickadd {
  position: absolute;
  right: var(--sbl-s-2);
  top: var(--sbl-s-2);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.4rem;
  height: 4.4rem;
  background: var(--sbl-raise);
  border: 1px solid var(--sbl-line);
  color: var(--sbl-paper);
  cursor: pointer;
  transition: background var(--sbl-dur) var(--sbl-ease), color var(--sbl-dur) var(--sbl-ease);
}
.sbl-card__quickadd:hover {
  background: var(--sbl-paper);
  color: var(--sbl-ink);
}
.sbl-card__quickadd svg {
  width: 1.6rem;
  height: 1.6rem;
  fill: currentColor;
}
.sbl-card__quickadd[aria-disabled='true'] {
  opacity: 0.5;
  pointer-events: none;
}

/* ============================================================
   Sheets — Sort / Filter / Quick add
   Plain <modal-dialog> (Dawn's global.js custom element supplies
   show()/hide(), focus-trap and ESC-to-close). No component-modal
   CSS is loaded on this template, so the contract lives here.
   ============================================================ */
.sbl-sheet:not([open]) { display: none; }
.sbl-sheet[open] {
  position: fixed;
  inset: 0;
  z-index: var(--sbl-z-modal);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: color-mix(in srgb, var(--sbl-paper) 55%, transparent);
}
@media (min-width: 750px) {
  .sbl-sheet[open] { align-items: center; }
}

.sbl-sheet__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 52rem;
  max-height: 85vh;
  background: var(--sbl-raise);
  border: var(--sbl-border);
}

.sbl-sheet__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sbl-s-3);
  padding: var(--sbl-s-4) var(--sbl-s-4) var(--sbl-s-3);
  border-bottom: var(--sbl-border);
}
.sbl-sheet__title {
  font-size: var(--sbl-t-h3);
  margin: 0;
}
.sbl-sheet__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 4.4rem;
  height: 4.4rem;
  margin: -1rem -1rem 0 0;
  background: none;
  border: 0;
  color: var(--sbl-paper);
  cursor: pointer;
}
.sbl-sheet__close svg { width: 1.6rem; height: 1.6rem; }

.sbl-sheet__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sbl-s-3) var(--sbl-s-4);
}

.sbl-sheet__footer {
  padding: var(--sbl-s-3) var(--sbl-s-4);
  border-top: var(--sbl-border);
}
.sbl-sheet__footer--split {
  display: flex;
  gap: var(--sbl-s-3);
}
.sbl-sheet__footer--split .sbl-btn { flex: 1; }
.sbl-sheet__submit {
  transition: opacity var(--sbl-dur) var(--sbl-ease);
}
.sbl-sheet__submit[aria-disabled='true'] {
  opacity: 0.6;
  pointer-events: none;
}

/* --- Sort list --- */
.sbl-sheet__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sbl-sheet__option {
  display: flex;
  align-items: center;
  gap: var(--sbl-s-2);
  min-height: 5.2rem;
  border-bottom: 1px solid var(--sbl-line-soft);
  font-size: var(--sbl-t-body);
  color: var(--sbl-paper);
  cursor: pointer;
}
.sbl-sheet__option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.sbl-sheet__option-label { flex: 1; }
.sbl-sheet__option-check {
  width: 1.6rem;
  height: 1.6rem;
  opacity: 0;
  color: var(--sbl-signal);
}
.sbl-sheet__option-check svg { width: 100%; height: 100%; fill: currentColor; }
.sbl-sheet__option:has(input:checked) .sbl-sheet__option-check {
  opacity: 1;
}
.sbl-sheet__option:has(input:checked) .sbl-sheet__option-label {
  color: var(--sbl-signal);
}
.sbl-sheet__option:has(input:focus-visible) {
  outline: 2px solid var(--sbl-signal);
  outline-offset: -2px;
}

/* --- Filter groups --- */
.sbl-filter-group {
  border: 0;
  margin: 0 0 var(--sbl-s-5);
  padding: 0;
}
.sbl-filter-group + .sbl-filter-group {
  border-top: var(--sbl-border);
  padding-top: var(--sbl-s-4);
}
.sbl-filter-group__label {
  padding: 0;
  margin: 0 0 var(--sbl-s-2);
  font-size: var(--sbl-t-micro);
  letter-spacing: var(--sbl-ls-label);
  text-transform: uppercase;
  color: var(--sbl-mute);
  font-weight: 500;
}
.sbl-filter-group__list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sbl-filter-chk {
  display: flex;
  align-items: center;
  gap: var(--sbl-s-2);
  min-height: 4.8rem;
  font-size: var(--sbl-t-body);
  color: var(--sbl-paper);
  cursor: pointer;
}
.sbl-filter-chk input {
  width: 2rem;
  height: 2rem;
  accent-color: var(--sbl-paper);
  flex: none;
}
.sbl-filter-chk__label { flex: 1; }
.sbl-filter-chk__count {
  color: var(--sbl-faint);
  font-size: var(--sbl-t-small);
}
.sbl-filter-chk.is-disabled {
  color: var(--sbl-faint);
  cursor: not-allowed;
}
.sbl-filter-chk.is-disabled .sbl-filter-chk__label { color: var(--sbl-faint); }

.sbl-filter-price {
  display: flex;
  align-items: center;
  gap: var(--sbl-s-2);
}
.sbl-filter-price__field {
  flex: 1;
}
.sbl-filter-price__field input {
  width: 100%;
  min-height: 4.4rem;
  padding: 0 var(--sbl-s-3);
  background: var(--sbl-ink);
  border: var(--sbl-border);
  color: var(--sbl-paper);
  font: inherit;
  font-size: var(--sbl-t-small);
}
.sbl-filter-price__sep {
  color: var(--sbl-faint);
}

/* --- Quick add sheet --- */
.sbl-quickadd-sheet__heading {
  min-width: 0;
}
.sbl-quickadd-sheet__heading .sbl-label { margin: 0 0 0.2rem; }
.sbl-quickadd-sheet__heading .sbl-sheet__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sbl-quickadd-sheet__label {
  margin: 0 0 var(--sbl-s-3);
  font-size: var(--sbl-t-small);
  color: var(--sbl-mute);
}
.sbl-quickadd-sheet__sizes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sbl-s-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 750px) {
  .sbl-quickadd-sheet__sizes { grid-template-columns: repeat(4, 1fr); }
}
.sbl-quickadd-sheet__size-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 4.8rem;
  padding: 0 var(--sbl-s-2);
  background: var(--sbl-ink);
  border: var(--sbl-border);
  color: var(--sbl-paper);
  font: inherit;
  font-size: var(--sbl-t-small);
  cursor: pointer;
  width: 100%;
}
.sbl-quickadd-sheet__size-btn:hover:not(:disabled) {
  border-color: var(--sbl-paper);
}
.sbl-quickadd-sheet__size-btn:disabled {
  color: var(--sbl-faint);
  border-color: var(--sbl-line-soft);
  text-decoration: line-through;
  cursor: not-allowed;
}
.sbl-quickadd-sheet__size-btn[aria-disabled='true'] {
  opacity: 0.6;
  pointer-events: none;
}
.sbl-quickadd-sheet__error {
  margin: var(--sbl-s-3) 0 0;
  font-size: var(--sbl-t-small);
  color: var(--sbl-alert);
}
.sbl-quickadd-sheet__error[hidden] { display: none; }

/* --- Busy state (Sort / Filter apply in flight) --- */
[data-sbl-body].is-loading {
  opacity: 0.5;
  pointer-events: none;
}
