/* ---------------------------------------------------------------------------
   Market Explorer.

   Loaded only on the Explorer template. Every colour comes from the theme
   tokens, so the map, tables and panels follow light and dark mode without a
   second palette to maintain.
   --------------------------------------------------------------------------- */

/* --- Head ---------------------------------------------------------------- */

.explorer-head {
	padding: clamp(1.5rem, 3.5vw, 2.75rem) 0 clamp(1.25rem, 2.5vw, 1.75rem);
	border-bottom: 1px solid var(--hc-line);
}
.explorer-head h1 {
	margin-bottom: 0.4rem;
	font-size: clamp(1.9rem, 4.5vw, 3rem);
	letter-spacing: -0.035em;
}
.explorer-head__dek {
	max-width: 52rem;
	margin-bottom: 1.5rem;
	color: var(--hc-ink-2);
	font-size: clamp(0.98rem, 1.5vw, 1.1rem);
	line-height: 1.55;
	text-wrap: pretty;
}

.explorer-scale {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(50%, 150px), 1fr));
	gap: 1px;
	margin: 0;
	background: var(--hc-line);
	border: 1px solid var(--hc-line);
	border-radius: var(--hc-radius-sm);
	overflow: hidden;
}
.explorer-scale > div { padding: 0.8rem 1rem; background: var(--hc-surface); }
.explorer-scale dt {
	margin-bottom: 0.15rem;
	color: var(--hc-ink-3);
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}
.explorer-scale dd {
	margin: 0;
	color: var(--hc-heading);
	font-size: 1.25rem;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.02em;
}

/* --- Toolbar ------------------------------------------------------------- */

.explorer { padding: clamp(1.5rem, 3vw, 2.25rem) 0 clamp(3rem, 6vw, 5rem); }
.explorer.is-loading .explorer-table { opacity: 0.55; }

.explorer-toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 0.75rem;
	padding: 1rem;
	margin-bottom: 1.5rem;
	border: 1px solid var(--hc-line);
	border-radius: var(--hc-radius);
	background: var(--hc-surface-2);
}
.explorer-toolbar__field { flex: 1 1 150px; min-width: 0; }
.explorer-toolbar__field--grow { flex: 2 1 240px; }
.explorer-toolbar__field label {
	display: block;
	margin-bottom: 0.3rem;
	color: var(--hc-ink-2);
	font-size: 0.7rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}
.explorer-toolbar__field input,
.explorer-toolbar__field select { min-height: 42px; }
.explorer-toolbar__actions { display: flex; gap: 0.5rem; flex: 0 0 auto; }

/* --- Layout -------------------------------------------------------------- */

.explorer-layout {
	display: grid;
	grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
	gap: clamp(1.5rem, 3vw, 2.5rem);
	align-items: start;
}
.explorer-map-panel__inner { position: sticky; top: calc(var(--hc-header-h) + 1rem); }

/* --- Map ----------------------------------------------------------------- */

.explorer-map__head { margin-bottom: 0.75rem; }
.explorer-map__metric span {
	display: block;
	margin-bottom: 0.3rem;
	color: var(--hc-ink-2);
	font-size: 0.7rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

.explorer-map {
	position: relative;
	margin: 0;
	padding: 0.75rem;
	border: 1px solid var(--hc-line);
	border-radius: var(--hc-radius);
	background: var(--hc-surface);
}
.explorer-map canvas { display: block; width: 100%; touch-action: pan-y; }

.explorer-map__tooltip {
	position: absolute;
	z-index: 3;
	transform: translate(-50%, -100%);
	padding: 0.4rem 0.6rem;
	border-radius: 6px;
	background: var(--hc-heading);
	color: var(--hc-bg);
	font-size: 0.76rem;
	line-height: 1.3;
	white-space: nowrap;
	pointer-events: none;
	box-shadow: var(--hc-shadow-md);
}
.explorer-map__tooltip[hidden] { display: none; }
.explorer-map__tooltip strong { display: block; font-weight: 700; }
.explorer-map__tooltip span { opacity: 0.85; font-variant-numeric: tabular-nums; }

.explorer-map__legend {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.3rem 0.7rem;
	margin-top: 0.75rem;
	padding-top: 0.7rem;
	border-top: 1px solid var(--hc-line);
	color: var(--hc-ink-3);
	font-size: 0.7rem;
}
.explorer-legend__label {
	width: 100%;
	color: var(--hc-ink-2);
	font-weight: 800;
	letter-spacing: 0.05em;
	text-transform: uppercase;
}
.explorer-legend__step { display: inline-flex; align-items: center; gap: 0.3rem; font-variant-numeric: tabular-nums; }
.explorer-legend__step i { width: 11px; height: 11px; border-radius: 3px; }

.explorer-map__note { margin: 0.75rem 0 0; color: var(--hc-ink-3); font-size: 0.75rem; line-height: 1.5; }

/* --- Detail panel -------------------------------------------------------- */

.explorer-detail {
	position: relative;
	margin-top: 1rem;
	padding: 1.1rem 1.2rem;
	border: 1px solid var(--hc-line);
	border-left: 3px solid var(--hc-accent);
	border-radius: var(--hc-radius-sm);
	background: var(--hc-surface);
}
.explorer-detail[hidden] { display: none; }
.explorer-detail h2 { margin: 0 0 0.75rem; font-size: 1.3rem; }
.explorer-detail__close {
	position: absolute;
	top: 0.5rem;
	right: 0.6rem;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	color: var(--hc-ink-3);
	font-size: 1.2rem;
	line-height: 1;
}
.explorer-detail__close:hover { background: var(--hc-surface-2); color: var(--hc-ink); }
.explorer-detail__loading { margin: 0; color: var(--hc-ink-3); }
.explorer-detail__list { margin: 0 0 0.9rem; }
.explorer-detail__list > div {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.45rem 0;
	border-bottom: 1px solid var(--hc-line);
}
.explorer-detail__list > div:last-child { border-bottom: 0; }
.explorer-detail__list dt { color: var(--hc-ink-2); font-size: 0.82rem; }
.explorer-detail__list dd {
	margin: 0;
	color: var(--hc-heading);
	font-size: 0.9rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* --- Results table ------------------------------------------------------- */

.explorer-results__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.85rem;
}
.explorer-status { margin: 0; color: var(--hc-ink-2); font-size: 0.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.explorer-table-wrap {
	overflow-x: auto;
	border: 1px solid var(--hc-line);
	border-radius: var(--hc-radius);
	background: var(--hc-surface);
}
.explorer-table { width: 100%; margin: 0; border-collapse: collapse; font-size: 0.88rem; }
.explorer-table th,
.explorer-table td {
	padding: 0.65rem 0.85rem;
	border-bottom: 1px solid var(--hc-line);
	text-align: left;
	white-space: nowrap;
	vertical-align: middle;
}
.explorer-table tbody tr:last-child th,
.explorer-table tbody tr:last-child td { border-bottom: 0; }
.explorer-table tbody tr:hover { background: var(--hc-surface-2); }
.explorer-table thead th {
	position: sticky;
	top: 0;
	z-index: 1;
	padding: 0;
	background: var(--hc-surface-2);
	border-bottom: 2px solid var(--hc-line-2);
}
.explorer-table thead th button {
	display: block;
	width: 100%;
	padding: 0.6rem 0.85rem;
	color: var(--hc-ink-2);
	font-size: 0.72rem;
	font-weight: 800;
	letter-spacing: 0.05em;
	text-align: left;
	text-transform: uppercase;
	white-space: nowrap;
}
.explorer-table thead th button:hover { color: var(--hc-ink); }
.explorer-table thead th.is-numeric button { text-align: right; }
.explorer-table thead th.is-sorted button { color: var(--hc-accent-text); }
.explorer-table thead th.is-sorted button::after { content: " ↓"; }
.explorer-table thead th.is-sorted[data-direction="ASC"] button::after { content: " ↑"; }
.explorer-table .is-numeric { text-align: right; font-variant-numeric: tabular-nums; }
.explorer-table__empty { padding: 2.5rem 1rem; color: var(--hc-ink-3); text-align: center; white-space: normal; }
.explorer-table__pick { width: 38px; padding-right: 0; }

.explorer-pick {
	display: grid;
	place-items: center;
	width: 22px;
	height: 22px;
	border: 1.5px solid var(--hc-line-2);
	border-radius: 5px;
	background: var(--hc-surface);
	transition: background 0.14s var(--hc-ease), border-color 0.14s var(--hc-ease);
}
.explorer-pick:hover { border-color: var(--hc-accent); }
.explorer-pick[aria-pressed="true"] { background: var(--hc-accent); border-color: var(--hc-accent); }
.explorer-pick[aria-pressed="true"]::after { content: "✓"; color: var(--hc-accent-ink); font-size: 0.72rem; font-weight: 800; }

.explorer-name {
	color: var(--hc-heading);
	font-size: 0.9rem;
	font-weight: 700;
	text-align: left;
}
.explorer-name:hover { color: var(--hc-link); text-decoration: underline; }
.explorer-profile-link { margin-left: 0.35rem; color: var(--hc-ink-3); text-decoration: none; }
.explorer-profile-link:hover { color: var(--hc-accent-text); }

.explorer-pager {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	margin-top: 1.25rem;
	color: var(--hc-ink-3);
	font-size: 0.85rem;
	font-variant-numeric: tabular-nums;
}

/* --- Notes --------------------------------------------------------------- */

.explorer-notes {
	max-width: 46rem;
	margin-top: clamp(2rem, 4vw, 3rem);
	padding-top: 1.5rem;
	border-top: 1px solid var(--hc-line);
}
.explorer-notes h2 { font-size: 1.1rem; }
.explorer-notes ul { margin: 0; padding-left: 1.15rem; color: var(--hc-ink-2); }
.explorer-notes li { margin-bottom: 0.5rem; font-size: 0.9rem; line-height: 1.55; }

/* --- Compare tray -------------------------------------------------------- */

.explorer-tray {
	position: sticky;
	bottom: 0;
	z-index: 40;
	margin-top: 1.5rem;
	padding: 0.75rem 0;
	border-top: 1px solid var(--hc-line);
	background: var(--hc-surface);
	box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.08);
}
.explorer-tray[hidden] { display: none; }
.explorer-tray__inner { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.explorer-tray__label {
	margin: 0;
	color: var(--hc-ink-3);
	font-size: 0.7rem;
	font-weight: 800;
	letter-spacing: 0.07em;
	text-transform: uppercase;
}
.explorer-tray__items { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; list-style: none; flex: 1; }
.explorer-tray__items li {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	padding: 0.25rem 0.3rem 0.25rem 0.6rem;
	border: 1px solid var(--hc-line-2);
	border-radius: var(--hc-radius-pill);
	font-size: 0.8rem;
	font-weight: 600;
}
.explorer-tray__items button {
	width: 20px;
	height: 20px;
	border-radius: 50%;
	color: var(--hc-ink-3);
	font-size: 0.95rem;
	line-height: 1;
}
.explorer-tray__items button:hover { background: var(--hc-surface-2); color: var(--hc-down); }
.explorer-tray__actions { display: flex; gap: 0.5rem; }

/* --- Compare modal ------------------------------------------------------- */

.explorer-modal {
	position: fixed;
	inset: 0;
	z-index: 950;
	display: grid;
	place-items: center;
	padding: 1rem;
	background: rgba(6, 14, 20, 0.6);
	backdrop-filter: blur(2px);
}
.explorer-modal[hidden] { display: none; }
.explorer-modal__panel {
	width: min(100%, 62rem);
	max-height: 86vh;
	overflow: auto;
	border-radius: var(--hc-radius);
	background: var(--hc-surface);
	box-shadow: var(--hc-shadow-lg);
}
.explorer-modal__head {
	position: sticky;
	top: 0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid var(--hc-line);
	background: var(--hc-surface);
}
.explorer-modal__head h2 { margin: 0; font-size: 1.15rem; }
.explorer-modal__body { padding: 1.25rem; }
.explorer-compare-wrap { overflow-x: auto; }
.explorer-compare { width: 100%; margin: 0; border-collapse: collapse; font-size: 0.88rem; }
.explorer-compare th,
.explorer-compare td { padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--hc-line); text-align: left; }
.explorer-compare thead th {
	color: var(--hc-heading);
	font-size: 0.85rem;
	font-weight: 800;
	border-bottom: 2px solid var(--hc-line-2);
}
.explorer-compare tbody th { color: var(--hc-ink-2); font-weight: 600; }
.explorer-compare .is-numeric { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

body.is-modal-open { overflow: hidden; }

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 1080px) {
	.explorer-layout { grid-template-columns: 1fr; }
	.explorer-map-panel__inner { position: static; }
	.explorer-map { max-width: 640px; }
}

@media (max-width: 640px) {
	.explorer-toolbar { padding: 0.85rem; }
	.explorer-toolbar__field { flex: 1 1 100%; }
	.explorer-toolbar__actions { flex: 1 1 100%; }
	.explorer-toolbar__actions .button { flex: 1; }
	.explorer-table { font-size: 0.82rem; }
	.explorer-tray__inner { flex-direction: column; align-items: stretch; }
	.explorer-tray__actions .button { flex: 1; }
}
