/* 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;
}

.deals-toolbar .ah-control {
  flex: 0 0 auto;
}

.deals-toolbar #dealsExportButton {
  padding: 0 var(--space-3);
}

/* Refresh button gets the cap-width padding (must equal --wgf-btn-cap exactly). */
.deals-toolbar #dealsRefreshButton {
  padding: 0 var(--wgf-btn-cap) !important;
  min-height: var(--wgf-btn-h);
}

.deals-toolbar .ah-realm-select {
  width: 100%;
}

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

.deals-realm-suggest {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  max-height: 260px;
  margin: 0;
  padding: var(--space-1);
  list-style: none;
  overflow-y: auto;
  /* Dropdown panel: near-black, thin metal rim (matches .wgf-dropdown__menu). */
  border: 1px solid var(--wgf-metal);
  border-radius: 6px;
  background: linear-gradient(180deg, #0c0c0f, #050507);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.58);
}

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

.deals-realm-suggest li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
}

.deals-realm-suggest li:hover,
.deals-realm-suggest li.is-active {
  background: rgba(244, 196, 92, 0.12);
  border-color: var(--wgf-border-neutral);
}

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

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

/* 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: wgf-tab red-button slices (ig-38 container law) --- */
/* The container is a plate-strip; each button IS the client red button dimmed
   at rest, pressed slices for the active state. Same padding==cap-width rule as
   .wgf-tab: 13px at 30px height. */
.deals-type-toggle {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 var(--space-1);
  border: 1px solid var(--wgf-metal-soft);
  border-radius: 0;
  background: linear-gradient(var(--wgf-well), var(--wgf-panel-1));
}

.deals-type-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 13px;                               /* == cap width at 30px height */
  border: 0;
  border-radius: 0;
  background:
    url(/assets/ui/128-redbutton-left-cap.png) left center / auto 100% no-repeat border-box,
    url(/assets/ui/128-redbutton-right-cap.png) right center / auto 100% no-repeat border-box,
    url(/assets/ui/_128-redbutton-center.png) left center / auto 100% repeat-x content-box;
  background-color: transparent;
  color: var(--wgf-gold-dim);
  font-family: var(--font-game);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow: var(--text-ink-outline);
  cursor: pointer;
  white-space: nowrap;
  filter: brightness(0.66) saturate(0.9);        /* dimmed = unselected */
  transition: filter var(--motion-fast) var(--ease-standard),
              color var(--motion-fast) var(--ease-standard);
}

.deals-type-btn:hover {
  filter: brightness(0.9) saturate(1);
  color: var(--wgf-gold-bright);
}

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

.deals-type-btn.is-active {
  /* selected = pressed red state (pressed cap slices + 1px sink) */
  background:
    url(/assets/ui/128-redbutton-left-cap-pressed.png) left center / auto 100% no-repeat border-box,
    url(/assets/ui/128-redbutton-right-cap-pressed.png) right center / auto 100% no-repeat border-box,
    url(/assets/ui/_128-redbutton-center-pressed.png) left center / auto 100% repeat-x content-box;
  background-color: transparent;
  color: var(--wgf-gold-bright);
  filter: none;
  transform: translateY(1px);
}

/* --- 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);
}

.deals-field-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ah-muted);
  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);
}

.deals-reset {
  height: 31px;
  margin-left: 0;
  padding: 0 12px;
  border: 1px solid var(--wgf-border-neutral-soft);
  border-radius: 4px;
  background: transparent;
  color: var(--wgf-gold-link);
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.deals-filterbar .deals-reset {
  margin-left: auto;
}

.deals-reset:hover {
  color: var(--ah-gold);
  border-color: var(--ah-gold-border);
}

/* --- Refresh button: exact wgf-btn-red slices (replaces ah-search-button approx.) --- */
#dealsRefreshButton {
  height: var(--wgf-btn-h);
  min-width: 96px;
  border: 0;
  border-radius: 0;
  letter-spacing: normal;
  text-transform: none;
  font-size: var(--text-sm);
  background:
    url(/assets/ui/128-redbutton-left-cap.png) left center / auto 100% no-repeat border-box,
    url(/assets/ui/128-redbutton-right-cap.png) right center / auto 100% no-repeat border-box,
    url(/assets/ui/_128-redbutton-center.png) left center / auto 100% repeat-x content-box;
  background-color: transparent;
  color: var(--wgf-gold-bright);
  font-family: var(--font-game);
  font-weight: 700;
  text-shadow: var(--text-ink-outline);
  cursor: pointer;
  transition: filter var(--motion-fast) var(--ease-standard);
}

#dealsRefreshButton:hover {
  filter: brightness(1.12);
}

#dealsRefreshButton:active {
  background:
    url(/assets/ui/128-redbutton-left-cap-pressed.png) left center / auto 100% no-repeat border-box,
    url(/assets/ui/128-redbutton-right-cap-pressed.png) right center / auto 100% no-repeat border-box,
    url(/assets/ui/_128-redbutton-center-pressed.png) left center / auto 100% repeat-x content-box;
  background-color: transparent;
  transform: translateY(1px);
  filter: brightness(0.92);
}

#dealsRefreshButton:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* --- Source select: wgf-dropdown collapsed look (CSS-only, native select) --- */
/* CSS-only limit: the native arrow is suppressed; the AH dropdown arrow slice
   rides the right edge. Open-menu styling requires the .wgf-dropdown JS component
   (markup change listed in report). */
#dealsSourceSelect {
  height: var(--wgf-dropdown-h);
  min-width: 180px;
  padding: 0 40px 0 12px;
  border: 0;
  border-radius: 0;
  background:
    url(/assets/ui/auctionhouse-ui-dropdown-arrow-down.png) right 6px center / auto 20px no-repeat,
    url(/assets/ui/auctionhouse-ui-dropdown-left.png) left center / auto 100% no-repeat,
    url(/assets/ui/auctionhouse-ui-dropdown-right.png) right center / auto 100% no-repeat,
    url(/assets/ui/auctionhouse-ui-dropdown-middle.png) left center / auto 100% repeat-x;
  color: var(--wgf-gold);
  font-family: var(--font-game);
  font-size: var(--text-sm);
  font-weight: 600;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  box-shadow: none;
}

#dealsSourceSelect:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* --- Info / caution bars: quiet stone plate rows, gold/red left accent ---
   Uses body class for specificity to override the inline <style> block in
   wow-auction-house/deals/index.html (.wgf-ah-page is on <body>). */
.wgf-ah-page .deals-freshness {
  border-radius: 0;
  background: var(--wgf-panel-1);
  border: 1px solid var(--wgf-border-neutral-soft);
  border-left: 3px solid var(--wgf-gold-dim);
  box-shadow: none;
}

.wgf-ah-page .deals-trust-warning {
  border-radius: 0;
  background: var(--wgf-panel-1);
  border: 1px solid rgba(var(--wgf-down-rgb), 0.25);
  border-left: 3px solid var(--wgf-down);
  box-shadow: none;
}

/* --- Explainer line --- */
.deals-explainer {
  margin: 0;
  padding: var(--space-2) 12px;
  background: var(--wgf-bg-base);
  border-bottom: 1px solid var(--wgf-border-neutral-soft);
  color: var(--ah-muted);
  font-size: 12.5px;
}

/* --- 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;
}

/* 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 */
.deals-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  text-decoration: none;
}

.deals-item-icon {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  flex: 0 0 auto;
  background: var(--ah-panel, #1a1f2b);
}

.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 chip: squared well chip, game font, no pill. */
.deals-src {
  display: inline-block;
  padding: 1px var(--space-2);
  border-radius: 3px;
  font-family: var(--font-game);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.03em;
  font-variant: small-caps;
  text-transform: none;
}

.deals-src--realm {
  background: color-mix(in srgb, var(--wgf-gold-primary) 14%, transparent);
  color: var(--wgf-gold-bright);
  border: 1px solid color-mix(in srgb, var(--wgf-gold-primary) 40%, transparent);
}

.deals-src--commodity {
  background: rgba(200, 120, 60, 0.16);
  color: #e0a36a;
  border: 1px solid rgba(200, 120, 60, 0.45);
}

/* Reference price sub-label */
.deals-ref-label {
  display: block;
  margin-top: 1px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #918777;
}

/* 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;
}

.deals-profit {
  font-weight: 800;
}
.deals-profit .money { color: var(--ah-green); }

/* --- 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 --- */
.deals-faq {
  margin-top: 28px;
  border-top: 1px solid var(--wgf-border-neutral-soft);
  padding-top: 20px;
}

.deals-faq h2 {
  font-family: var(--font-display);
  color: var(--ah-gold);
  font-size: 1.2rem;
  margin: 0 0 12px;
}

.deals-faq-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px var(--space-5);
}

.deals-faq-list dt {
  font-weight: 800;
  font-size: 13px;
  color: var(--ah-gold-soft);
  margin-bottom: var(--space-1);
}

.deals-faq-list dd {
  margin: 0;
  color: var(--ah-muted);
  font-size: 13px;
  line-height: 1.58;
}

.deals-faq-list dd strong {
  color: var(--ah-text);
}

/* --- 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 #dealsSourceSelect {
    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 #dealsExportButton,
  .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;
  }
  .deals-faq-list {
    grid-template-columns: 1fr;
  }
}

@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; }
}
