/*
   Portrait: a tablet standing up, the board above the players.
   Loaded in order with the others (see index.html): a later rule wins. */

/* PORTRAIT */

/* Built for landscape (16:10, 4:3). In portrait the board goes on top and
   the scores and keypad become a band along the bottom. Sizes are in vmin,
   so they follow the screen's width here. */
@media (orientation: portrait) {
	/* The keypad is a little taller than wide (4:5). On a narrow screen the band
	   gets shorter rather than the keypad getting any narrower than that. */
	main {
		/* The one use of vh: here vmin is the width, and the band must also
		   leave the board enough of the height. */
		--band: min(42vh, 60vw);
		--tip-depth: calc(var(--band) * 0.76); /* the score box is about half the keypad */
		--u: calc(var(--band) / 60); /* 1vmin while the band is 60vw tall; less when it's shorter */
		display: grid;
		grid-template-columns: 100%;
		grid-template-rows: minmax(0, 1fr) var(--band);
	}

	/* The board, its left buttons and its right column share the top area. */
	.ctrl-section,
	.dartboard-section,
	.btn-section {
		grid-row: 1;
		grid-column: 1;
	}

	.ctrl-section {
		justify-self: start;
		height: 100%;
	}

	.dartboard-section {
		width: 100%;
		max-width: none;
		height: 100%;
		container-type: size;
	}

	/* Fits between the buttons on the left and the darts column on the right. */
	.board-frame {
		width: calc(min(100cqw - 30vmin, 98cqh) * 1.01);
		margin: 0;
	}

	/* The right-hand column at the right edge; a key's width here too (the keypad is
	   the band's, inset to line up with it: see .calc-tbl below). */
	.btn-section {
		--card-w: calc((var(--band) * 0.82 - 2 * var(--side-pad) - 15px) / 4);
		--done-w: calc(2 * var(--card-w) + 5px); /* two keys wide */
		--done-h: calc((var(--band) - 2 * var(--side-pad) - 15px) / 4); /* one key tall here */
		justify-self: end;
		height: 100%;
		width: auto;
	}

	/* Done a key tall here: its parts bigger. */
	.side-btn {
		font-size: 6vmin;
	}

	.done-pass .icon {
		width: 7vmin;
		height: 7vmin;
	}

	.done-btn:not(.disabled) .done-score {
		margin-right: 1.4vmin;
	}

	.done-total:not(:empty) {
		font-size: 5.4vmin;
	}

	.done-note {
		font-size: 2.8vmin;
	}

	.done-btn.noting .done-note {
		width: 7.2vmin;
	}

	.done-check {
		font-size: 6vmin;
	}

	/* The two panels side by side along the bottom, the keypad on the left. */
	aside {
		grid-row: 2;
		flex-direction: row;
		width: auto;
		height: auto;
		padding: 0 var(--side-pad) var(--side-pad);
	}

	.scores-card {
		flex: 1 1 0;
	}

	/* Held to the keypad's right edge, which moves: it folds away to the left. */
	.calc-tbl {
		left: auto;
		right: -5px;
		width: calc(var(--band) * 0.82 + 10px);
	}

	/* Bottom left, where the keypad is in every layout. */
	.calc-section {
		--keys-h: 100cqh;
		order: -1;
		width: calc(var(--band) * 0.82);
		height: 100%;
		margin: 0 var(--side-pad) 0 0;
		transition: width var(--medium) var(--ease-out), margin var(--medium) var(--ease-out), visibility var(--medium), filter var(--medium) var(--ease-out);
	}

	aside.keypad-hidden .calc-section {
		width: 0;
		height: 100%;
		margin: 0;
	}

	/* The keypad folds away to the left here: the arrow points left to hide it,
	   right to bring it back. */
	.keypad-btn .keypad-arrow {
		transform: rotate(90deg);
	}

	.keypad-btn[aria-expanded="false"] .keypad-arrow {
		transform: rotate(-90deg);
	}

	.player-menu.opening {
		animation-name: menu-up;
	}

	.player-menu.closing {
		animation-name: menu-down;
	}

	.toast {
		left: 50%;
		max-width: 80vw;
	}

	/* Kept clear of the buttons either side. */
	.toast.review {
		max-width: 56vw;
	}

	.settings-section {
		width: 90%;
	}

	/* Tall screen: only as tall as it needs. */
	.settings-main {
		height: auto;
	}

	/* Board layout fills the band along the bottom: the controls go into
	   columns, with Reset and Done down the right. */
	.visuals-panel {
		display: grid;
		grid-template-columns: minmax(0, 1fr) calc(18 * var(--m));
		grid-template-rows: auto 1fr;
		width: 100%;
		column-gap: calc(2 * var(--m));
		row-gap: calc(1.5 * var(--m));
	}

	.visuals-panel .settings-heading {
		grid-column: 1 / -1;
	}

	/* Each slider the full width, one under another; the two colour rows side by side under them. */
	.visuals-controls {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		column-gap: calc(2 * var(--m));
		row-gap: calc(2 * var(--m));
		align-content: start;
	}

	.visuals-controls > .range,
	.visuals-panel .check-line {
		grid-column: 1 / -1;
		align-self: start;
	}

	.visuals-panel .swatch {
		width: calc(5.5 * var(--m));
		height: calc(5.5 * var(--m));
	}

	.visuals-actions {
		grid-template-columns: none;
		align-content: end;
		margin-top: 0;
	}
}
