/*
 * 9J PRIZE CATALOG -- the search bar, the filter chips, and the COMPACT prize
 * grid on the Prizes screen.
 *
 * Everything is scoped to `[data-view="prizes"]`: a prize card anywhere else
 * (none today, but the card builder is shared) keeps its full size. Linked
 * before phase8k.css (which stays LAST): the 8K "the card image is contained"
 * rules are not restated or overridden here -- this sheet never declares the
 * image's object-fit or height, and the 4:3 media box is left as 8K set it, so
 * every card's box is final before its photo arrives and nothing jumps.
 *
 * Presentation only. Nothing here reorders the page: the top stack (YOUR
 * ARSENAL, BID MISSIONS, TAKE THE LEAD) stays above the catalog bar, and the
 * cards stay in the order the catalog painted them (8Q.3C).
 */

/* ------------------------------------------------------------ the bar */

/* The point "show the results" scrolls back to: the row the bar sits in before it sticks. */
.pcat-top { height: 0; }

/*
 * Sticky UNDER the app bar (sticky at top 0, z-index 20, padding-top the safe
 * area). The app bar's height is set by its 44px bell button: 10 + 44 + 10 px
 * of content plus a 1px border = 65px at every width (measured at 320, 390 and
 * 1280 -- the two-line title block is 42px, so it never decides). 64px tucks
 * this bar 1px under that border, so there is never a seam for cards to show
 * through. The bar carries its own background so cards slide behind it.
 */
.pcat-bar {
  position: sticky;
  top: calc(var(--safe-top) + 64px);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px calc(-1 * var(--gutter)) 0;
  padding: 8px var(--gutter);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}

.pcat-search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.pcat-search__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--text-faint);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

/* 16px: anything smaller and iPhone Safari zooms the page on focus. */
.pcat-search__input {
  width: 100%;
  height: 44px;
  padding: 0 42px 0 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}
.pcat-search__input::placeholder { color: var(--text-faint); }
.pcat-search__input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* One clear control, ours -- not WebKit's own as well. */
.pcat-search__input::-webkit-search-cancel-button,
.pcat-search__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }

.pcat-search__clear {
  position: absolute;
  right: 4px;
  top: 50%;
  width: 36px;
  height: 36px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.pcat-search__clear:focus-visible { outline: 2px solid var(--accent); }

.pcat-sort { flex: 0 0 auto; }

.pcat-sort__select {
  height: 44px;
  max-width: 9.5rem;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}
.pcat-sort__select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------------------------------------------------------- the chips */

/* One row that scrolls sideways: never wraps into a second row of controls above the cards. */
.pcat-filters {
  display: flex;
  gap: 6px;
  margin: 10px calc(-1 * var(--gutter)) 0;
  padding: 0 var(--gutter) 2px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.pcat-filters::-webkit-scrollbar { display: none; }

.pcat-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.pcat-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pcat-chip.is-active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-elev));
  color: var(--text);
}
.pcat-chip__count {
  min-width: 1.4em;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-faint);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.pcat-chip.is-active .pcat-chip__count { color: var(--accent); }

.pcat-count {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--text-faint);
}

.pcat-empty {
  margin: 18px 0 0;
  padding: 18px 16px;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  text-align: center;
}
.pcat-empty__text { margin: 0 0 8px; color: var(--text-dim); }

/* ------------------------------------------------- the compact grid */

/*
 * Two columns on a phone, three once there is room (the shell caps the page
 * at 720px, so three is the most a card can usefully shrink to). minmax(0,..)
 * so a long name can never widen its column past the screen.
 */
[data-view="prizes"] .prize-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (min-width: 600px) {
  [data-view="prizes"] .prize-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
}

[data-view="prizes"] .prize { display: flex; flex-direction: column; }
[data-view="prizes"] .prize__body { flex: 1 1 auto; padding: 8px 10px 10px; }

/* Short, readable names: two lines at most, never cut mid-card. */
[data-view="prizes"] .prize__name {
  font-size: 0.92rem;
  line-height: 1.22;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* The one-line description is on the prize page; on a half-width card it was a second, fainter title. */
[data-view="prizes"] .prize__sub { display: none; }

[data-view="prizes"] .prize__row {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-top: 6px;
}
[data-view="prizes"] .prize__bid,
[data-view="prizes"] .prize__leader { max-width: 100%; }
[data-view="prizes"] .prize__bid-label { font-size: 0.6rem; }
[data-view="prizes"] .prize__bid-value { font-size: 1.02rem; }
[data-view="prizes"] .prize__leader { font-size: 0.72rem; }

[data-view="prizes"] .prize__badge {
  top: 6px;
  left: 6px;
  padding: 3px 8px;
  font-size: 0.58rem;
}

[data-view="prizes"] .prize__chips { left: 6px; right: 6px; bottom: 6px; gap: 3px; }
[data-view="prizes"] .prize__chip { padding: 2px 7px; font-size: 0.62rem; }

[data-view="prizes"] .prize__marks { margin-top: 6px; }
[data-view="prizes"] .prize__mark { font-size: 0.66rem; }

/* A countdown on a half-width card: the units share the width rather than overflowing it. */
[data-view="prizes"] .prize .countdown { gap: 3px; }
[data-view="prizes"] .prize .countdown--inset { margin-top: 8px; }
[data-view="prizes"] .prize .countdown__unit { flex: 1 1 0; min-width: 0; padding: 4px 2px; }
[data-view="prizes"] .prize .countdown__value { font-size: 0.86rem; }
[data-view="prizes"] .prize .countdown__label { font-size: 0.5rem; }

@media (prefers-reduced-motion: reduce) {
  .pcat-bar { backdrop-filter: none; }
}
