/*
   The page itself: the layout of board, players and keypad, type, and what every
   part shares.
   Loaded in order with the others (see index.html): a later rule wins. */

/* GENERAL */

html, body {
	margin: 0;
	padding: 0;
	height: 100%;
	width: 100%;
	overflow: hidden;
	font-family: var(--font);
}

/* Behind a phone's notch and home bar margins: the same as the board's background (main), so they blend in.
   The colour under it is what iOS tints its status bar from. */
html {
	-webkit-text-size-adjust: 100%; /* iOS enlarges text when turned sideways, and can leave it so on turning back */
	text-size-adjust: 100%;
	background: linear-gradient(#000000, #161616, #000000) #000000;
	/* The page itself never bounces or stretches when dragged past its edge, and a
	   sideways swipe doesn't turn into Back or Forward (Chrome and Edge, touch or trackpad). */
	overscroll-behavior: none;
}

body {
	/* Held in place, so iOS can't leave the page scrolled up after the keyboard closes. */
	position: fixed;
	top: 0;
	left: 0;
	/* Clear of a phone's notch and home bar, once, and within the screen's height. */
	box-sizing: border-box;
	padding-top: env(safe-area-inset-top);
	padding-right: env(safe-area-inset-right);
	padding-bottom: env(safe-area-inset-bottom);
	padding-left: env(safe-area-inset-left);
	/* A scoreboard, not a document: taps and double taps never select text. */
	user-select: none;
	-webkit-user-select: none;
	-webkit-touch-callout: none;
	-webkit-tap-highlight-color: transparent;
	transform: scale(1);
	transform-origin: 0 0;
	overscroll-behavior: none;
	touch-action: pan-x pan-y; /* an app, not a page: no pinch or double tap zoom */
}

/* On a phone's small screen, thinner lines and tighter corners, in proportion to everything else. */
@media (max-width: 600px), (max-height: 500px) {
	:root {
		--line: 1.6px;
		--radius: 7px;
	}
}

/* Standing up in a home screen app, iOS keeps the page off the home bar anyway: a
   half its room is enough to keep the bottom clear of the screen's rounded corners. */
@media (display-mode: standalone) and (orientation: portrait) {
	body {
		padding-bottom: calc(env(safe-area-inset-bottom) / 2);
	}
}

/* Sideways, sizes in vmin take the full height: the home bar just sits over the bottom edge. */
@media (orientation: landscape) {
	body {
		padding-bottom: 0;
	}
}

main {
	display: flex;
	height: 100%;
	background: var(--page);
}

section {
	position: relative;
}

/* The players in their own rounded panel (.scores-card) and the keypad's keys
   on their own under it, standing in from the screen's edges as the buttons
   do. A size container: the keypad's height is a share of the room (cqh). */
aside {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 30%;
	box-sizing: border-box;
	padding: var(--side-pad) 0 var(--side-pad) var(--side-pad);
	z-index: 1;
	container-type: size;
}

.scores-card,
.visuals-panel {
	background: var(--panel);
	border: var(--border);
	border-radius: var(--radius);
}

.scores-card {
	display: flex;
	flex-direction: column;
	flex: 1 1 0;
	min-width: 0;
	min-height: 0;
	overflow: hidden;
}

/* A game whose players are a grid (cricket): the grid in place of the cards. */
.marks-grid {
	display: none;
}

.scores-card.grid-mode .scores-section {
	display: none;
}

.scores-card.grid-mode .marks-grid {
	display: flex;
	flex: 1 1 0;
	min-height: 0;
	padding: calc(1 * var(--u));
}

.marks-grid table {
	width: 100%;
	height: 100%;
	border-collapse: collapse;
	table-layout: fixed;
	font-family: var(--font-condensed);
	color: var(--text);
	text-shadow: 0 0 8px black;
}

.marks-grid th,
.marks-grid td {
	text-align: center;
	border-bottom: 1px solid #323232;
}

.marks-grid thead th {
	padding: calc(1 * var(--u)) calc(0.5 * var(--u));
	font-size: calc(3.2 * var(--u));
	font-weight: 500;
}

/* A player's name over their column: on two lines when it needs them, then cut. */
.grid-name {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
	overflow-wrap: anywhere;
	line-height: 1.05;
}

/* The numbers down the left. */
.marks-grid tbody th {
	width: 18%;
	font-size: calc(4 * var(--u));
	font-weight: 500;
	color: var(--text-soft);
}

.marks-grid td {
	font-size: calc(5.2 * var(--u));
	line-height: 1;
}

/* The thrower's column. */
.marks-grid .active {
	background: linear-gradient(var(--active-top), var(--active-bottom));
	background: color-mix(in srgb, var(--active-bottom) 55%, transparent);
}

.marks-grid thead th.active {
	background: linear-gradient(var(--active-top), var(--active-bottom));
	border-radius: var(--radius) var(--radius) 0 0;
}

/* Marks from the darts on the board, not yet sent. */
.marks-grid .pending {
	color: var(--hit, #ffc848);
}

/* Closed by everyone: nothing left on it. */
.marks-grid tr.dead {
	opacity: 0.35;
}

.marks-grid tr.points td,
.marks-grid tr.points th {
	border-bottom: none;
	font-size: calc(4.4 * var(--u));
	font-weight: 600;
}

/* A mode with no keypad: its button goes. */
.ctrl-section .ctrl-btn.unused {
	display: none;
}

/* The keypad folds away to give the players the whole column: its room
   shrinks to nothing, the gap above it with it. */
aside.keypad-hidden .calc-section {
	height: 0;
	margin-top: 0;
	visibility: hidden;
}

/* Set for a moment while the list is laid out for where the keypad is going. */
aside.keypad-instant :is(.scores-section, .calc-section) {
	transition: none !important;
}
