/* ==========================================================================
   TuServerMu - User Hover Card (tsmu-usercard)
   Shown when the mouse rests on a username / avatar link.
   Markup is produced by Themes/default/scripts/usercard.js
   Data comes from index.php?action=usercard;u=<id>  (Sources/UserCard.php)
   ========================================================================== */

.tsmu-uc {
	--uc-accent: #2563eb;
	--uc-accent-soft: rgba(37, 99, 235, 0.12);
	position: absolute;
	z-index: 9999;
	width: 344px;
	max-width: calc(100vw - 24px);
	box-sizing: border-box;
	border: 1px solid #d9e6f5;
	border-radius: 14px;
	background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
	box-shadow: 0 24px 54px rgba(15, 23, 42, 0.22), 0 2px 6px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.95);
	color: #0f2744;
	font-size: 13px;
	line-height: 1.45;
	text-align: left;
	overflow: hidden;
	opacity: 0;
	transform: translateY(8px) scale(0.985);
	transition: opacity 0.16s ease, transform 0.16s ease;
	pointer-events: none;
}

.tsmu-uc.is-visible {
	opacity: 1;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

.tsmu-uc * {
	box-sizing: border-box;
}

/* --- top accent + cover ------------------------------------------------- */
.tsmu-uc-cover {
	position: relative;
	height: 62px;
	background: linear-gradient(135deg, #16305a 0%, #24559c 55%, #3b82f6 100%);
}

.tsmu-uc-cover::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 4px;
	background: linear-gradient(90deg, #21d4a8, #2563eb, #f59e0b);
}

.tsmu-uc-cover::after {
	content: "";
	position: absolute;
	inset: 0;
	background:
		radial-gradient(circle at 82% 18%, rgba(255, 255, 255, 0.22), transparent 55%),
		repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0 8px, transparent 8px 16px);
	pointer-events: none;
}

/* --- head: avatar + identity ------------------------------------------- */
/* The avatar overlaps the cover; the identity column is padded down by exactly
   the overlap so the username always starts below the blue band. */
.tsmu-uc-head {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 0 16px;
	margin-top: -28px;
}

/* Avatars on this forum run from 0.5 to 1.78 w/h (portrait character art, square
   logos and wide banners all mixed), so the frame must never crop: the real image
   is contained inside it and a blurred copy of itself fills the leftover space. */
.tsmu-uc-avatar {
	position: relative;
	flex: 0 0 auto;
	width: 78px;
	height: 78px;
}

/* The frame clips, the wrapper does not - so the online dot can hang over the
   corner instead of being cut off by overflow: hidden. */
.tsmu-uc-avatar-frame {
	position: absolute;
	inset: 0;
	border-radius: 12px;
	border: 3px solid #ffffff;
	background: #e8f0fb;
	box-shadow: 0 8px 18px rgba(15, 23, 42, 0.22);
	overflow: hidden;
}

.tsmu-uc-avatar-fill {
	position: absolute;
	inset: 0;
	background-position: center;
	background-size: cover;
	background-repeat: no-repeat;
	filter: blur(10px) saturate(1.25);
	transform: scale(1.35);
	opacity: 0.55;
	pointer-events: none;
}

.tsmu-uc-avatar img {
	position: relative;
	z-index: 1;
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

.tsmu-uc-avatar .tsmu-uc-initial {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	font-size: 30px;
	font-weight: 900;
	color: #24559c;
	background: linear-gradient(135deg, #dbeafe, #eff6ff);
}

.tsmu-uc-dot {
	position: absolute;
	z-index: 2;
	right: -3px;
	bottom: -3px;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	border: 3px solid #ffffff;
	background: #94a3b8;
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.3);
}

.tsmu-uc.is-online .tsmu-uc-dot {
	background: #22c55e;
	box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.22);
}

.tsmu-uc-identity {
	min-width: 0;
	/* 28px overlap + 4px breathing room = never on top of the cover. */
	padding-top: 32px;
	flex: 1 1 auto;
}

.tsmu-uc-name {
	display: block;
	margin: 0 0 4px;
	font-size: 17px;
	font-weight: 900;
	line-height: 1.2;
	color: #0f2744;
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tsmu-uc-name:hover {
	color: #e11d48;
}

.tsmu-uc-name .tsmu-uc-name-text {
	color: inherit;
}

.tsmu-uc-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
}

.tsmu-uc-chip {
	display: inline-block;
	max-width: 100%;
	padding: 3px 9px;
	border-radius: 11px;
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tsmu-uc-chip.is-group {
	background: linear-gradient(135deg, #6c5ce7, #a29bfe);
	color: #ffffff;
	box-shadow: 0 2px 5px rgba(108, 92, 231, 0.32);
}

/* Secondary chip: post-count group, member title or join year. Deliberately not
   an online/offline badge - the dot on the avatar covers that. */
.tsmu-uc-chip.is-sub {
	background: #eef4fb;
	color: #47617f;
	border: 1px solid #dbe6f3;
}

.tsmu-uc-body {
	padding: 12px 16px 14px;
}

.tsmu-uc-title {
	margin: 10px 0 0;
	font-size: 12px;
	font-style: italic;
	color: #55708f;
	text-align: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* --- rank + progress ---------------------------------------------------- */
.tsmu-uc-rank {
	margin-top: 12px;
	padding: 10px 12px;
	border: 1px solid #e2ebf6;
	border-radius: 11px;
	background: #ffffff;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.tsmu-uc-rank-top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 7px;
}

.tsmu-uc-rank-name {
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	padding: 3px 10px;
	border-radius: 11px;
}

.tsmu-uc-rank-value {
	font-size: 12px;
	font-weight: 900;
	color: #0f2744;
}

.tsmu-uc-bar {
	position: relative;
	height: 7px;
	border-radius: 99px;
	background: #e8eef6;
	overflow: hidden;
}

.tsmu-uc-bar span {
	display: block;
	height: 100%;
	border-radius: 99px;
	background: linear-gradient(90deg, #22c55e, #3b82f6, #8b5cf6);
	transition: width 0.4s ease;
}

.tsmu-uc-rank-note {
	margin-top: 6px;
	font-size: 10.5px;
	font-weight: 600;
	color: #7c8ea3;
	text-transform: uppercase;
	letter-spacing: 0.4px;
}

/* rank palette - mirrors Display.template.php */
.tsmu-uc-rank-name.rank-grey { background: #dfe6e9; color: #636e72; border: 1px solid #b2bec3; }
.tsmu-uc-rank-name.rank-brown { background: #d7ccc8; color: #5d4037; border: 1px solid #a1887f; }
.tsmu-uc-rank-name.rank-orange { background: #ffe0b2; color: #e65100; border: 1px solid #ffb74d; }
.tsmu-uc-rank-name.rank-yellow { background: #fff9c4; color: #f9a825; border: 1px solid #fdd835; }
.tsmu-uc-rank-name.rank-green { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.tsmu-uc-rank-name.rank-teal { background: #e0f2f1; color: #00695c; border: 1px solid #80cbc4; }
.tsmu-uc-rank-name.rank-blue { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }
.tsmu-uc-rank-name.rank-purple { background: #f3e5f5; color: #7b1fa2; border: 1px solid #ce93d8; }
.tsmu-uc-rank-name.rank-red { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.tsmu-uc-rank-name.rank-gold { background: linear-gradient(135deg, #fff8e1, #ffecb3); color: #ff8f00; border: 1px solid #ffca28; }
.tsmu-uc-rank-name.rank-mythic { background: linear-gradient(135deg, #212121, #000000); color: #00e5ff; border: 1px solid #00e5ff; text-shadow: 0 0 5px #00e5ff; }

/* --- stat tiles --------------------------------------------------------- */
.tsmu-uc-stats {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 6px;
	margin-top: 10px;
}

.tsmu-uc-stat {
	position: relative;
	padding: 9px 4px 8px;
	border: 1px solid #e2ebf6;
	border-radius: 10px;
	background: #ffffff;
	text-align: center;
	overflow: hidden;
}

.tsmu-uc-stat::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 3px;
	background: var(--stat-accent, #2563eb);
}

.tsmu-uc-stat.is-posts { --stat-accent: #2563eb; }
.tsmu-uc-stat.is-thanks { --stat-accent: #16a34a; }
.tsmu-uc-stat.is-given { --stat-accent: #ef4444; }
.tsmu-uc-stat.is-ratio { --stat-accent: #f97316; }
.tsmu-uc-stat.is-topics { --stat-accent: #8b5cf6; }

.tsmu-uc-stat em {
	display: block;
	font-style: normal;
	font-size: 9px;
	font-weight: 800;
	letter-spacing: 0.45px;
	text-transform: uppercase;
	color: #8195ab;
	margin-bottom: 2px;
}

.tsmu-uc-stat strong {
	display: block;
	font-size: 14px;
	font-weight: 900;
	color: #0f2744;
	line-height: 1.15;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tsmu-uc-stat.is-thanks strong { color: #15803d; }
.tsmu-uc-stat.is-given strong { color: #dc2626; }
.tsmu-uc-stat.is-ratio strong { color: #ea580c; }
.tsmu-uc-stat.is-topics strong { color: #7c3aed; }

/* --- meta rows ---------------------------------------------------------- */
.tsmu-uc-meta {
	list-style: none;
	margin: 11px 0 0;
	padding: 0;
	border: 1px solid #e6edf6;
	border-radius: 11px;
	background: #ffffff;
	overflow: hidden;
}

.tsmu-uc-meta li {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: 7px 11px;
	border-bottom: 1px solid #f0f4f9;
	font-size: 12px;
}

.tsmu-uc-meta li:last-child {
	border-bottom: 0;
}

.tsmu-uc-meta em {
	font-style: normal;
	font-size: 10px;
	font-weight: 800;
	letter-spacing: 0.4px;
	text-transform: uppercase;
	color: #8195ab;
	white-space: nowrap;
}

.tsmu-uc-meta strong {
	font-weight: 700;
	color: #0f2744;
	text-align: right;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tsmu-uc-meta a {
	color: #1d4ed8;
	text-decoration: none;
	font-weight: 700;
}

.tsmu-uc-meta a:hover {
	text-decoration: underline;
}

.tsmu-uc-meta .is-discord strong {
	color: #5865f2;
}

/* --- badges ------------------------------------------------------------- */
.tsmu-uc-badges {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 11px;
}

.tsmu-uc-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 9px;
	border: 1px solid #e2ebf6;
	background: linear-gradient(135deg, #ffffff, #f2f7fd);
	color: #24559c;
	font-size: 12px;
	text-decoration: none;
	box-shadow: 0 2px 5px rgba(15, 23, 42, 0.08);
	transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.tsmu-uc-badge:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 12px rgba(15, 23, 42, 0.16);
}

.tsmu-uc-badge.is-membership { color: #7b1fa2; }
.tsmu-uc-badge.is-posts { color: #1565c0; }
.tsmu-uc-badge.is-thanks { color: #15803d; }

.tsmu-uc-badge-more {
	display: inline-flex;
	align-items: center;
	padding: 0 9px;
	height: 28px;
	border-radius: 9px;
	background: #eef4fb;
	border: 1px solid #dbe6f3;
	color: #55708f;
	font-size: 11px;
	font-weight: 800;
	text-decoration: none;
}

/* --- footer actions ----------------------------------------------------- */
.tsmu-uc-actions {
	display: flex;
	gap: 6px;
	padding: 11px 16px 14px;
	border-top: 1px solid #eaf0f7;
	background: linear-gradient(180deg, #f7fbff 0%, #eef5fd 100%);
}

.tsmu-uc-btn {
	flex: 1 1 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	padding: 8px 6px;
	border-radius: 9px;
	border: 1px solid #cfdff2;
	background: #ffffff;
	color: #1d4ed8;
	font-size: 11px;
	font-weight: 800;
	letter-spacing: 0.3px;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	transition: background 0.14s ease, color 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease;
}

.tsmu-uc-btn:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 14px rgba(29, 78, 216, 0.18);
	color: #1d4ed8;
}

.tsmu-uc-btn.is-primary {
	background: linear-gradient(135deg, #2563eb, #1d4ed8);
	border-color: #1d4ed8;
	color: #ffffff;
}

.tsmu-uc-btn.is-primary:hover {
	color: #ffffff;
}

/* --- arrow -------------------------------------------------------------- */
.tsmu-uc-arrow {
	position: absolute;
	width: 12px;
	height: 12px;
	background: #16305a;
	border: 1px solid #d9e6f5;
	border-right: 0;
	border-bottom: 0;
	transform: rotate(45deg);
	pointer-events: none;
}

.tsmu-uc.is-below .tsmu-uc-arrow {
	top: -7px;
}

.tsmu-uc.is-above .tsmu-uc-arrow {
	bottom: -7px;
	background: #eef5fd;
	border: 1px solid #d9e6f5;
	border-left: 0;
	border-top: 0;
}

/* --- loading / error states -------------------------------------------- */
.tsmu-uc-loading {
	padding: 18px 16px 20px;
}

.tsmu-uc-skel {
	display: flex;
	align-items: center;
	gap: 12px;
}

.tsmu-uc-skel-avatar,
.tsmu-uc-skel-line {
	background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 37%, #eef2f7 63%);
	background-size: 400% 100%;
	animation: tsmu-uc-shimmer 1.3s ease infinite;
	border-radius: 8px;
}

.tsmu-uc-skel-avatar {
	width: 56px;
	height: 56px;
	flex: 0 0 auto;
	border-radius: 12px;
}

.tsmu-uc-skel-lines {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	gap: 7px;
}

.tsmu-uc-skel-line {
	height: 10px;
}

.tsmu-uc-skel-line.is-short {
	width: 52%;
}

.tsmu-uc-skel-grid {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 6px;
	margin-top: 14px;
}

.tsmu-uc-skel-grid span {
	height: 42px;
	border-radius: 10px;
	background: linear-gradient(90deg, #eef2f7 25%, #f8fafc 37%, #eef2f7 63%);
	background-size: 400% 100%;
	animation: tsmu-uc-shimmer 1.3s ease infinite;
}

@keyframes tsmu-uc-shimmer {
	0% { background-position: 100% 50%; }
	100% { background-position: 0 50%; }
}

.tsmu-uc-error {
	padding: 22px 16px;
	text-align: center;
	font-weight: 700;
	color: #7c8ea3;
}

/* --- small screens: no hover cards ------------------------------------- */
@media (max-width: 720px) {
	.tsmu-uc {
		display: none !important;
	}
}

@media (prefers-reduced-motion: reduce) {
	.tsmu-uc,
	.tsmu-uc-bar span,
	.tsmu-uc-badge,
	.tsmu-uc-btn {
		transition: none;
	}

	.tsmu-uc-skel-avatar,
	.tsmu-uc-skel-line,
	.tsmu-uc-skel-grid span {
		animation: none;
	}
}
