/*
 * Shared styles for the entity blocks (tournament, season, standings, team, player,
 * stats-leaders, news-list, directory, search, profile, follow-button).
 * Colours come only from tokens.css. Sizes follow bin/scales.json. Controls are 44px.
 */

.mse {
	display: block;
	max-width: 960px;
	/* The page already has its gutter: no side padding, and left-aligned with the page title. */
	margin: 0;
	padding: 0;
	box-sizing: border-box;
	color: var(--text);
	font-family: var(--wp--preset--font-family--sans, "Inter", "Noto Sans Devanagari", system-ui, sans-serif);
	font-size: 14px;
	line-height: 20px;
}

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

.mse a {
	color: inherit;
}

/* Buttons that are links keep their own colours (the rule above would otherwise win). */
.mse a.mse-btn {
	color: var(--text);
}

.mse a.mse-btn--solid,
.mse a.mse-btn[aria-pressed="true"] {
	color: var(--bg);
}

.mse :focus-visible {
	outline: 2px solid var(--accent-text);
	outline-offset: 2px;
}

.mse__h1,
.mse__h2,
.mse__h3,
.mse__h4 {
	margin: 0;
	font-family: var(--wp--preset--font-family--display, "Inter", "Noto Sans Devanagari", system-ui, sans-serif);
	font-weight: 700;
}

.mse__h1 {
	font-size: 24px;
	line-height: 32px;
}

.mse__h2 {
	margin: 24px 0 8px;
	font-size: 18px;
	line-height: 24px;
}

.mse__h3 {
	margin: 16px 0 8px;
	font-size: 16px;
	line-height: 24px;
}

.mse__h4 {
	margin: 12px 0 6px;
	font-size: 14px;
	line-height: 20px;
	color: var(--muted);
}

.mse__muted {
	color: var(--muted);
	font-size: 14px;
}

.mse__head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 12px 16px;
	padding: 16px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 16px;
}

.mse__head-text {
	flex: 1 1 200px;
	min-width: 0;
}

.mse__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 8px;
}

.mse-chip {
	display: inline-flex;
	align-items: center;
	padding: 2px 10px;
	background: var(--surface-2);
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm);
	font-size: 14px;
	line-height: 16px;
	font-weight: 700;
}

/* Chips that are links get a 44px touch area without growing. */
a.mse-chip {
	position: relative;
}

a.mse-chip::after {
	content: "";
	position: absolute;
	inset: -12px -4px;
}

.mse-badge {
	display: inline-block;
	align-self: flex-start;
	justify-self: start;
	width: fit-content;
	padding: 2px 8px;
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm);
	font-size: 14px;
	line-height: 16px;
	font-weight: 700;
	background: var(--surface-2);
}

.mse-badge--live {
	background: var(--accent);
	border-color: var(--accent);
	color: var(--on-accent);
}

.mse-badge--paused {
	background: transparent;
	border-color: var(--accent-text);
	color: var(--accent-text);
}

.mse-badge--breaking {
	background: var(--accent-tint-strong);
	border-color: var(--accent-text);
	color: var(--accent-text);
}

.mse-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	min-width: 44px;
	padding: 0 16px;
	border: 1px solid var(--control-line);
	border-radius: var(--radius-sm);
	background: var(--surface);
	color: var(--text);
	font: inherit;
	font-weight: 700;
	text-decoration: none;
	cursor: pointer;
}

.mse-btn:hover {
	border-color: var(--text);
}

.mse-btn--solid,
.mse-btn[aria-pressed="true"] {
	background: var(--text);
	border-color: var(--text);
	color: var(--bg);
}

.mse-follow {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
}

.mse-follow__note a {
	position: relative;
}

.mse-follow__note a::after {
	content: "";
	position: absolute;
	inset: -14px -4px;
}

.mse-follow__note {
	margin: 0;
	color: var(--muted);
	font-size: 14px;
	line-height: 16px;
}

/* Crest and avatar: initials always render, the image sits over them. */
.mse-crest,
.mse-avatar {
	position: relative;
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	border-radius: 999px;
	background: var(--surface-2);
	color: var(--on-crest);
	font-family: var(--wp--preset--font-family--display, "Inter", "Noto Sans Devanagari", system-ui, sans-serif);
	font-weight: 700;
	box-shadow: inset 0 0 0 2px var(--crest-ring);
}

.mse-crest--s {
	width: 36px;
	height: 36px;
	font-size: 14px;
}

.mse-crest--m {
	width: 60px;
	height: 60px;
	font-size: 14px;
}

.mse-crest--l {
	width: 56px;
	height: 56px;
	font-size: 16px;
}

.mse-avatar--s {
	width: 32px;
	height: 32px;
	font-size: 14px;
}

.mse-avatar--l {
	width: 56px;
	height: 56px;
	font-size: 16px;
}

.mse-crest img,
.mse-avatar img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	background: var(--crest-disc);
}

.mse-crest img {
	object-fit: contain;
	padding: 2px;
}

.ms-text-only .mse-crest img,
.ms-text-only .mse-avatar img,
.ms-text-only .mse-news__img {
	display: none;
}

.ms-text-only .mse * {
	animation: none;
	transition: none;
}

/* Lists and cards */
.mse-list {
	display: grid;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.mse-list__item {
	margin: 0;
}

.mse-card,
.mse-match {
	display: block;
	padding: 12px 16px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-md);
	text-decoration: none;
}

a.mse-match:hover,
a.mse-card:hover {
	border-color: var(--line-strong);
}

a.mse-match,
a.mse-card {
	min-height: 44px;
}

.mse-match {
	display: grid;
	gap: 8px;
}

.mse-match__sides {
	display: grid;
	gap: 8px;
}

.mse-match__team {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.mse-match__name {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	font-weight: 600;
}

.mse-match__score {
	font-family: var(--wp--preset--font-family--display, "Inter", "Noto Sans Devanagari", system-ui, sans-serif);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.mse-match__result {
	font-weight: 600;
}

.mse-match__meta {
	color: var(--muted);
	font-size: 14px;
	line-height: 16px;
}

.mse-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.mse-tile {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 16px 12px;
	text-align: center;
	text-decoration: none;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-md);
	font-weight: 600;
}

.mse-tile:hover {
	border-color: var(--line-strong);
}

/* Tabs: real links, current one marked in words for assistive tech and by weight and underline. */
.mse-tabs {
	display: flex;
	gap: 4px;
	margin: 16px 0 0;
	padding: 0;
	list-style: none;
	overflow-x: auto;
	scrollbar-width: none;
	border-bottom: 1px solid var(--line-strong);
}

.mse-tabs::-webkit-scrollbar {
	display: none;
}

.mse-tabs a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 12px;
	border-bottom: 2px solid transparent;
	color: var(--muted);
	font-weight: 600;
	text-decoration: none;
	white-space: nowrap;
}

.mse-tabs a[aria-current="page"] {
	border-bottom-color: var(--text);
	color: var(--text);
	font-weight: 700;
}

.mse-empty {
	margin: 8px 0;
	padding: 16px;
	background: var(--surface);
	border: 1px dashed var(--line-strong);
	border-radius: var(--radius-md);
	color: var(--muted);
	text-align: center;
}

/* Tables */
.mse-table {
	width: 100%;
	border-collapse: collapse;
	background: var(--surface);
	font-variant-numeric: tabular-nums;
}

.mse-table caption {
	padding: 8px 0;
	text-align: left;
	font-weight: 700;
}

.mse-table th,
.mse-table td {
	padding: 10px 6px;
	text-align: right;
	border-bottom: 1px solid var(--line);
	white-space: nowrap;
}

.mse-table th {
	background: var(--surface-2);
	border-bottom: 1px solid var(--line-strong);
	font-size: 14px;
	line-height: 16px;
	font-weight: 700;
}

.mse-table th:first-child,
.mse-table td:first-child,
.mse-table .mse-table__left {
	text-align: left;
}

.mse-table-wrap {
	overflow-x: auto;
	border: 1px solid var(--line);
	border-radius: var(--radius-md);
}

.mse-teamcell {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
	text-decoration: none;
}

/* Stat blocks */
.mse-stats {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
	gap: 8px;
	margin: 0;
	padding: 0;
}

.mse-stats div {
	padding: 12px;
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius-md);
}

.mse-stats dt {
	color: var(--muted);
	font-size: 14px;
	line-height: 16px;
}

.mse-stats dd {
	margin: 0;
	font-family: var(--wp--preset--font-family--display, "Inter", "Noto Sans Devanagari", system-ui, sans-serif);
	font-size: 24px;
	line-height: 32px;
	font-weight: 700;
}

.mse-links {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.mse-links a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 16px;
	background: var(--surface);
	border: 1px solid var(--line-strong);
	border-radius: var(--radius-sm);
	font-weight: 600;
	text-decoration: none;
}

.mse-links a:hover {
	border-color: var(--text);
}

@media (min-width: 720px) {
	.mse__h1 {
		font-size: 28px;
		line-height: 36px;
	}

	.mse-match__sides {
		grid-template-columns: 1fr 1fr;
		gap: 16px;
	}

	.mse-table th,
	.mse-table td {
		padding: 10px 12px;
	}
}
