/* auctimogger-tracker UI — design tokens + components.
   Dark, dense, keyboard-friendly; every dynamic value renders server-side,
   this sheet only styles it. */

:root {
  --bg: #0b0d12;
  --surface: #12151d;
  --surface-2: #171b25;
  --surface-3: #1d2230;
  --border: #272e3d;
  --border-soft: #1e2431;
  --text: #d8dde8;
  --muted: #8b94a7;
  --faint: #5c6577;
  --accent: #5aa2ff;
  --accent-soft: rgba(90, 162, 255, 0.14);
  --ok: #3fb950;
  --ok-soft: rgba(63, 185, 80, 0.15);
  --warn: #d29922;
  --warn-soft: rgba(210, 153, 34, 0.15);
  --bad: #f85149;
  --bad-soft: rgba(248, 81, 73, 0.14);
  --vwap: #f0b429;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  /* WoW item-quality palette (loot-color convention). */
  --q-poor: #9d9d9d;
  --q-common: #d8dde8;
  --q-uncommon: #1eff00;
  --q-rare: #0070dd;
  --q-epic: #a335ee;
  --q-legendary: #ff8000;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1200px 400px at 70% -10%, rgba(90, 162, 255, 0.07), transparent),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

h1 { font-size: 1.35rem; margin: 0 0 .4rem; }
h2 { font-size: .95rem; margin: 1.6rem 0 .55rem; color: var(--text); letter-spacing: .02em; }

code {
  font-family: var(--mono);
  color: #ffa657;
  font-size: .92em;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: .06em .32em;
}

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.up { color: var(--ok); font-variant-numeric: tabular-nums; }
.down { color: var(--bad); font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- layout */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: .55rem 1.4rem;
  background: rgba(13, 16, 22, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

nav.main { display: flex; gap: .15rem; flex-wrap: wrap; }
nav.main a {
  color: var(--muted);
  padding: .28rem .65rem;
  border-radius: 999px;
  white-space: nowrap;
}
nav.main a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
nav.main a.active { color: var(--text); background: var(--accent-soft); }

.topbar .spacer { flex: 1; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.2rem 1.4rem 3rem; }

footer.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.4rem 2.2rem;
  color: var(--faint);
  font-size: .82rem;
  border-top: 1px solid var(--border-soft);
}

/* ------------------------------------------------------------- switcher */

.switcher {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-left: auto;
}
.switcher label { color: var(--muted); font-size: .85rem; white-space: nowrap; }
noscript .switcher button { margin-left: .3rem; }

/* ---------------------------------------------------------------- cards */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: .8rem;
  margin: .6rem 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  transition: border-color .12s ease;
}
.card:hover { border-color: var(--border); }

.card h3 {
  margin: 0 0 .5rem;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.card h3 a { color: var(--text); }

.kpi { font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi small { font-size: .8rem; color: var(--muted); font-weight: 400; }

.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .12rem 0; }
.kv .k { color: var(--muted); }
.kv .v { font-variant-numeric: tabular-nums; text-align: right; }

/* ---------------------------------------------------------------- tables */

.scroll-x { overflow-x: auto; margin: .5rem 0; }

table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: .34rem .6rem;
  text-align: right;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
th:last-child, td:last-child { text-align: left; }

thead th {
  color: var(--muted);
  font-weight: 550;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

tbody tr { transition: background .1s ease; }
tbody tr:hover { background: var(--surface-2); }

th[data-sortable] { cursor: pointer; user-select: none; }
th[data-sortable]:hover { color: var(--text); }
th[data-sortable]::after { content: "⇅"; margin-left: .3rem; color: var(--faint); font-size: .75rem; }
th[data-sortable][aria-sort="ascending"]::after { content: "↑"; color: var(--accent); }
th[data-sortable][aria-sort="descending"]::after { content: "↓"; color: var(--accent); }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  padding: .05rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.badge.info { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* quality chips: colored text, subtle — the loot-color convention */
.q { font-size: .78rem; }
.q.poor { color: var(--q-poor); }
.q.common { color: var(--q-common); }
.q.uncommon { color: var(--q-uncommon); }
.q.rare { color: var(--q-rare); }
.q.epic { color: var(--q-epic); }
.q.legendary { color: var(--q-legendary); }

/* pet badge marks battle-pet hits */
.badge.pet { color: #62c86e; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-block;
  padding: .3rem .8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.btn:hover { background: var(--surface-3); border-color: var(--faint); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: wait; }
.btn-primary { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn-primary:hover { background: rgba(90, 162, 255, 0.24); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); border-color: transparent; }
.btn-sm { padding: .12rem .55rem; font-size: .8rem; }

.toolbar {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  margin: .4rem 0 .6rem;
}
.toolbar label { color: var(--muted); font-size: .85rem; }

/* ----------------------------------------------------------------- forms */

input[type="text"], input[type="search"], input[type="number"], select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .3rem .55rem;
  font: inherit;
}
input[type="text"], input[type="search"] { width: min(26rem, 100%); }
input:focus-visible, select:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.searchbox { position: relative; max-width: 30rem; }
.completions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 22rem;
  overflow-y: auto;
}
.completions:empty { display: none; }
.completions .hit { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem .6rem; }
.completions .hit:hover, .completions .hit.active { background: var(--accent-soft); }
.completions .hit .meta { color: var(--faint); font-size: .8rem; text-align: right; white-space: nowrap; }
.completions .hit a { color: var(--text); }

/* -------------------------------------------------------------- tooltips */

.tip {
  position: relative;
  border-bottom: 1px dotted var(--faint);
  cursor: help;
  border-radius: 3px;
}
.tip:hover, .tip:focus-visible {
  color: var(--text);
  border-bottom-color: var(--muted);
}
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 21rem;
  white-space: normal;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: .45rem .65rem;
  font-size: .8rem;
  font-weight: 400;
  line-height: 1.45;
  text-transform: none;
  letter-spacing: normal;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transition: opacity .1s ease;
  z-index: 60;
  pointer-events: none;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; visibility: visible; }
/* With scripting active, the shared floating #tooltip layer takes over:
   the CSS bubble is clipped by .scroll-x tables (it extends above the
   header row), which read as a bright band instead of a tooltip. */
html.js .tip::after { display: none; }
html.js .tip:hover, html.js .tip:focus-visible { background: transparent; }

/* Shared floating tooltip (created by app.js, positioned in viewport
   coordinates so table scroll containers can never clip it). */
#tooltip {
  position: fixed;
  display: none;
  max-width: min(21rem, 90vw);
  white-space: normal;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: .45rem .65rem;
  font-size: .8rem;
  font-weight: 400;
  line-height: 1.45;
  text-align: left;
  z-index: 90;
  pointer-events: none;
}

/* ----------------------------------------------------------------- chart */

.chart-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: .8rem 1rem; }
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-hover {
  position: absolute;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .35rem .6rem;
  font-size: .8rem;
  white-space: nowrap;
  box-shadow: var(--shadow);
  z-index: 50;
}
.chart-hover:empty { display: none; }
.chart-legend { display: flex; gap: 1.1rem; flex-wrap: wrap; color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.chart-legend .key { display: inline-flex; align-items: center; gap: .35rem; }
.chart-legend .swatch { width: .9rem; height: .45rem; border-radius: 2px; display: inline-block; }
.chart-legend .swatch.vwap {
  background: transparent;
  height: 0;
  width: 1.1rem;
  border-top: 2px dashed var(--vwap);
  border-radius: 0;
}

/* ----------------------------------------------------------------- misc */

.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  padding: 1.4rem;
  text-align: center;
  margin: .6rem 0;
}

.bar {
  background: linear-gradient(90deg, var(--accent), #7cc0ff);
  height: .5rem;
  min-width: 1px;
  display: inline-block;
  vertical-align: middle;
  border-radius: 2px;
}

.feed-links a { margin-right: .9rem; }

.pagenav { display: flex; gap: .8rem; align-items: center; margin: .6rem 0; color: var(--muted); }

.glossary dt { font-weight: 600; margin-top: .8rem; }
.glossary dd { margin: .15rem 0 0 0; color: var(--muted); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: .5rem; padding: .5rem .9rem; }
  .switcher { margin-left: 0; }
  .wrap { padding: 1rem .9rem 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .tip::after, tbody tr, .btn { transition: none; }
  .btn:active { transform: none; }
}

@media print {
  .topbar, .btn, .completions, .chart-hover { display: none !important; }
  .scroll-x { overflow-x: visible; }
  body { background: none; color: #000; }
  th, td { border-color: #bbb; }
  thead th { background: none; color: #000; }
}
