/* Items catalog — leather pouch bag (Itemiary-style) + filter rail */

/* Fill the viewport under the nav — scroll inside the bag, not the page.
   Bag + filters are centered together so left/right gutters match. */
.items-main {
  /* Room for Shop/Crafted column + gap + 3×50px buff grid + shade pads */
  --items-filters-width: 32rem;
  --items-side-gap: 1rem;
  /* Keep the catalog's original fluid desktop size, but calculate it from the
     content container rather than 100vw so the filter rail cannot fall beyond
     the scrollbar edge on wide screens. */
  --items-catalog-width: min(
    96rem,
    calc(100% - var(--items-filters-width) - 3 * var(--items-side-gap))
  );
  width: 100%;
  margin: 0 auto;
  padding: 0.5rem 0 0.5rem;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#items-catalog {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.items-shell {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  flex: 1 1 auto;
  min-height: 0;
}

/* 1fr | bag | filters | 1fr — equal side gutters around the whole block */
.items-layout {
  display: grid;
  /* Keep the catalog fluid and reserve the full filter rail beside it. */
  grid-template-columns:
    minmax(0, 1fr)
    minmax(0, var(--items-catalog-width))
    var(--items-filters-width)
    minmax(0, 1fr);
  column-gap: var(--items-side-gap, 1rem);
  align-items: stretch;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Filter rail — sits with the bag in the centered pair.
   Cap height on short viewports so the full OptionsFont rail stays reachable. */
.items-filters {
  --items-filters-top: 0.75rem;
  --items-filters-scroll-thumb: #eac914;
  --items-filters-scroll-track: #816230;
  --items-filters-scroll-frame: #472a24;
  grid-column: 3;
  justify-self: start;
  position: sticky;
  top: var(--items-filters-top);
  z-index: 5;
  width: var(--items-filters-width);
  /* Grid row is viewport-bounded on /items/ + /create/; scroll when content is taller */
  max-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--items-filters-scroll-thumb) var(--items-filters-scroll-track);
}

.items-filters::-webkit-scrollbar {
  width: 10px;
}

.items-filters::-webkit-scrollbar-track {
  border: 2px solid var(--items-filters-scroll-frame);
  background: var(--items-filters-scroll-track);
}

.items-filters::-webkit-scrollbar-thumb {
  border: 2px solid var(--items-filters-scroll-frame);
  border-radius: 0;
  background: var(--items-filters-scroll-thumb);
}

.items-bag__empty {
  margin: 0.75rem 0 0.25rem;
  text-align: center;
  font-family: var(--bpb-font-body);
  font-size: 0.9rem;
  color: var(--bpb-ink-muted);
}

.items-bag__empty[hidden] {
  display: none;
}

/* Catalog stage — width matches .site-nav; no panel chrome */
.items-bag {
  position: relative;
  grid-column: 2;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  box-sizing: border-box;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  overflow-x: hidden;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.items-bag__stage {
  width: 100%;
  max-width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}

.items-bag__stage > .bpb-bg {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

/* Skeleton preview (loading only) */
.items-bag__inner {
  padding: 0.35rem;
}

.items-bag__grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr));
  gap: 0.25rem;
}

.items-bag__cell--skel {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem;
  border-radius: 0.2rem;
  background: rgba(90, 60, 35, 0.12);
}

.items-bag__skel-icon {
  width: 100%;
  height: 100%;
}

.items-status {
  margin: 0;
  text-align: center;
  font-family: var(--bpb-font-body);
  font-size: 0.9rem;
  color: var(--bpb-ink-muted);
}

.items-skel-wrap {
  width: 100%;
}

/*
 * Desktop filter rail: keep the 1440p composition, but densify it when the
 * viewport is shorter. The page shell is intentionally locked to the viewport
 * so an internal rail scrollbar would compete with the catalog; `zoom` scales
 * the existing game-sized controls as one unit without changing their layout
 * or the catalog grid. The 410px reserve covers the nav/frame chrome and the
 * 713px content height is the current full OptionsFont stack.
 */
@media (min-width: 1241px) {
  .items-filters {
    --items-filter-zoom: clamp(
      0.64,
      calc((100dvh - 410px) / 713px),
      1
    );
    zoom: var(--items-filter-zoom);
    overflow: hidden;
  }
}

@media (max-width: 900px) {
  .items-layout {
    grid-template-columns: minmax(0, 1fr);
    justify-content: center;
    row-gap: 0.85rem;
  }

  .items-bag {
    grid-column: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    justify-self: stretch;
  }

  .items-filters {
    grid-column: 1;
    justify-self: stretch;
  }

  .items-filters {
    position: static;
    width: min(100%, var(--items-filters-width));
    justify-self: center;
    /* Stacked: grid row is content-sized — cap to viewport instead of 100% */
    max-height: calc(100dvh - 4rem);
  }
}

@media (max-width: 640px) {
  .items-bag {
    padding: 0;
  }
}
