/**
 * Tribal Order Vault — the Vault Sheet (data table view of the catalog).
 * Scoped under .tov-sheet-wrap; uses the same Vault Ledger tokens as the grid.
 */

.tov-sheet-wrap {
	--tov-bg: #0a0a0b;
	--tov-surface: #151517;
	--tov-surface-2: #1b1b1f;
	--tov-surface-3: #232329;
	--tov-gold: #d4a24e;
	--tov-gold-bright: #ecc677;
	--tov-legendary: #d4a24e;
	--tov-rare: #b145c4;
	--tov-common: #ffffff;
	--tov-line: rgba(212, 162, 78, 0.18);
	--tov-line-strong: rgba(212, 162, 78, 0.55);
	--tov-text: #f4f1ea;
	--tov-text-muted: #a19d95;
	/* AA: #6f6b64 on #0a0a0b was 3.74:1; #857f75 is ~4.99:1 for the small labels. */
	--tov-text-dim: #857f75;
	--tov-focus: #ecc677;
	--tov-danger: #d9634e;
	--tov-font-display: "Oswald", "Bebas Neue", "Arial Narrow", sans-serif;
	--tov-font-body: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;

	--tov-r-sm: 2px;
	--tov-r-md: 6px;
	--tov-r-pill: 999px;

	--tov-space-1: 4px;
	--tov-space-2: 8px;
	--tov-space-3: 12px;
	--tov-space-4: 16px;
	--tov-space-5: 24px;

	--tov-dur-fast: 120ms;
	--tov-dur-base: 220ms;
	--tov-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
	--tov-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

	box-sizing: border-box;
	width: 100%;
	max-width: 1400px;
	margin: 0 auto;
	padding: 32px 24px 64px;
	font-family: var(--tov-font-body);
	color: var(--tov-text);
}
.tov-sheet-wrap * {
	box-sizing: border-box;
}

.tov-sheet-head {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 16px;
	padding-bottom: 16px;
	margin-bottom: 20px;
	border-bottom: 1px solid var(--tov-line);
}
.tov-sheet-eyebrow {
	margin: 0 0 4px;
	font-family: var(--tov-font-display);
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.3em;
	text-transform: uppercase;
	color: var(--tov-gold);
}
.tov-sheet-title {
	margin: 0;
	font-family: var(--tov-font-display);
	font-weight: 700;
	font-size: clamp(1.8rem, 3.5vw, 2.6rem);
	line-height: 0.95;
	text-transform: uppercase;
	color: var(--tov-text);
}
.tov-sheet-title em {
	font-style: normal;
	color: var(--tov-gold);
}
.tov-sheet-tools {
	display: flex;
	align-items: center;
	gap: 14px;
}
.tov-sheet-search {
	width: 240px;
	max-width: 52vw;
	height: 42px;
	padding: 0 14px;
	font-size: 14px;
	color: var(--tov-text);
	background: var(--tov-surface);
	border: 1px solid var(--tov-line);
	border-radius: 6px;
}
.tov-sheet-search:focus {
	outline: none;
	border-color: var(--tov-gold);
	box-shadow: 0 0 0 3px rgba(212, 162, 78, 0.18);
}
.tov-sheet-count {
	font-size: 13px;
	color: var(--tov-text-muted);
	white-space: nowrap;
}
.tov-sheet-count b {
	color: var(--tov-gold);
	font-variant-numeric: tabular-nums;
}

/* Filters trigger */
.tov-sheet-filters-trigger {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	height: 42px;
	padding: 0 16px;
	font-family: var(--tov-font-display);
	font-weight: 500;
	font-size: 13px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--tov-text);
	background: var(--tov-surface);
	border: 1px solid var(--tov-line);
	border-radius: var(--tov-r-md);
	cursor: pointer;
	transition: border-color var(--tov-dur-base) var(--tov-ease-out),
		color var(--tov-dur-base) var(--tov-ease-out),
		background var(--tov-dur-base) var(--tov-ease-out);
}
.tov-sheet-filters-trigger:hover {
	border-color: var(--tov-line-strong);
	color: var(--tov-gold);
}
.tov-sheet-filters-trigger[aria-expanded="true"] {
	color: var(--tov-gold);
	border-color: var(--tov-gold);
	background: var(--tov-surface-2);
}
.tov-sheet-filters-trigger:focus-visible {
	outline: 2px solid var(--tov-focus);
	outline-offset: 2px;
}
.tov-sheet-filters-trigger svg {
	width: 15px;
	height: 15px;
}
.tov-sheet-filters-badge {
	display: none;
	place-items: center;
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	font-family: var(--tov-font-body);
	font-weight: 600;
	font-size: 11px;
	color: var(--tov-bg);
	background: var(--tov-gold);
	border-radius: var(--tov-r-pill);
}
.tov-sheet-filters-trigger.has-active .tov-sheet-filters-badge {
	display: grid;
}

/* Filter drawer */
.tov-sheet-filters-panel {
	overflow: hidden;
	max-height: 0;
	opacity: 0;
	margin-bottom: 0;
	border: 1px solid transparent;
	border-radius: 8px;
	background: linear-gradient(180deg, var(--tov-surface-2), var(--tov-surface));
	transition: max-height var(--tov-dur-base) var(--tov-ease-out),
		opacity var(--tov-dur-fast) var(--tov-ease-out),
		margin-bottom var(--tov-dur-base) var(--tov-ease-out),
		border-color var(--tov-dur-base) var(--tov-ease-out);
}
.tov-sheet-filters-panel.is-open {
	/* See database.css: a phone's single-column facet stack with real term
	   counts exceeds 1400px and clips. 4000px clears any real height. */
	max-height: 4000px;
	opacity: 1;
	margin-bottom: 20px;
	border-color: var(--tov-line);
}
.tov-sheet-filters-inner {
	padding: var(--tov-space-5);
}
.tov-sheet-filters-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: var(--tov-space-5) var(--tov-space-4);
}
.tov-sheet-facet {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
}
.tov-sheet-facet-legend {
	display: flex;
	align-items: center;
	gap: var(--tov-space-2);
	width: 100%;
	padding: 0 0 var(--tov-space-2);
	margin-bottom: var(--tov-space-2);
	font-family: var(--tov-font-display);
	font-weight: 600;
	font-size: 11px;
	letter-spacing: 0.18em;
	text-transform: uppercase;
	color: var(--tov-gold);
	border-bottom: 1px solid var(--tov-line);
}
.tov-sheet-facet-n {
	margin-left: auto;
	font-weight: 400;
	color: var(--tov-text-dim);
}
.tov-sheet-facet-options {
	display: flex;
	flex-direction: column;
	gap: 2px;
	max-height: 190px;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--tov-gold) transparent;
}
.tov-sheet-opt {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 8px;
	min-height: 36px;
	font-size: 13px;
	color: var(--tov-text-muted);
	border-radius: var(--tov-r-sm);
	cursor: pointer;
	user-select: none;
	transition: color var(--tov-dur-fast) var(--tov-ease-out),
		background var(--tov-dur-fast) var(--tov-ease-out);
}
.tov-sheet-opt:hover {
	color: var(--tov-text);
	background: var(--tov-surface-3);
}
.tov-sheet-opt input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: -1px;
}
.tov-sheet-opt-box {
	position: relative;
	flex: 0 0 auto;
	width: 16px;
	height: 16px;
	border: 1px solid var(--tov-line-strong);
	border-radius: var(--tov-r-sm);
	background: var(--tov-bg);
	transition: border-color var(--tov-dur-fast) var(--tov-ease-out),
		background var(--tov-dur-fast) var(--tov-ease-out);
}
.tov-sheet-opt-box::after {
	content: "";
	position: absolute;
	inset: 0;
	margin: auto;
	width: 4px;
	height: 8px;
	border: solid var(--tov-bg);
	border-width: 0 2px 2px 0;
	transform: rotate(45deg) translate(-1px, -1px) scale(0);
	transform-origin: center;
	transition: transform var(--tov-dur-fast) var(--tov-ease-spring);
}
.tov-sheet-opt input:checked ~ .tov-sheet-opt-box {
	background: var(--tov-gold);
	border-color: var(--tov-gold);
}
.tov-sheet-opt input:checked ~ .tov-sheet-opt-box::after {
	transform: rotate(45deg) translate(-1px, -1px) scale(1);
}
.tov-sheet-opt input:checked ~ .tov-sheet-opt-label {
	color: var(--tov-text);
	font-weight: 600;
}
.tov-sheet-opt input:focus-visible ~ .tov-sheet-opt-box {
	outline: 2px solid var(--tov-focus);
	outline-offset: 2px;
}
.tov-sheet-opt-label {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.tov-sheet-opt-count {
	flex: 0 0 auto;
	font-size: 11px;
	color: var(--tov-text-dim);
	font-variant-numeric: tabular-nums;
}
.tov-sheet-filters-foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--tov-space-2);
	margin-top: var(--tov-space-5);
	padding-top: var(--tov-space-4);
	border-top: 1px solid var(--tov-line);
}
.tov-sheet-filters-foot-label {
	font-size: 11px;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--tov-text-dim);
	margin-right: var(--tov-space-1);
}
.tov-sheet-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 4px 5px 4px 10px;
	font-size: 11px;
	color: var(--tov-text);
	background: var(--tov-surface-3);
	border: 1px solid var(--tov-line);
	border-radius: var(--tov-r-pill);
}
.tov-sheet-chip-tax {
	color: var(--tov-gold);
	text-transform: uppercase;
	letter-spacing: 0.08em;
	font-size: 9px;
}
.tov-sheet-chip-x {
	display: grid;
	place-items: center;
	width: 16px;
	height: 16px;
	color: var(--tov-text-muted);
	background: transparent;
	border: 0;
	border-radius: var(--tov-r-pill);
	cursor: pointer;
	line-height: 1;
	transition: color var(--tov-dur-fast), background var(--tov-dur-fast);
}
.tov-sheet-chip-x:hover {
	color: var(--tov-bg);
	background: var(--tov-gold);
}
.tov-sheet-chip-x:focus-visible {
	outline: 2px solid var(--tov-focus);
	outline-offset: 1px;
}
.tov-sheet-reset {
	margin-left: auto;
	padding: 5px 11px;
	font-family: var(--tov-font-body);
	font-size: 11px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--tov-text-muted);
	background: transparent;
	border: 1px solid var(--tov-line);
	border-radius: var(--tov-r-pill);
	cursor: pointer;
	transition: color var(--tov-dur-fast), border-color var(--tov-dur-fast);
}
.tov-sheet-reset:hover {
	color: var(--tov-danger);
	border-color: var(--tov-danger);
}
.tov-sheet-reset:focus-visible {
	outline: 2px solid var(--tov-focus);
	outline-offset: 2px;
}
.tov-sheet-reset:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* KPI strip — nine tiles, same composition + math as the Database grid:
   one emphasized "Cards Shown" plate spanning both rows + eight secondary. */
.tov-sheet-kpis {
	display: grid;
	grid-template-columns: 1.2fr repeat(4, minmax(0, 1fr));
	grid-auto-rows: 1fr;
	gap: var(--tov-space-3);
	margin-bottom: 20px;
}
.tov-sheet-kpi {
	position: relative;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 3px;
	padding: var(--tov-space-4);
	background: var(--tov-surface);
	border: 1px solid var(--tov-line);
	border-radius: var(--tov-r-md);
}
.tov-sheet-kpi::before {
	content: "";
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	background: var(--tov-gold);
	opacity: 0.7;
}
.tov-sheet-kpi--legendary::before { background: var(--tov-legendary); opacity: 0.9; }
.tov-sheet-kpi--rare::before      { background: var(--tov-rare); opacity: 0.9; }
.tov-sheet-kpi--common::before    { background: var(--tov-common); opacity: 0.55; }
.tov-sheet-kpi--hero::before      { background: linear-gradient(90deg, var(--tov-gold), var(--tov-gold-bright)); opacity: 1; }
.tov-sheet-kpi-value {
	display: block;
	font-family: var(--tov-font-display);
	font-weight: 700;
	font-size: 1.5rem;
	line-height: 1;
	color: var(--tov-gold);
	font-variant-numeric: tabular-nums;
}
.tov-sheet-kpi--rare .tov-sheet-kpi-value   { color: var(--tov-rare); }
.tov-sheet-kpi--common .tov-sheet-kpi-value { color: var(--tov-text); }
.tov-sheet-kpi-label {
	display: block;
	font-size: 10px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--tov-text-dim);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Primary "Cards Shown" plate — spans both rows, larger, gold-washed. */
.tov-sheet-kpi--primary {
	grid-column: 1;
	grid-row: 1 / span 2;
	justify-content: flex-end;
	gap: 6px;
	padding: var(--tov-space-5);
	background:
		radial-gradient(120% 90% at 0% 100%, rgba(212, 162, 78, 0.14), transparent 60%),
		linear-gradient(160deg, var(--tov-surface-2), var(--tov-surface));
	border-color: var(--tov-line-strong);
}
.tov-sheet-kpi--primary::before {
	height: 4px;
	opacity: 1;
	background: linear-gradient(90deg, var(--tov-gold-bright), var(--tov-gold), transparent);
}
.tov-sheet-kpi--primary .tov-sheet-kpi-value {
	font-size: 3rem;
	color: var(--tov-gold-bright);
}
.tov-sheet-kpi--primary .tov-sheet-kpi-label {
	font-size: 13px;
	letter-spacing: 0.2em;
	color: var(--tov-text-muted);
}

/* A2: rarity KPI tiles are filter controls on the Sheet too — same behavior as
   the Database grid (toggle the matching rarity facet; pressed = active). */
.tov-sheet-kpi--legendary { --tov-kpi-edge: var(--tov-legendary); }
.tov-sheet-kpi--rare      { --tov-kpi-edge: var(--tov-rare); }
.tov-sheet-kpi--common    { --tov-kpi-edge: var(--tov-common); }

.tov-sheet-kpi--control {
	appearance: none;
	-webkit-appearance: none;
	width: 100%;
	margin: 0;
	text-align: left;
	font: inherit;
	color: inherit;
	cursor: pointer;
	transition: border-color var(--tov-dur-base) var(--tov-ease-out),
		box-shadow var(--tov-dur-base) var(--tov-ease-out),
		background var(--tov-dur-base) var(--tov-ease-out);
}
.tov-sheet-kpi--control:hover {
	border-color: color-mix(in srgb, var(--tov-kpi-edge, var(--tov-gold)) 55%, var(--tov-line));
}
.tov-sheet-kpi--control:hover::before {
	opacity: 1;
}
.tov-sheet-kpi--control:focus-visible {
	outline: 2px solid var(--tov-focus);
	outline-offset: 2px;
}
.tov-sheet-kpi--control[aria-pressed="true"] {
	border-color: color-mix(in srgb, var(--tov-kpi-edge, var(--tov-gold)) 65%, var(--tov-line));
	background: var(--tov-surface-2);
	box-shadow:
		inset 0 0 0 1px color-mix(in srgb, var(--tov-kpi-edge, var(--tov-gold)) 45%, transparent),
		inset 0 0 24px -12px var(--tov-kpi-edge, var(--tov-gold));
}
.tov-sheet-kpi--control[aria-pressed="true"]::before {
	height: 4px;
	opacity: 1;
}
.tov-sheet-kpi--control:disabled {
	cursor: default;
	opacity: 0.75;
}

/* Below ~1080px: primary becomes a full-width banner, secondary flow 4-up. */
@media (max-width: 1080px) {
	.tov-sheet-kpis {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
	.tov-sheet-kpi--primary {
		grid-column: 1 / -1;
		grid-row: auto;
		flex-direction: row;
		align-items: baseline;
		justify-content: flex-start;
		gap: var(--tov-space-3);
		padding: var(--tov-space-4) var(--tov-space-5);
	}
	.tov-sheet-kpi--primary .tov-sheet-kpi-value {
		font-size: 2.1rem;
	}
}

/* table */
.tov-sheet-scroll {
	overflow-x: auto;
	border: 1px solid var(--tov-line);
	border-radius: 8px;
	background: var(--tov-surface);
}

/* B3: sticky column header. `position:sticky` on <th> only pins if its scroll
   container actually scrolls on that axis — and this container only scrolls
   horizontally, so the sticky header (below) was a no-op. Cap the scroll box to
   a viewport-derived height on desktop/tablet so it scrolls BOTH axes and the
   header sticks. DESKTOP/TABLET ONLY: on phones a nested vertical scroll traps
   touch and fights the horizontal swipe of a wide table, so there we keep the
   natural full-page scroll (header simply not sticky). */
@media (min-width: 768px) {
	.tov-sheet-scroll {
		max-height: calc(100vh - 168px);
		overflow: auto;
		overscroll-behavior: contain;
	}
}
.tov-sheet {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}
.tov-sheet thead th {
	position: sticky;
	top: 0;
	z-index: 1;
	text-align: left;
	padding: 0;
	background: var(--tov-surface-2);
	border-bottom: 1px solid var(--tov-line-strong);
	white-space: nowrap;
}
.tov-sheet th.is-num,
.tov-sheet td.is-num {
	text-align: right;
	font-variant-numeric: tabular-nums;
}
.tov-sheet-sort {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	width: 100%;
	padding: 12px 14px;
	font-family: var(--tov-font-display);
	font-weight: 600;
	font-size: 12px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--tov-text-muted);
	background: transparent;
	border: 0;
	cursor: pointer;
	transition: color 0.12s ease;
}
.is-num .tov-sheet-sort {
	justify-content: flex-end;
}
.tov-sheet-sort:hover {
	color: var(--tov-text);
}
.tov-sheet-arrow {
	width: 8px;
	height: 8px;
	opacity: 0;
	border-right: 2px solid var(--tov-gold);
	border-bottom: 2px solid var(--tov-gold);
	transform: rotate(45deg);
	transition: opacity 0.12s ease, transform 0.12s ease;
}
th[aria-sort="ascending"] .tov-sheet-sort,
th[aria-sort="descending"] .tov-sheet-sort {
	color: var(--tov-gold);
}
th[aria-sort="ascending"] .tov-sheet-arrow {
	opacity: 1;
	transform: rotate(-135deg);
}
th[aria-sort="descending"] .tov-sheet-arrow {
	opacity: 1;
	transform: rotate(45deg);
}

.tov-sheet tbody th,
.tov-sheet tbody td {
	padding: 11px 14px;
	border-bottom: 1px solid rgba(212, 162, 78, 0.08);
	color: var(--tov-text-muted);
	font-weight: 400;
	vertical-align: middle;
}
.tov-sheet tbody tr:hover td,
.tov-sheet tbody tr:hover th {
	background: var(--tov-surface-3);
}
.tov-sheet-cardcell {
	text-align: left;
}
.tov-sheet-cardcell a {
	font-family: var(--tov-font-display);
	font-weight: 600;
	font-size: 15px;
	letter-spacing: 0.01em;
	color: var(--tov-text);
	text-decoration: none;
}
.tov-sheet-cardcell a:hover {
	color: var(--tov-gold);
}
.tov-sheet-hero-badge {
	display: inline-flex;
	align-items: center;
	margin-right: 6px;
	color: var(--tov-gold);
	vertical-align: -2px;
}
.tov-sheet-hero-badge svg {
	width: 15px;
	height: 15px;
}
.tov-sheet-rarity {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--tov-rarity, var(--tov-text));
}
.tov-sheet-rarity::before {
	content: "";
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: var(--tov-rarity, var(--tov-text-dim));
}
.tov-sheet tr.is-hidden {
	display: none;
}

.tov-sheet-noresults,
.tov-sheet-empty {
	padding: 40px 16px;
	text-align: center;
	color: var(--tov-text-muted);
}

/* Visually-hidden utility (matches database.css) — used by the live KPI so its
   number is announced with a "cards shown" unit instead of a bare integer. */
.tov-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 600px) {
	.tov-sheet-tools {
		width: 100%;
		flex-wrap: wrap;
	}
	.tov-sheet-search {
		flex: 1 1 100%;
		max-width: none;
	}
	.tov-sheet-filters-trigger {
		flex: 1 1 auto;
		justify-content: center;
	}
	.tov-sheet-kpis {
		grid-template-columns: repeat(2, 1fr);
		gap: var(--tov-space-2);
	}
	.tov-sheet-kpi {
		padding: var(--tov-space-3);
	}
	.tov-sheet-kpi-value {
		font-size: 1.35rem;
	}
	.tov-sheet-kpi--primary {
		padding: var(--tov-space-4);
	}
	.tov-sheet-kpi--primary .tov-sheet-kpi-value {
		font-size: 2rem;
	}
}


/* iOS zoom guard: Safari auto-zooms any focused control under 16px and never
   zooms back out. Same-selector restatement, so it simply wins by order. */
@media (max-width: 860px) {
	.tov-sheet-search {
		font-size: 16px;
	}
}
