/**
 * 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, #0B1E36);
	overflow: hidden;
	font-family: var(--mp-font-family, 'JetBrains Mono', 'SF Mono', 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%;
	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--top {
		padding-top: calc(var(--mp-bar-height, 35px) - 4px) !important;
	}

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

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

	.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;
	}
}

/* ──────────────────────────────────────────────
   Financial Card Widget — [marketpulse_card]
   ────────────────────────────────────────────── */

.marketpulse-card-widget {
	display: block;
	width: 100%;
	max-width: var(--mp-card-max-width, 380px);
	margin: 16px 0;
	border-radius: 14px;
	box-sizing: border-box;
	font-family: var(--mp-font-family, 'JetBrains Mono', 'SF Mono', monospace);
	overflow: hidden;
	transition: all 0.25s ease;
}

.marketpulse-card-widget *,
.marketpulse-card-widget *::before,
.marketpulse-card-widget *::after {
	box-sizing: border-box;
}

/* ── Light Theme (Default / User Reference) ── */
.marketpulse-card--light {
	background: #FFFFFF;
	border: 1px solid #E2E8F0;
	box-shadow: none;
	color: #1E293B;
}

.marketpulse-card--light .marketpulse-card-row:nth-child(odd) {
	background: #F1F5F9;
}

.marketpulse-card--light .marketpulse-card-row:nth-child(even) {
	background: #FFFFFF;
}

.marketpulse-card--light .marketpulse-card-row:hover {
	background: #E2E8F0;
}

.marketpulse-card--light .marketpulse-card-row__label {
	color: #0284C7;
}

.marketpulse-card--light .marketpulse-card-row__value {
	color: #1E293B;
}

.marketpulse-card--light .marketpulse-card__header {
	background: #F8FAFC;
	border-bottom: 1px solid #E2E8F0;
}

.marketpulse-card--light .marketpulse-card__title {
	color: #0F172A;
}

.marketpulse-card--light .marketpulse-card__time {
	color: #64748B;
}

/* ── Navy Theme (Institutional Finance) ── */
.marketpulse-card--navy {
	background: #0B1E36;
	border: 1px solid rgba(255, 255, 255, 0.1);
	box-shadow: none;
	color: #FFFFFF;
}

.marketpulse-card--navy .marketpulse-card-row:nth-child(odd) {
	background: rgba(255, 255, 255, 0.04);
}

.marketpulse-card--navy .marketpulse-card-row:nth-child(even) {
	background: transparent;
}

.marketpulse-card--navy .marketpulse-card-row:hover {
	background: rgba(56, 189, 248, 0.08);
}

.marketpulse-card--navy .marketpulse-card-row__label {
	color: #38BDF8;
}

.marketpulse-card--navy .marketpulse-card-row__value {
	color: #F8FAFC;
}

.marketpulse-card--navy .marketpulse-card__header {
	background: rgba(255, 255, 255, 0.03);
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.marketpulse-card--navy .marketpulse-card__title {
	color: #FFFFFF;
}

.marketpulse-card--navy .marketpulse-card__time {
	color: rgba(255, 255, 255, 0.5);
}

/* ── Dark Theme (Carbon Midnight) ── */
.marketpulse-card--dark {
	background: #111827;
	border: 1px solid #1F2937;
	box-shadow: none;
	color: #F9FAFB;
}

.marketpulse-card--dark .marketpulse-card-row:nth-child(odd) {
	background: rgba(255, 255, 255, 0.03);
}

.marketpulse-card--dark .marketpulse-card-row:nth-child(even) {
	background: transparent;
}

.marketpulse-card--dark .marketpulse-card-row:hover {
	background: rgba(255, 255, 255, 0.06);
}

.marketpulse-card--dark .marketpulse-card-row__label {
	color: #60A5FA;
}

.marketpulse-card--dark .marketpulse-card-row__value {
	color: #F3F4F6;
}

.marketpulse-card--dark .marketpulse-card__header {
	background: #0F172A;
	border-bottom: 1px solid #1F2937;
}

.marketpulse-card--dark .marketpulse-card__title {
	color: #F9FAFB;
}

.marketpulse-card--dark .marketpulse-card__time {
	color: #9CA3AF;
}

/* ── Header ── */
.marketpulse-card__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 18px;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
}

.marketpulse-card__title {
	display: flex;
	align-items: center;
	gap: 8px;
}

.marketpulse-card__pulse-dot {
	display: inline-block;
	width: 8px;
	height: 8px;
	background: #10B981;
	border-radius: 50%;
	box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
	animation: mpPulse 2s infinite;
}

@keyframes mpPulse {
	0% {
		box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
	}
	70% {
		box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
	}
}

.marketpulse-card__time {
	font-size: 11px;
	font-weight: 500;
	opacity: 0.8;
}

/* ── Row & Content ── */
.marketpulse-card__list {
	padding: 6px;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.marketpulse-card-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 14px;
	border-radius: 8px;
	font-size: 13.5px;
	line-height: 1.4;
	transition: background 0.15s ease;
}

.marketpulse-card-row__left {
	display: inline-flex;
	align-items: center;
	gap: 9px;
	font-weight: 500;
	letter-spacing: 0.02em;
}

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

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

.marketpulse-card-row__label {
	font-size: 13px;
	letter-spacing: 0.02em;
}

.marketpulse-card-row__right {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	text-align: right;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.marketpulse-card-row__arrow {
	font-size: 11px;
	line-height: 1;
}

.marketpulse-card-row__value {
	font-weight: 600;
	letter-spacing: 0.01em;
}

.marketpulse-card-row__change {
	font-size: 11.5px;
	font-weight: 500;
	margin-left: 2px;
}

/* Direction Colors */
.marketpulse-card-row--positive .marketpulse-card-row__arrow,
.marketpulse-card-row--positive .marketpulse-card-row__change {
	color: #10B981;
}

.marketpulse-card-row--negative .marketpulse-card-row__arrow,
.marketpulse-card-row--negative .marketpulse-card-row__change {
	color: #EF4444;
}

.marketpulse-card-row--neutral .marketpulse-card-row__arrow,
.marketpulse-card-row--neutral .marketpulse-card-row__change {
	color: #94A3B8;
}

/* ── Columns (Grid layout for wider containers) ── */
.marketpulse-card--cols-2 {
	max-width: var(--mp-card-max-width, 760px);
}

.marketpulse-card--cols-2 .marketpulse-card__list {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 6px;
}

.marketpulse-card--cols-3 {
	max-width: var(--mp-card-max-width, 1140px);
}

.marketpulse-card--cols-3 .marketpulse-card__list {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 6px;
}

@media (max-width: 680px) {
	.marketpulse-card--cols-2 .marketpulse-card__list,
	.marketpulse-card--cols-3 .marketpulse-card__list {
		grid-template-columns: 1fr;
	}
}

.marketpulse-card__empty {
	padding: 24px;
	text-align: center;
	font-size: 12px;
	opacity: 0.7;
}
