/* Voidscape: The Market (/market). Extends landing.css; same tokens, same voice.
   The page is the Void Auctioneer's ledger read from outside the game:
   listing rows anchored by real (pre-tinted) item sprites in recessed slots,
   coin amounts in authentic RSC stack colours, numerals set in Alagard.
   Pixel sprites scale at integer multiples only (market.js sizes them). */

.market {
	--gp-y: #ffe93b;   /* coin stacks below 100K - RSC chat yellow, tamed a step */
	--gp-w: #f7f3ff;   /* 100K..10M - RSC white */
	--gp-g: #3fe58c;   /* 10M+ - RSC green */
	--up: #7cd992;
	--down: #e07a6d;
	--slot: rgba(9, 5, 16, .78);
	--slot-line: rgba(143, 85, 223, .34);
	--glass: rgba(21, 16, 34, .66);
	background-image:
		radial-gradient(1100px 640px at 50% 320px, var(--void-2) 0%, var(--void) 62%),
		radial-gradient(760px 420px at 82% 40px, rgba(201, 164, 91, .07) 0%, transparent 70%);
}

.skip-link {
	position: fixed;
	top: 10px;
	left: 10px;
	z-index: 100;
	transform: translateY(-160%);
	border: 1px solid var(--line-strong);
	border-radius: 7px;
	background: var(--void-2);
	color: var(--text);
	padding: 9px 13px;
}

.skip-link:focus { transform: translateY(0); }

.px { image-rendering: pixelated; }

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* Alagard carries every numeral on the page - the ledger is written in the
   game's own hand. Sizes stay >=12px so the face never costs legibility. */
.num { font-family: var(--display); font-weight: 400; letter-spacing: .02em; }

.gp-y { color: var(--gp-y); }
.gp-w { color: var(--gp-w); }
.gp-g { color: var(--gp-g); }

@keyframes rise {
	from { opacity: 0; transform: translateY(14px); }
	to { opacity: 1; transform: translateY(0); }
}

/* ======================= hero ======================= */
.market-hero { padding-bottom: 10px; }

.market-status {
	width: fit-content;
	max-width: min(680px, 100%);
	margin: 20px auto 0;
	display: flex;
	align-items: center;
	gap: 9px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: rgba(18, 13, 29, .82);
	padding: 7px 14px;
	font-size: 12px;
	color: var(--muted);
}

.status-rune { width: 8px; height: 8px; border-radius: 50%; background: var(--purple-hi); box-shadow: 0 0 9px var(--purple); flex: 0 0 auto; }
.market-status.is-live { border-color: rgba(92, 194, 141, .32); }
.market-status.is-live .status-rune { background: var(--live); box-shadow: 0 0 9px var(--live); }
.market-status.is-mock { border-color: rgba(143, 85, 223, .58); color: #d6c2f3; }
.market-status.is-mock .status-rune { background: var(--purple-hi); box-shadow: 0 0 13px var(--purple-hi); }
.market-status.is-error { border-color: rgba(207, 83, 83, .45); color: #e8a598; }
.market-status.is-error .status-rune { background: #cf5353; box-shadow: 0 0 9px #cf5353; }

/* ======================= preview (mock) notice ======================= */
.mock-notice {
	position: relative;
	z-index: 1;
	width: min(920px, calc(100% - 56px));
	margin: 16px auto 4px;
	display: grid;
	grid-template-columns: 74px 1fr;
	align-items: center;
	gap: 20px;
	border: 1px solid rgba(143, 85, 223, .42);
	border-radius: 10px;
	background: linear-gradient(102deg, rgba(74, 38, 113, .34), rgba(18, 13, 29, .94) 46%);
	box-shadow: 0 22px 70px rgba(0, 0, 0, .28), inset 0 1px rgba(255, 255, 255, .035);
	padding: 18px 24px;
}

.mock-notice[hidden] { display: none; }
.mock-notice-eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--purple-hi); }
.mock-notice h2 { font-family: var(--display); font-size: 20px; margin: 2px 0 4px; }
.mock-notice p:last-child { color: var(--muted); font-size: 14px; }

.mock-notice-slot {
	width: 74px;
	height: 64px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--slot);
	border: 1px solid var(--slot-line);
	border-radius: 8px;
	box-shadow: inset 0 2px 10px rgba(0, 0, 0, .6);
}

/* ======================= tallies ======================= */
.tallies {
	position: relative;
	z-index: 1;
	width: min(1160px, calc(100% - 56px));
	margin: 26px auto 0;
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 14px;
}

.tally {
	display: grid;
	grid-template-columns: 56px 1fr;
	grid-template-rows: auto auto;
	column-gap: 14px;
	align-items: center;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: var(--glass);
	padding: 14px 16px;
	animation: rise .5s ease-out backwards;
}

.tally:nth-child(2) { animation-delay: .06s; }
.tally:nth-child(3) { animation-delay: .12s; }
.tally:nth-child(4) { animation-delay: .18s; }

.tally-slot {
	grid-row: 1 / span 2;
	width: 56px;
	height: 52px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--slot);
	border: 1px solid var(--slot-line);
	border-radius: 7px;
	box-shadow: inset 0 2px 8px rgba(0, 0, 0, .55);
}

.tally .num { font-size: 26px; line-height: 1.1; color: var(--text); }
.tally-label { font-size: 12px; color: var(--muted); letter-spacing: .03em; }

/* Wide screens give the 48x32 icons room to double cleanly (the sizer picks
   the largest integer multiple that fits, so a bigger slot means crisp 2x). */
@media (min-width: 1100px) {
	.tally { grid-template-columns: 104px 1fr; }
	.tally-slot { width: 104px; height: 72px; }
}

/* ======================= ledger layout ======================= */
.ledger-grid {
	position: relative;
	z-index: 1;
	width: min(1160px, calc(100% - 56px));
	margin: 22px auto 0;
	display: grid;
	grid-template-columns: minmax(0, 1fr) 330px;
	gap: 18px;
	align-items: start;
}

.panel-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.panel-title { font-family: var(--display); font-size: 21px; letter-spacing: .02em; }
.panel-sub { font-size: 12px; color: var(--faint); }

.browse,
.rail-panel {
	border: 1px solid var(--line);
	border-radius: 12px;
	background: var(--glass);
	padding: 18px;
}

.rail { display: grid; gap: 18px; }

/* ---- browse tools ---- */
.browse-tools { display: grid; gap: 10px; margin-bottom: 12px; }

.search-wrap input {
	width: 100%;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: rgba(9, 5, 16, .6);
	color: var(--text);
	font-family: var(--body);
	font-size: 14px;
	padding: 10px 13px;
}

.search-wrap input::placeholder { color: var(--faint); }
.search-wrap input:focus { outline: none; border-color: var(--line-strong); box-shadow: 0 0 0 3px rgba(143, 85, 223, .16); }
.search-hint { color: var(--faint); font-size: 11.5px; margin: 6px 2px 0; }
.sort-row[hidden] { display: none; }

.sort-row { display: flex; gap: 6px; flex-wrap: wrap; }

.sort-btn,
.range-btn {
	border: 1px solid var(--line);
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	font-family: var(--body);
	font-size: 12px;
	padding: 6px 12px;
	cursor: pointer;
	transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.sort-btn:hover,
.range-btn:hover { border-color: var(--line-strong); color: var(--text); }

.sort-btn.is-on,
.range-btn.is-on {
	border-color: rgba(201, 164, 91, .55);
	color: var(--gold-hi);
	background: rgba(201, 164, 91, .08);
}

/* ---- category rail: the in-game tiles, flattened to chips ---- */
.cat-rail {
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	margin-bottom: 14px;
	padding-bottom: 2px;
}

.cat-chip {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: rgba(9, 5, 16, .45);
	color: var(--muted);
	font-family: var(--body);
	font-size: 12px;
	padding: 5px 10px 5px 6px;
	cursor: pointer;
	transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.cat-chip img { display: block; }
.cat-chip:hover { border-color: var(--line-strong); color: var(--text); }
.cat-chip.is-on { border-color: var(--line-strong); background: rgba(143, 85, 223, .16); color: var(--text); }

/* ---- listing rows: the ledger itself ---- */
.listing-rows { list-style: none; display: grid; gap: 7px; }

.listing-row {
	width: 100%;
	display: grid;
	grid-template-columns: 58px minmax(0, 1fr) auto auto;
	align-items: center;
	gap: 14px;
	border: 1px solid rgba(143, 85, 223, .2);
	border-radius: 9px;
	background: rgba(13, 8, 22, .55);
	padding: 8px 14px 8px 8px;
	cursor: pointer;
	text-align: left;
	color: var(--text);
	font-family: var(--body);
	transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.listing-row:hover {
	border-color: var(--line-strong);
	background: rgba(21, 13, 36, .72);
	transform: translateY(-1px);
}

.listing-rows.is-entering .listing-row { animation: rise .4s ease-out backwards; }

.slot {
	position: relative;
	width: 58px;
	height: 50px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--slot);
	border: 1px solid var(--slot-line);
	border-radius: 7px;
	box-shadow: inset 0 2px 8px rgba(0, 0, 0, .55);
	flex: 0 0 auto;
	overflow: hidden;
}

/* Slot sprites are sized explicitly (integer multiples) by market.js; opt out
   of landing.css's global img max-width so a clamp can never distort them. */
.slot img,
.tally-slot img,
.mock-notice-slot img,
.detail-slot img { display: block; max-width: none; }

/* Stack count sits top-left in the slot, exactly where the game draws it. */
.slot .stack {
	position: absolute;
	top: 2px;
	left: 4px;
	font-family: var(--display);
	font-size: 12px;
	line-height: 1;
	text-shadow: 1px 1px 0 rgba(0, 0, 0, .9);
}

.slot.is-missing::after {
	content: "?";
	font-family: var(--display);
	font-size: 20px;
	color: var(--faint);
}

.listing-main { min-width: 0; }
.listing-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listing-meta { font-size: 12px; color: var(--faint); margin-top: 2px; }

.listing-each { text-align: right; }
.listing-each .num { font-size: 17px; display: block; }
.listing-each small { font-size: 11px; color: var(--faint); }
.listing-history { color: var(--gold-hi); font-family: var(--display); font-size: 15px; }

.listing-age { width: 52px; text-align: right; font-size: 12px; color: var(--faint); }

.browse-empty { color: var(--muted); font-size: 14px; padding: 26px 8px; text-align: center; }

/* ---- rail: just sold ---- */
.sales-feed,
.hot-list { list-style: none; display: grid; gap: 6px; }

.feed-waiting { color: var(--faint); font-size: 13px; padding: 6px 2px; }

.sale-row {
	display: grid;
	grid-template-columns: 40px minmax(0, 1fr) auto;
	align-items: center;
	gap: 10px;
	border: 1px solid transparent;
	border-radius: 8px;
	padding: 5px 8px 5px 5px;
}

.sale-row.is-new { animation: glint 1.6s ease-out backwards; }

@keyframes glint {
	0% { border-color: rgba(226, 192, 130, .75); background: rgba(201, 164, 91, .14); }
	100% { border-color: transparent; background: transparent; }
}

.sale-row .slot { width: 40px; height: 36px; border-radius: 6px; }
.sale-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sale-sub { font-size: 11px; color: var(--faint); margin-top: 1px; }
.sale-gp { text-align: right; }
.sale-gp .num { font-size: 14px; display: block; }
.sale-gp small { font-size: 10px; color: var(--faint); }

/* ---- rail: hot list ---- */
.hot-row {
	width: 100%;
	display: grid;
	grid-template-columns: 40px minmax(0, 1fr) 64px auto;
	align-items: center;
	gap: 10px;
	border: 1px solid transparent;
	border-radius: 8px;
	background: transparent;
	color: var(--text);
	font-family: var(--body);
	padding: 5px 8px 5px 5px;
	cursor: pointer;
	text-align: left;
	transition: border-color .15s ease, background .15s ease;
}

.hot-row:hover { border-color: var(--line); background: rgba(21, 13, 36, .5); }
.hot-row .slot { width: 40px; height: 36px; border-radius: 6px; }
.hot-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hot-sub { font-size: 11px; color: var(--faint); margin-top: 1px; }
.hot-spark { width: 64px; height: 22px; }
.hot-spark path { fill: none; stroke: var(--purple-hi); stroke-width: 1.5; }
.hot-spark .spark-fill { fill: rgba(143, 85, 223, .16); stroke: none; }

.hot-delta { font-size: 12px; white-space: nowrap; }
.hot-delta.is-up { color: var(--up); }
.hot-delta.is-down { color: var(--down); }
.hot-delta.is-flat { color: var(--faint); }

/* ======================= footer ======================= */
.market-foot {
	position: relative;
	z-index: 1;
	width: min(1160px, calc(100% - 56px));
	margin: 30px auto 46px;
	border-top: 1px solid var(--line);
	padding-top: 18px;
	color: var(--faint);
	font-size: 13px;
	display: grid;
	gap: 6px;
}

.market-foot a { color: var(--muted); }
.market-foot a:hover { color: var(--text); }

/* ======================= item detail: a page of the ledger ======================= */
.detail-backdrop {
	position: fixed;
	inset: 0;
	z-index: 40;
	background: rgba(5, 3, 10, .62);
	backdrop-filter: blur(3px);
}

.detail-backdrop[hidden] { display: none; }

.detail {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: 41;
	width: min(560px, 100%);
	overflow-y: auto;
	background: linear-gradient(160deg, rgba(30, 19, 48, .97), rgba(13, 9, 21, .985) 55%);
	border-left: 1px solid var(--line-strong);
	box-shadow: -30px 0 80px rgba(0, 0, 0, .5);
	padding: 26px 26px 34px;
	animation: detail-in .28s ease-out;
}

.detail[hidden] { display: none; }

@keyframes detail-in {
	from { transform: translateX(26px); opacity: 0; }
	to { transform: translateX(0); opacity: 1; }
}

.detail-close {
	position: absolute;
	top: 14px;
	right: 16px;
	width: 34px;
	height: 34px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: rgba(9, 5, 16, .6);
	color: var(--muted);
	font-size: 19px;
	line-height: 1;
	cursor: pointer;
}

.detail-close:hover { color: var(--text); border-color: var(--line-strong); }

.detail-head {
	display: grid;
	grid-template-columns: 86px 1fr;
	gap: 16px;
	align-items: center;
	margin-bottom: 16px;
	padding-right: 40px;
}

.detail-slot {
	position: relative;
	width: 86px;
	height: 74px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--slot);
	border: 1px solid var(--slot-line);
	border-radius: 9px;
	box-shadow: inset 0 3px 12px rgba(0, 0, 0, .6);
	overflow: hidden;
}

.detail-name { font-family: var(--display); font-size: 26px; line-height: 1.15; }
.detail-desc { color: var(--muted); font-size: 13px; font-style: italic; margin-top: 3px; }

.detail-stats {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 8px;
	margin-bottom: 18px;
}

.mini-stat {
	border: 1px solid var(--line);
	border-radius: 8px;
	background: rgba(9, 5, 16, .45);
	padding: 9px 11px;
}

.mini-stat .num { font-size: 16px; display: block; }
.mini-stat .range-line { display: flex; align-items: baseline; gap: 3px; white-space: nowrap; font-size: 14px; color: var(--faint); }
.mini-stat span:last-child { font-size: 10.5px; color: var(--faint); letter-spacing: .04em; text-transform: uppercase; }

/* ---- chart ---- */
.chart-block { margin-bottom: 18px; }
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.chart-title { font-size: 13px; color: var(--muted); font-weight: 500; }
.range-row { display: flex; gap: 5px; }

.chart-wrap {
	position: relative;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: rgba(9, 5, 16, .45);
	padding: 12px 10px 6px;
	min-height: 120px;
}

.chart-wrap svg { display: block; width: 100%; height: auto; }

.chart-empty { color: var(--faint); font-size: 13px; padding: 34px 12px; text-align: center; }

/* Grid, axes and marks: recessive lines, 2px series stroke, text in ink tokens.
   The y-axis gp ticks are Alagard (the risk this page takes); dates stay in the
   body face so the axis never turns into a headline. */
.chart-grid line { stroke: rgba(178, 140, 242, .12); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--purple-hi); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-band { fill: rgba(143, 85, 223, .13); }
.chart-area { fill: url(#market-area-fade); }
.chart-vol rect { fill: rgba(143, 85, 223, .22); }
.chart-ytick { font-family: var(--display); font-size: 12px; fill: var(--muted); }
.chart-xtick { font-family: var(--body); font-size: 10.5px; fill: var(--faint); }
.chart-last-dot { fill: var(--gold-hi); stroke: rgba(9, 5, 16, .9); stroke-width: 2; }
.chart-last-label { font-family: var(--body); font-size: 10.5px; fill: var(--gold-hi); }
.chart-cross { stroke: rgba(226, 192, 130, .45); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-hover-dot { fill: var(--purple-hi); stroke: rgba(9, 5, 16, .9); stroke-width: 2; }

.chart-tip {
	position: absolute;
	pointer-events: none;
	z-index: 5;
	border: 1px solid var(--line-strong);
	border-radius: 8px;
	background: rgba(13, 9, 21, .96);
	box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
	padding: 8px 11px;
	font-size: 12px;
	color: var(--muted);
	white-space: nowrap;
	transform: translate(-50%, calc(-100% - 12px));
}

.chart-tip strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 2px; }

/* ---- detail lists ---- */
.detail-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-sub { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--purple-hi); margin-bottom: 8px; }

.detail-listings,
.detail-sales { list-style: none; display: grid; gap: 5px; }

.detail-listings li,
.detail-sales li {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 10px;
	border: 1px solid rgba(143, 85, 223, .16);
	border-radius: 7px;
	background: rgba(9, 5, 16, .4);
	padding: 6px 10px;
	font-size: 12.5px;
	color: var(--muted);
}

.detail-listings .num,
.detail-sales .num { font-size: 13.5px; }

.detail-none { color: var(--faint); font-size: 12.5px; border: none !important; background: none !important; padding-left: 0 !important; }

/* ======================= responsive ======================= */
@media (max-width: 980px) {
	.ledger-grid { grid-template-columns: 1fr; }
	.tallies { grid-template-columns: repeat(2, 1fr); }
	.rail { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
	.tallies,
	.ledger-grid,
	.market-foot { width: calc(100% - 32px); }
	.mock-notice { width: calc(100% - 32px); grid-template-columns: 1fr; gap: 10px; }
	.mock-notice-slot { display: none; }
	/* Item icons are 48x32 full-frame; the slot must hold them at 1x. */
	.tally { grid-template-columns: 56px 1fr; padding: 11px 12px; }
	.tally-slot { width: 56px; height: 44px; }
	.tally .num { font-size: 20px; }
	.browse, .rail-panel { padding: 13px; }
	.listing-row { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 10px; padding: 7px 10px 7px 7px; }
	.slot { width: 48px; height: 44px; }
	.listing-age { display: none; }
	.detail { width: 100%; border-left: none; padding: 20px 16px 30px; }
	.detail-cols { grid-template-columns: 1fr; }
	.detail-stats { grid-template-columns: repeat(3, 1fr); }
}

/* ======================= a11y floor ======================= */
:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
	.tally,
	.listing-rows.is-entering .listing-row,
	.sale-row.is-new,
	.detail { animation: none; }
	.listing-row,
	.sort-btn, .range-btn, .cat-chip, .hot-row { transition: none; }
	.stars { animation: none; }
}
