/**
 * Trading Performance Calendar — frontend styles.
 * Designed to match the STEEV GTS visual identity (steevgts.com):
 * white premium SaaS surfaces, #5260FE indigo accent, large soft radii,
 * diffused shadows, refined green/red performance tones.
 * Typography is inherited from the active theme so it always matches the site.
 */

/* ---------- Design tokens ---------- */
.tpc-calendar {
	--tpc-accent: #5260FE;
	--tpc-accent-soft: #EEF0FF;
	--tpc-accent-glow: rgba(82, 96, 254, 0.22);

	--tpc-bg: #FFFFFF;
	--tpc-surface: #F7F8FC;
	--tpc-border: #ECEEF6;
	--tpc-text: #0B0D1C;
	--tpc-text-soft: #5A607A;
	--tpc-text-faint: #9AA0B8;

	--tpc-green: #0B9E6C;
	--tpc-green-deep: #067A52;
	--tpc-green-bg-1: #F0FBF6;
	--tpc-green-bg-2: #DDF5EA;
	--tpc-green-bg-3: #C2EDDA;
	--tpc-green-border: #A9E4CB;

	--tpc-red: #E5484D;
	--tpc-red-deep: #C22F35;
	--tpc-red-bg-1: #FEF4F4;
	--tpc-red-bg-2: #FCE2E3;
	--tpc-red-bg-3: #F9CBCD;
	--tpc-red-border: #F5B5B8;

	--tpc-flat: #5A607A;
	--tpc-flat-bg: #F3F4F9;
	--tpc-flat-border: #DDE0EC;

	--tpc-radius: 24px;
	--tpc-radius-md: 16px;
	--tpc-radius-sm: 12px;
	--tpc-shadow:
		0 1px 2px rgba(11, 13, 28, 0.04),
		0 24px 60px -16px rgba(23, 28, 80, 0.12);
	--tpc-shadow-hover:
		0 2px 6px rgba(11, 13, 28, 0.06),
		0 10px 24px -6px rgba(23, 28, 80, 0.16);

	position: relative;
	box-sizing: border-box;
	max-width: 880px;
	margin: 0 auto;
	padding: clamp(20px, 4vw, 36px);
	background: var(--tpc-bg);
	border: 1px solid var(--tpc-border);
	border-radius: var(--tpc-radius);
	box-shadow: var(--tpc-shadow);
	color: var(--tpc-text);
	font-family: inherit; /* blend with the site's typography */
	line-height: 1.45;
	overflow: hidden;
	animation: tpc-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Soft indigo sheen along the top edge — subtle premium detail. */
.tpc-calendar::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 160px;
	background:
		radial-gradient(120% 100% at 50% 0%, var(--tpc-accent-glow) 0%, rgba(82, 96, 254, 0) 62%);
	opacity: 0.35;
	pointer-events: none;
}

.tpc-calendar > * {
	position: relative;
}

.tpc-calendar *,
.tpc-calendar *::before,
.tpc-calendar *::after {
	box-sizing: inherit;
}

/* ---------- Dark theme (optional via theme="dark" or theme="auto") ---------- */
.tpc-theme-dark {
	--tpc-accent: #6E7BFF;
	--tpc-accent-soft: rgba(110, 123, 255, 0.14);
	--tpc-accent-glow: rgba(110, 123, 255, 0.25);

	--tpc-bg: #0D1022;
	--tpc-surface: #151936;
	--tpc-border: #23284A;
	--tpc-text: #F2F3FA;
	--tpc-text-soft: #9AA0C2;
	--tpc-text-faint: #676D93;

	--tpc-green: #3DD68C;
	--tpc-green-deep: #6FE3AC;
	--tpc-green-bg-1: rgba(61, 214, 140, 0.08);
	--tpc-green-bg-2: rgba(61, 214, 140, 0.16);
	--tpc-green-bg-3: rgba(61, 214, 140, 0.26);
	--tpc-green-border: rgba(61, 214, 140, 0.38);

	--tpc-red: #FF7076;
	--tpc-red-deep: #FF9AA0;
	--tpc-red-bg-1: rgba(255, 112, 118, 0.08);
	--tpc-red-bg-2: rgba(255, 112, 118, 0.16);
	--tpc-red-bg-3: rgba(255, 112, 118, 0.26);
	--tpc-red-border: rgba(255, 112, 118, 0.38);

	--tpc-flat: #B9BEDA;
	--tpc-flat-bg: rgba(148, 156, 200, 0.12);
	--tpc-flat-border: rgba(148, 156, 200, 0.32);

	--tpc-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 24px 60px -12px rgba(0, 0, 0, 0.55);
	--tpc-shadow-hover: 0 4px 14px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
	.tpc-theme-auto {
		--tpc-accent: #6E7BFF;
		--tpc-accent-soft: rgba(110, 123, 255, 0.14);
		--tpc-accent-glow: rgba(110, 123, 255, 0.25);

		--tpc-bg: #0D1022;
		--tpc-surface: #151936;
		--tpc-border: #23284A;
		--tpc-text: #F2F3FA;
		--tpc-text-soft: #9AA0C2;
		--tpc-text-faint: #676D93;

		--tpc-green: #3DD68C;
		--tpc-green-deep: #6FE3AC;
		--tpc-green-bg-1: rgba(61, 214, 140, 0.08);
		--tpc-green-bg-2: rgba(61, 214, 140, 0.16);
		--tpc-green-bg-3: rgba(61, 214, 140, 0.26);
		--tpc-green-border: rgba(61, 214, 140, 0.38);

		--tpc-red: #FF7076;
		--tpc-red-deep: #FF9AA0;
		--tpc-red-bg-1: rgba(255, 112, 118, 0.08);
		--tpc-red-bg-2: rgba(255, 112, 118, 0.16);
		--tpc-red-bg-3: rgba(255, 112, 118, 0.26);
		--tpc-red-border: rgba(255, 112, 118, 0.38);

		--tpc-flat: #B9BEDA;
		--tpc-flat-bg: rgba(148, 156, 200, 0.12);
		--tpc-flat-border: rgba(148, 156, 200, 0.32);

		--tpc-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 24px 60px -12px rgba(0, 0, 0, 0.55);
		--tpc-shadow-hover: 0 4px 14px rgba(0, 0, 0, 0.5);
	}
}

/* ---------- Header ---------- */
.tpc-header {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px 24px;
	margin-bottom: 22px;
}

.tpc-eyebrow {
	display: inline-block;
	margin-bottom: 6px;
	padding: 5px 12px;
	background: var(--tpc-accent-soft);
	border-radius: 999px;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--tpc-accent);
}

.tpc-month-label {
	margin: 0;
	font-size: clamp(22px, 3.4vw, 28px);
	font-weight: 800;
	letter-spacing: -0.025em;
	line-height: 1.15;
	color: var(--tpc-text);
}

.tpc-header-right {
	display: flex;
	align-items: center;
	gap: 14px;
}

/* Hero monthly total */
.tpc-hero {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 1px;
	padding: 10px 18px;
	background: var(--tpc-surface);
	border: 1px solid var(--tpc-border);
	border-radius: var(--tpc-radius-md);
}

.tpc-hero-value {
	font-size: clamp(22px, 3.2vw, 30px);
	font-weight: 800;
	letter-spacing: -0.03em;
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
	color: var(--tpc-text);
}

.tpc-hero.tpc-pos {
	background: var(--tpc-green-bg-1);
	border-color: var(--tpc-green-border);
}
.tpc-hero.tpc-pos .tpc-hero-value { color: var(--tpc-green); }

.tpc-hero.tpc-neg {
	background: var(--tpc-red-bg-1);
	border-color: var(--tpc-red-border);
}
.tpc-hero.tpc-neg .tpc-hero-value { color: var(--tpc-red); }

.tpc-hero.tpc-flat .tpc-hero-value { color: var(--tpc-flat); }

.tpc-hero-caption {
	font-size: 10.5px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.09em;
	color: var(--tpc-text-faint);
}

/* Navigation */
.tpc-nav {
	display: flex;
	gap: 8px;
	flex-shrink: 0;
}

.tpc-nav-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	background: rgba(255, 255, 255, 0.65);
	-webkit-backdrop-filter: blur(8px);
	backdrop-filter: blur(8px);
	border: 1px solid var(--tpc-border);
	border-radius: 999px;
	color: var(--tpc-text-soft);
	cursor: pointer;
	transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.tpc-theme-dark .tpc-nav-btn {
	background: rgba(21, 25, 54, 0.65);
}

.tpc-nav-btn:hover {
	color: #fff;
	background: var(--tpc-accent);
	border-color: var(--tpc-accent);
	transform: translateY(-1px);
	box-shadow: 0 8px 20px -6px var(--tpc-accent-glow);
}

.tpc-nav-btn:focus-visible {
	outline: 2px solid var(--tpc-accent);
	outline-offset: 2px;
}

.tpc-nav-btn:disabled {
	opacity: 0.5;
	cursor: wait;
}

/* ---------- Win/Loss ratio bar ---------- */
.tpc-ratio {
	margin-bottom: 18px;
}

.tpc-ratio-track {
	height: 8px;
	border-radius: 999px;
	background: var(--tpc-red-bg-2);
	overflow: hidden;
}

.tpc-ratio-win {
	display: block;
	height: 100%;
	border-radius: 999px;
	background: linear-gradient(90deg, var(--tpc-green) 0%, #23c589 100%);
	transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.tpc-ratio-caption {
	display: flex;
	justify-content: space-between;
	margin-top: 6px;
	font-size: 11.5px;
	font-weight: 600;
}

.tpc-ratio-wins { color: var(--tpc-green); }
.tpc-ratio-losses { color: var(--tpc-red); }

/* ---------- Stats cards ---------- */
.tpc-stats {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 10px;
	margin-bottom: 22px;
}

.tpc-stat {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 14px 16px;
	background: var(--tpc-surface);
	border: 1px solid var(--tpc-border);
	border-radius: var(--tpc-radius-md);
	transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.tpc-stat:hover {
	transform: translateY(-3px);
	border-color: var(--tpc-accent-glow);
	box-shadow: var(--tpc-shadow-hover);
}

.tpc-stat-label {
	font-size: 10.5px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--tpc-text-faint);
	white-space: nowrap;
}

.tpc-stat-value {
	font-size: 20px;
	font-weight: 800;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
	color: var(--tpc-text);
}

.tpc-stat-value.tpc-pos { color: var(--tpc-green); }
.tpc-stat-value.tpc-neg { color: var(--tpc-red); }
.tpc-stat-value.tpc-flat { color: var(--tpc-flat); }

.tpc-stat-sub {
	font-size: 11px;
	color: var(--tpc-text-soft);
	font-variant-numeric: tabular-nums;
	min-height: 14px;
}

/* ---------- Calendar grid ---------- */
.tpc-grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 7px;
}

.tpc-dow {
	padding: 6px 0 9px;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.09em;
	text-align: center;
	color: var(--tpc-text-faint);
}

.tpc-day {
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	min-height: 76px;
	padding: 9px 10px;
	border-radius: var(--tpc-radius-sm);
	border: 1px solid transparent;
	transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}

.tpc-blank {
	background: transparent;
	border: none;
	min-height: 0;
}

.tpc-empty {
	background: var(--tpc-surface);
	border-color: var(--tpc-border);
}

.tpc-empty .tpc-daynum {
	color: var(--tpc-text-faint);
}

/* Profit — deeper shade = larger move */
.tpc-pos { background: var(--tpc-green-bg-2); border-color: var(--tpc-green-border); }
.tpc-pos.tpc-i1 { background: var(--tpc-green-bg-1); }
.tpc-pos.tpc-i2 { background: var(--tpc-green-bg-2); }
.tpc-pos.tpc-i3 { background: var(--tpc-green-bg-3); }

/* Loss — deeper shade = larger move */
.tpc-neg { background: var(--tpc-red-bg-2); border-color: var(--tpc-red-border); }
.tpc-neg.tpc-i1 { background: var(--tpc-red-bg-1); }
.tpc-neg.tpc-i2 { background: var(--tpc-red-bg-2); }
.tpc-neg.tpc-i3 { background: var(--tpc-red-bg-3); }

.tpc-flat {
	background: var(--tpc-flat-bg);
	border-color: var(--tpc-flat-border);
}

.tpc-day:not(.tpc-blank):hover {
	transform: translateY(-3px) scale(1.03);
	box-shadow: var(--tpc-shadow-hover);
	z-index: 1;
}

.tpc-daynum {
	font-size: 11.5px;
	font-weight: 700;
	color: var(--tpc-text-soft);
	font-variant-numeric: tabular-nums;
}

.tpc-value {
	align-self: flex-end;
	font-size: 14.5px;
	font-weight: 800;
	letter-spacing: -0.01em;
	font-variant-numeric: tabular-nums;
}

.tpc-pos .tpc-value { color: var(--tpc-green-deep); }
.tpc-neg .tpc-value { color: var(--tpc-red-deep); }
.tpc-flat .tpc-value { color: var(--tpc-flat); }

/* Best / worst day markers */
.tpc-best::after,
.tpc-worst::after {
	content: "";
	position: absolute;
	top: 9px;
	right: 9px;
	width: 0;
	height: 0;
	border-left: 4px solid transparent;
	border-right: 4px solid transparent;
}

.tpc-best::after {
	border-bottom: 6px solid var(--tpc-green);
}

.tpc-worst::after {
	border-top: 6px solid var(--tpc-red);
}

/* Today — indigo ring, matches the site accent */
.tpc-today {
	box-shadow: inset 0 0 0 2px var(--tpc-accent);
}

.tpc-today .tpc-daynum {
	color: var(--tpc-accent);
}

/* ---------- Legend ---------- */
.tpc-legend {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 8px 20px;
	margin-top: 20px;
	padding-top: 18px;
	border-top: 1px solid var(--tpc-border);
}

.tpc-legend-item {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	font-size: 12px;
	font-weight: 600;
	color: var(--tpc-text-soft);
}

.tpc-legend-note {
	margin-left: auto;
	font-size: 11px;
	color: var(--tpc-text-faint);
}

.tpc-dot {
	width: 10px;
	height: 10px;
	border-radius: 4px;
	display: inline-block;
}

.tpc-dot-pos { background: var(--tpc-green-bg-2); border: 1.5px solid var(--tpc-green); }
.tpc-dot-neg { background: var(--tpc-red-bg-2); border: 1.5px solid var(--tpc-red); }
.tpc-dot-flat { background: var(--tpc-flat-bg); border: 1.5px solid var(--tpc-flat); }
.tpc-dot-empty { background: var(--tpc-surface); border: 1.5px solid var(--tpc-border); }

/* ---------- Animations ---------- */
@keyframes tpc-rise {
	from { opacity: 0; transform: translateY(10px); }
	to   { opacity: 1; transform: translateY(0); }
}

.tpc-loading {
	opacity: 0.55;
	pointer-events: none;
	transition: opacity 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
	.tpc-calendar,
	.tpc-calendar * {
		animation: none !important;
		transition: none !important;
	}
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
	.tpc-stats {
		grid-template-columns: repeat(2, 1fr);
	}
	.tpc-day {
		min-height: 62px;
		padding: 7px 8px;
	}
	.tpc-value {
		font-size: 12.5px;
	}
	.tpc-hero {
		align-items: flex-start;
	}
}

@media (max-width: 480px) {
	.tpc-calendar {
		padding: 16px;
		border-radius: 18px;
	}
	.tpc-header {
		gap: 12px;
	}
	.tpc-header-right {
		width: 100%;
		justify-content: space-between;
	}
	.tpc-stats {
		gap: 8px;
	}
	.tpc-stat {
		padding: 11px 12px;
		border-radius: 12px;
	}
	.tpc-stat-value {
		font-size: 16px;
	}
	.tpc-grid {
		gap: 4px;
	}
	.tpc-day {
		min-height: 50px;
		padding: 5px 6px;
		border-radius: 9px;
	}
	.tpc-daynum {
		font-size: 9.5px;
	}
	.tpc-value {
		font-size: 10.5px;
		letter-spacing: -0.02em;
	}
	.tpc-dow {
		font-size: 9px;
	}
	.tpc-best::after,
	.tpc-worst::after {
		top: 6px;
		right: 6px;
	}
	.tpc-legend-note {
		margin-left: 0;
		width: 100%;
	}
}
