/****************************
 *
 * Standings dashboards (nba, b.league, mec, unrivaled)
 * Loaded after the site-wide style.css and before each page's own style.css.
 * A page sets --content-width (default 500px) and --columns (default 1) on .dashboard
 * when its tables need more room. See nba/style.css.
 *
 ****************************/

/* On :root, not .dashboard: the live card is appended to <body>, outside the section */
:root {
	--color-surface-raised: #2a2a2a; /* Change the headshot and jersey badge backdrop color */
	--color-line-subtle: #282828; /* Change the row divider color */
	--color-text-dim: #585858; /* Change the out-of-contention text color */
	--color-info: #7fa3ba; /* Change the play-in, wildcard and tournament seed color */
	--color-win: #8db48d; /* Change the win color */
	--color-win-dim: #5f7f5f; /* Change the faded win color */
	--color-loss: #c27a7a; /* Change the loss color */
	--color-loss-dim: #8a5858; /* Change the faded loss color */
	--color-live: #d45b5b; /* Change the live dot color */
}

/****************************
 *
 * Layout
 * The base stylesheet styles every section as a full-height page frame. Auto margins center the
 * content when it fits and keep the top reachable when it doesn't (justify-content: center would
 * clip it on small screens). The padding keeps the same 25px of breathing room the base margins give.
 *
 ****************************/
.dashboard {
	justify-content: flex-start;
}
.dashboard > header {
	margin-top: auto;
	padding-top: 25px;
}
.dashboard > footer {
	margin-bottom: auto;
	padding-bottom: 25px;
}
.standings {
	margin: 0 auto;
	width: 100%;
	max-width: var(--content-width);
}

/****************************
 *
 * Table groups
 *
 ****************************/
.conferences {
	display: grid;
	grid-template-columns: repeat(var(--columns, 1), minmax(0, 1fr));
	gap: 25px 40px;
}
.conf {
	min-width: 0;
	padding: 10px 0;
	border-block: 2px solid var(--color-line);
}
.conf h5 {
	margin: 0 0 6px;
	color: var(--color-text);
	font-size: clamp(0.75em, 6vw, 1.5em);
	font-weight: 400;
	text-transform: lowercase;
}

/****************************
 *
 * Table
 *
 ****************************/
.conf table {
	width: 100%;
	border-collapse: collapse;
	font-size: clamp(0.75em, 3.6vw, 1em);
	font-variant-numeric: tabular-nums;
	text-transform: lowercase;
}
.conf th,
.conf td {
	padding: 6px;
	text-align: right;
	white-space: nowrap;
}
.conf th {
	color: var(--color-text-muted);
	font-weight: 400;
}
.conf td {
	color: var(--color-text);
	border-top: 1px solid var(--color-line-subtle);
}
.conf th:nth-child(2),
.conf td:nth-child(2) {
	width: 100%;
	text-align: left;
}
.conf td:nth-child(2) {
	max-width: 0; /* lets the team cell shrink below its content so the ellipsis can kick in */
	overflow: hidden;
}
.conf th:first-child,
.conf td:first-child {
	width: 2.4em;
	text-align: center;
	border-left: 3px solid transparent;
}

/* Seed + team */
.conf td:first-child {
	color: var(--color-text-strong);
	font-weight: bold;
}
.team {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--color-text-strong);
	font-weight: bold;
}
.team img {
	width: 1.5em;
	height: 1.5em;
	object-fit: contain;
}
.team .name { /* a long nickname gets an ellipsis instead of spilling out of the table */
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.team .abbr {
	display: none;
}

/* Berths: gold for the top tier, steel blue for the next. Each page's script names the second tier
   its own way (play-in, wildcard, playoff). */
.conf tr.direct td:first-child {
	color: var(--color-accent);
	border-left-color: var(--color-accent);
}
.conf tr.playin td:first-child,
.conf tr.wildcard td:first-child,
.conf tr.playoff td:first-child {
	color: var(--color-info);
	border-left-color: var(--color-info);
}

/* Out of the picture: dim the row so the berths stand out */
.conf tr.out td,
.conf tr.out .team {
	color: var(--color-text-dim);
}
.conf tr.out img {
	opacity: 0.45;
}

/* Wins, losses and strks: green and red, dimmed to match on faded rows */
.conf td:nth-child(3),
.conf td.strk.W {
	color: var(--color-win);
}
.conf td:nth-child(4),
.conf td.strk.L {
	color: var(--color-loss);
}
.conf tr.out td:nth-child(3),
.conf tr.out td.strk.W {
	color: var(--color-win-dim);
}
.conf tr.out td:nth-child(4),
.conf tr.out td.strk.L {
	color: var(--color-loss-dim);
}

/****************************
 *
 * Key and message
 *
 ****************************/
.key {
	display: flex;
	flex-wrap: wrap;
	gap: 5px 20px;
	margin: 0;
	color: var(--color-text-muted);
	font-size: clamp(0.75em, 3.6vw, 1em);
	text-transform: lowercase;
}
.swatch {
	display: inline-block;
	width: 3px;
	height: 0.9em;
	margin-right: 8px;
	vertical-align: -0.1em;
}
.swatch.direct {
	background-color: var(--color-accent);
}
.swatch.playin,
.swatch.wildcard,
.swatch.playoff {
	background-color: var(--color-info);
}
.message {
	margin: 0;
	padding-top: 10px;
	color: var(--color-text-muted);
	font-size: clamp(0.75em, 6vw, 1.5em);
	text-transform: lowercase;
}

/****************************
 *
 * Live games
 *
 ****************************/
.live {
	position: relative;
	flex: none;
	width: 0.6em;
	height: 0.6em;
	margin-left: 2px;
	border-radius: 50%;
	background-color: var(--color-live);
	cursor: pointer;
	animation: live-pulse 1.6s ease-out infinite;
}
.live::after { /* larger tap and hover target around the dot */
	content: "";
	position: absolute;
	inset: -8px;
}
.live:focus-visible {
	outline: 2px solid var(--color-accent);
	outline-offset: 3px;
}
@keyframes live-pulse {
	0% {
		box-shadow: 0 0 0 0 rgba(237, 237, 237, 0.75); /* Change the pulse color */
	}
	70% {
		box-shadow: 0 0 0 0.5em rgba(237, 237, 237, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(237, 237, 237, 0);
	}
}
@media (prefers-reduced-motion: reduce) {
	.live {
		animation: none;
		box-shadow: 0 0 0 2px rgba(237, 237, 237, 0.5);
	}
}

/* Score overlay: the box itself is the base stylesheet's .popup; this only sets its width */
.live-card {
	min-width: 270px;
}
/* Top row: logo, name, score, vs or @, score, name, logo */
.live-card .matchup {
	display: grid;
	grid-template-columns: 1fr auto 1fr; /* equal outer columns keep vs/@ dead center, under the clock */
	align-items: center;
	gap: 12px;
	color: var(--color-text-strong);
	font-weight: bold;
}
.live-card .side {
	display: flex;
	align-items: center;
	gap: 8px;
}
.live-card .side:last-child {
	justify-content: flex-end;
}
.live-card .side b {
	color: var(--color-accent-hover); /* Change the score color */
	font-size: 1.3em;
}
.live-card .logo {
	flex: none;
	width: 1.6em;
	height: 1.6em;
	object-fit: contain;
}
.live-card .sep {
	color: var(--color-text-muted);
	font-weight: 400;
}
.live-card .status {
	margin-top: 4px;
	color: var(--color-text);
	text-align: center;
}
/* Latest play: player badge, time tag, text, points */
.live-card .play {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 8px;
	padding-top: 8px;
	border-top: 1px solid var(--color-line);
	color: var(--color-text-strong);
	line-height: 1.35;
}
.live-card .shot, /* headshot (nba) */
.live-card .num { /* jersey number, with a headshot over it once it loads (b.league) */
	flex: none;
	width: 2.4em;
	height: 2.4em;
	border-radius: 50%;
	background-color: var(--color-surface-raised);
}
.live-card .shot,
.live-card .num img {
	object-fit: cover;
	object-position: 50% 12%; /* headshots are usually wide with the face near the top */
}
.live-card .when {
	margin-right: 8px;
	color: var(--color-text-muted);
}
.live-card .pts {
	margin-left: 6px;
	color: var(--color-win);
	font-weight: bold;
}

/****************************
 *
 * Small screens
 * (media queries can't read custom properties, so these breakpoints are written out)
 *
 ****************************/
@media (max-width: 860px) {
	.conferences {
		--columns: 1;
		row-gap: 0;
	}
	.conf + .conf { /* stacked: the first table's bottom line is the only divider, like the base nav blocks */
		border-top-width: 0;
	}
}
@media (max-width: 520px) {
	.team .name {
		display: none;
	}
	.team .abbr {
		display: inline;
	}
	.conf th,
	.conf td {
		padding-left: 4px;
		padding-right: 4px;
	}
}
