/**
 * IC360 Community Market Explorer.
 *
 * Scoped to .icd-explorer and .icd-* class names so it cannot affect any other IC360 view.
 * Every colour resolves from the IC360 design tokens when they exist and falls back to the
 * same values when the stylesheet is loaded on its own (preview harness, print, email).
 */

.icd-explorer {
	--icd-ink: var(--ic-ink, #0b1a2e);
	--icd-ink-2: var(--ic-ink-2, #3b4a5f);
	--icd-mute: var(--ic-mute, #56657a);
	--icd-line: var(--ic-line, #dbe3ec);
	--icd-surface: var(--ic-surface, #fff);
	--icd-accent: var(--ic-accent, #0a7a9e);
	--icd-accent-ink: var(--ic-accent-ink, #06627f);
	--icd-accent-2: var(--ic-accent-2, #22d3ee);
	--icd-navy: var(--ic-navy, #081426);
	--icd-navy-2: var(--ic-navy-2, #0f2540);
	--icd-warn: var(--ic-warn, #b45309);
	--icd-r: var(--ic-r, 12px);
	--icd-shadow: var(--ic-shadow, 0 1px 2px rgba(8, 20, 38, .06), 0 6px 18px rgba(8, 20, 38, .06));
	--icd-shadow-up: var(--ic-shadow-up, 0 2px 4px rgba(8, 20, 38, .08), 0 14px 32px rgba(8, 20, 38, .12));

	margin: 0 0 38px;
	color: var(--icd-ink);
	font-size: 16px;
	line-height: 1.55;
}

.icd-explorer *,
.icd-explorer *::before,
.icd-explorer *::after {
	box-sizing: border-box;
}

.icd-explorer a:focus-visible,
.icd-explorer [tabindex]:focus-visible {
	outline: 3px solid var(--icd-accent-2);
	outline-offset: 2px;
	border-radius: 6px;
}

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

.icd-explorer__head {
	margin: 0 0 20px;
	padding: 22px 24px 20px;
	border: 1px solid var(--icd-line);
	border-left: 4px solid var(--icd-accent);
	border-radius: var(--icd-r);
	background: linear-gradient(180deg, #f8fbfe 0%, var(--icd-surface) 100%);
	box-shadow: var(--icd-shadow);
}

.icd-explorer__eyebrow {
	margin: 0 0 8px;
	font-size: .74rem;
	font-weight: 700;
	letter-spacing: .14em;
	text-transform: uppercase;
	color: var(--icd-accent-ink);
}

.icd-explorer__head h2 {
	margin: 0 0 8px;
	font-size: clamp(1.35rem, 2.4vw, 1.75rem);
	line-height: 1.2;
	color: var(--icd-ink);
}

.icd-explorer__lead {
	margin: 0;
	max-width: 820px;
	color: var(--icd-mute);
}

/* ---------- Market tiles ---------- */

.icd-markets {
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: 12px;
	margin: 0 0 20px;
	padding: 0;
	list-style: none;
}

.icd-market {
	margin: 0;
}

.icd-market__link {
	display: flex;
	flex-direction: column;
	gap: 2px;
	height: 100%;
	padding: 16px 18px;
	border: 1px solid var(--icd-line);
	border-radius: var(--icd-r);
	background: var(--icd-surface);
	box-shadow: var(--icd-shadow);
	color: var(--icd-ink);
	text-decoration: none;
	transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

a.icd-market__link:hover,
a.icd-market__link:focus-visible {
	transform: translateY(-2px);
	box-shadow: var(--icd-shadow-up);
	border-color: #b9d9e6;
}

.icd-market__label {
	font-size: .82rem;
	font-weight: 600;
	letter-spacing: .02em;
	color: var(--icd-mute);
}

.icd-market__count {
	margin-top: 4px;
	font-size: 2rem;
	font-weight: 700;
	line-height: 1.05;
	font-variant-numeric: tabular-nums;
	color: var(--icd-ink);
}

.icd-market__meta {
	font-size: .78rem;
	color: var(--icd-mute);
}

.icd-market__cta {
	margin-top: 10px;
	font-size: .8rem;
	font-weight: 700;
	color: var(--icd-accent-ink);
}

.icd-market.is-gap .icd-market__link {
	background: #fbfcfe;
	border-style: dashed;
}

.icd-market.is-gap .icd-market__count {
	font-size: 1.05rem;
	color: var(--icd-warn);
}

/* ---------- Jump chips ---------- */

.icd-jump {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 14px;
}

.icd-chip {
	display: inline-flex;
	align-items: center;
	padding: 5px 12px;
	border: 1px solid #cfe4ee;
	border-radius: 999px;
	background: #eaf3f8;
	color: var(--icd-accent-ink);
	font-size: .78rem;
	font-weight: 600;
	text-decoration: none;
	transition: background .15s ease, border-color .15s ease;
}

.icd-chip:hover,
.icd-chip:focus-visible {
	background: #dcedf5;
	border-color: #a9d3e3;
}

/* ---------- Matrix ---------- */

.icd-matrix__wrap {
	overflow-x: auto;
	/* Without paint containment Chrome adds the table's full width to the document scroll width, even though the
	   wrapper clips it; the page then reports a horizontal overflow it cannot scroll. */
	contain: paint;
	border: 1px solid var(--icd-line);
	border-radius: var(--icd-r);
	background: var(--icd-surface);
	box-shadow: var(--icd-shadow);
	scrollbar-width: thin;
}

/* The table is a scroll region: it takes focus so keyboard users can reach every market column. */

.icd-matrix__wrap:focus-visible {
	outline: 3px solid var(--icd-accent-2);
	outline-offset: 3px;
}

.icd-matrix {
	width: 100%;
	min-width: 760px;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
}

.icd-matrix caption {
	text-align: left;
}

.icd-matrix thead th {
	padding: 12px 10px;
	border-bottom: 1px solid var(--icd-line);
	background: #eef3f9;
	color: var(--icd-ink);
	font-size: .72rem;
	font-weight: 700;
	letter-spacing: .07em;
	text-transform: uppercase;
	text-align: center;
	vertical-align: bottom;
}

.icd-matrix thead th.icd-matrix__corner {
	text-align: left;
	padding-left: 18px;
}

.icd-matrix thead th.icd-matrix__market {
	width: 11%;
	min-width: 92px;
	max-width: 118px;
	text-wrap: balance;
	line-height: 1.25;
}

.icd-matrix thead th.icd-matrix__sum {
	width: 74px;
	color: var(--icd-accent-ink);
	background: #e6f0f7;
}

.icd-matrix__group th {
	position: sticky;
	left: 0;
	padding: 9px 18px;
	background: var(--icd-navy);
	color: #dbe8f5;
	font-size: .72rem;
	font-weight: 700;
	letter-spacing: .12em;
	text-transform: uppercase;
	text-align: left;
	scroll-margin-top: 16px;
}

.icd-matrix__row th,
.icd-matrix__row td {
	padding: 9px 10px;
	border-bottom: 1px solid #eef2f7;
	font-size: .92rem;
	text-align: center;
}

.icd-matrix__row th.icd-matrix__term {
	position: sticky;
	left: 0;
	z-index: 1;
	padding-left: 18px;
	background: var(--icd-surface);
	font-weight: 600;
	text-align: left;
	white-space: nowrap;
}

.icd-matrix__row th.icd-matrix__term a {
	color: var(--icd-ink);
	text-decoration: none;
}

.icd-matrix__row th.icd-matrix__term a:hover,
.icd-matrix__row th.icd-matrix__term a:focus-visible {
	color: var(--icd-accent-ink);
	text-decoration: underline;
}

.icd-matrix__row:hover th.icd-matrix__term,
.icd-matrix__row:hover td {
	background: #f6fafe;
}

.icd-matrix__row.is-gap th.icd-matrix__term span {
	color: #8a93a2;
	font-weight: 500;
}

.icd-cell__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 34px;
	padding: 3px 8px;
	border-radius: 7px;
	color: var(--icd-accent-ink);
	font-weight: 700;
	text-decoration: none;
	transition: background .15s ease, color .15s ease;
}

.icd-cell__link:hover,
.icd-cell__link:focus-visible {
	background: var(--icd-accent);
	color: #fff;
}

.icd-cell.is-empty {
	color: #aeb8c6;
}

.icd-matrix__row td.icd-matrix__sum,
.icd-matrix tfoot td.icd-matrix__sum {
	color: var(--icd-accent-ink);
	font-weight: 700;
	background: #f4f9fc;
}

.icd-matrix tfoot th,
.icd-matrix tfoot td {
	padding: 12px 10px;
	border-top: 2px solid var(--icd-line);
	background: #f8fbfd;
	color: var(--icd-ink);
	font-size: .82rem;
	font-weight: 700;
	text-align: center;
}

.icd-matrix tfoot th {
	position: sticky;
	left: 0;
	text-align: left;
	padding-left: 18px;
}

/* ---------- Legend and method ---------- */

.icd-legend {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 24px;
	margin: 12px 0 0;
}

.icd-legend__item {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-size: .82rem;
	color: var(--icd-mute);
}

.icd-legend__swatch {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	flex: 0 0 auto;
}

.icd-legend__swatch--live {
	background: var(--icd-accent);
}

.icd-legend__swatch--gap {
	background: #c3ccd8;
}

.icd-method {
	margin: 16px 0 0;
	padding: 14px 16px;
	border: 1px solid var(--icd-line);
	border-left: 3px solid var(--icd-navy-2);
	border-radius: 10px;
	background: #f7f9fc;
	color: var(--icd-ink-2);
	font-size: .84rem;
}

.icd-method p {
	margin: 0 0 8px;
}

.icd-method p:last-child {
	margin-bottom: 0;
}

/* ---------- Empty state ---------- */

.icd-empty {
	padding: 22px 24px;
	border: 1px dashed var(--icd-line);
	border-radius: var(--icd-r);
	background: #fbfcfe;
}

.icd-empty h3 {
	margin: 0 0 6px;
	font-size: 1.05rem;
	color: var(--icd-ink);
}

.icd-empty p {
	margin: 0;
	max-width: 760px;
	color: var(--icd-mute);
}

/* ---------- Utilities ---------- */

.icd-sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

@media (max-width: 980px) {
	.icd-markets {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 720px) {
	.icd-explorer__head {
		padding: 18px 18px 16px;
	}

	.icd-markets {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.icd-market__count {
		font-size: 1.6rem;
	}

	.icd-matrix__row th,
	.icd-matrix__row td {
		padding: 8px;
		font-size: .88rem;
	}
}

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

@media print {
	.icd-jump {
		display: none;
	}

	.icd-matrix__wrap {
		overflow: visible;
		box-shadow: none;
	}
}
