/* Ratchet Research: Institutional Research, Goblin Ethics.
   Colours come from the emblem: its gold gear (brand and controls), the goblin's lime (prices up),
   the candle red (prices down) and the green-black of the chart screen behind him. Marcellus
   (SIL OFL 1.1, self-hosted) sets the name and headings; numbers use the system face with
   tabular figures. Dark is the default; light follows the system setting. */
@font-face {
  font-family: "Marcellus";
  src: url("/fonts/Marcellus-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
:root {
  --bg: #0c1510; --panel: #131f18; --raise: #1a2a20; --text: #e8ecdf; --muted: #98a693; --line: #253629;
  --gold: #f0b000; --gold-deep: #b98500; --accent: var(--gold);
  --ok: #8fcf2a; --bad: #e5513f; --warn: #f0b000;
  --display: "Marcellus", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --ui: system-ui, -apple-system, "Segoe UI", Ubuntu, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #edf1e8; --panel: #fbfcf7; --raise: #f3f6ee; --text: #18221b; --muted: #59685b; --line: #d2dbcb;
    --gold: #9c6c00; --gold-deep: #7a5400; --ok: #3f7f12; --bad: #b8352a; --warn: #9c6c00;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--ui); }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 400; }
h2 { font-size: 18px; margin: 24px 0 8px; }

/* the brand plate: the one loud thing on the page */
.brand {
  display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap;
  padding: 8px 16px; background: linear-gradient(var(--panel), var(--bg));
  border-bottom: 2px solid var(--gold-deep);
}
.brand-home { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-emblem { display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45)); }
.brand-name { font: 25px/1 var(--display); letter-spacing: .01em; color: var(--gold); }
.brand-tagline { font: italic 14px/1.3 var(--display); color: var(--muted); }
.colophon {
  display: flex; gap: 12px; align-items: flex-start; max-width: 760px;
  margin: 8px 12px 28px; padding-top: 14px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px;
}
.colophon p { margin: 0; }
.colophon img { flex: none; opacity: .85; }

/* shared pieces the terminal's tabs use */
.card { background: var(--raise); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; display: flex; flex-direction: column; }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 17px; margin-top: 2px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.card small { color: var(--muted); margin-top: 2px; }
.ok { color: var(--ok); } .bad { color: var(--bad); }
.mono { font-family: ui-monospace, monospace; font-size: 13px; }
.chart { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px; }
table { width: 100%; border-collapse: collapse; margin-top: 16px; background: var(--panel); border: 1px solid var(--line); }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
th small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
th a { text-decoration: none; color: inherit; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: 13px; }
.filters { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin: 16px 0 8px; }
.frow { display: flex; gap: 8px; margin: 4px 0; flex-wrap: wrap; }
select, input, button { font: inherit; padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); color: var(--text); }
button { cursor: pointer; }
.pager { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dt { color: var(--muted); } dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
label { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }

/* item information from Wowhead: tooltip, quality colours (the game's own), tables */
pre.tip { white-space: pre-wrap; max-width: 560px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; font-family: inherit; }
.q-poor { color: #9d9d9d; } .q-common { color: var(--text); } .q-uncommon { color: #1eff00; } .q-rare { color: #0070dd; }
.q-epic { color: #a335ee; } .q-legendary { color: #ff8000; } .q-artifact { color: #e6cc80; } .q-heirloom { color: #00ccff; }
@media (prefers-color-scheme: light) {
  .q-uncommon { color: #1a8a00; } .q-rare { color: #0059b3; } .q-epic { color: #8a2bd0; }
  .q-legendary { color: #c25e00; } .q-artifact { color: #8f7a35; } .q-heirloom { color: #00809f; }
}
details.infotable { margin: 10px 0; } details.infotable > summary { cursor: pointer; font-family: var(--display); font-size: 16px; }
button.sortbtn { all: unset; cursor: pointer; font-weight: 600; color: var(--accent); }

/* the terminal: full width, panels in a grid */
.term-wrap { padding: 8px 12px 32px; }
.term { display: flex; flex-direction: column; gap: 8px; }
.term .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; min-width: 0; }
.term .up { color: var(--ok); } .term .down { color: var(--bad); }
.term-watch { display: flex; gap: 6px; align-items: center; overflow-x: auto; white-space: nowrap; padding: 2px 0; font-size: 13px; }
.term-watch-label { color: var(--gold); }
.term-chip { display: inline-flex; gap: 6px; padding: 2px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); text-decoration: none; background: var(--panel); }
.term-chip.on { border-color: var(--accent); }
.term-watch-tools { margin-left: auto; display: inline-flex; gap: 10px; padding-left: 12px; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
.term-head { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
.term-pick { font: 21px/1.2 var(--display); background: none; border: 1px solid var(--line); color: var(--text); padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.term-pick .caret { color: var(--muted); font-size: 13px; }
.term-star { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 2px; }
.term-star.on { color: var(--gold); }
.term-stats { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.term-stats .stat { display: flex; flex-direction: column; }
.term .stat .label { color: var(--muted); font-size: 12px; }
.term .stat .value { font-size: 15px; }
.term-head-links { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 13px; }
.term-head-links a { color: var(--accent); }
.term-selector { background: var(--panel); border: 1px solid var(--accent); border-radius: 6px; padding: 10px 12px; }
#term-search { width: 100%; font-size: 16px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); }
.term-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin: 6px 0; }
.term-tabs button, .term-tabs a, .term-seg a { background: none; border: 1px solid var(--line); color: var(--text); padding: 2px 10px; border-radius: 5px; cursor: pointer; text-decoration: none; font: 13px var(--ui); }
.term-tabs .on, .term-seg .on { border-color: var(--gold-deep); color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, transparent); }
.term-table { margin-top: 6px; font-size: 13px; }
.term-table td, .term-table th { padding: 4px 8px; }
.term-table td.num { white-space: nowrap; }
.term-table a { color: var(--accent); }
.term-table .term-group td { padding-top: 10px; border-bottom: 1px solid var(--line); }
.term-sub { font: 16px var(--display); margin: 12px 0 2px; }
#term-rows tr.on td { font-weight: 600; }
#term-rows tr.hi { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.term-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px 260px; gap: 8px; align-items: start; }
.term-chart .chart { border: 0; padding: 0; }
.term-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.term-seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.term-ind-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--line); color: var(--text); padding: 2px 10px; border-radius: 6px; cursor: pointer; font: 13px var(--ui); }
.term-ind-btn:hover { border-color: var(--accent); color: var(--accent); }
/* Lightweight Charts lays itself out with a table: keep the site's table styles out of it */
.tv-lightweight-charts table { width: auto; margin: 0; border: 0; background: none; border-collapse: separate; }
.tv-lightweight-charts th, .tv-lightweight-charts td { padding: 0; border: 0; }
/* the chart's right-click menu (TradingView's layout: a check column, the label, the shortcut) */
.tv-menu { position: fixed; z-index: 1000; min-width: 260px; padding: 4px 0; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22); font: 13px var(--ui); }
.tv-menu button { display: flex; align-items: center; width: 100%; gap: 8px; padding: 7px 14px 7px 8px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.tv-menu button:hover, .tv-menu button:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); outline: none; }
.tv-menu-mark { width: 16px; text-align: center; color: var(--accent); }
.tv-menu-label { flex: 1; white-space: nowrap; }
.tv-menu-key { color: var(--muted); font-size: 12px; white-space: nowrap; padding-left: 24px; }
.tv-menu-sep { height: 1px; margin: 4px 0; background: var(--line); }
.tv-vline { position: absolute; top: 0; bottom: 28px; width: 0; border-left: 1px dashed var(--muted); pointer-events: none; z-index: 2; }
.tv-legend { position: absolute; top: 4px; left: 8px; z-index: 3; display: flex; flex-wrap: wrap; gap: 4px 14px; font: 12px var(--ui); pointer-events: none; font-variant-numeric: tabular-nums; }
.term-ind-btn .fx { font-style: italic; font-weight: 600; }
.term-ind-count { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); border-radius: 6px; padding: 0 6px; font-size: 11px; }
.term-modal-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; }
.term-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
.term-modal { position: relative; width: min(460px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); padding: 12px 14px; }
.term-modal-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 6px; }
.term-modal-head h3 { margin: 0; font-size: 18px; }
.term-modal-x { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px; }
.term-modal-x:hover { color: var(--text); }
.term-ind-list { list-style: none; margin: 0; padding: 0; }
.term-ind-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 6px; border-radius: 6px; color: var(--text); text-decoration: none; }
.term-ind-row:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.term-ind-check { flex: none; width: 18px; height: 18px; margin-top: 2px; border: 1px solid var(--line); border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; color: var(--bg); }
.term-ind-row.on .term-ind-check { background: var(--accent); border-color: var(--accent); }
.term-ind-text { display: flex; flex-direction: column; }
.term-ind-name { font-weight: 600; font-size: 14px; }
.term-ind-row.off { opacity: .55; cursor: default; }
.term-ind-row.off:hover { background: none; }
.term-ind-warn { color: var(--bad); }
.term-ind-windows { display: flex; align-items: center; gap: 4px; margin: -2px 0 6px 34px; }
.term-ind-windows .note { margin-right: 4px; }
.term-book table.book { margin-top: 4px; }
.depth-cell { position: relative; }
.depth-bar { position: absolute; right: 0; top: 2px; bottom: 2px; background: color-mix(in srgb, var(--bad) 18%, transparent); border-radius: 2px; }
.depth-text { position: relative; }
.term-changes { list-style: none; padding: 0; margin: 0; font-size: 13px; max-height: 440px; overflow-y: auto; }
.term-changes li { display: flex; flex-wrap: wrap; gap: 0 8px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.term-plan h3 { font-size: 18px; margin: 2px 0 4px; }
.term-dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; }
.term-dl dt { color: var(--muted); font-size: 13px; }
.term-dl dd { margin: 0; }
.term-inline label { font-size: 13px; }
.term-inline input, .term-inline select { margin-left: 6px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); max-width: 120px; }
.term-bottom { overflow-x: auto; }
.infotable th.num, .infotable td.num { white-space: nowrap; text-align: center; }
.term-tooltip { white-space: pre-wrap; font: 13px/1.5 var(--ui); margin: 4px 0; }
.term-empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.term-first img { display: block; margin: 0 auto 12px; max-width: 60vw; height: auto; }
.term kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font: 12px ui-monospace, monospace; }
.term-dl { max-width: 360px; }
/* two columns: the planner goes under the chart, so the book has the right column to itself */
@media (max-width: 1280px) {
  .term-grid { grid-template-columns: minmax(0, 1fr) 300px; grid-template-areas: "chart book" "plan book"; }
  .term-chart { grid-area: chart; } .term-book { grid-area: book; } .term-plan { grid-area: plan; }
}
@media (max-width: 860px) { .term-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: none; } .term-chart, .term-book, .term-plan { grid-area: auto; } .term-head-links { margin-left: 0; } .term-watch { flex-wrap: wrap; white-space: normal; overflow-x: visible; } .term-watch-tools { margin-left: 0; padding-left: 0; } }
@media (max-width: 600px) {
  .brand { padding: 6px 12px; } .brand-name { font-size: 21px; } .brand-emblem { width: 40px; height: 40px; }
  .brand-tagline { flex-basis: 100%; font-size: 13px; }
}
/* phones: each Wowhead table row becomes a card of labelled lines; the headings stay as a wrapping
   row of sort buttons */
@media (max-width: 600px) {
  .infotable table, .infotable thead, .infotable tbody { display: block; border: 0; background: none; }
  .infotable table { margin-top: 6px; }
  .infotable thead tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
  .infotable thead tr::before { content: "Sort by"; color: var(--muted); font-size: 12px; }
  .infotable thead th { border: 0; padding: 2px 0; text-align: left; }
  .infotable tbody tr { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; margin: 8px 0; padding: 4px 0; }
  .infotable tbody td { display: grid; grid-template-columns: 8.5em minmax(0, 1fr); gap: 10px; border: 0; padding: 3px 10px; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  .infotable tbody td::before { content: attr(data-label); color: var(--muted); font-size: 12px; padding-top: 2px; }
  .infotable th.num, .infotable td.num { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
