/**
 * Minecraft Bingo 排行榜 — front-end styles.
 *
 * The widget deliberately avoids hard-coded light/dark surfaces: borders,
 * stripes and muted text are built from translucent layers so the leaderboard
 * adapts to whatever colour scheme the active theme uses. Only the accent colour
 * (configurable) and the medal colours are absolute.
 */

.mcb-bingo {
	min-width: 0;
	max-width: 100%;
	--mcb-accent: #5b8c3e;
	--mcb-avatar-size: 48px;
	--mcb-radius: 12px;
	--mcb-line: rgba(128, 128, 128, 0.28);
	--mcb-line-soft: rgba(128, 128, 128, 0.16);
	--mcb-tint: rgba(128, 128, 128, 0.08);
	--mcb-tint-soft: rgba(128, 128, 128, 0.045);

	/* 排行榜自身的底色。以前是透明的，页面渐变会透上来显得发灰、字发虚。 */
	--mcb-surface: #fbfcfe;
	--mcb-surface-line: rgba(15, 23, 42, 0.10);

	/* 前三名各用一套底色，和普通行拉开差距 */
	--mcb-gold: #fdf1cd;
	--mcb-gold-bar: #e0ae28;
	--mcb-silver: #e8eef6;
	--mcb-silver-bar: #a9b6c4;
	--mcb-bronze: #f9e7d6;
	--mcb-bronze-bar: #c2854f;

	box-sizing: border-box;
	margin: 1.5em 0;
	color: inherit;
	font-size: 1rem;
	line-height: 1.5;
}

.mcb-bingo *,
.mcb-bingo *::before,
.mcb-bingo *::after {
	box-sizing: border-box;
}

/* ---------------------------------------------------------------- header -- */

/* 标题、副标题、统计行统一居中 */
.mcb-bingo__head {
	margin-bottom: 1.15em;
	text-align: center;
}

.mcb-bingo__title {
	margin: 0 0 0.3em;
	font-size: 1.6em;
	line-height: 1.3;
	font-weight: 700;
	letter-spacing: 0.04em;
}

.mcb-bingo__subtitle {
	margin: 0 0 0.3em;
	opacity: 0.85;
}

.mcb-bingo__meta,
.mcb-bingo__foot {
	margin: 0.25em 0 0;
	font-size: 0.82em;
	opacity: 0.65;
	text-align: center;
}

.mcb-bingo__foot {
	margin-top: 0.9em;
}

.mcb-bingo__empty {
	margin: 0;
	padding: 1.5em;
	text-align: center;
	opacity: 0.7;
	border: 1px dashed var(--mcb-line);
	border-radius: var(--mcb-radius);
}

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

.mcb-bingo__scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--mcb-surface-line);
	border-radius: var(--mcb-radius);
	background: var(--mcb-surface);
	box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);

	/*
	 * 列多的时候表格会远比容器宽。不写死宽度的话，容器会被内容撑开，
	 * 结果整页出现横向滚动条、右侧几列直接看不到。
	 * 这里把容器钉在父级宽度内，让表格在容器里横向滚动。
	 */
	width: 100%;
	max-width: 100%;
}

.mcb-bingo__table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	border-spacing: 0;
	background: transparent;
	font-variant-numeric: tabular-nums;
}

/*
 * Astra 主题给 table / td / th 都加了 1px 全边框，只在插件里写 border-bottom
 * 是压不住的 —— 剩下的三边会留下来变成密集的竖线。这里显式清零。
 */
.mcb-bingo__table th,
.mcb-bingo__table td {
	border: 0;
}

.mcb-bingo__table thead th {
	padding: 0.85em 0.9em;
	font-size: 0.78em;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-align: center;
	white-space: nowrap;
	color: inherit;
	border: 0;
	border-bottom: 2px solid var(--mcb-accent);
	background: var(--mcb-tint);
	background: color-mix(in srgb, var(--mcb-accent) 14%, transparent);
}

/* 名字列的表头跟数据一样左对齐，避免"表头居中、数据靠左"的错位感 */
.mcb-bingo__table thead th.mcb-col-player {
	text-align: left;
	padding-left: 1.15em;
}

.mcb-bingo__table tbody td {
	padding: 0.7em 0.9em;
	vertical-align: middle;
	white-space: nowrap;
	border: 0;
	border-bottom: 1px solid var(--mcb-line-soft);
}

.mcb-bingo__table tbody tr:last-child td {
	border-bottom: 0;
}

/* Zebra striping first, highlights afterwards so they win on specificity. */
/* 斑马纹要排除前三名，否则偶数行的名次底色会被它盖掉 */
.mcb-bingo--zebra .mcb-bingo__table tbody tr:nth-child(even):not(.mcb-top) {
	background: var(--mcb-tint-soft);
}

/* 前三名：金 / 银 / 铜，底色和左侧色条都跟着名次走 */
.mcb-bingo__table tbody tr.mcb-top-1 {
	background: var(--mcb-gold);
}

.mcb-bingo__table tbody tr.mcb-top-2 {
	background: var(--mcb-silver);
}

.mcb-bingo__table tbody tr.mcb-top-3 {
	background: var(--mcb-bronze);
}

.mcb-bingo__table tbody tr.mcb-top-1 td:first-child {
	box-shadow: inset 4px 0 0 0 var(--mcb-gold-bar);
}

.mcb-bingo__table tbody tr.mcb-top-2 td:first-child {
	box-shadow: inset 4px 0 0 0 var(--mcb-silver-bar);
}

.mcb-bingo__table tbody tr.mcb-top-3 td:first-child {
	box-shadow: inset 4px 0 0 0 var(--mcb-bronze-bar);
}

.mcb-bingo--compact .mcb-bingo__table thead th {
	padding: 0.4em 0.55em;
}

.mcb-bingo--compact .mcb-bingo__table tbody td {
	padding: 0.3em 0.55em;
}

.mcb-bingo--compact .mcb-avatar {
	--mcb-avatar-size: calc(var(--mcb-avatar-size) * 0.75);
}

.mcb-align-center {
	text-align: center;
}

.mcb-align-right {
	text-align: right;
}

/* ------------------------------------------------------------ avatar/name -- */

.mcb-avatar {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--mcb-avatar-size);
	height: var(--mcb-avatar-size);
	overflow: hidden;
	border-radius: 8px;
	background: var(--mcb-tint);
	vertical-align: middle;
	flex: 0 0 auto;
}

.mcb-bingo--avatar-circle .mcb-avatar {
	border-radius: 50%;
}

.mcb-bingo--avatar-square .mcb-avatar {
	border-radius: 2px;
}

/* Shown when the skin service is unreachable or avatars are disabled. */
.mcb-avatar__initials {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: calc(var(--mcb-avatar-size) * 0.36);
	font-weight: 700;
	letter-spacing: 0.02em;
	color: #fff;
	background-color: hsl(var(--mcb-hue, 140) 42% 45%);
	text-transform: uppercase;
	user-select: none;
}

/* Covers the initials once the skin image loads; harmless if it never does. */
.mcb-avatar__img {
	position: relative;
	z-index: 1;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	border: 0;
}

.mcb-cell-player {
	font-weight: 600;
	white-space: nowrap;
}

.mcb-player-link {
	text-decoration: none;
	border-bottom: 1px solid var(--mcb-line);
}

.mcb-player-link:hover,
.mcb-player-link:focus {
	border-bottom-color: var(--mcb-accent);
}

.mcb-cell-uuid .mcb-uuid {
	font-size: 0.78em;
	opacity: 0.7;
	word-break: break-all;
}

/* ------------------------------------------------------------------ rank -- */

.mcb-rank {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.9em;
	height: 1.9em;
	padding: 0 0.4em;
	border-radius: 8px;
	font-size: 0.88em;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	line-height: 1;
	white-space: nowrap;
	background: var(--mcb-tint);
}

.mcb-rank--1 {
	background: linear-gradient(160deg, #ffd85e, #dfa523);
	color: #4a3200;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.mcb-rank--2 {
	background: linear-gradient(160deg, #eaeff4, #a9b5c1);
	color: #333a41;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.mcb-rank--3 {
	background: linear-gradient(160deg, #f2c69d, #c07c42);
	color: #3d2410;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.mcb-percent,
.mcb-duration {
	white-space: nowrap;
}

/* ----------------------------------------------------------------- cards -- */

.mcb-bingo__cards {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
	gap: 14px;
}

.mcb-card {
	display: flex;
	flex-direction: column;
	gap: 12px;
	margin: 0;
	padding: 14px;
	border: 1px solid var(--mcb-line);
	border-radius: var(--mcb-radius);
	background: var(--mcb-tint-soft);
}

.mcb-card.mcb-top-1 {
	border-color: color-mix(in srgb, var(--mcb-accent) 55%, transparent);
	background: color-mix(in srgb, var(--mcb-accent) 10%, transparent);
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}

.mcb-card.mcb-top-2,
.mcb-card.mcb-top-3 {
	border-color: color-mix(in srgb, var(--mcb-accent) 32%, transparent);
	background: color-mix(in srgb, var(--mcb-accent) 6%, transparent);
}

.mcb-card__head {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

.mcb-card__head .mcb-cell-rank {
	margin-left: auto;
}

.mcb-card__head .mcb-cell-player {
	font-size: 1.05em;
}

.mcb-card__head .mcb-cell-uuid {
	flex-basis: 100%;
}

.mcb-card__stats {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
	gap: 8px;
	margin: 0;
	padding: 0;
}

.mcb-stat {
	display: flex;
	flex-direction: column;
	gap: 2px;
	margin: 0;
	padding: 7px 9px;
	border-radius: 8px;
	background: var(--mcb-tint);
}

.mcb-stat dt {
	margin: 0;
	font-size: 0.72em;
	opacity: 0.7;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mcb-stat dd {
	margin: 0;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- error -- */

.mcb-bingo--error {
	padding: 1em 1.15em;
	border: 1px solid rgba(214, 54, 56, 0.45);
	border-radius: var(--mcb-radius);
	background: rgba(214, 54, 56, 0.07);
}

.mcb-bingo--error p {
	margin: 0.25em 0;
}

.mcb-bingo__hint {
	font-size: 0.85em;
	opacity: 0.75;
}

/* ------------------------------------------------------------ small screens */

@media (max-width: 600px) {
	.mcb-bingo {
		font-size: 0.94rem;
	}

	.mcb-bingo__table thead th,
	.mcb-bingo__table tbody td {
		padding: 0.45em 0.5em;
	}

	.mcb-bingo__cards {
		grid-template-columns: 1fr;
	}
}
