/* base.css: reset, type, layout primitives, shared chrome (header, nav, sub-bar slot, ticker shell, footer),
 * chips, coins, verdict stamps, ledger rows, buttons, controls, reveal hooks, reduced-motion collapse.
 * Page/module styles live in css/modules/<id>.css. Keep this file under 400 lines. */

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100dvh; overflow-x: clip;
  background: var(--bg-app) var(--lantern) no-repeat fixed;
  color: var(--text-primary);
  font: 400 var(--text-base) / var(--leading-body) var(--font-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--color-gold); text-decoration: none; }
a:hover { color: var(--color-gold-hover); text-decoration: underline; text-underline-offset: 3px; }
ul, ol { margin: 0; padding: 0; }
table { border-collapse: collapse; width: 100%; }
:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; transition: none; }
::selection { background: var(--color-gold); color: var(--text-inverted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a.sr-only:focus-visible { position: fixed; top: var(--space-2); left: var(--space-2); z-index: 70; width: auto; height: auto; clip: auto; overflow: visible; padding: var(--space-2) var(--space-4); min-height: var(--tap); display: inline-flex; align-items: center; background: var(--color-gold); color: var(--text-inverted); border-radius: var(--radius-control); }

/* Type */
h1, h2, h3, h4 {
  margin: 0; font-family: var(--font-display); font-style: normal;
  font-weight: var(--display-wght); font-stretch: var(--display-wdth); font-variation-settings: "wdth" var(--display-wdth);
  letter-spacing: -0.02em; line-height: 1.08; overflow-wrap: anywhere; min-width: 0;
}
h1 { font-size: var(--text-display-s); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
p { margin: 0; max-width: var(--measure); }
p + p { margin-top: var(--space-4); }
.lede { font-size: var(--text-lg); color: var(--text-secondary); }
.muted { color: var(--text-muted); }
.mono, .num, time, .stamp { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.stamp { font-size: var(--text-xs); color: var(--text-muted); letter-spacing: 0; }
small { font-size: var(--text-sm); }

/* Layout */
.wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--gutter); }
.wrap-narrow { max-width: 760px; }
main { padding-block: var(--space-8) var(--space-16); }
.section { padding-block: var(--space-10); }
.section + .section { border-top: 1px solid var(--border-subtle); }
.grid { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.spread { display: flex; justify-content: space-between; gap: var(--space-3); align-items: baseline; flex-wrap: wrap; }

/* Header: wordmark + one nav row. Under 900px the nav wraps to its own scrolling row; chrome.js writes the live height into --header-h. */
.site-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  background: oklch(0.13 0.018 260 / 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}
.site-header .wrap { display: flex; align-items: center; gap: var(--space-4); height: 100%; }
.wordmark { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-primary); font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg); letter-spacing: -0.02em; min-height: var(--tap); }
.wordmark:hover { text-decoration: none; color: var(--color-gold); }
.wordmark svg { width: 26px; height: 26px; }
.site-nav { margin-left: auto; display: flex; gap: var(--space-1); overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.site-nav::-webkit-scrollbar { display: none; }
.site-nav a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--space-3); color: var(--text-secondary); font-size: var(--text-sm); white-space: nowrap; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--text-primary); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--color-gold); border-bottom-color: var(--color-gold); }
@media (max-width: 899px) {
  .site-header { height: auto; }
  .site-header .wrap { flex-wrap: wrap; padding-block: var(--space-1); row-gap: 0; }
  .site-nav { order: 3; flex-basis: 100%; margin-left: 0; flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); scroll-snap-type: x proximity; }
  .site-nav a { padding: 0 var(--space-2); min-height: 40px; scroll-snap-align: start; }
}

/* Sub-bar slot: the market bar (js/modules/market-bar.js) mounts here on atlas pages and sticks under the header */
.sub-bar { position: sticky; top: var(--header-h); z-index: 30; min-height: var(--bar-h); background: oklch(0.17 0.022 260 / 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border-subtle); }
.sub-bar:empty { display: none; }

/* Ticker shell (module fills it) */
.ticker-shell { min-height: 40px; border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface); overflow: hidden; }
.ticker-shell:empty { display: none; }

/* Footer */
.site-footer { border-top: 1px solid var(--border-subtle); padding-block: var(--space-10); color: var(--text-secondary); font-size: var(--text-sm); }
.site-footer .wrap { display: grid; gap: var(--space-4); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.site-footer nav a { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--text-secondary); white-space: nowrap; }
.site-footer nav a:hover { color: var(--color-gold); }
.pledge { color: var(--text-primary); max-width: var(--measure); }
.pledge::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--color-gold); margin-right: var(--space-2); vertical-align: -1px; }
.disclosure { max-width: var(--measure); color: var(--text-muted); }
.disclosure--ink { color: var(--ink-soft); }
.sources { font-size: var(--text-xs); color: var(--text-muted); max-width: none; }
.sources code { font-family: var(--font-mono); color: var(--text-secondary); }

/* Chips */
/* The hidden attribute wins over any display a class sets (the stale chip, sheets, tabs); until-found stays searchable. */
[hidden]:not([hidden="until-found"]) { display: none !important; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: var(--radius-full); font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.6; border: 1px solid currentColor; white-space: nowrap; vertical-align: middle; }
.chip-forever { color: var(--chip-forever); background: var(--chip-forever-bg); }
.chip-retail, .chip-midnight { color: var(--chip-retail); background: var(--chip-retail-bg); }
.chip-est { color: var(--text-muted); border-style: dashed; }
.chip-lean-alliance { color: var(--pin-alliance); }
.chip-lean-horde { color: var(--pin-horde); }
.chip-lean-contested { color: var(--text-secondary); }
.is-stale { color: var(--color-ruby); }

/* Verdict stamps: the word carries the meaning, colour follows. .v-* classes come from js/core/verdicts.js. */
.stamp-v { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-control); font-family: var(--font-mono); font-size: var(--text-xs); line-height: 1.6; border: 1px solid currentColor; white-space: nowrap; }
.v-worth { color: var(--v-worth); background: var(--v-worth-bg); }
.v-thin { color: var(--v-thin); background: var(--v-thin-bg); }
.v-floor { color: var(--v-floor); background: var(--v-floor-bg); }
.v-nodata { color: var(--v-nodata); border-style: var(--v-nodata-border); }
.confidence { color: var(--text-muted); font-family: var(--font-mono); font-size: var(--text-xs); }
.reason { color: var(--text-secondary); font-size: var(--text-sm); }

/* Item icons; a missing icon is a quiet letter tile, never Blizzard's red question mark */
.icon { width: 28px; height: 28px; border-radius: 4px; box-shadow: 0 0 0 1px var(--color-gold-dim); background: var(--bg-surface-elevated); flex: none; }
.icon-sm { width: 22px; height: 22px; }
.icon-tile { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 4px; background: var(--bg-surface-elevated); color: var(--text-secondary); font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 600; border: 1px solid var(--border-subtle); flex: none; }
.icon-sm.icon-tile { width: 22px; height: 22px; font-size: 10px; }
.paper .icon-tile { background: var(--paper-ledger-line); color: var(--ink-soft); border-color: transparent; }

/* Coins: three currency segments, tabular mono (gold.js goldHtml output) */
.gold { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.coin-g { color: var(--coin-gold); }
.coin-s { color: var(--coin-silver); }
.coin-c { color: var(--coin-copper); }
.coin-g::after, .coin-s::after, .coin-c::after { content: ""; display: inline-block; width: 0.55em; height: 0.55em; border-radius: 50%; background: currentColor; margin-left: 1px; vertical-align: 0.05em; opacity: 0.9; }
.gold.neg { color: var(--color-ruby); }
.gold.neg > span { color: inherit; }
.delta-up { color: var(--color-emerald); }
.delta-down { color: var(--color-ruby); }

/* Tiers (relative among worth-it units; glow + coin colour, never a verdict). verdicts.tierClass -> coin-gold|coin-silver|coin-copper */
.tier-gold, .coin-gold { color: var(--coin-gold); }
.tier-silver, .coin-silver { color: var(--coin-silver); }
.tier-copper, .coin-copper { color: var(--coin-copper); }
.bg-tier-gold { background: var(--coin-gold-bg); }
.bg-tier-silver { background: var(--coin-silver-bg); }
.bg-tier-copper { background: var(--coin-copper-bg); }

/* Item quality names */
.q0 { color: var(--q0); } .q1 { color: var(--q1); } .q2 { color: var(--q2); }
.q3 { color: var(--q3); } .q4 { color: var(--q4); } .q5 { color: var(--q5); }

/* Ledger rows: hairline + gold tick; the hairline draws left to right when the ledger lights (data-shown) */
.ledger { display: grid; }
.ledger-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-2) var(--space-4); align-items: center; padding: var(--space-3) 0 var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-subtle); min-height: var(--tap); transition: background var(--dur-fast) var(--ease-out); }
.ledger-row::before { content: ""; position: absolute; left: 0; top: 50%; width: var(--ledger-tick); height: 60%; transform: translateY(-50%); background: var(--color-gold); }
.ledger-row:hover { background: oklch(0.82 0.16 85 / 0.04); }
.ledger-row:first-child { border-top: 1px solid var(--border-subtle); }
a.ledger-row { color: inherit; }
a.ledger-row:hover { text-decoration: none; }
.ledger-row .figure { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
.ledger-head { font-size: var(--text-xs); color: var(--text-muted); text-transform: none; }
.ledger-hairline { height: 1px; background: var(--color-gold-dim); transform-origin: left; transform: scaleX(0); transition: transform var(--dur-slow) var(--ease-out); }
[data-shown] > .ledger-hairline, .ledger-hairline[data-shown] { transform: scaleX(1); }

/* Honest states as copy, not errors */
.empty, .no-scan, .no-art { border: 1px dashed var(--border-strong); border-radius: var(--radius-control); padding: var(--space-4); color: var(--text-secondary); }

/* The one bright surface */
.paper { background: var(--paper-ledger); color: var(--ink); border-radius: var(--radius-card); padding: var(--space-6); background-image: repeating-linear-gradient(transparent 0 27px, var(--paper-ledger-line) 27px 28px); }
.paper h1, .paper h2, .paper h3, .paper p { color: var(--ink); }
.paper .muted, .paper .stamp { color: var(--ink-soft); }
.paper a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--color-gold-dim); text-underline-offset: 3px; }
.paper .ledger-row { border-color: var(--paper-ledger-line); }
.paper .ledger-row:hover { background: oklch(0.90 0.04 85); }
.card { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-card); padding: var(--space-5); }

/* Buttons (8 states: default, hover, focus-visible, active, disabled, loading, error, success) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--tap); padding: 0 var(--space-5); border-radius: var(--radius-control); font-weight: 600; font-size: var(--text-sm); white-space: nowrap; border: 1px solid var(--border-strong); color: var(--text-primary); background: var(--bg-surface-elevated); transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); }
.btn:hover { background: var(--bg-surface-hover); border-color: var(--color-gold-dim); text-decoration: none; color: var(--text-primary); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn[data-state="loading"] { color: var(--text-muted); }
.btn[data-state="error"] { border-color: var(--color-ruby); color: var(--color-ruby); }
.btn[data-state="success"] { border-color: var(--color-emerald); color: var(--color-emerald); }
.btn-primary { position: relative; overflow: hidden; background: var(--color-gold); color: var(--text-inverted); border-color: var(--color-gold); }
.btn-primary:hover { background: var(--color-gold-hover); color: var(--text-inverted); }
.btn-primary::after { content: ""; position: absolute; inset: 0; background: var(--gold-sheen); transform: translateX(-120%); }
.btn-primary:hover::after { transition: transform var(--dur-slow) var(--ease-in-out); transform: translateX(120%); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--text-secondary); }
.btn-quiet:hover { color: var(--text-primary); background: var(--bg-surface-hover); }

/* Controls: segmented radio groups, toggle chips, steppers, inputs */
.field { display: grid; gap: var(--space-1); }
.field label, .label { font-size: var(--text-sm); color: var(--text-secondary); }
.input, select, textarea, input[type="text"], input[type="number"], input[type="search"] { min-height: var(--tap); width: 100%; padding: 0 var(--space-3); background: var(--bg-surface); border: 1px solid var(--border-strong); border-radius: var(--radius-control); color: var(--text-primary); }
.input:hover, input:hover, select:hover { border-color: var(--color-gold-dim); }
.input[aria-invalid="true"], input[aria-invalid="true"] { border-color: var(--color-ruby); }
input[type="range"] { width: 100%; accent-color: var(--color-gold); min-height: var(--tap); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--color-gold); width: 20px; height: 20px; }
.chip-toggle { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--space-3); border: 1px solid var(--border-strong); border-radius: var(--radius-full); font-size: var(--text-sm); color: var(--text-secondary); background: var(--bg-surface); transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out); }
.chip-toggle[aria-pressed="true"] { color: var(--text-inverted); background: var(--color-gold); border-color: var(--color-gold); }
.chip-toggle[disabled] { opacity: 0.45; cursor: not-allowed; border-style: dashed; }
.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: relative; border: 1px solid var(--border-strong); border-radius: var(--radius-control); padding: 2px; background: var(--bg-surface); }
.segmented > label, .segmented > button { position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; min-height: 36px; min-width: 72px; padding: 0 var(--space-3); font-size: var(--text-sm); color: var(--text-secondary); border-radius: 4px; cursor: pointer; white-space: nowrap; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented > label:has(input:checked), .segmented > button[aria-pressed="true"], .segmented > button[aria-checked="true"] { color: var(--text-inverted); background: var(--color-gold); }
.segmented > label:has(input:focus-visible) { outline: 2px solid var(--color-gold); outline-offset: 2px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-control); background: var(--bg-surface); }
.stepper button { min-width: 36px; min-height: 36px; color: var(--text-secondary); font-family: var(--font-mono); }
.stepper button:hover { color: var(--text-primary); background: var(--bg-surface-hover); }
.stepper output { min-width: 3.5ch; text-align: center; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Tables: card rows under 640px */
th, td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
th { font-weight: 600; font-size: var(--text-xs); color: var(--text-muted); }
td.num, th.num { text-align: right; }
@media (max-width: 639px) {
  table.cards thead { display: none; }
  table.cards tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: var(--space-3) 0; border-bottom: 1px solid var(--border-subtle); }
  table.cards td { border: 0; padding: 2px 0; }
  table.cards td[data-label]::before { content: attr(data-label) " "; color: var(--text-muted); font-size: var(--text-xs); }
}

/* Details (collapsed groups: vendor floor today, no scan yet, also found here) */
details > summary { list-style: none; cursor: pointer; min-height: var(--tap); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: "+"; font-family: var(--font-mono); color: var(--color-gold); }
details[open] > summary::after { content: "–"; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: var(--space-6); transform: translate(-50%, 16px); opacity: 0; z-index: 60; background: var(--bg-surface-elevated); border: 1px solid var(--border-strong); border-left: 3px solid var(--color-gold); border-radius: var(--radius-control); padding: var(--space-3) var(--space-4); font-size: var(--text-sm); max-width: calc(100vw - 2 * var(--gutter)); transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out); }
.toast.is-shown { transform: translate(-50%, 0); opacity: 1; }

/* Reveal hooks (motion.reveal toggles data-shown once; --i staggers). Used for the one orchestrated moment per page only. */
[data-reveal] { opacity: 0; transform: translateY(12px); transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); transition-delay: calc(var(--i, 0) * var(--stagger)); }
[data-reveal][data-shown] { opacity: 1; transform: none; }
.rule-draw { height: 1px; background: var(--color-gold); transform-origin: left; transform: scaleX(0); transition: transform var(--dur-slow) var(--ease-out); }
[data-shown] .rule-draw, .rule-draw[data-shown] { transform: scaleX(1); }
/* A stamp "setting": scale .92 -> 1 + opacity, driven by motion.sequence adding .is-set */
.sets { opacity: 0; transform: scale(0.92); transition: opacity var(--dur-pop) var(--ease-out), transform var(--dur-pop) var(--ease-out); }
.sets.is-set { opacity: 1; transform: none; }

/* Blizzard credit line: rendered under every piece of map art, never hidden at any width */
.art-credit { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-2); }

/* Reduced motion: global collapse */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  [data-reveal] { opacity: 1; transform: none; transition: opacity 150ms linear; }
  .rule-draw, .ledger-hairline { transform: scaleX(1); transition: none; }
  .sets { opacity: 1; transform: none; transition: none; }
  .btn-primary::after { display: none; }
}
