/**
 * Closo Wholesale Marketplace — W1 catalog UX: left filter rail + card photo
 * carousel. Loaded ONLY by the catalog (/wholesale/lots) via $meta['css'],
 * after wholesale-market.css; same token family (accent #452B90, ink #1A202C,
 * muted #556070, line #E4E2EE, soft #FAFAFC; Poppins/Inter/JetBrains Mono).
 *
 * Layout contract: views/market/index.php wraps the catalog in
 * .wm-layout = .wm-rail (faire-style filter column) + .wm-main (toolbar,
 * chips, grid, pager, teaser). Under 900px the rail becomes a full-screen
 * sheet opened from the toolbar's Filters button — no-JS via :target
 * (the button links to #wm-rail), upgraded to .is-open by
 * wholesale-market.js. Filter STATE lives in the URL only.
 */

/* ── layout ─────────────────────────────────────────────────────────── */
.wm-layout { display: flex; align-items: flex-start; }
.wm-main { flex: 1; min-width: 0; }

/* Gutter rebalance: the rail owns the 48px page gutter on the left, the
 * main column keeps it on the right. Same rhythm as the base sheet. */
.wm-layout .wm-applied { padding: 12px 48px 0 24px; }
.wm-layout .wm-grid { padding: 16px 48px 28px 24px; }
.wm-layout .wm-pager { padding: 0 48px 28px 24px; }
.wm-layout .wm-empty { padding: 72px 48px 72px 24px; }
.wm-layout .wm-teaser { margin: 0 48px 28px 24px; }

/* ── toolbar (Filters button + sort) ────────────────────────────────── */
.wm-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 48px 0 24px;
}
.wm-filters-open {
  display: none; /* mobile-only control — shown under 900px below */
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #1A202C;
  border: 1px solid #E4E2EE;
  border-radius: 999px;
  padding: 11px 18px;
  text-decoration: none;
  background: #fff;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.wm-filters-open:hover { border-color: #452B90; color: #452B90; }
.wm-filters-open-n {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #452B90;
  border-radius: 99px;
  padding: 1px 7px;
}
.wm-applied-clear {
  font-size: 12.5px;
  font-weight: 600;
  color: #556070;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wm-applied-clear:hover { color: #452B90; }

/* ── the rail ───────────────────────────────────────────────────────── */
.wm-rail {
  width: 264px;
  flex: none;
  box-sizing: border-box;
  padding: 20px 18px 28px 48px;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  background: #fff;
}
.wm-rail-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 10px;
}
.wm-rail-head b {
  font-family: "Poppins", "Inter", sans-serif;
  font-weight: 600;
  font-size: 15px;
}
.wm-rail-clearall {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: #556070;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wm-rail-clearall:hover { color: #452B90; }
.wm-rail-close { display: none; /* sheet-only control */ }

.wm-rail-group { border-top: 1px solid #E4E2EE; padding: 13px 0; }
.wm-rail-group summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: #1A202C;
}
.wm-rail-group summary::-webkit-details-marker { display: none; }
.wm-rail-group summary::after {
  content: "";
  margin-left: auto;
  width: 7px;
  height: 7px;
  border-right: 2px solid #556070;
  border-bottom: 2px solid #556070;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}
.wm-rail-group[open] summary::after { transform: rotate(225deg); }

.wm-rail-opts {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 9px;
  max-height: 264px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.wm-rail-opt {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  padding: 7px 9px;
  border-radius: 8px;
  color: #1A202C;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.wm-rail-opt:hover { background: #FAFAFC; color: #452B90; }
.wm-rail-opt.is-on { color: #452B90; font-weight: 600; background: #EDE8F8; }
.wm-rail-count {
  margin-left: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: #556070;
}
.wm-rail-opt.is-on .wm-rail-count { color: #452B90; }

.wm-rail-search {
  box-sizing: border-box;
  width: 100%;
  margin-bottom: 6px;
  border: 1px solid #E4E2EE;
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12.5px;
  color: #1A202C;
  background: #FAFAFC;
  outline: none;
}
.wm-rail-search:focus { border-color: #452B90; background: #fff; }
.wm-rail-search::placeholder { color: #556070; }

.wm-rail-range {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.wm-rail-range input[type="number"] {
  box-sizing: border-box;
  width: 0;
  flex: 1;
  border: 1px solid #E4E2EE;
  border-radius: 8px;
  padding: 8px 9px;
  font: inherit;
  font-size: 13px;
  color: #1A202C;
  background: #fff;
  outline: none;
  -moz-appearance: textfield;
}
.wm-rail-range input[type="number"]::-webkit-outer-spin-button,
.wm-rail-range input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.wm-rail-range input[type="number"]:focus { border-color: #452B90; }
.wm-rail-dash { color: #556070; font-size: 12px; }
.wm-rail-apply {
  border: 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  background: #452B90;
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.wm-rail-apply:hover { background: #321F69; }

/* ── card photo carousel ────────────────────────────────────────────── */
.wm-car-btn {
  position: absolute;
  z-index: 2;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
  color: #1A202C;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(26, 32, 44, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, color 0.15s ease;
}
/* Ships [hidden] (no-JS never shows a dead control) — and the display rule
 * above would defeat the attribute without this. */
.wm-car-btn[hidden] { display: none; }
.wm-car-prev { left: 10px; }
.wm-car-next { right: 10px; }
.wm-card:hover .wm-car-btn:not([hidden]),
.wm-card:focus-within .wm-car-btn:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
}
.wm-car-btn:hover { color: #452B90; }
.wm-car-dots {
  position: absolute;
  z-index: 2;
  left: 50%;
  transform: translateX(-50%);
  bottom: 12px;
  display: flex;
  gap: 4px;
  pointer-events: none;
}
.wm-car-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 2px rgba(26, 32, 44, 0.4);
}
.wm-car-dots i.is-on { background: #fff; }
/* Touch: arrows are always live (no hover reveal to wait for). */
@media (hover: none) {
  .wm-car-btn:not([hidden]) { opacity: 1; pointer-events: auto; }
  .wm-car-btn { width: 34px; height: 34px; }
}

/* ── responsive ─────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .wm-toolbar { padding: 14px 24px 0 24px; }
  .wm-layout .wm-applied { padding: 12px 24px 0; }
  .wm-layout .wm-grid { padding: 14px 24px 24px; }
  .wm-layout .wm-pager { padding: 0 24px 24px; }
  .wm-layout .wm-empty { padding: 60px 24px; }
  .wm-layout .wm-teaser { margin: 0 24px 24px; }
  .wm-rail { padding-left: 24px; }
}

@media (max-width: 900px) {
  .wm-filters-open { display: inline-flex; }

  /* The rail becomes a full-screen sheet: closed by default, opened by the
   * :target fallback (no-JS) or the .is-open class (JS toggle). */
  .wm-rail { display: none; }
  .wm-rail:target,
  .wm-rail.is-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 120;
    width: auto;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 16px 40px;
    background: #fff;
  }
  html.wm-rail-lock { overflow: hidden; }
  .wm-rail-head {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
    align-items: center;
    padding: 4px 0 10px;
    border-bottom: 1px solid #E4E2EE;
    margin-bottom: 4px;
  }
  .wm-rail-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 26px;
    line-height: 1;
    color: #1A202C;
    text-decoration: none;
  }
  .wm-rail-close:hover { background: #F4F2FA; }
  .wm-rail-clearall { margin-left: auto; }
  .wm-rail-head .wm-rail-clearall + .wm-rail-close { margin-left: 0; }
  .wm-rail-head b { margin-right: auto; }

  /* Sheet tap targets ≥44px. */
  .wm-rail-opt { padding: 12px 10px; }
  .wm-rail-opts { max-height: none; overflow: visible; }
  .wm-rail-search { padding: 12px 10px; font-size: 16px; /* no iOS zoom */ }
  .wm-rail-range input[type="number"] { padding: 12px 10px; font-size: 16px; }
  .wm-rail-apply { padding: 12px 16px; }
  .wm-rail-group summary { padding: 6px 0; min-height: 32px; }
}

@media (max-width: 640px) {
  .wm-toolbar { padding: 12px 16px 0; }
  .wm-layout .wm-applied { padding: 12px 16px 0; }
  .wm-layout .wm-grid { padding: 14px 16px 24px; }
  .wm-layout .wm-pager { padding: 0 16px 24px; }
  .wm-layout .wm-empty { padding: 56px 16px; }
  .wm-layout .wm-teaser { margin: 0 16px 24px; }
  /* The toolbar keeps the Filters button on the left; the base sheet hides
   * .wm-sort at this width. */
}

/* ── rail hide/show (desktop) — the /w/ storefront ftog pattern ───────── */
.wm-rail-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; font-family: inherit;
  border: 1px solid #E4E2EE; border-radius: 999px; padding: 8px 15px;
  background: #fff; color: #1A202C; cursor: pointer;
}
.wm-rail-toggle:hover { border-color: #452B90; color: #452B90; }
@media (max-width: 899px) { .wm-rail-toggle { display: none; } }
@media (min-width: 900px) {
  .wm-layout.filters-off .wm-rail { display: none; }
  .wm-layout.filters-off .wm-applied,
  .wm-layout.filters-off .wm-grid { padding-left: 48px; }
}
