/* ============================================================
   OSJ Sharp — shop archive
   ============================================================ */

.osj-shop { padding-block: 32px 72px; }

.osj-shop__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

/* ============================================================
   Filter rail
   ============================================================ */
/*
 * Below 1001px the rail is gone entirely and the filter sheet replaces it
 * (MOBILE-VARIANT-HANDOFF §1.3). It is display:none rather than visually
 * hidden so its duplicate of the filter markup is not announced twice.
 */
.osj-filters { display: none; }

.osj-filters__heading {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-link);
}

.osj-filters__body {
  display: flex;
  flex-direction: column;
  gap: 26px;
}

/* The sheet is the same markup at touch sizing. */
.osj-filters--sheet { display: flex; flex-direction: column; gap: 28px; }
.osj-filters--sheet .osj-filters__group + .osj-filters__group { padding-top: 22px; }
.osj-filters--sheet .osj-filters__link,
.osj-filters--sheet .osj-filters__check { min-height: 48px; font-size: 15.5px; }
.osj-filters--sheet .osj-filters__box { width: 20px; height: 20px; }
.osj-filters--sheet .osj-chip { padding: 11px 15px; font-size: 14px; }
.osj-filters--sheet .osj-filters__chips { gap: 9px; }
.osj-filters--sheet .osj-field { padding: 13px 12px; font-size: 14px; }

.osj-filters__group + .osj-filters__group {
  padding-top: 26px;
  border-top: 1px solid var(--border-subtle);
}
.osj-filters__label {
  margin-bottom: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-link);
}

/* --- Collapsible groups ---------------------------------------------
 *
 * Each group is a <details>. No script: the rail has to keep working with
 * JavaScript off, and a disclosure is the one widget the platform already
 * gives us for free, keyboard and screen-reader behaviour included.
 */
.osj-filters__summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding: 4px 0;
  cursor: pointer;
  list-style: none;             /* Firefox */
  user-select: none;
}
.osj-filters__summary::-webkit-details-marker { display: none; }
.osj-filters__summary::after {
  content: "";
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  color: var(--text-muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform var(--dur-base) var(--ease-out);
}
[open] > .osj-filters__summary::after {
  transform: rotate(-135deg) translate(-2px, -2px);
}
.osj-filters__summary:focus-visible {
  outline: 2px solid var(--focus-ring, currentColor);
  outline-offset: 3px;
}

/* --- "Show N more categories" ---------------------------------------- */
.osj-filters__more { margin-top: 10px; }
.osj-filters__more > .osj-filters__list { margin-top: 10px; }
.osj-filters__more-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-link);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.osj-filters__more-toggle::-webkit-details-marker { display: none; }
.osj-filters__more-toggle:hover { text-decoration: underline; }
.osj-filters__more-toggle:focus-visible {
  outline: 2px solid var(--focus-ring, currentColor);
  outline-offset: 3px;
}
/* One <summary> carrying both labels, swapped on state — so the control keeps
   its identity and focus rather than being replaced on toggle. */
.osj-filters__more-hide { display: none; }
.osj-filters__more[open] .osj-filters__more-show { display: none; }
.osj-filters__more[open] .osj-filters__more-hide { display: inline; }

@media (prefers-reduced-motion: reduce) {
  .osj-filters__summary::after { transition: none; }
}

.osj-filters__list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.osj-filters__link {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: 14.5px;
  color: var(--text-body);
}
.osj-filters__link:hover { color: var(--text-strong); text-decoration: none; }
.osj-filters__link.is-active { color: var(--text-strong); font-weight: var(--weight-semibold); }
.osj-filters__count { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); }

.osj-filters__chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.osj-filters__check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  color: var(--text-body);
}
.osj-filters__check:hover { color: var(--text-strong); text-decoration: none; }
.osj-filters__box {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--surface-card);
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.osj-filters__check.is-checked .osj-filters__box {
  background: var(--brand);
  border-color: var(--brand);
  /* Inline SVG tick — no extra request, and it inherits nothing so it stays
     legible whatever the surrounding theme scope is. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314110B' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12 5 5L20 7'/%3E%3C/svg%3E");
  background-size: 11px;
  background-repeat: no-repeat;
  background-position: center;
}
.osj-filters__check .osj-filters__count { margin-left: auto; }

.osj-filters__price { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.osj-filters__price .osj-field { flex: 1; min-width: 0; width: auto; }
/* Two fields share a 244px rail, so the spinner buttons are ~20px that the
   number itself needs. The keyboard still steps the value with arrow keys. */
.osj-filters__price .osj-field::-webkit-outer-spin-button,
.osj-filters__price .osj-field::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.osj-filters__price .osj-field { -moz-appearance: textfield; appearance: textfield; }
.osj-filters__dash { color: var(--text-muted); }
.osj-filters__go { flex-basis: 100%; }

.osj-filters__clear {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-link);
}

/* ============================================================
   Results column
   ============================================================ */
.osj-shop__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
  padding-bottom: var(--space-5);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}
.osj-shop__count { font-family: var(--font-mono); font-size: 13px; color: var(--text-body); }
.osj-shop__sort { display: flex; align-items: center; gap: 10px; }
.osj-shop__sort-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.osj-shop__empty {
  padding: var(--space-9) 0;
  text-align: center;
}
.osj-shop__empty h2 {
  margin-bottom: var(--space-3);
  font-size: 1.5rem;
  font-weight: var(--weight-ultra);
  text-transform: uppercase;
  letter-spacing: -0.02em;
}
.osj-shop__empty p { margin-bottom: var(--space-5); color: var(--text-body); }

/* ============================================================
   1001px and up — the rail becomes a permanent sticky column
   ============================================================ */
/* ============================================================
   Mobile Filter / Sort triggers — §1.3
   ============================================================ */
.osj-shop__mobile-controls {
  display: flex;
  gap: 10px;
  margin-bottom: var(--space-5);
}
.osj-shop__trigger {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text-strong);
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.osj-shop__trigger:hover { background: var(--surface-sunken); }
.osj-shop__trigger-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--ink-900);
  color: var(--sand-50);
  font-family: var(--font-mono);
  font-size: 11px;
}

/*
 * The sheets need JavaScript to open. Without it the triggers would be dead
 * controls, so they hide and the always-visible rail is shown instead —
 * filtering still works, it just takes more vertical space.
 */
.no-js .osj-shop__mobile-controls { display: none; }
.no-js .osj-filters { display: block; margin-bottom: var(--space-6); }

@media (min-width: 1001px) {
  .osj-shop { padding-block: 44px 96px; }
  .osj-shop__layout { grid-template-columns: 244px minmax(0, 1fr); gap: 44px; }

  .osj-filters {
    position: sticky;
    top: var(--sticky-offset);
    display: flex;
    flex-direction: column;
    gap: 30px;
    /* A long rail must be able to scroll independently, or the bottom filters
       become unreachable on a short viewport. With the category list capped
       this rarely engages, but a short window or an open disclosure still can.

       The gutter is reserved rather than added on demand, so the rail does not
       jog sideways the moment a group is expanded, and the counts stop sitting
       flush against the scrollbar when it does appear. */
    max-height: calc(100vh - var(--sticky-offset) - var(--space-5));
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding-right: 10px;
  }

  /* The sheets and their triggers are mobile-only. */
  .osj-shop__mobile-controls { display: none; }
  .osj-sheet--side,
  .osj-sheet--bottom { display: none; }
}

/* The inline sort control gives way to the Sort sheet below 1001px. */
@media (max-width: 1000px) {
  .osj-shop__sort--desktop { display: none; }
  .osj-shop__toolbar { margin-bottom: var(--space-5); }
}
