/**
 * CryptoFrame Crypto Markets — table, ticker and widget styles.
 */

/* -------------------------------------------------------------------------
 * Market table
 * ---------------------------------------------------------------------- */

.cfxcm-table-wrap {
	width: 100%;
}

.cfxcm-table__toolbar {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
	margin-bottom: 0.75rem;
}

.cfxcm-table__filter {
	flex: 1 1 12rem;
	max-width: 22rem;
}

.cfxcm-table__count {
	margin: 0;
	color: var(--cfxcm-muted, #6b7280);
	font-size: var(--cfx-fs-xs, 0.8125rem);
	white-space: nowrap;
}

/* A horizontally scrollable region needs to be focusable so it can be reached
   and scrolled from the keyboard. */
.cfxcm-table__scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

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

.cfxcm-table {
	width: 100%;
	border-collapse: collapse;
	font-variant-numeric: tabular-nums;
}

.cfxcm-table__th {
	padding: 0.5rem 0.75rem;
	border-bottom: 2px solid var(--cfxcm-border, rgba(0, 0, 0, 0.1));
	color: var(--cfxcm-muted, #6b7280);
	font-size: var(--cfx-fs-xs, 0.8125rem);
	font-weight: 600;
	text-align: right;
	white-space: nowrap;
}

.cfxcm-table__th--rank,
.cfxcm-table__th--name {
	text-align: left;
}

.cfxcm-table__th[data-cfxcm-sort] {
	cursor: pointer;
	user-select: none;
}

.cfxcm-table__th[data-cfxcm-sort]::after {
	content: "";
	display: inline-block;
	width: 0.6em;
	margin-left: 0.35em;
	opacity: 0.35;
}

.cfxcm-table__th[aria-sort="ascending"]::after {
	content: "\2191";
	opacity: 1;
}

.cfxcm-table__th[aria-sort="descending"]::after {
	content: "\2193";
	opacity: 1;
}

.cfxcm-table__td {
	padding: 0.6rem 0.75rem;
	border-bottom: 1px solid var(--cfxcm-border, rgba(0, 0, 0, 0.08));
	text-align: right;
	white-space: nowrap;
}

.cfxcm-table__td--rank,
.cfxcm-table__td--name {
	text-align: left;
	font-weight: 400;
}

.cfxcm-table__td--rank {
	color: var(--cfxcm-muted, #6b7280);
	width: 3rem;
}

.cfxcm-table__td--spark {
	width: 130px;
}

.cfxcm-table__row[hidden] {
	display: none;
}

.cfxcm-table.is-compact .cfxcm-table__td,
.cfxcm-table.is-compact .cfxcm-table__th {
	padding: 0.4rem 0.5rem;
}

.cfxcm-table__pager {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-top: 0.75rem;
}

.cfxcm-table__pager[hidden] {
	display: none;
}

.cfxcm-table__pager-status {
	margin: 0;
	color: var(--cfxcm-muted, #6b7280);
	font-size: var(--cfx-fs-xs, 0.8125rem);
}

/* -------------------------------------------------------------------------
 * Ticker
 * ---------------------------------------------------------------------- */

.cfxcm-ticker {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	overflow: hidden;
	padding: 0.5rem 0;
	border-block: 1px solid var(--cfxcm-border, rgba(0, 0, 0, 0.1));
}

.cfxcm-ticker__viewport {
	display: flex;
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
}

.cfxcm-ticker__track {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 1.5rem;
	margin: 0;
	padding: 0 0.75rem;
	list-style: none;
	white-space: nowrap;
	animation: cfxcm-marquee 45s linear infinite;
}

.cfxcm-ticker.is-paused .cfxcm-ticker__track {
	animation-play-state: paused;
}

.cfxcm-ticker:hover .cfxcm-ticker__track,
.cfxcm-ticker:focus-within .cfxcm-ticker__track {
	animation-play-state: paused;
}

@keyframes cfxcm-marquee {
	from {
		transform: translateX(0);
	}
	to {
		transform: translateX(-100%);
	}
}

.cfxcm-ticker__item {
	display: inline-flex;
	align-items: center;
}

.cfxcm-ticker__link {
	display: inline-flex;
	align-items: baseline;
	gap: 0.4rem;
	color: inherit;
	text-decoration: none;
}

.cfxcm-ticker__symbol {
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.cfxcm-ticker__price {
	font-variant-numeric: tabular-nums;
}

.cfxcm-ticker.is-compact {
	font-size: var(--cfx-fs-sm, 0.9375rem);
}

/* The pause control is a WCAG requirement for moving content, not an
   enhancement, so it is always rendered and never hidden on small screens. */
.cfxcm-ticker__pause {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	padding: 0;
	border: 1px solid var(--cfxcm-border, rgba(0, 0, 0, 0.1));
	border-radius: 50%;
	background: var(--cfxcm-surface, #fff);
	color: inherit;
	cursor: pointer;
}

.cfxcm-ticker__pause-icon {
	display: block;
	width: 0.65rem;
	height: 0.65rem;
	border-left: 3px solid currentColor;
	border-right: 3px solid currentColor;
}

.cfxcm-ticker__pause[aria-pressed="true"] .cfxcm-ticker__pause-icon {
	width: 0;
	height: 0;
	border-left: 0.65rem solid currentColor;
	border-right: 0;
	border-top: 0.4rem solid transparent;
	border-bottom: 0.4rem solid transparent;
}

@media (prefers-reduced-motion: reduce) {
	.cfxcm-ticker__track {
		animation: none;
	}

	.cfxcm-ticker__viewport {
		overflow-x: auto;
	}
}

/* -------------------------------------------------------------------------
 * Dominance
 * ---------------------------------------------------------------------- */

.cfxcm-dominance {
	list-style: none;
	margin: 0;
	padding: 0;
}

.cfxcm-dominance__row {
	display: grid;
	grid-template-columns: 4rem 1fr 4rem;
	align-items: center;
	gap: 0.75rem;
	padding: 0.35rem 0;
}

.cfxcm-dominance__symbol {
	font-weight: 700;
	text-transform: uppercase;
	font-size: var(--cfx-fs-sm, 0.9375rem);
}

.cfxcm-dominance__bar {
	display: block;
	height: 0.6rem;
	border-radius: 999px;
	background: var(--cfxcm-surface-alt, #f6f7f9);
	overflow: hidden;
}

.cfxcm-dominance__fill {
	display: block;
	height: 100%;
	width: var(--cfxcm-width, 0%);
	border-radius: inherit;
	background: var(--cfxcm-accent, #2563eb);
}

.cfxcm-dominance__row--other .cfxcm-dominance__fill {
	background: var(--cfxcm-muted, #6b7280);
}

.cfxcm-dominance__value {
	text-align: right;
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

/* -------------------------------------------------------------------------
 * Sentiment gauge
 * ---------------------------------------------------------------------- */

.cfxcm-gauge {
	text-align: center;
}

.cfxcm-gauge__dial {
	max-width: 260px;
	margin: 0 auto;
}

.cfxcm-gauge__dial svg {
	display: block;
	width: 100%;
	height: auto;
}

.cfxcm-gauge__track {
	stroke: var(--cfxcm-surface-alt, #f6f7f9);
}

/* The arc length is 251 units for an 80-unit radius half circle; the dash
   offset walks it back proportionally to the index value. */
.cfxcm-gauge__arc {
	stroke: currentColor;
	stroke-dasharray: 251;
	stroke-dashoffset: calc(251 - (251 * var(--cfxcm-gauge-value, 0) / 100));
	transition: stroke-dashoffset 0.6s ease;
}

.cfxcm-gauge__needle {
	stroke: currentColor;
	transform: rotate(var(--cfxcm-gauge-angle, 0deg));
	transform-origin: 100px 100px;
	transition: transform 0.6s ease;
}

.cfxcm-gauge__hub {
	fill: currentColor;
}

.cfxcm-gauge--extreme-fear {
	color: var(--cfxcm-down, #dc2626);
}

.cfxcm-gauge--fear {
	color: #ea580c;
}

.cfxcm-gauge--neutral {
	color: #ca8a04;
}

.cfxcm-gauge--greed {
	color: #65a30d;
}

.cfxcm-gauge--extreme-greed {
	color: var(--cfxcm-up, #16a34a);
}

.cfxcm-gauge__value {
	margin: 0.25rem 0 0;
	font-size: var(--cfx-fs-xl, 1.5rem);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.cfxcm-gauge__scale {
	font-size: 0.6em;
	font-weight: 400;
	color: var(--cfxcm-muted, #6b7280);
}

.cfxcm-gauge__label {
	margin: 0;
	font-weight: 600;
}

.cfxcm-gauge__source {
	margin: 0.5rem 0 0;
	font-size: var(--cfx-fs-xs, 0.8125rem);
	color: var(--cfxcm-muted, #6b7280);
}

/* -------------------------------------------------------------------------
 * Converter
 * ---------------------------------------------------------------------- */

.cfxcm-converter__row {
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
	align-items: flex-end;
}

.cfxcm-converter__actions {
	margin-top: 0.75rem;
}

.cfxcm-converter__result {
	margin-top: 0.75rem;
	padding: 0.75rem;
	border-radius: var(--cfxcm-radius-sm, 6px);
	background: var(--cfxcm-surface-alt, #f6f7f9);
}

.cfxcm-converter__result p {
	margin: 0;
}

.cfxcm-converter__amount {
	font-size: var(--cfx-fs-lg, 1.125rem);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.cfxcm-converter__rate,
.cfxcm-converter__hint {
	color: var(--cfxcm-muted, #6b7280);
	font-size: var(--cfx-fs-xs, 0.8125rem);
}

.cfxcm-converter.is-compact .cfxcm-converter__row {
	flex-direction: column;
	align-items: stretch;
}

/* -------------------------------------------------------------------------
 * In-article and sidebar
 * ---------------------------------------------------------------------- */

.cfxcm-in-article {
	margin: 1.5rem 0;
}

.cfxcm-in-article__body {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.cfxcm-in-article__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	margin-top: 0.6rem;
	padding-top: 0.6rem;
	border-top: 1px solid var(--cfxcm-border, rgba(0, 0, 0, 0.08));
}

.cfxcm-in-article__link {
	font-size: var(--cfx-fs-xs, 0.8125rem);
	font-weight: 600;
	text-decoration: none;
}

.cfxcm-in-article__foot .cfxcm-freshness {
	margin: 0;
}

.cfxcm-asset-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.cfxcm-asset-header__identity {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

@media (max-width: 600px) {
	.cfxcm-table__td--volume,
	.cfxcm-table__th--volume {
		display: none;
	}
}

/* -------------------------------------------------------------------------
 * Live update flash
 *
 * A brief tint when a polled value changes, so a reader notices the update
 * without the layout moving. Suppressed entirely under reduced motion.
 * ---------------------------------------------------------------------- */

.is-flash-up {
	animation: cfxcm-flash-up 0.7s ease-out;
}

.is-flash-down {
	animation: cfxcm-flash-down 0.7s ease-out;
}

@keyframes cfxcm-flash-up {
	from {
		color: var(--cfxcm-up, #16a34a);
	}
	to {
		color: inherit;
	}
}

@keyframes cfxcm-flash-down {
	from {
		color: var(--cfxcm-down, #dc2626);
	}
	to {
		color: inherit;
	}
}
