/* /rares/ and /rares/{category}/: the title, then two separate boxes.
   The catalogue console holds everything that changes what is shown (search,
   the current order and count, the sort menu, the card/ledger switch, and
   the categories as a strip of chips). The catalogue card under it holds
   only the rares: the grid (five a row, each on its floor) or the ledger,
   and the day's movers at its foot. The card keeps the centred height as a
   minimum and grows with the page, so nothing scrolls inside it. */

/* —— Title strip —— */
.rares-toolbar {
  align-items: center;
  margin: 0 0 0.75rem;
}

/* —— The catalogue console ——
   Built like the navigation console (habbend-nav.css): one bordered panel
   with a 12px radius in the pixel font, a bar of 30px controls over a tinted
   strip of 26px chips. */
.rares-console {
  position: relative;
  /* Over the card below, so the sort menu and the search suggestions can
     hang out of the console. */
  z-index: 5;
  margin: 0 0 0.75rem;
  border: 1px solid var(--content-box-border, var(--panel-border));
  border-radius: 12px;
  background: var(--content-box-bg, var(--bg-elevated));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
  color: var(--fg);
  font-family: var(--font-pixel, var(--font));
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
}

.rares-console a {
  text-decoration: none;
}

/* Row 1: the bar. */
.rc-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.5rem;
}

.rc-grow {
  flex: 1 1 auto;
  min-width: 0;
}

.rc-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 100%;
  min-width: 0;
  height: 36px;
  box-sizing: border-box;
  padding: 0 8px 0 4px;
  border: 1px solid var(--content-box-border, var(--panel-border));
  border-radius: 10px;
  background: var(--field-bg);
}

.rc-search:focus-within {
  border-color: var(--accent);
}

/* The magnifier is the submit button. */
.rc-search-go {
  appearance: none;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.rc-search-go:hover,
.rc-search-go:focus-visible {
  color: var(--fg);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}

.rc-search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.8125rem;
  outline: none;
}

.rc-search-input::placeholder {
  color: var(--muted);
}

.rc-search .catalogue-search-suggest {
  left: 0;
  right: auto;
  width: min(24rem, calc(100vw - 2rem));
}

/* What the card is showing: the order (or the search), then the count. */
.rc-status {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.rc-status-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rc-status-count {
  color: var(--fg);
  font-weight: 400;
}

/* The sort menu and the view switch, as console controls: flat, 30px, no
   bevel or drop shadow. */
.rares-console .rares-sort-menu > summary.btn,
.rares-console .rares-view-toggle {
  height: 30px;
  min-height: 0;
  border: 1px solid var(--content-box-border, var(--panel-border));
  border-radius: 8px;
  background: transparent;
  background-image: none;
  box-shadow: none;
}

.rares-console .rares-sort-menu > summary.btn {
  padding: 0 9px;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.8125rem;
  transform: none;
}

.rares-console .rares-sort-menu > summary.btn:hover,
.rares-console .rares-sort-menu[open] > summary.btn {
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}

.rares-console .rares-view-toggle {
  align-self: center;
}

.rares-console .rares-view-btn {
  min-width: 2.1rem;
  background-image: none;
}

/* A removable filter, as a console chip. The shared chip's white text only
   reads on the dark theme; this one takes the page's ink. */
.rares-console .rares-active-chip,
.rares-console .rares-active-chip:hover {
  flex: 0 0 auto;
  height: 26px;
  min-height: 0;
  box-sizing: border-box;
  padding: 0 6px 0 8px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--fg);
  font-size: 0.75rem;
}

/* Row 2: the categories. */
.rc-cats {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border-top: 1px solid var(--panel-border);
  border-radius: 0 0 12px 12px;
  background: rgba(0, 0, 0, 0.18);
  /* Phones: one line that swipes. */
  overflow-x: auto;
  scrollbar-width: none;
}

.rc-cats::-webkit-scrollbar {
  display: none;
}

html[data-theme="light"] .rc-cats,
html[data-theme="paper"] .rc-cats {
  background: rgba(30, 36, 44, 0.04);
}

.rc-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  height: 26px;
  box-sizing: border-box;
  padding: 0 8px 0 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--bg-elevated);
  color: var(--fg);
  font-size: 0.8125rem;
  line-height: 1;
  white-space: nowrap;
}

html[data-theme="light"] .rc-cat,
html[data-theme="paper"] .rc-cat {
  border-color: var(--panel-border);
  background: var(--field-bg);
}

.rc-cat:hover,
.rc-cat:focus-visible {
  color: var(--fg);
  border-color: var(--content-box-border, var(--panel-border));
}

.rc-cat.is-active,
html[data-theme="light"] .rc-cat.is-active,
html[data-theme="paper"] .rc-cat.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.rc-cat .rares-filter-option-dot {
  width: 0.55rem;
  height: 0.55rem;
}

.rc-cat-count {
  color: var(--muted);
  font-size: 0.75rem;
}

/* —— The tile ——
   The furniture admin's tile: no card, the furni on a framed floor tall
   enough for the viewer's 128px cap at native pixels, the name on up to two
   lines, then the value with the category beside it. */
.rares-catalog .rare-tile.rare-tile--shelf {
  position: relative;
  gap: 0.4rem;
  min-width: 0;
  padding: 0.5rem 0.5rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  box-shadow: none;
}

.rares-catalog .rare-tile.rare-tile--shelf:hover,
.rares-catalog .rare-tile.rare-tile--shelf:focus-visible {
  background: var(--surface-raised);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--content-box-border));
}

/* The highlight is instant and the tile does not move. A card tile fades its
   colours and lifts 2px over 150ms; dragging the cursor across a row of
   shelf tiles then ran two of those at once the whole way (one tile fading
   in, the last fading out), about 3.7 repaints per cursor movement, each
   with its own layer update and commit, so the highlight trailed the
   cursor. Without the transition a tile repaints once on entry and once on
   exit: the same drag is ~120 paints instead of 270–550 (traced). */
.rares-catalog .rare-tile.rare-tile--shelf {
  transition: none;
}

.rares-catalog .rare-tile.rare-tile--shelf:hover,
.rares-catalog .rare-tile.rare-tile--shelf:active {
  transform: none;
  box-shadow: none;
}

/* On a pointer device every tile keeps the compositor layer habbend.css
   gives it, so the highlight repaints that one small layer and not a strip
   of the whole card. It must not change between states: toggling transform
   relays the tile out. */
@media (hover: hover) and (pointer: fine) {
  .rares-catalog .rare-tile.rare-tile--shelf,
  .rares-catalog .rare-tile.rare-tile--shelf:hover,
  .rares-catalog .rare-tile.rare-tile--shelf:active {
    transform: translateZ(0);
  }
}

.rares-catalog .rare-tile--shelf .rare-thumb {
  aspect-ratio: auto;
  width: 100%;
  height: 8.5rem;
  border: 1px solid var(--content-box-border);
  border-radius: 6px;
}

/* habbend.css insets the name and value line of a card tile; a shelf tile
   lines them up with the stage's edge, hence the doubled class. */
.rares-catalog .rare-tile.rare-tile--shelf h3 {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  margin: 0;
  padding: 0;
  font-size: 0.84rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.25;
  white-space: normal;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.rares-catalog .rare-tile.rare-tile--shelf .rare-meta {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  min-width: 0;
  min-height: 1.5rem;
  margin: auto 0 0;
  padding: 0;
  border-top: 0;
}

html .rares-catalog .rare-tile.rare-tile--shelf .rare-meta .price {
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: var(--fg);
  font-size: 0.84rem;
  font-weight: 400;
  white-space: nowrap;
}

.rares-catalog .rare-tile--shelf .rare-meta .currency-icon {
  width: 14px;
  height: 14px;
}

.rares-catalog .rare-tile--shelf .rare-meta > .muted {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  white-space: nowrap;
  -webkit-font-smoothing: none;
}

.rares-catalog .rare-tile--shelf .furni-cat-chip {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* —— Movers (the strip at the card's foot) —— */
.rares-rail-kicker {
  margin: 0.7rem 0.5rem 0.2rem;
  font-family: var(--font-pixel);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
}

.rares-rail-empty {
  margin: 0 0.5rem;
}

.rares-rail-mover {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  color: var(--fg);
  font-family: var(--font-pixel);
  font-size: 0.74rem;
  text-decoration: none;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
}

.rares-rail-mover:hover,
.rares-rail-mover:focus-visible {
  background: var(--surface-raised);
  color: var(--fg);
}

.rares-rail-mover img,
.rares-rail-mover-blank {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  object-fit: contain;
}

.rares-rail-mover-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rares-rail-mover-pct {
  font-weight: 700;
}

.rares-rail-mover-pct.is-up,
.rares-ledger-delta.is-up {
  color: var(--success);
}

.rares-rail-mover-pct.is-down,
.rares-ledger-delta.is-down {
  color: var(--danger);
}

/* —— Ledger —— */
.rares-ledger {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-family: var(--font-pixel);
  font-size: 0.78rem;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
}

.rares-ledger th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.4rem 0.6rem;
  background: var(--field-bg);
  border-bottom: 1px solid var(--content-box-border);
  text-align: left;
  font-weight: 400;
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.rares-ledger th a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: inherit;
  text-decoration: none;
}

.rares-ledger th a:hover,
.rares-ledger th.is-active {
  color: var(--fg);
}

.rares-ledger th.is-active a {
  color: var(--fg);
}

.rares-ledger td {
  padding: 0.22rem 0.6rem;
  border-bottom: 1px solid var(--panel-border, rgba(127, 127, 127, 0.18));
  white-space: nowrap;
  vertical-align: middle;
}

.rares-ledger tbody tr {
  cursor: pointer;
}

.rares-ledger tbody tr:hover td {
  background: var(--surface-raised);
}

.rares-ledger-col-index {
  width: 2rem;
  color: var(--muted);
  font-size: 0.66rem;
}

th.rares-ledger-col-category {
  width: 7rem;
}

th.rares-ledger-col-value {
  width: 5rem;
}

th.rares-ledger-col-breakdown {
  width: 7.4rem;
}

th.rares-ledger-col-date {
  width: 5.4rem;
}

th.rares-ledger-col-move {
  width: 4.8rem;
}

.rares-ledger-col-rare {
  overflow: hidden;
}

.rares-ledger-name > span:last-child {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rares-ledger-col-value {
  text-align: right;
}

.rares-ledger-col-move {
  text-align: right;
  font-weight: 700;
}

.rares-ledger-col-date,
.rares-ledger-col-category {
  color: var(--muted);
}

.rares-ledger-col-category .rares-filter-option-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  margin-right: 0.35rem;
  vertical-align: -1px;
}

.rares-ledger-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--fg);
  font-weight: 700;
  text-decoration: none;
}

.rares-ledger-name:hover {
  color: var(--fg);
}

.rares-ledger-thumb {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid var(--content-box-border);
  background: var(--surface-raised);
}

.rares-ledger-thumb img {
  max-width: 24px;
  max-height: 24px;
  image-rendering: pixelated;
}

.rares-ledger-col-value .price {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.rares-ledger-stacks {
  display: flex;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rares-ledger-stacks li {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  font-size: 0.68rem;
  color: var(--muted);
}

.rares-ledger-stacks .currency-icon {
  width: 15px;
  height: 15px;
}

.rares-ledger-col-value .currency-icon {
  width: 16px;
  height: 16px;
}

.rares-ledger-none {
  color: var(--muted);
  font-family: var(--font-body);
}

.rares-ledger-sort-ind {
  width: 11px;
  height: 11px;
}

.rares-ledger-mobile-move {
  display: none;
}

/* —— Stacked layout (phone and tablet) —— */
@media (max-width: 819px) {
  /* The same box as on desktop: the rares, the pager, and the movers as
     its foot. */
  .rares-centered-card {
    overflow: clip;
    background: var(--content-box-bg);
    border: 1px solid var(--content-box-border);
    border-radius: var(--content-box-radius);
    box-shadow: var(--content-box-shadow);
  }

  .rares-centered-body {
    display: flex;
    flex-direction: column;
  }

  .rares-catalog-scroll {
    padding: 0.5rem 0.5rem 0.8rem;
  }

  .rares-catalog .rare-tile--shelf .rare-thumb {
    height: 8.5rem;
  }

  .rares-rail-movers {
    padding: 0.55rem 0.6rem 0.7rem;
    border-top: 1px solid var(--content-box-border);
    background: var(--field-bg);
  }

  .rares-rail-kicker {
    margin-top: 0;
  }

  .rares-catalog-scroll--ledger {
    padding: 0;
  }

  .rares-catalog-scroll--ledger .rares-pagination {
    padding: 0.6rem 0.6rem 0.8rem;
  }

  .rares-ledger {
    min-width: 0;
    font-size: 0.875rem;
  }

  /* Keep the item and its value together in the viewport. Secondary
     columns remain available on desktop and on the rare's detail page. */
  .rares-ledger-col-index,
  .rares-ledger-col-category,
  .rares-ledger-col-breakdown,
  .rares-ledger-col-date,
  .rares-ledger-col-move {
    display: none;
  }

  .rares-ledger th {
    padding: 0.6rem;
    font-size: 0.75rem;
  }

  .rares-ledger td {
    padding: 0.5rem 0.6rem;
  }

  th.rares-ledger-col-value {
    width: 7.25rem;
    text-align: right;
  }

  .rares-ledger-name {
    min-height: 2rem;
    gap: 0.5rem;
    font-weight: 400;
    line-height: 1.4;
  }

  .rares-ledger-name > span:last-child {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .rares-ledger-thumb {
    width: 32px;
    height: 32px;
  }

  .rares-ledger-col-value .price {
    max-width: 100%;
    font-size: 0.875rem;
    white-space: normal;
  }

  .rares-ledger-amount {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .rares-ledger-col-value .currency-icon {
    flex: 0 0 auto;
  }

  .rares-ledger-mobile-move {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.3;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

/* —— Centred card (desktop) —— */
@media (min-width: 820px) {
  body.rares-centered-page {
    display: flex;
    flex-direction: column;
  }

  .rares-centered-page .rares-centered-wrap {
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: min(980px, calc(100% - 2rem));
    margin: 0 auto;
    padding: var(--habbend-page-top, 1.5rem) 0 2rem;
  }

  .rares-centered-page .rares-centered-wrap > .site-header,
  .rares-centered-page .rares-centered-wrap > .site-footer {
    flex: 0 0 auto;
    width: 100%;
    max-width: none;
  }

  .rares-centered-page .rares-centered-wrap > .site-footer {
    margin-top: 0;
    padding-bottom: 1.25rem;
  }

  .rares-centered-page .rares-centered-main {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: var(--rares-centered-card-h, 579px);
  }

  .rares-centered-page .rares-centered-card {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: clip;
    background: var(--content-box-bg);
    border: 1px solid var(--content-box-border);
    border-radius: var(--content-box-radius);
    box-shadow: var(--content-box-shadow);
  }

  .rares-centered-page .rares-toolbar {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    align-items: center;
    margin: 0 0 0.75rem;
    padding: 0;
    background: transparent;
    border-bottom: 0;
  }

  /* The console on one line: search, status, then the controls at the right;
     the chips wrap rather than hide. */
  .rares-centered-page .rares-console {
    flex: 0 0 auto;
  }

  .rc-bar {
    flex-wrap: nowrap;
    height: 3.25rem;
    padding: 0 0.5rem 0 0.5rem;
  }

  .rc-search {
    flex: 0 1 15rem;
  }

  .rc-cats {
    flex-wrap: wrap;
    overflow: visible;
  }

  .rares-centered-page .rares-centered-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
  }

  .rares-centered-page .rares-catalog-pane {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .rares-centered-page .rares-rail-movers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem 0.7rem;
    border-top: 1px solid var(--content-box-border);
    background: var(--field-bg);
  }

  .rares-centered-page .rares-rail-kicker {
    margin: 0 0.4rem 0 0;
  }

  .rares-centered-page .rares-rail-mover {
    padding: 0.25rem 0.55rem;
    border: 1px solid var(--control-border);
    border-radius: 6px;
    background: var(--control-bg);
  }

  .rares-centered-page .rares-rail-empty {
    margin: 0;
  }

  /* Grows with the grid: the page scrolls, the card does not. */
  .rares-centered-page .rares-catalog-scroll {
    flex: 1 1 auto;
    padding: 0.6rem 0.65rem 0.9rem;
  }

  .rares-centered-page .rares-catalog-scroll--ledger {
    padding: 0;
  }

  .rares-centered-page .rares-catalog-scroll--ledger .rares-pagination {
    padding: 0.6rem 0.9rem 0.8rem;
  }

  /* Five tiles a row, as the homepage shelves. */
  .rares-centered-page .rares-catalog-pane .rare-grid.rares-catalog {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.25rem;
  }

  .rares-centered-page .rares-pagination {
    margin: 0.9rem 0.45rem 0;
  }

  .rares-centered-page .rares-empty-state {
    padding: 1rem 0.3rem;
  }
}
