/**
 * CryptoFrame Crypto Markets — heatmap styles.
 *
 * Tile area comes from a grid span the template calculates server side, and
 * colour intensity from a custom property. Colour is never the only carrier of
 * meaning: every tile prints its percentage as text, and each has a full
 * sentence available to assistive technology.
 */

.cfxcm-heatmap__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
	grid-auto-rows: 84px;
	gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.cfxcm-heatmap__cell {
	grid-column: span var(--cfxcm-span, 1);
	grid-row: span var(--cfxcm-span, 1);
	min-width: 0;
}

.cfxcm-heatmap__tile {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.1rem;
	width: 100%;
	height: 100%;
	padding: 0.35rem;
	border-radius: var(--cfxcm-radius-sm, 6px);
	color: #fff;
	text-align: center;
	text-decoration: none;
	overflow: hidden;
	transition: transform 0.15s ease;
}

a.cfxcm-heatmap__tile:hover,
a.cfxcm-heatmap__tile:focus-visible {
	transform: scale(1.03);
	z-index: 1;
	position: relative;
}

a.cfxcm-heatmap__tile:focus-visible {
	outline: 2px solid var(--cfxcm-accent, #2563eb);
	outline-offset: 2px;
}

/* Intensity is mixed against the surface rather than applied as opacity, so a
   quiet tile stays fully opaque and its text keeps its contrast. */
.cfxcm-heatmap__cell--up .cfxcm-heatmap__tile {
	background: color-mix(
		in srgb,
		var(--cfxcm-up, #16a34a) calc(35% + (var(--cfxcm-intensity, 0) * 65%)),
		#3f4550
	);
}

.cfxcm-heatmap__cell--down .cfxcm-heatmap__tile {
	background: color-mix(
		in srgb,
		var(--cfxcm-down, #dc2626) calc(35% + (var(--cfxcm-intensity, 0) * 65%)),
		#3f4550
	);
}

.cfxcm-heatmap__cell--flat .cfxcm-heatmap__tile {
	background: #4b5563;
}

.cfxcm-heatmap__symbol {
	font-weight: 700;
	font-size: 0.8125rem;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cfxcm-heatmap__change {
	font-size: 0.8125rem;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

/* Price is the first thing to go when a tile is small: symbol and percentage
   are the information the module exists to convey. */
.cfxcm-heatmap__price {
	font-size: 0.6875rem;
	opacity: 0.85;
	font-variant-numeric: tabular-nums;
}

.cfxcm-heatmap__cell:not([style*="--cfxcm-span:2"]):not([style*="--cfxcm-span:3"]):not([style*="--cfxcm-span:4"]) .cfxcm-heatmap__price {
	display: none;
}

.cfxcm-heatmap.is-compact .cfxcm-heatmap__grid {
	grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
	grid-auto-rows: 66px;
}

.cfxcm-heatmap.is-compact .cfxcm-heatmap__price {
	display: none;
}

/* -------------------------------------------------------------------------
 * Legend
 * ---------------------------------------------------------------------- */

.cfxcm-heatmap__legend {
	display: flex;
	align-items: center;
	gap: 0.4rem;
	flex-wrap: wrap;
	margin: 0.75rem 0 0;
	color: var(--cfxcm-muted, #6b7280);
	font-size: var(--cfx-fs-xs, 0.8125rem);
}

.cfxcm-heatmap__key {
	display: inline-block;
	width: 1rem;
	height: 0.6rem;
	border-radius: 2px;
}

.cfxcm-heatmap__key--up {
	background: var(--cfxcm-up, #16a34a);
}

.cfxcm-heatmap__key--down {
	background: var(--cfxcm-down, #dc2626);
}

.cfxcm-heatmap__legend-note {
	flex: 1 1 100%;
}

@media (max-width: 480px) {
	.cfxcm-heatmap__grid {
		grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
		grid-auto-rows: 70px;
	}

	.cfxcm-heatmap__price {
		display: none;
	}
}
