/**
 * MarketPulse Ticker — Frontend Styles
 *
 * CSS-only infinite horizontal scroll ticker.
 * Uses CSS custom properties for dynamic theming.
 * Zero dependencies on Bootstrap, jQuery, or theme styles.
 *
 * @package MarketPulse
 */

/* ──────────────────────────────────────────────
   Reset — Prevent theme interference
   ────────────────────────────────────────────── */

#marketpulse-ticker,
#marketpulse-ticker *,
#marketpulse-ticker *::before,
#marketpulse-ticker *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
	text-decoration: none;
	line-height: 1;
}

/* ──────────────────────────────────────────────
   Ticker Bar — Base styles (inline mode)
   ────────────────────────────────────────────── */

.marketpulse-bar {
	position: relative;
	left: 0;
	right: 0;
	z-index: 999999;
	height: var(--mp-bar-height, 35px);
	background: var(--mp-bg, #1A4731);
	overflow: hidden;
	font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
	font-size: var(--mp-font-size, 13px);
	font-weight: 400;
	color: var(--mp-text, #FFFFFF);
	white-space: nowrap;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	user-select: none;
}

/* ──────────────────────────────────────────────
   Position: Fixed Top
   ────────────────────────────────────────────── */

.marketpulse-pos--top {
	position: fixed;
	top: 0;
}

body.marketpulse-has-bar--top {
	padding-top: var(--mp-bar-height, 35px) !important;
}

/* ──────────────────────────────────────────────
   Position: Fixed Bottom
   ────────────────────────────────────────────── */

.marketpulse-pos--bottom {
	position: fixed;
	top: auto;
	bottom: 0;
	border-bottom: none;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

body.marketpulse-has-bar--bottom {
	padding-bottom: var(--mp-bar-height, 35px) !important;
}

/* ──────────────────────────────────────────────
   Track — Scrolling container
   ────────────────────────────────────────────── */

.marketpulse-track {
	display: flex;
	width: max-content;
	height: 100%;
	align-items: center;
	animation: marketpulse-scroll var(--mp-speed, 35s) linear infinite;
	will-change: transform;
}

/* ──────────────────────────────────────────────
   Pause on Hover
   ────────────────────────────────────────────── */

.marketpulse-bar--pausable .marketpulse-track:hover {
	animation-play-state: paused;
}

/* ──────────────────────────────────────────────
   Scroll Animation
   ────────────────────────────────────────────── */

@keyframes marketpulse-scroll {
	0% {
		transform: translateX(0);
	}
	100% {
		transform: translateX(-50%);
	}
}

/* ──────────────────────────────────────────────
   Content — Duplicated for seamless loop
   ────────────────────────────────────────────── */

.marketpulse-content {
	display: inline-flex;
	align-items: center;
	height: 100%;
	padding: 0 24px;
	gap: 0;
	flex-shrink: 0;
}

/* ──────────────────────────────────────────────
   Individual Ticker Items
   ────────────────────────────────────────────── */

.marketpulse-item {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 0 24px;
	height: 100%;
	color: var(--mp-text, #FFFFFF);
	letter-spacing: 0.02em;
	transition: opacity 0.2s ease;
}

.marketpulse-item:hover {
	opacity: 0.85;
}

/* Direction colors */
.marketpulse-item--positive .marketpulse-arrow,
.marketpulse-item--positive .marketpulse-change {
	color: var(--mp-positive, #00E676);
}

.marketpulse-item--negative .marketpulse-arrow,
.marketpulse-item--negative .marketpulse-change {
	color: var(--mp-negative, #FF5252);
}

.marketpulse-item--neutral .marketpulse-arrow,
.marketpulse-item--neutral .marketpulse-change {
	color: var(--mp-neutral, #B0BEC5);
}

/* ──────────────────────────────────────────────
   Item Sub-elements
   ────────────────────────────────────────────── */

.marketpulse-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	opacity: 0.7;
	flex-shrink: 0;
}

.marketpulse-icon svg {
	width: 14px;
	height: 14px;
	display: block;
}

.marketpulse-label {
	font-weight: 600;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	opacity: 0.85;
}

.marketpulse-arrow {
	font-size: calc(var(--mp-font-size, 13px) - 3px);
	line-height: 1;
}

.marketpulse-value {
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.01em;
	font-weight: 500;
}

.marketpulse-change {
	font-size: calc(var(--mp-font-size, 13px) - 1px);
	opacity: 0.75;
	font-variant-numeric: tabular-nums;
}

/* ──────────────────────────────────────────────
   Separator
   ────────────────────────────────────────────── */

.marketpulse-separator {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 100%;
	position: relative;
}

.marketpulse-separator::before {
	content: '';
	width: 1px;
	height: 14px;
	background: var(--mp-separator, rgba(255, 255, 255, 0.15));
	border-radius: 1px;
}

/* ──────────────────────────────────────────────
   Responsive — Tablet
   ────────────────────────────────────────────── */

@media (max-width: 1024px) {

	.marketpulse-bar {
		font-size: calc(var(--mp-font-size, 13px) - 1px);
	}

	.marketpulse-item {
		padding: 0 12px;
		gap: 4px;
	}

	.marketpulse-separator {
		width: 14px;
	}
}

/* ──────────────────────────────────────────────
   Responsive — Mobile
   ────────────────────────────────────────────── */

@media (max-width: 600px) {

	.marketpulse-bar {
		font-size: calc(var(--mp-font-size, 13px) - 2px);
		height: calc(var(--mp-bar-height, 35px) - 4px);
	}

	body.marketpulse-has-bar {
		padding-top: calc(var(--mp-bar-height, 35px) - 4px) !important;
	}

	.marketpulse-item {
		padding: 0 8px;
		gap: 3px;
	}

	.marketpulse-content {
		padding: 0 12px;
	}

	.marketpulse-separator {
		width: 10px;
		font-size: 6px;
	}
}

/* ──────────────────────────────────────────────
   Accessibility — Reduced Motion
   ────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {

	.marketpulse-track {
		animation: none;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
	}
}

/* ──────────────────────────────────────────────
   WordPress Admin Bar Adjustment (Top only)
   ────────────────────────────────────────────── */

.admin-bar .marketpulse-pos--top {
	top: 32px;
}

@media (max-width: 782px) {
	.admin-bar .marketpulse-pos--top {
		top: 46px;
	}
}
