/* Auction House Deals page - layered on top of assets/ah/base.css.
   Reuses .ah-window / .ah-table / .coin / quality-color classes and the
   --ah-* / --wgf-* design tokens defined there. */

/* Chrome-kit structural tokens come from /static/css/_tokens.css (single home,
   2026-07-04 uiux-standardization) - the old mirror copy here is gone. */

/* --- Toolbar: override the AH grid toolbar with a flexible wrap layout --- */
.ah-toolbar.deals-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px var(--space-3);
  align-items: center;
  padding: 12px;
}

.deals-toolbar .ah-realm-wrap {
  flex: 0 1 300px;
  max-width: 300px;
  margin-right: var(--space-1);
}

.deals-toolbar .deals-type-toggle {
  flex: 0 0 auto;
}

/* Realm typeahead wears the kit search well (.wgf-input--search); this glue only
   sizes it to fill the realm slot of the toolbar. */
.deals-realm-wrap .deals-realm-box {
  flex: 1 1 auto;
  min-width: 0;
}

.deals-realm-wrap {
  position: relative;
}

/* Realm suggest menu: the LOOK is the kit's .wgf-dropdown__menu / .wgf-dropdown__opt
   (near-black panel, radio-dot rows, gold-gradient hover bar - ig-51). Only the
   typeahead-specific positioning + visibility glue lives here. */
.deals-realm-suggest {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 260px;
  overflow-y: auto;
}

/* The kit menu shows via .wgf-dropdown.is-open; this typeahead toggles [hidden]. */
.deals-realm-suggest.wgf-dropdown__menu:not([hidden]) {
  display: block;
}

/* Keyboard-active row wears the same gold-gradient bar the kit paints on :hover. */
.deals-realm-suggest .wgf-dropdown__opt.is-active {
  background: linear-gradient(180deg, var(--wgf-gold-bright), var(--wgf-gold-accent));
  color: var(--wgf-on-gold);
}
.deals-realm-suggest .wgf-dropdown__opt.is-active::before {
  box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.5);
}

.deals-realm-suggest__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.deals-realm-suggest__meta {
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--wgf-gold-link);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

/* On the lit gold bar the meta chip inherits the dark on-gold ink. */
.deals-realm-suggest .wgf-dropdown__opt:hover .deals-realm-suggest__meta,
.deals-realm-suggest .wgf-dropdown__opt.is-active .deals-realm-suggest__meta {
  color: inherit;
}

/* Ensure [hidden] works on .deals-field even though display:flex in the author
   stylesheet would otherwise beat the browser's user-agent [hidden]{display:none}. */
.deals-field[hidden] { display: none !important; }

/* --- Deal-type tab strip ---
   The strip is the kit's .wgf-tabrow and each button is a kit .wgf-tab (red-button
   slices, dimmed at rest, pressed when .is-active) - the slice recipe lives ONLY in
   wgf-chrome.css now. .deals-type-btn stays as the JS hook + responsive-layout hook. */
.deals-type-btn {
  white-space: nowrap;
}

/* --- Filter bar: squared stone well, thin metal border, inset depth --- */
.deals-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px var(--space-3);
  padding: 12px;
  background: var(--wgf-well);
  border-radius: 0;
  border-bottom: 1px solid var(--wgf-metal-soft);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.75), inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}

.deals-field {
  display: flex;
  flex-direction: column;
  flex: 1 1 110px;
  max-width: 180px;
  min-width: 0;
  gap: var(--space-1);
}

/* Label law (13-ingame-reference sec 1): labels read in warm gold small-caps Friz,
   above the well; white/grey is reserved for values. */
.deals-field-label {
  font-family: var(--font-game);
  font-size: 11px;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  color: var(--wgf-gold-muted);
  text-shadow: var(--text-ink-outline);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deals-input {
  width: 100%;
  min-width: 0;
}

/* AH inputfield 3-slice treatment on filter number inputs (ig-62 pattern). */
.deals-filterbar .deals-input {
  height: var(--wgf-input-h);
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background:
    url(/assets/ui/auctionhouse-ui-inputfield-left.png) left center / auto 100% no-repeat,
    url(/assets/ui/auctionhouse-ui-inputfield-right.png) right center / auto 100% no-repeat,
    url(/assets/ui/auctionhouse-ui-inputfield-middle.png) left center / auto 100% repeat-x;
  color: var(--wgf-text);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  box-shadow: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

.deals-filterbar .deals-input::-webkit-outer-spin-button,
.deals-filterbar .deals-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.deals-filterbar .deals-input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Reset filters + Export CSV are kit .wgf-btn-dark charcoal secondaries; only the
   filterbar layout glue lives here. Export ships [hidden] and the kit's
   display:inline-flex would otherwise beat the UA [hidden] rule. */
.deals-filterbar .deals-reset {
  margin-left: auto;
}

.deals-export[hidden] {
  display: none !important;
}

/* Refresh = kit .wgf-btn-red; source select = kit .wgf-dropdown--native.
   Both bespoke re-implementations are deleted (one home: wgf-chrome.css). */

/* --- Context strip under the filters ---
   ONE .wgf-dialog-banner--notice (ig-50 system notice) carries the trust warning +
   snapshot provenance + the live freshness line; everything else in .deals-context
   is a quiet caption line - no bordered-box stack (ig-38 container law). */
.deals-context {
  margin: var(--space-3) 0 var(--space-2);
  padding: 0 12px;
}

.deals-freshness {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.4rem;
  margin: var(--space-2) 0 0;
  font-size: var(--text-sm);
}

.deals-freshness[hidden] {
  display: none;
}

.deals-fresh-item strong {
  font-weight: 600;
  color: var(--wgf-gold-muted);
  margin-right: 0.25rem;
}

.deals-fresh-emph {
  color: var(--wgf-gold);
  font-weight: 600;
}

/* Quiet caption lines (demoted from the old bordered-box stack) */
.deals-explainer {
  margin: var(--space-2) 0 0;
  color: var(--ah-muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.deals-explainer:empty {
  display: none;
}

.deals-meta-note {
  margin: var(--space-1) 0 0;
  color: var(--ah-muted);
  opacity: 0.75;
  font-size: 0.78rem;
  line-height: 1.45;
}

.deals-advanced {
  margin: 0 0 var(--space-2);
}

/* Hero context line (above the window, set by ah-deals.js updateContextHeading) */
.deals-hero-context {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--wgf-gold);
  margin: 0.15rem 0 0.35rem;
}

.deals-hero-context[hidden] {
  display: none;
}

/* --- Table --- */
.deals-table-shell {
  border-left: 0;
}

.deals-table {
  min-width: 940px;
}

/* In-game journal column headers: Friz gold small-caps on a raised plate band.
   Matches .wgf-colhead__cell (ig-62 AH column header tabs). */
.deals-table thead th {
  background: linear-gradient(180deg, var(--wgf-plate-hi), var(--wgf-well));
  color: var(--wgf-gold-muted);
  font-family: var(--font-game);
  font-size: 11px;
  font-weight: 700;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  text-shadow: var(--text-ink-outline);
  border: 1px solid var(--wgf-metal-soft);
  border-bottom: 1px solid var(--wgf-metal);
}

.deals-table th.ah-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.deals-table thead th.ah-sortable:hover {
  background: linear-gradient(180deg, var(--wgf-panel-3), var(--wgf-panel-2));
  color: var(--wgf-gold-bright);
}

.deals-table th.is-sorted {
  color: var(--wgf-gold-bright);
}

.deals-table th .sort-arrow {
  font-size: 10px;
  margin-left: 2px;
}

/* Value-alignment law (13-ingame-reference sec 1): numeric columns right-align,
   header and cell alike (.wgf-colhead__cell.is-num pattern). Price + Available
   already right-align via base.css; this completes the set. */
.deals-table thead th.col-price,
.deals-table thead th.col-market,
.deals-table thead th.col-discount,
.deals-table thead th.col-spread,
.deals-table thead th.col-profit,
.deals-table thead th.col-qty {
  text-align: right;
}

.deals-table td.col-market,
.deals-table td.col-discount,
.deals-table td.col-spread,
.deals-table td.col-profit {
  text-align: right;
}

/* Render-stable column hiding, toggled per deal type from JS. */
.deals-table.hide-col-discount .col-discount,
.deals-table.hide-col-spread .col-spread {
  display: none;
}

/* Hairline metal row separators */
.deals-table tbody td {
  vertical-align: top;
  border-bottom: 1px solid var(--wgf-metal-soft);
}

/* Whole row is clickable -> item detail view */
.deals-row {
  cursor: pointer;
}

/* Gold gradient hover per AH kit (matches .ah-table tbody tr:hover in base.css) */
.deals-row:hover {
  background: linear-gradient(180deg, rgba(var(--wgf-gold-rgb), 0.10), rgba(var(--wgf-gold-rgb), 0.04));
}

/* Empty state: centered Friz gold (ig-26 "Tip:" voice on empty AH table) */
.deals-table .ah-empty {
  padding: 38px var(--space-2) !important;
  color: var(--wgf-gold-bright) !important;
  font-family: var(--font-game);
  font-size: var(--text-sm) !important;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  text-align: center;
  text-shadow: var(--text-ink-outline);
}

.deals-table .ah-empty strong {
  display: block;
  margin-bottom: var(--space-2);
}

/* Available cell: keep the count and sub-line cleanly stacked and aligned */
.deals-table .col-qty {
  text-align: right;
  white-space: nowrap;
}
.deals-qty {
  display: block;
  font-weight: 700;
}
.deals-qty-sub {
  display: block;
  margin-top: 1px;
}

.deals-table .col-source,
.deals-table .col-discount,
.deals-table .col-spread,
.deals-table .col-updated {
  white-space: nowrap;
}

/* Item cell. The icon is the ONE first-party AH row icon (.wgf-ah-fpicon, 30px
   square, ah/base.css) - owner ruling 2026-08-02: NO quality ring on AH rows;
   quality reads through the q-* color on the item name. The icon's own
   margin-right provides the icon/name spacing. */
.deals-item {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  text-decoration: none;
}

.deals-item:hover .deals-item-name {
  text-decoration: underline;
}

.deals-badge {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ah-muted);
}

/* Source tag: the kit .wgf-chip squared mini-plate; only the semantic label
   colors live here (gold = realm, bronze = commodity). */
.deals-src {
  font-size: 10.5px;
}

.deals-src--realm {
  color: var(--wgf-gold-bright);
}

.deals-src--commodity {
  color: #e0a36a;
}

/* Reference price sub-label: consumes .ah-subtext (one muted sub-line home,
   same as the qty sub-line); this adds only the block layout + small-caps cut. */
.deals-ref-label {
  display: block;
  margin-top: 1px;
  font-size: 10px;
  font-variant: small-caps;
  letter-spacing: 0.04em;
}

/* Discount badge, color-graded by magnitude */
.deals-disc {
  font-weight: 800;
}
.deals-disc--hot { color: var(--ah-gold); }
.deals-disc--good { color: var(--ah-green); }
.deals-disc--ok { color: #9fcf7a; }
.deals-disc--none { color: var(--ah-muted); font-weight: 600; }

.deals-spread {
  font-weight: 700;
  color: #cdb88a;
}

/* Money rows are WHITE coin notation; emphasis via weight, color reserved for
   sign (ig-29 invoice law: negative money renders RED with red-tinted coins). */
.deals-profit {
  font-weight: 800;
}
.deals-profit--neg,
.deals-profit--neg .wgf-price {
  color: var(--wgf-down);
}
.deals-profit--neg .wgf-coin {
  filter: hue-rotate(-35deg) saturate(1.6) brightness(0.95);
}

/* --- About / glossary section --- */
.deals-about {
  width: min(1500px, calc(100vw - 44px));
  margin: var(--space-4) auto 0;
  padding: 0 2px var(--space-2);
  color: var(--ah-text);
}

.deals-about h2 {
  font-family: var(--font-display);
  color: var(--ah-gold);
  font-size: 1.2rem;
  margin: 0 0 var(--space-2);
}

.deals-about p {
  color: var(--ah-muted);
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 70ch;
}

.deals-glossary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px var(--space-4);
  margin: var(--space-3) 0;
}

.deals-glossary dt {
  color: var(--ah-gold-soft);
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 2px;
}

.deals-glossary dd {
  margin: 0;
  color: var(--ah-muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.deals-about-note {
  font-style: italic;
  font-size: 12px !important;
  color: #918777 !important;
}

/* --- Score column --- */
.col-score {
  width: 64px;
  text-align: center;
  white-space: nowrap;
}

/* M17 deal-score chip styling now lives in the canonical assets/wgf-deal-score.css
   (single home, linked on the deals page). The minimal glue that used to live here
   was removed once the canonical sheet shipped (2026-06-23). */

/* --- FAQ section ---
   The FAQ is THE SPELLBOOK now (owner law 2026-08-04). Its look lives in the one
   home — assets/wgf-spellbook.css — which this page links, and the section opts
   in with `class="deals-faq wgf-spellbook"`. The bespoke two-column dl styling
   that used to live here is DELETED rather than left dormant: at equal
   specificity it would have fought the component and the winner would have come
   down to <link> order, which is the exact failure mode logged in
   wgf-zonebg.css. Only the section's own outer spacing stays here. */
.deals-faq {
  margin-top: 28px;
}

/* --- Responsive --- */
@media (max-width: 720px) {
  /* Turn each deal into a self-contained card instead of forcing a sideways
     scroll of a 10-column table. Score + Item form the card header; the key
     decision fields stack below as labelled rows (label via td::before from
     each cell's data-th). Reference-only columns are dropped on phones. */
  .deals-table,
  .deals-table tbody {
    display: block;
    min-width: 0;
  }
  .deals-table thead {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .deals-table tbody tr {
    display: block;
  }
  .deals-table .deals-row {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 0.3rem 0.6rem;
    padding: var(--space-2) 12px;
    margin-bottom: var(--space-2);
    /* Mobile deal card: in-game tooltip plate (squared). */
    border: 1px solid var(--wgf-metal);
    border-radius: 5px;
    background: linear-gradient(180deg, rgba(12, 12, 30, 0.97), rgba(5, 5, 16, 0.97));
  }
  .deals-table .deals-row > td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 2px 0;
    border: 0;
    white-space: normal;
    text-align: left;
  }
  .deals-table .deals-row > td::before {
    content: attr(data-th);
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ah-muted);
  }
  /* Card header: score badge (col 1) + item name (col 2) on the first grid row */
  .deals-table .deals-row .col-score { grid-column: 1; grid-row: 1; justify-content: center; }
  .deals-table .deals-row .col-name  { grid-column: 2; grid-row: 1; font-weight: 700; }
  .deals-table .deals-row .col-score::before,
  .deals-table .deals-row .col-name::before { display: none; }
  .deals-table .deals-row .col-qty { text-align: left; }
  /* Reference-only columns: drop on phones to keep the card lean */
  .deals-table .deals-row .col-source,
  .deals-table .deals-row .col-market,
  .deals-table .deals-row .col-spread,
  .deals-table .deals-row .col-updated {
    display: none;
  }
  .ah-toolbar.deals-toolbar {
    gap: var(--space-2);
    padding: var(--space-2);
  }
  .deals-toolbar .ah-realm-wrap,
  .deals-toolbar .wgf-dropdown--native {
    flex: 1 1 100%;
    max-width: none;
  }
  .deals-toolbar .ah-realm-wrap {
    width: 100%;
    margin-right: 0;
  }
  .deals-realm-suggest {
    right: 0;
  }
  .deals-type-toggle {
    width: 100%;
    justify-content: stretch;
  }
  .deals-type-btn {
    flex: 1 1 auto;
    text-align: center;
  }
  .deals-toolbar #dealsRefreshButton {
    flex: 1 1 100%;
    width: 100%;
  }
  .deals-filterbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    padding: var(--space-2);
  }
  .deals-input {
    width: 100%;
  }
  .deals-field {
    min-width: 0;
  }
  .deals-filterbar .deals-reset {
    margin-left: 0;
    width: 100%;
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .deals-filterbar {
    grid-template-columns: 1fr;
  }
  .deals-type-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .deals-type-btn {
    min-height: 32px;
  }
}


/* ---- Deals loading caption (2026-06-28) ----------------------------------------
   Sets expectation during the (multi-second) deal scan so the shimmer skeleton
   does not read as a stuck/empty table. See assets/ah-deals.js renderSkeleton. */
.deals-loading-row td {
  padding: var(--space-3) var(--space-3);
  color: var(--wgf-muted, #c9c3b8);
  font-size: 14px;
  background: rgba(244, 196, 92, 0.04);
}
.deals-loading-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-right: var(--space-2);
  vertical-align: -2px;
  border-radius: 50%;
  border: 2px solid rgba(244, 196, 92, 0.25);
  border-top-color: var(--wgf-gold-link, #f5c451);
  animation: deals-spin 0.7s linear infinite;
}
@keyframes deals-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .deals-loading-spinner { animation: none; }
}
