/*
 * Fund Holdings Explorer — public widget styles.
 *
 * Design language: a quiet, institutional "fund disclosure" feel —
 * serif display numerals for the headline figures (the way a printed
 * annual report sets its big numbers), a disciplined sans for data,
 * tabular figures throughout, and a single signature device: each row
 * in the Top Holdings spotlight carries its own proportional backdrop
 * bar, so the ranked list doubles as a chart without ever feeling like
 * a dashboard widget.
 *
 * Everything is scoped under .fhe-explorer so it can't leak into the
 * surrounding theme, and the theme can't easily leak into it either.
 */

.fhe-explorer {
	--fhe-ink: #1b2430;
	--fhe-navy: #1f3a5f;
	--fhe-navy-soft: rgba(31, 58, 95, 0.08);
	--fhe-paper: #faf9f6;
	--fhe-line: #e3e1dc;
	--fhe-muted: #6b7280;
	--fhe-gain: #2f7a6b;
	--fhe-gain-soft: rgba(47, 122, 107, 0.1);
	--fhe-loss: #a8432f;
	--fhe-loss-soft: rgba(168, 67, 47, 0.1);
	--fhe-radius: 3px;
	--fhe-font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
	--fhe-font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

	box-sizing: border-box;
	color: var(--fhe-ink);
	font-family: var(--fhe-font-body);
	line-height: 1.45;
	max-width: 100%;
}

.fhe-explorer *,
.fhe-explorer *::before,
.fhe-explorer *::after {
	box-sizing: inherit;
}

.fhe-explorer button {
	font-family: inherit;
}

.fhe-explorer .fhe-loading,
.fhe-explorer .fhe-empty,
.fhe-explorer .fhe-error {
	padding: 3em 1em;
	text-align: center;
	color: var(--fhe-muted);
	font-size: 0.95em;
}

/* ----------------------------- Header ----------------------------- */

.fhe-header {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: flex-end;
	gap: 1.5em;
	padding-bottom: 1.5em;
	border-bottom: 1px solid var(--fhe-line);
	margin-bottom: 1.75em;
}

.fhe-header-fundname {
	font-family: var(--fhe-font-display);
	font-size: 1.7em;
	line-height: 1.15;
	margin: 0 0 0.15em;
	color: var(--fhe-navy);
}

.fhe-header-asof {
	color: var(--fhe-muted);
	font-size: 0.9em;
}

.fhe-date-picker {
	display: flex;
	align-items: center;
	gap: 0.5em;
}

.fhe-date-picker label {
	font-size: 0.8em;
	color: var(--fhe-muted);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}

.fhe-select {
	font-family: inherit;
	font-size: 0.95em;
	padding: 0.5em 0.75em;
	border: 1px solid var(--fhe-line);
	border-radius: var(--fhe-radius);
	background: #fff;
	color: var(--fhe-ink);
}

.fhe-select:focus-visible,
.fhe-explorer button:focus-visible,
.fhe-explorer input:focus-visible,
.fhe-explorer th[tabindex]:focus-visible {
	outline: 2px solid var(--fhe-navy);
	outline-offset: 2px;
}

/* ----------------------------- KPI strip --------------------------- */

.fhe-kpis {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 1px;
	background: var(--fhe-line);
	border: 1px solid var(--fhe-line);
	margin-bottom: 2em;
	border-radius: var(--fhe-radius);
	overflow: hidden;
}

.fhe-kpi {
	background: var(--fhe-paper);
	padding: 1.1em 1.25em;
}

.fhe-kpi-label {
	font-size: 0.72em;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--fhe-muted);
	margin-bottom: 0.35em;
}

.fhe-kpi-value {
	font-family: var(--fhe-font-display);
	font-size: 1.5em;
	font-variant-numeric: tabular-nums;
	color: var(--fhe-ink);
}

.fhe-kpi-value.is-gain { color: var(--fhe-gain); }
.fhe-kpi-value.is-loss { color: var(--fhe-loss); }

/* Top summary strip: textured tiles, white value over gold label. */
.fhe-kpis {
	gap: 1em;
	background: none;
	border: 0;
	border-radius: 0;
	overflow: visible;
}

.fhe-kpis .fhe-kpi {
	background: #003057 url("../images/bg-repeat.jpg") repeat;
	background-size: 42px 42px;
	border-radius: var(--fhe-radius);
	padding: 1.4em 1.25em;
	text-align: center;
}

.fhe-kpis .fhe-kpi-value,
.fhe-kpis .fhe-kpi-value.is-gain,
.fhe-kpis .fhe-kpi-value.is-loss {
	margin: 0 0 0.3em;
	padding: 0;
	font-family: var(--fhe-font-display);
	font-weight: 400;
	letter-spacing: normal;
	text-transform: none;
	font-size: 2.3em;
	line-height: 1.15;
	color: #fff;
}

.fhe-kpis .fhe-kpi-label {
	margin: 0;
	font-size: 1.15em;
	text-transform: none;
	letter-spacing: normal;
	color: #d9b453;
}

/* ----------------------------- Breakdown charts --------------------- */

.fhe-panel-title {
	font-size: 0.95em;
	font-weight: 600 !important;
	font-family: var(--fhe-font-body) !important;
	margin: 0 0 0.9em;
	color: var(--fhe-ink);
}

.fhe-bar-row {
	display: grid;
	grid-template-columns: 9em 1fr auto;
	align-items: center;
	gap: 0.75em;
	padding: 0.4em 0;
	font-size: 0.88em;
}

.fhe-bar-row + .fhe-bar-row {
	border-top: 1px solid var(--fhe-line);
}

.fhe-bar-label {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	color: var(--fhe-ink);
}

.fhe-bar-track {
	background: var(--fhe-line);
	border-radius: 2px;
	height: 0.6em;
	overflow: hidden;
}

.fhe-bar-fill {
	background: var(--fhe-navy);
	height: 100%;
	border-radius: 2px;
	transition: width 0.4s ease;
}

.fhe-bar-value {
	font-variant-numeric: tabular-nums;
	color: var(--fhe-muted);
	white-space: nowrap;
	font-size: 0.92em;
}

/* ----------------------------- Global holdings map -------------------- */

.fhe-map-section {
	margin-bottom: 2em;
}

.fhe-map-section-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	justify-content: space-between;
	gap: 0.5em;
	margin-bottom: 0.9em;
}

.fhe-map-hint {
	font-size: 0.82em;
	color: var(--fhe-muted);
}

.fhe-map-wrap {
	position: relative;
	border: 1px solid var(--fhe-line);
	border-radius: var(--fhe-radius);
	background: var(--fhe-paper);
	padding: 0.5em;
}

.fhe-map-svg {
	display: block;
	width: 100%;
	height: auto;
	max-height: 460px;
}

.fhe-map-country {
	fill: #e9e6df;
	stroke: var(--fhe-paper);
	stroke-width: 0.4;
	transition: fill 0.3s ease, stroke-width 0.15s ease;
}

.fhe-map-country.has-data {
	cursor: pointer;
}

.fhe-map-country.has-data:hover,
.fhe-map-country.has-data:focus-visible {
	stroke: var(--fhe-ink);
	stroke-width: 1;
	outline: none;
}

.fhe-map-country.is-selected {
	stroke: var(--fhe-ink);
	stroke-width: 1.4;
}

/* Brand colors, ordered light to dark. The palest brand tint (#c7d7ec) is
   left out because it disappears against the light background on large displays. */
.fhe-map-bucket-0 { fill: #6bbbae; background: #6bbbae; }
.fhe-map-bucket-1 { fill: #7a99ac; background: #7a99ac; }
.fhe-map-bucket-2 { fill: #007d99; background: #007d99; }
.fhe-map-bucket-3 { fill: #266782; background: #266782; }
.fhe-map-bucket-4 { fill: #003057; background: #003057; }

.fhe-map-unavailable {
	padding: 2em;
	text-align: center;
	color: var(--fhe-muted);
}

.fhe-map-tooltip {
	position: absolute;
	pointer-events: none;
	background: var(--fhe-ink);
	color: #fff;
	padding: 0.5em 0.7em;
	border-radius: var(--fhe-radius);
	font-size: 0.8em;
	line-height: 1.4;
	max-width: 200px;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
	z-index: 5;
}

.fhe-map-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 1.1em;
	margin-top: 0.85em;
	font-size: 0.78em;
	color: var(--fhe-muted);
}

.fhe-legend-item {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	white-space: nowrap;
}

.fhe-legend-swatch {
	display: inline-block;
	width: 0.85em;
	height: 0.85em;
	border-radius: 2px;
}

/* ----------------------------- Map + sidebar two-column layout --------- */

.fhe-map-layout {
	display: grid;
	grid-template-columns: 1fr 280px;
	gap: 1.5em;
	align-items: start;
}

@media (max-width: 900px) {
	.fhe-map-layout {
		grid-template-columns: 1fr;
	}
}

.fhe-map-col {
	min-width: 0;
}

.fhe-map-sidebar {
	display: flex;
	flex-direction: column;
	gap: 1.25em;
	min-width: 0;
}

.fhe-sidebar-section {
	border: 1px solid var(--fhe-line);
	border-radius: var(--fhe-radius);
	overflow: hidden;
}

.fhe-sidebar-title {
	font-size: 0.72em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--fhe-muted);
	margin: 0;
	padding: 0.65em 1em;
	background: var(--fhe-paper);
	border-bottom: 1px solid var(--fhe-line);
}

.fhe-sidebar-row {
	display: flex;
	align-items: center;
	gap: 0.55em;
	padding: 0.55em 1em;
	font-size: 0.82em;
	border-bottom: 1px solid var(--fhe-line);
}

.fhe-sidebar-row:last-child {
	border-bottom: none;
}

.fhe-sidebar-rank {
	font-family: var(--fhe-font-display);
	color: var(--fhe-muted);
	font-size: 0.85em;
	min-width: 1.25em;
	text-align: center;
	flex-shrink: 0;
}

.fhe-sidebar-flag {
	font-size: 1.1em;
	line-height: 1;
	flex-shrink: 0;
}

.fhe-sidebar-name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 500;
}

.fhe-sidebar-value {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	font-weight: 600;
	font-size: 0.9em;
}

.fhe-sidebar-pct {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	color: var(--fhe-muted);
	font-size: 0.85em;
	min-width: 3.2em;
	text-align: right;
	flex-shrink: 0;
}

/* ----------------------------- Top companies carousel ------------------ */

@keyframes fhe-carousel-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.fhe-carousel {
	padding: 1.25em 1em 1em;
}

.fhe-carousel-slide {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	gap: 0.6em;
	min-height: 8.5em;
	animation: fhe-carousel-in 0.3s ease;
}

.fhe-carousel-logo-wrap {
	width: 3.75em;
	height: 3.75em;
	border-radius: 8px;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--fhe-paper);
	border: 1px solid var(--fhe-line);
	flex-shrink: 0;
}

.fhe-carousel-logo-img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: contain;
}

.fhe-carousel-logo-wrap.fhe-logo-dark-bg {
	background: var(--fhe-ink);
	border-color: var(--fhe-ink);
}

.fhe-carousel-logo-fallback {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background: var(--fhe-navy-soft);
	color: var(--fhe-navy);
	font-size: 1.1em;
	font-weight: 700;
}

.fhe-carousel-name {
	font-weight: 600;
	font-size: 0.85em;
	line-height: 1.3;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	color: var(--fhe-ink);
}

.fhe-carousel-value {
	font-family: var(--fhe-font-display);
	font-size: 1.3em;
	font-variant-numeric: tabular-nums;
	color: var(--fhe-navy);
	font-weight: 600;
}

.fhe-carousel-controls {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-top: 0.9em;
	padding-top: 0.75em;
	border-top: 1px solid var(--fhe-line);
}

.fhe-carousel-btn {
	background: none;
	border: 1px solid var(--fhe-line);
	border-radius: var(--fhe-radius);
	width: 2em;
	height: 2em;
	cursor: pointer;
	font-size: 1.15em;
	color: var(--fhe-navy);
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	padding: 0;
}

.fhe-carousel-btn:hover {
	border-color: var(--fhe-navy);
	background: var(--fhe-navy-soft);
}

.fhe-carousel-counter {
	font-size: 0.78em;
	color: var(--fhe-muted);
	font-variant-numeric: tabular-nums;
}

/* ----------------------------- Country drill-down panel ---------------- */

.fhe-country-detail {
	grid-column: 1 / -1;
	margin-top: 1em;
	border: 1px solid var(--fhe-line);
	border-radius: var(--fhe-radius);
	background: #fff;
	padding: 1.25em;
}

.fhe-detail-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 1em;
}

.fhe-detail-head h4 {
	font-family: var(--fhe-font-display);
	font-size: 1.25em;
	margin: 0;
	color: var(--fhe-navy);
}

.fhe-detail-loading,
.fhe-detail-empty {
	color: var(--fhe-muted);
	font-size: 0.9em;
}

.fhe-detail-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
	gap: 1px;
	background: var(--fhe-line);
	border: 1px solid var(--fhe-line);
	border-radius: var(--fhe-radius);
	overflow: hidden;
	margin-bottom: 1.4em;
}

.fhe-detail-stats .fhe-kpi {
	padding: 0.85em 1em;
}

.fhe-detail-stats .fhe-kpi-value {
	font-size: 1.2em;
}

.fhe-detail-columns {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 2em;
	margin-bottom: 1.4em;
}

@media (max-width: 650px) {
	.fhe-detail-columns { grid-template-columns: 1fr; }
}

.fhe-detail-subtitle {
	font-size: 0.85em;
	font-weight: 600;
	margin: 0 0 0.6em;
	color: var(--fhe-ink);
}

.fhe-mini-list {
	border-top: 1px solid var(--fhe-line);
}

.fhe-mini-row {
	display: flex;
	align-items: center;
	gap: 0.6em;
	padding: 0.45em 0;
	border-bottom: 1px solid var(--fhe-line);
	font-size: 0.85em;
}

.fhe-mini-name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 600;
}

.fhe-mini-value {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.fhe-mini-gl {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	font-size: 0.92em;
	min-width: 4.5em;
	text-align: right;
}

.fhe-btn-primary {
	background: var(--fhe-navy);
	color: #fff;
	border-color: var(--fhe-navy);
}

.fhe-btn-primary:hover {
	background: #16304f;
	border-color: #16304f;
}

/* ----------------------------- Top holdings spotlight ---------------- */

.fhe-spotlight {
	margin-top: 2.5em;
	margin-bottom: 2.5em;
}

.fhe-spotlight-list {
	border: 1px solid var(--fhe-line);
	border-radius: var(--fhe-radius);
	overflow: hidden;
}

.fhe-spotlight-row {
	position: relative;
	display: grid;
	grid-template-columns: 2.25em 1fr auto auto;
	align-items: center;
	gap: 1em;
	padding: 0.75em 1em;
	overflow: hidden;
}

.fhe-spotlight-row + .fhe-spotlight-row {
	border-top: 1px solid var(--fhe-line);
}

.fhe-spotlight-row .fhe-skyline {
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	background: var(--fhe-navy-soft);
	transition: width 0.5s ease;
	z-index: 0;
}

.fhe-spotlight-rank {
	position: relative;
	z-index: 1;
	font-family: var(--fhe-font-display);
	color: var(--fhe-muted);
	font-size: 0.95em;
}

.fhe-spotlight-main {
	position: relative;
	z-index: 1;
	min-width: 0;
}

.fhe-spotlight-name {
	font-weight: 600;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.fhe-spotlight-meta {
	font-size: 0.8em;
	color: var(--fhe-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.fhe-spotlight-value {
	position: relative;
	z-index: 1;
	font-variant-numeric: tabular-nums;
	text-align: right;
	font-weight: 600;
	white-space: nowrap;
}

.fhe-spotlight-gain {
	position: relative;
	z-index: 1;
	font-variant-numeric: tabular-nums;
	text-align: right;
	font-size: 0.88em;
	white-space: nowrap;
	min-width: 5em;
}

@media (max-width: 600px) {
	.fhe-spotlight-row { grid-template-columns: 1.75em 1fr auto; }
	.fhe-spotlight-gain { display: none; }
}

.fhe-pill {
	display: inline-block;
	padding: 0.1em 0.5em;
	border-radius: 999px;
	font-size: 0.85em;
}

.fhe-pill.is-gain { background: var(--fhe-gain-soft); color: var(--fhe-gain); }
.fhe-pill.is-loss { background: var(--fhe-loss-soft); color: var(--fhe-loss); }

/* ----------------------------- Table toolbar -------------------------- */

.fhe-toolbar {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75em;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 1em;
}

.fhe-toolbar-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6em;
	flex: 1 1 auto;
}

.fhe-search {
	flex: 1 1 220px;
	min-width: 180px;
	font-family: inherit;
	font-size: 0.95em;
	padding: 0.55em 0.8em;
	border: 1px solid var(--fhe-line);
	border-radius: var(--fhe-radius);
}

.fhe-btn {
	font-size: 0.85em;
	padding: 0.55em 1em;
	background: #fff;
	border: 1px solid var(--fhe-line);
	border-radius: var(--fhe-radius);
	color: var(--fhe-navy);
	cursor: pointer;
	white-space: nowrap;
}

.fhe-btn:hover { border-color: var(--fhe-navy); }

/* ----------------------------- Table ---------------------------------- */

.fhe-table-wrap {
	overflow-x: auto;
	border: 1px solid var(--fhe-line);
	border-radius: var(--fhe-radius);
}

.fhe-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.88em;
}

.fhe-table th,
.fhe-table td {
	padding: 0.65em 0.9em;
	text-align: left;
	white-space: nowrap;
}

.fhe-table th {
	background: var(--fhe-paper);
	font-weight: 600;
	color: var(--fhe-ink);
	border-bottom: 1px solid var(--fhe-line);
	position: sticky;
	top: 0;
	cursor: pointer;
	user-select: none;
}

.fhe-table th[data-numeric="1"],
.fhe-table td[data-numeric="1"] {
	text-align: right;
	font-variant-numeric: tabular-nums;
}

.fhe-table th .fhe-sort-arrow {
	display: inline-block;
	margin-left: 0.3em;
	opacity: 0.4;
}

.fhe-table th[aria-sort="ascending"] .fhe-sort-arrow,
.fhe-table th[aria-sort="descending"] .fhe-sort-arrow {
	opacity: 1;
}

.fhe-table tbody tr {
	border-bottom: 1px solid var(--fhe-line);
}

.fhe-table tbody tr:last-child {
	border-bottom: none;
}

.fhe-table tbody tr:hover {
	background: var(--fhe-paper);
}

.fhe-table .fhe-security-cell {
	font-weight: 600;
	max-width: 22em;
	overflow: hidden;
	text-overflow: ellipsis;
}

.fhe-gain-text { color: var(--fhe-gain); }
.fhe-loss-text { color: var(--fhe-loss); }

/* ----------------------------- Pagination ------------------------------ */

.fhe-pagination {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1em;
	margin-top: 1em;
	font-size: 0.85em;
	color: var(--fhe-muted);
}

.fhe-pagination-controls {
	display: flex;
	gap: 0.5em;
}

.fhe-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* ----------------------------- Fund value trend ------------------------ */

.fhe-trend-section {
	margin-top: 2.5em;
}

.fhe-trend-chart {
	position: relative;
}

.fhe-trend-bars {
	display: flex;
	align-items: flex-end;
	gap: 2px;
	height: 180px;
	padding: 0 2px;
	border-bottom: 1px solid var(--fhe-line);
}

.fhe-trend-bar-col {
	flex: 1 1 0;
	height: 100%;
	min-width: 0;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	cursor: pointer;
}

.fhe-trend-bar {
	width: 100%;
	max-width: 28px;
	background: var(--fhe-navy);
	border-radius: 3px 3px 0 0;
	transition: height 0.4s ease, background 0.15s ease;
}

.fhe-trend-bar-col:hover .fhe-trend-bar,
.fhe-trend-bar-col:focus-visible .fhe-trend-bar {
	background: #16304f;
}

.fhe-trend-bar-col:focus-visible {
	outline: none;
}

.fhe-trend-axis {
	display: flex;
	gap: 2px;
	padding: 0.5em 2px 0;
}

.fhe-trend-axis-label {
	flex: 1 1 0;
	min-width: 0;
	text-align: center;
	font-size: 0.72em;
	color: var(--fhe-muted);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.fhe-trend-tooltip {
	position: absolute;
	pointer-events: none;
	background: var(--fhe-ink);
	color: #fff;
	padding: 0.5em 0.7em;
	border-radius: var(--fhe-radius);
	font-size: 0.8em;
	line-height: 1.4;
	white-space: nowrap;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
	z-index: 5;
}

/* ----------------------------- Reduced motion -------------------------- */

@media (prefers-reduced-motion: reduce) {
	.fhe-explorer * {
		transition: none !important;
	}
}
