/* NBATracker: the Timing Tower.
   Built to DESIGN-BRIEF.md. Four inks, one signal, two type families,
   hard corners, hairline rules, no depth effects. Every vertical measure
   is a multiple of 8px. */

:root {
	--ink: oklch(0.13 0.025 262);
	--ink-2: oklch(0.19 0.025 262);
	--rule: oklch(0.32 0.02 262);
	--paper: oklch(0.94 0.008 80);
	--steel: oklch(0.64 0.025 250);
	--signal: oklch(0.74 0.19 48);

	--display: "Big Shoulders Display", "Arial Narrow", "Helvetica Neue Condensed", Impact, sans-serif;
	--text: "Archivo", Helvetica, Arial, sans-serif;

	--gutter: 24px;
	--strip: 48px;
	--rail-w: 240px;

	/* tower column widths */
	--c-name: 184px;
	--c-match: 80px;
	--c-tr: 56px;
	--c-block: 192px;
	--c-ruler: 240px;
	--c-sec: 44px;
	--c-caret: 16px;
	--c-gap: 8px;

	/* the written note: the one reading-size text on the page.
	   34em of Archivo is about 65 characters a line. */
	--say: 16px;
	--say-lede: 18px;
	--measure: 544px;
	--measure-lede: 612px;
}

* {
	box-sizing: border-box;
	border-radius: 0;
}

html,
body {
	margin: 0;
	padding: 0;
	background: var(--ink);
	color: var(--paper);
	font-family: var(--text);
	font-size: 13px;
	line-height: 1.4;
	-webkit-font-smoothing: antialiased;
}

body {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

.num {
	font-variant-numeric: tabular-nums;
	font-feature-settings: "tnum" 1;
}

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
}

button:focus-visible,
input:focus-visible,
.strip:focus-visible,
.ledger:focus-visible {
	outline: 2px solid var(--paper);
	outline-offset: -2px;
}

a {
	color: var(--paper);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.skip {
	position: absolute;
	left: -9999px;
	top: 8px;
	z-index: 10;
	background: var(--paper);
	color: var(--ink);
	padding: 8px 12px;
	text-decoration: none;
}

.skip:focus {
	left: 8px;
	outline: 2px solid var(--signal);
}

/* ---------- masthead ---------- */

.masthead {
	display: grid;
	grid-template-columns: repeat(12, 1fr);
	column-gap: var(--gutter);
	align-items: end;
	padding: 32px var(--gutter) 16px;
	border-bottom: 2px solid var(--paper);
}

.masthead .date {
	grid-column: 1 / span 6;
	justify-self: start;
	margin: 0;
	font-family: var(--display);
	font-weight: 900;
	font-size: 96px;
	line-height: 1;
	letter-spacing: -0.005em;
	white-space: nowrap;
	position: relative;
}

.masthead .date.stale::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: 52%;
	height: 2px;
	background: var(--signal);
}

.masthead .meta {
	grid-column: 7 / span 6;
	color: var(--steel);
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	text-align: right;
	gap: 4px;
	padding-bottom: 8px;
}

.masthead .meta .gen.stale {
	color: var(--signal);
}

.masthead .how {
	color: var(--steel);
}

/* ---------- frame ---------- */

.frame {
	display: grid;
	grid-template-columns: var(--rail-w) minmax(0, 1fr);
	flex: 1;
}

/* ---------- rail ---------- */

.rail {
	border-right: 1px solid var(--rule);
	position: sticky;
	top: 0;
	align-self: start;
	max-height: 100vh;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: var(--rule) transparent;
}

.rail .label {
	color: var(--steel);
	font-weight: 500;
}

.rail .games-label {
	padding: 16px var(--gutter) 8px;
	border-top: 1px solid var(--rule);
}

.games {
	display: flex;
	flex-direction: column;
}

.game {
	display: flex;
	flex-direction: column;
	gap: 2px;
	text-align: left;
	padding: 8px var(--gutter);
	border-left: 4px solid transparent;
	border-bottom: 1px solid var(--rule);
}

.game .tip {
	font-family: var(--display);
	font-weight: 700;
	font-size: 32px;
	line-height: 1;
}

.game .pair {
	color: var(--steel);
}

.game .tip.tba {
	color: var(--steel);
	font-size: 22px;
	padding-top: 6px;
}

.game.active {
	border-left-color: var(--paper);
}

.game.active .pair {
	color: var(--paper);
}

.filters {
	padding: 8px 0 16px;
}

.filter-row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px var(--gutter);
}

.filter-row .label {
	padding: 0;
	width: 56px;
}

.sq {
	width: 40px;
	height: 40px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--rule);
	color: var(--paper);
	font-weight: 500;
	position: relative;
}

.sq.wide {
	width: auto;
	padding: 0 12px;
	gap: 8px;
}

.sq.active {
	background: var(--paper);
	color: var(--ink);
	border-color: var(--paper);
}

.sq.active .roster-mark {
	background: var(--ink);
}

.sq.active .roster-mark.carried {
	background: transparent;
	border-color: var(--ink);
}

.search {
	width: 100%;
	appearance: none;
	-webkit-appearance: none;
	background: transparent;
	border: 0;
	border-bottom: 1px solid var(--rule);
	color: var(--paper);
	padding: 8px 0;
	font: inherit;
}

.search::-webkit-search-decoration,
.search::-webkit-search-cancel-button {
	-webkit-appearance: none;
	display: none;
}

.search::placeholder {
	color: var(--steel);
}

.search:focus {
	outline: none;
	border-bottom-color: var(--signal);
}

.search-wrap {
	padding: 8px var(--gutter);
}

/* ---------- tower ---------- */

.tower {
	min-width: 0;
	padding-bottom: 32px;
}

.tower-tools {
	display: flex;
	align-items: center;
	gap: 24px;
	height: 40px;
	padding: 0 var(--gutter);
	color: var(--steel);
	border-bottom: 1px solid var(--rule);
}

.tower-tools .count {
	margin-left: auto;
	white-space: nowrap;
}

/* the ruler key: the real marks, at size */
.key {
	display: flex;
	align-items: center;
	gap: 16px;
	white-space: nowrap;
}

.key span {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.key i {
	display: inline-block;
}

.key .k-iqr {
	width: 12px;
	height: 6px;
	background: var(--steel);
}

.key .k-span {
	width: 12px;
	height: 2px;
	background: var(--steel);
}

.key .k-line {
	width: 1px;
	height: 14px;
	background: var(--paper);
}

.key .k-pred {
	width: 2px;
	height: 14px;
	background: var(--signal);
}

.key .k-tight {
	width: 6px;
	height: 6px;
	background: var(--steel);
}

.key .k-carried {
	width: 6px;
	height: 6px;
	border: 1px solid var(--steel);
}

/* sort row: the sort control for viewports where the secondary headers
   are hidden. Hidden on wide desktops. */
.sort-row {
	display: none;
	align-items: center;
	gap: 16px;
	height: 40px;
	padding: 0 var(--gutter);
	border-bottom: 1px solid var(--rule);
	color: var(--steel);
	overflow-x: auto;
	scrollbar-width: none;
}

.sort-row .label {
	font-weight: 500;
}

.sort-opt {
	color: var(--paper);
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
}

.sort-opt.on {
	color: var(--signal);
	text-decoration: underline;
	text-underline-offset: 4px;
}

.grid-row {
	display: grid;
	grid-template-columns:
		4px var(--c-name) var(--c-match) var(--c-tr)
		var(--c-block) var(--c-ruler) minmax(0, 1fr) var(--c-caret);
	column-gap: var(--c-gap);
	align-items: center;
	padding-right: var(--gutter);
}

.thead {
	height: 32px;
	color: var(--steel);
	border-bottom: 1px solid var(--rule);
	position: sticky;
	top: 0;
	background: var(--ink);
	z-index: 2;
}

.thead .h {
	text-align: left;
	white-space: nowrap;
}

.thead .h.sort {
	color: var(--signal);
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.thead .h svg {
	display: inline-block;
}

.thead .block-head {
	display: grid;
	grid-template-columns: 48px 52px 44px 48px;
}

.thead .sec-head {
	display: grid;
	grid-template-columns: repeat(var(--sec-n, 7), var(--c-sec));
	column-gap: 8px;
}

/* the shared axis */
.axis {
	position: relative;
	height: 24px;
}

.axis .base {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 6px;
	height: 1px;
	background: var(--steel);
}

.axis .tick {
	position: absolute;
	bottom: 6px;
	width: 1px;
	height: 3px;
	background: var(--steel);
}

.axis .tick.major {
	height: 6px;
}

.axis .tick-label {
	position: absolute;
	bottom: 13px;
	transform: translateX(-50%);
	font-size: 12px;
	color: var(--steel);
	line-height: 1;
}

.axis .tick-label.first {
	transform: none;
}

.axis .tick-label.last {
	transform: translateX(-100%);
}

/* strips */

.item {
	border-bottom: 1px solid var(--rule);
	will-change: transform;
}

.strip {
	min-height: var(--strip);
	position: relative;
	cursor: pointer;
	/* a row reached by keyboard stops below the 32px sticky head, not under it */
	scroll-margin-top: 40px;
}

.strip .band {
	align-self: stretch;
	background: var(--band, var(--rule));
}

.strip .name {
	display: flex;
	align-items: baseline;
	gap: 8px;
	min-width: 0;
	white-space: nowrap;
	overflow: hidden;
}

.strip .surname {
	font-family: var(--display);
	font-weight: 700;
	font-size: 22px;
	line-height: 1;
	text-transform: uppercase;
	letter-spacing: 0.01em;
}

.strip:hover .surname,
.strip.focus .surname {
	color: var(--signal);
}

.strip .first {
	color: var(--steel);
	overflow: hidden;
	text-overflow: ellipsis;
}

.match-inline {
	display: none;
}

.strip .match {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tr {
	display: inline-flex;
	align-items: center;
	gap: 8px;
}

.tier-sq {
	width: 24px;
	height: 24px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--paper);
	font-weight: 600;
	line-height: 1;
}

.tier-sq.c {
	border-style: dashed;
}

.roster-mark {
	display: inline-block;
	width: 6px;
	height: 6px;
	background: var(--steel);
}

.roster-mark.carried {
	background: transparent;
	border: 1px solid var(--steel);
}

.block {
	display: grid;
	grid-template-columns: 48px 52px 44px 48px;
	align-items: baseline;
	white-space: nowrap;
}

.block .pred {
	font-size: 18px;
	font-weight: 600;
}

.block .line {
	color: var(--steel);
}

.block .delta {
	color: var(--paper);
}

.block .pover {
	color: var(--steel);
}

/* the ruler */

.ruler {
	position: relative;
	height: 24px;
}

.ruler .span {
	position: absolute;
	top: 11px;
	height: 2px;
	background: var(--steel);
}

.ruler .iqr {
	position: absolute;
	top: 9px;
	height: 6px;
	background: var(--steel);
}

/* the naive tick runs taller than the bar so it stays visible on it */
.ruler .naive {
	position: absolute;
	top: 3px;
	width: 1px;
	height: 18px;
	background: var(--paper);
}

.ruler .pred {
	position: absolute;
	top: 5px;
	width: 2px;
	height: 14px;
	background: var(--signal);
}

.ruler .clip {
	position: absolute;
	right: 0;
	top: 5px;
	color: var(--steel);
	font-size: 14px;
	line-height: 1;
}

.sec {
	display: grid;
	grid-template-columns: repeat(var(--sec-n, 7), var(--c-sec));
	column-gap: 8px;
	align-items: center;
}

.sec .v {
	font-size: 14px;
	font-weight: 500;
}

.caret-wrap {
	color: var(--steel);
	display: inline-flex;
	justify-content: flex-end;
}

.item.open .caret {
	transform: rotate(90deg);
}

/* expanded strip */

.detail {
	overflow: hidden;
	height: 0;
	background: var(--ink-2);
}

.detail-inner {
	padding: 16px var(--gutter) 16px 24px;
	display: grid;
	grid-template-columns: 2fr 1fr;
	column-gap: 32px;
}

.detail-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	column-gap: 24px;
	row-gap: 16px;
}

.dstat .dhead {
	display: flex;
	justify-content: space-between;
	align-items: baseline;
	margin-bottom: 4px;
}

.dstat .dhead .k {
	color: var(--steel);
	font-weight: 500;
}

.dstat .dhead .v {
	font-size: 18px;
	font-weight: 600;
}

.dstat .dq {
	color: var(--steel);
	font-size: 12px;
	margin-top: 4px;
}

.dstat .dq b {
	color: var(--paper);
	font-weight: 500;
}

.dstat .dsub {
	color: var(--steel);
	display: flex;
	justify-content: space-between;
	margin-top: 2px;
}

.angles {
	display: flex;
	flex-direction: column;
	gap: 8px;
	border-left: 1px solid var(--rule);
	padding-left: 24px;
}

.angles .k {
	color: var(--steel);
	font-weight: 500;
}

.angles .kv {
	color: var(--steel);
}

.angles .kv b {
	color: var(--paper);
	font-weight: 500;
}

/* ---------- the written notes ---------- */

.words {
	padding: 24px var(--gutter);
	border-bottom: 1px solid var(--rule);
	display: grid;
	grid-template-columns: minmax(0, var(--measure-lede)) minmax(0, var(--measure));
	column-gap: 48px;
	row-gap: 24px;
	align-items: start;
}

.words[hidden],
.voice[hidden] {
	display: none;
}

#gameNotes:empty {
	display: none;
}

#gameNotes .voice + .voice {
	margin-top: 24px;
}

.voice:focus-visible {
	outline: 2px solid var(--paper);
	outline-offset: 4px;
}

.voice .head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin: 0 0 8px;
}

.by {
	margin: 0 0 8px;
	color: var(--steel);
	font-size: 12px;
	font-weight: 500;
	line-height: 1.4;
}

.voice .head .by {
	margin: 0;
}

.by abbr {
	text-decoration: underline dotted;
	text-underline-offset: 3px;
	cursor: help;
}

.by b {
	color: var(--paper);
	font-weight: 600;
}

.by .short {
	display: none;
}

.say {
	margin: 0;
	overflow-wrap: anywhere;
	max-width: var(--measure);
	font-size: var(--say);
	line-height: 1.55;
	font-weight: 400;
	color: var(--paper);
}

.voice.lede .say {
	max-width: var(--measure-lede);
	font-size: var(--say-lede);
	line-height: 1.5;
}

.more {
	display: none;
	min-height: 32px;
	align-items: center;
	color: var(--paper);
	font-size: 13px;
	font-weight: 500;
	text-decoration: underline;
	text-underline-offset: 3px;
	white-space: nowrap;
}

/* the player's note: first in the opened row, over the eight rulers */
.d-main {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 24px;
}

.detail-inner.noted {
	padding-bottom: 24px;
}

.detail-inner.noted .angles {
	align-self: start;
}

.linkbtn {
	align-self: flex-start;
	min-height: 32px;
	color: var(--paper);
	text-decoration: underline;
	text-underline-offset: 3px;
	text-align: left;
}

/* ---------- footer ---------- */

.ledger {
	border-top: 1px solid var(--rule);
	padding: 24px var(--gutter) 32px;
	color: var(--steel);
	max-width: 72ch;
}

.ledger p {
	margin: 0 0 8px;
}

.ledger a {
	color: var(--steel);
}

.keys-toggle {
	color: var(--paper);
	text-decoration: underline;
	text-underline-offset: 3px;
}

.empty {
	padding: 32px var(--gutter);
	color: var(--steel);
}

/* ---------- motion ---------- */

.detail.anim {
	transition: height 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
	.detail.anim {
		transition: none;
	}
}

/* ---------- breakpoints ---------- */

@media (max-width: 1439px) {
	:root {
		--c-name: 168px;
		--c-match: 80px;
		--c-ruler: 200px;
		--c-block: 184px;
		--c-sec: 40px;
	}
	.block,
	.thead .block-head {
		grid-template-columns: 44px 48px 40px 48px;
	}
	.key span:nth-child(n + 5) {
		display: none;
	}
	:root {
		--say-lede: 16px;
		--measure-lede: 544px;
	}
	/* the game note goes under the card note: side by side it
	   would drop under 50 characters a line */
	.words {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* from 1280 to 1319 the seven small stat columns need 28px more than the
   tower has, so the page scrolled sideways; a 36px column still holds them */
@media (min-width: 1280px) and (max-width: 1319px) {
	:root {
		--c-sec: 36px;
	}
}

@media (max-width: 1279px) {
	.frame {
		grid-template-columns: minmax(0, 1fr);
	}
	.rail {
		position: static;
		max-height: none;
		border-right: 0;
		border-bottom: 1px solid var(--rule);
		display: grid;
		grid-template-columns: minmax(0, 1fr) auto;
		align-items: center;
		column-gap: 16px;
	}
	.rail > .games-label {
		display: none;
	}
	.filters {
		order: 2;
	}
	.games {
		order: 1;
	}
	.games {
		flex-direction: row;
		overflow-x: auto;
		scroll-snap-type: x mandatory;
		scrollbar-width: thin;
		scrollbar-color: var(--rule) transparent;
		border-right: 1px solid var(--rule);
		align-self: stretch;
	}
	.game {
		border-bottom: 0;
		border-left: 0;
		border-top: 4px solid transparent;
		border-right: 1px solid var(--rule);
		min-width: 112px;
		flex: 0 0 auto;
		scroll-snap-align: start;
	}
	.game.active {
		border-top-color: var(--paper);
	}
	.filters {
		display: flex;
		align-items: center;
		padding: 8px var(--gutter) 8px 0;
		gap: 16px;
	}
	.filter-row {
		padding: 0;
	}
	.filter-row .label {
		width: auto;
	}
	.search-wrap {
		padding: 0;
		width: 160px;
	}
	:root {
		--c-name: 152px;
		--c-match: 80px;
		--c-block: 184px;
		--c-ruler: 180px;
	}
	.sec {
		grid-template-columns: repeat(3, var(--c-sec));
	}
	.thead .sec-head {
		grid-template-columns: repeat(3, var(--c-sec));
	}
	.sec .v:nth-child(n + 4),
	.thead .sec-head .h:nth-child(n + 4) {
		display: none;
	}
	.sort-row {
		display: flex;
	}
}

@media (max-width: 1023px) {
	:root {
		--c-name: 132px;
		--c-match: 76px;
		--c-block: 176px;
	}
	.sec {
		grid-template-columns: repeat(2, var(--c-sec));
	}
	.thead .sec-head {
		grid-template-columns: repeat(2, var(--c-sec));
	}
	.sec .v:nth-child(n + 3),
	.thead .sec-head .h:nth-child(n + 3) {
		display: none;
	}
	.key span:nth-child(n + 3) {
		display: none;
	}
	.detail-inner {
		grid-template-columns: 1fr;
		row-gap: 16px;
	}
	.angles {
		border-left: 0;
		padding-left: 0;
		border-top: 1px solid var(--rule);
		padding-top: 16px;
	}
}

@media (max-width: 767px) {
	:root {
		--gutter: 16px;
		--strip: 40px;
		--c-name: minmax(0, 1fr);
		--c-tr: 24px;
		--c-block: 92px;
		--c-ruler: 104px;
		--c-caret: 12px;
		--c-gap: 6px;
	}
	.masthead {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
		padding: 24px var(--gutter) 16px;
	}
	.masthead .date {
		font-size: 56px;
	}
	.masthead .meta {
		padding-bottom: 0;
		align-items: flex-start;
		text-align: left;
	}
	.rail {
		grid-template-columns: 1fr;
	}
	.games {
		border-right: 0;
	}
	.filters {
		flex-wrap: wrap;
		padding: 8px var(--gutter);
	}
	.game .tip {
		font-size: 24px;
	}
	.tower-tools {
		gap: 12px;
	}
	.key {
		gap: 12px;
	}
	.grid-row {
		grid-template-columns:
			4px var(--c-name) var(--c-tr) var(--c-block) var(--c-ruler) var(--c-caret);
	}
	.strip .match,
	.strip .sec,
	.strip .roster-mark,
	.thead .match,
	.thead .sec-head {
		display: none;
	}
	.match-inline {
		display: inline;
	}
	.strip .name {
		flex-direction: column;
		align-items: flex-start;
		gap: 0;
		line-height: 1.1;
	}
	.strip .surname {
		font-size: 18px;
	}
	.strip .first {
		font-size: 12px;
		max-width: 100%;
	}
	.block,
	.thead .block-head {
		grid-template-columns: 44px 48px;
	}
	.block {
		grid-template-rows: auto auto;
		line-height: 1.1;
	}
	.block .pred {
		font-size: 16px;
		grid-row: 1;
		grid-column: 1;
	}
	.block .pover {
		grid-row: 1;
		grid-column: 2;
	}
	.block .line {
		grid-row: 2;
		grid-column: 1;
		font-size: 12px;
	}
	.block .delta {
		grid-row: 2;
		grid-column: 2;
		font-size: 12px;
	}
	.thead .block-head .h:nth-child(2),
	.thead .block-head .h:nth-child(3) {
		display: none;
	}
	.detail-inner {
		padding: 16px var(--gutter);
	}
	.detail-grid {
		grid-template-columns: repeat(2, 1fr);
	}
	/* phone: the card note shows two lines and opens in place; a picked
	   game's note shows whole, because it was asked for */
	.words {
		padding: 16px var(--gutter) 24px;
		row-gap: 16px;
	}
	.voice.lede:not(.open) .say {
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		line-clamp: 2;
		overflow: hidden;
	}
	.voice.lede.cut .more {
		display: inline-flex;
	}
	.voice.lede .by .long {
		display: none;
	}
	.voice.lede .by .short {
		display: inline;
	}
	.ledger {
		padding: 24px var(--gutter);
	}
}
