/* =====================================================================================================
   AUCTION HOUSE (track WEB-D). Page layer on top of lunaria.css — consumes tokens only.
   ===================================================================================================== */

/* ---- Accents per category (drives tiles, dots, bars) ---------------------------------------------- */
.accent-primary { --accent: var(--color-primary); --accent-soft: var(--color-primary-soft); }
.accent-secondary { --accent: var(--color-secondary); --accent-soft: var(--color-secondary-soft); }
.accent-gold { --accent: var(--color-gold); --accent-soft: var(--color-gold-soft); }
.accent-accent { --accent: var(--color-accent); --accent-soft: var(--color-accent-soft); }
.accent-success { --accent: var(--color-success); --accent-soft: var(--color-success-soft); }
.accent-warning { --accent: var(--color-warning); --accent-soft: var(--color-warning-soft); }
.accent-muted { --accent: var(--color-text-muted); --accent-soft: rgb(169 180 211 / 12%); }

.h3 { font-size: var(--fs-xl); }
.h4 { font-size: var(--fs-lg); }
.price { color: var(--color-gold); font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); white-space: nowrap; }

/* ---- Hero ----------------------------------------------------------------------------------------- */
.market-hero { padding-bottom: var(--sp-6); }
.hero-search { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; max-width: 760px; margin-bottom: var(--sp-4); }
.hero-search .search { flex: 1 1 320px; }
.market-meta { gap: var(--sp-2) var(--sp-3); }

/* ---- Combobox / suggestions ---------------------------------------------------------------------- */
.combobox { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  z-index: var(--z-dropdown);
  list-style: none; margin: 0; padding: var(--sp-1);
  background: var(--color-surface-menu, var(--color-surface-solid));
  border: 1px solid var(--color-border-highlight);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  max-height: 22rem; overflow-y: auto;
}
.suggest li {
  display: flex; justify-content: space-between; gap: var(--sp-3); align-items: baseline;
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); cursor: pointer; color: var(--color-text);
}
.suggest li .meta { font-size: var(--fs-xs); color: var(--color-text-faint); white-space: nowrap; }
.suggest li mark { background: transparent; color: var(--color-primary); font-weight: var(--fw-bold); padding: 0; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--color-primary-soft); }
.suggest li.is-empty { color: var(--color-text-faint); cursor: default; }

/* ---- Ticker --------------------------------------------------------------------------------------- */
.ticker-wrap { margin: var(--sp-2) 0 0; }
.ticker-item { color: var(--color-text-muted); }
.ticker-item:hover { text-decoration: none; color: var(--color-text); }
.ticker-item .plus { color: var(--color-gold); font-weight: var(--fw-bold); font-size: var(--fs-xs); }
.ticker-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-primary); box-shadow: var(--glow-primary-soft); }

/* ---- Stat cards ----------------------------------------------------------------------------------- */
.market-stats { padding-top: var(--sp-6); }
.stat-card .value.is-text { font-size: var(--fs-lg); line-height: var(--lh-snug); overflow-wrap: anywhere; }

.quiet-market { margin-bottom: var(--sp-4); }

/* ---- Category tiles ------------------------------------------------------------------------------- */
.cat-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.cat-tile {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; gap: 2px var(--sp-3);
  padding: var(--sp-4); color: var(--color-text); text-decoration: none;
  border-top: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
}
.cat-tile:hover { text-decoration: none; color: var(--color-text); }
.cat-tile .glyph {
  grid-row: 1 / span 3; width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent); font-size: var(--fs-xl); line-height: 1;
}
.cat-tile .name { font-weight: var(--fw-bold); }
.cat-tile .count { font-size: var(--fs-sm); color: var(--accent); font-weight: var(--fw-semibold); }
.cat-tile .from { font-size: var(--fs-xs); color: var(--color-text-faint); line-height: var(--lh-snug); }
.cat-tile.is-empty .count { color: var(--color-text-faint); }
.cat-tile.is-empty .glyph { filter: saturate(0.6); opacity: 0.8; }

/* ---- Two-column layouts --------------------------------------------------------------------------- */
.market-two, .item-two { display: grid; gap: var(--sp-6); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) {
  .market-two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
  .item-two { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
}
.market-two .section-head, .item-two .section-head { margin-bottom: var(--sp-4); }

/* ---- Listing rows --------------------------------------------------------------------------------- */
.listing-name { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.listing-name a { overflow-wrap: anywhere; }
.listing-name .sub { display: flex; flex-wrap: wrap; gap: var(--sp-1); align-items: center; font-size: var(--fs-xs); }
.lunaria-table.is-compact td { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.lunaria-table td time { color: var(--color-text-muted); white-space: nowrap; font-size: var(--fs-sm); }
.only-sm { display: none; }
@media (max-width: 767.98px) {
  .hide-md { display: none; }
}
@media (max-width: 559.98px) {
  .hide-sm { display: none; }
  .only-sm { display: inline; }
}

/* Grade colours (loot-card convention; a hint, not a rarity claim) */
.tag.q-0 { background: rgb(169 180 211 / 12%); color: var(--color-text-muted); }
.tag.q-1 { background: rgb(234 240 255 / 10%); color: var(--color-text); }
.tag.q-2 { background: var(--color-success-soft); color: var(--color-success); }
.tag.q-3 { background: var(--color-primary-soft); color: var(--color-primary); }
.tag.q-4 { background: var(--color-secondary-soft); color: var(--color-secondary); }
.tag.q-5 { background: var(--color-gold-soft); color: var(--color-gold); }

/* ---- Side lists ----------------------------------------------------------------------------------- */
.bar-list, .mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.bar-list a { display: grid; grid-template-columns: 7.5rem 1fr 2.5rem; gap: var(--sp-3); align-items: center; color: var(--color-text); padding: var(--sp-1) 0; }
.bar-list a:hover { text-decoration: none; color: #fff; }
.bar-label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 8px; border-radius: var(--r-pill); background: rgb(169 180 211 / 10%); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 60%, transparent), var(--accent)); }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--color-text-muted); font-size: var(--fs-sm); }
.mini-list li { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: baseline; padding: var(--sp-2) 0; border-bottom: 1px solid var(--color-border); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list a { font-weight: var(--fw-semibold); min-width: 0; overflow-wrap: anywhere; }
.mini-list .meta { font-size: var(--fs-sm); color: var(--color-text-faint); white-space: nowrap; }

/* ---- Charts --------------------------------------------------------------------------------------- */
.market-chart-panel { min-height: 0; }
.market-chart { position: relative; height: 260px; }
.market-chart.is-tall { height: 320px; }
@media (max-width: 559.98px) { .market-chart, .market-chart.is-tall { height: 240px; } }
.market-chart canvas { width: 100% !important; height: 100% !important; }
.chart-table { margin-top: var(--sp-4); }
.chart-table summary { cursor: pointer; color: var(--color-primary); font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.chart-table[open] summary { margin-bottom: var(--sp-3); }
.history-empty { padding: var(--sp-8) var(--sp-4); }
.history-empty p { max-width: 60ch; margin-left: auto; margin-right: auto; }

/* ---- How it works --------------------------------------------------------------------------------- */
.grid-3 { display: grid; gap: var(--sp-6); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.how-it-works h3 { font-size: var(--fs-lg); margin-top: var(--sp-3); }
.how-it-works p { color: var(--color-text-muted); }
.step {
  display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  font-family: var(--font-display); color: var(--color-text-on-gold);
  background: linear-gradient(135deg, var(--color-gold), var(--color-gold-strong)); box-shadow: var(--glow-gold);
}

/* ---- Search page ---------------------------------------------------------------------------------- */
.search-layout { display: grid; gap: var(--sp-6); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1024px) {
  .search-layout { grid-template-columns: 300px minmax(0, 1fr); }
  .filters-panel { position: sticky; top: calc(var(--nav-height) + var(--sp-4)); }
}
.filters.is-stacked { flex-direction: column; align-items: stretch; }
.filters.is-stacked .field { min-width: 0; flex: none; }
.filters .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.filters .field.actions { flex-flow: row wrap; gap: var(--sp-2); }
.filters label { font-size: var(--fs-sm); }
.results { min-width: 0; }
.results-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.results-head h2 { margin: 0; }
.active-filters { margin-bottom: var(--sp-3); gap: var(--sp-2); }

/* Chips (sort + category) */
.sort-chips, .cat-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 0.35rem 0.85rem; border-radius: var(--r-pill);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text-muted); font-size: var(--fs-sm); font-weight: var(--fw-semibold); white-space: nowrap;
}
.chip:hover { color: var(--color-text); border-color: var(--color-border-highlight); text-decoration: none; }
.chip.is-active { color: var(--color-text-on-primary); background: var(--color-primary); border-color: transparent; }
.chip .n { font-size: var(--fs-xs); opacity: 0.75; font-variant-numeric: tabular-nums; }

/* ---- Catalogue ------------------------------------------------------------------------------------ */
.catalogue-head { display: flex; flex-wrap: wrap; gap: var(--sp-3); justify-content: space-between; align-items: center; margin-bottom: var(--sp-3); }
.catalogue-filter { flex: 1 1 280px; max-width: 420px; }
.cat-chips { margin-bottom: var(--sp-4); }
.filter-empty { text-align: center; padding: var(--sp-6); margin: 0; }

/* ---- Item page ------------------------------------------------------------------------------------ */
.item-hero h1 { overflow-wrap: anywhere; }
.item-tags { margin-bottom: var(--sp-4); gap: var(--sp-2); }
.item-tags a.tag:hover { text-decoration: none; filter: brightness(1.15); }
.kv { margin: 0; display: grid; gap: var(--sp-2); }
.kv dt { font-size: var(--fs-xs); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-text-muted); }
.kv dd { margin: 0 0 var(--sp-2); color: var(--color-text-muted); font-size: var(--fs-sm); }

/* Phones: keep the hero tight and the search usable */
@media (max-width: 559.98px) {
  .hero-search .btn { flex: 1 1 auto; }
  .bar-list a { grid-template-columns: 6rem 1fr 2rem; }
}

/* Phones: denser stat cards + two-up category tiles so the market reads at a glance */
@media (max-width: 479.98px) {
  .market-stats .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .market-stats .stat-card { padding: var(--sp-4); }
  .market-stats .stat-card .value { font-size: var(--fs-xl); }
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .cat-tile { grid-template-columns: 1fr; padding: var(--sp-3); }
  .cat-tile .glyph { grid-row: auto; width: 36px; height: 36px; font-size: var(--fs-lg); margin-bottom: var(--sp-1); }
  .cat-tile .from { display: none; }
}

/* Select chevron: lunaria.css sets .form-select background-image without repeat/position (tiles across the
   field). Scoped fix here; reported upstream as a shared-CSS need. */
.filters-panel .form-select { background-repeat: no-repeat; background-position: right 0.85rem center; background-size: 14px 14px; padding-right: 2.4rem; appearance: none; }

/* Filters: the name search stays visible; the rest folds away on small screens. */
.more-filters { display: contents; }
.more-filters > summary { display: none; }
@media (max-width: 1023.98px) {
  .more-filters { display: block; }
  .more-filters > summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none;
    padding: var(--sp-2) 0; color: var(--color-primary); font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
  .more-filters > summary::-webkit-details-marker { display: none; }
  .more-filters > summary::after { content: "+"; font-size: var(--fs-lg); line-height: 1; }
  .more-filters[open] > summary::after { content: "\2212"; }
  .more-filters .more-body { display: flex; flex-direction: column; gap: var(--sp-3); padding-top: var(--sp-2); }
  .filters-panel h2 { margin-bottom: var(--sp-2); }
}
@media (min-width: 1024px) { .more-filters .more-body { display: contents; } }

/* Cheapest-listing highlight: one gradient across the row (the shared tr.is-top td rule repeats it per cell). */
.listing-table tr.is-top td { background: transparent; }
.listing-table tr.is-top { background: linear-gradient(90deg, var(--color-gold-soft), transparent 70%); }
.listing-table tr.is-top td:first-child { box-shadow: inset 3px 0 0 var(--color-gold); }
.lunaria-table td.num { white-space: nowrap; }
.listings-section { padding-top: var(--sp-4); }
