@use "../../style/mixins";
@use "../../style/variables";

:host {
	display: flex;
	flex-flow: column nowrap;
	width: 100%;
	background-color: var(--main-bg-color);

	@include mixins.full-height;

	&.dkgreen {
		--main-bg-color: #19262e;
		--main-bg-color-lt: #22353f;
		--main-bg-color-dk: #142026;
	}

	&.dkblue {
		--main-bg-color: #001552;
		--main-bg-color-lt: #22353f;
		--main-bg-color-dk: #142026;
		--main-text-color: #fff;
		--main-text-color-lt: #ffe9c0;
		--main-text-color-dk: #dcdbdb;
		--dialog-text-color: #001552;
	}

	&.ltblue {
		--main-bg-color: #34385a;
		--main-bg-color-lt: #22353f;
		--main-bg-color-dk: #142026;
		--main-text-color: #fff;
		--main-text-color-lt: #ffe9c0;
		--main-text-color-dk: #dcdbdb;
		--dialog-text-color: #34385a;
	}

	&.white {
		--main-bg-color: #fff;
		--main-bg-color-lt: #b9b9b9;
		--main-bg-color-dk: #f6f5f5;
		--main-text-color: #000;
		--main-text-color-lt: #646464;
		--main-text-color-dk: #8c8c8c;
		--dialog-text-color: #000;
	}

	&.brown {
		--main-bg-color: brown;
		--main-bg-color-lt: #ad2d2d;
		--main-bg-color-dk: #982626;
		--main-text-color: #fff;
		--main-text-color-lt: #ffe9c0;
		--main-text-color-dk: #dcdbdb;
		--dialog-text-color: #601616;
	}

	&.black {
		--main-bg-color: #000;
		--main-bg-color-lt: #3a3a3a;
		--main-bg-color-dk: #171717;
	}

	.controls {
		min-width: 170px;

		.feature {
			display: none;

			&.enabled {
				display: unset;
			}
		}

		.ctrl {
			display: inline-block;
			color: var(--main-text-color);
			user-select: none;

			.link {
				text-decoration: none;
				font-weight: normal;
				color: var(--main-text-color);
				margin-left: 16px;
				padding: 0.2em 0.8em;

				i {
					margin-right: 2px;
				}

				&:hover {
					color: var(--main-text-color-lt);
				}

				&[disabled] {
					color: var(--main-text-color-dk);
				}

				@include mixins.respond-to(tiny-up) {
					margin-left: 10px;
				}
			}

			.button {
				background-color: transparent;
				background-image: none;
				border-color: transparent;
				border-radius: 3px;

				&:hover {
					border-color: var(--main-bg-color-lt);
				}
			}

			&.ctrl-name {
				font-weight: 600;
				cursor: pointer;

				.icon-logo {
					color: red;
				}

				span.name {
					margin-left: 6px;
				}
			}

			.inactive {
				color: var(--main-text-color-dk);

				&:hover {
					color: var(--main-text-color-dk);
				}
			}

			&.ctrl-game {
				float: right;
			}

			&.ctrl-time {
				cursor: default;
				float: right;
				padding-right: 12px;
				padding-top: 2px;

				.text {
					margin-right: 26px;
					font-variant-numeric: lining-nums;
				}

				small {
					margin-right: 6px;
				}

				.time {
					min-width: 98px;
					display: inline-block;
					text-align: right;
					font-variant-numeric: slashed-zero tabular-nums;
				}
			}

			&.ctrl-stats {
				cursor: default;

				.menu-button {
					display: none;
				}

				.label {
					margin-left: 10px;
				}
			}

		}

		@include mixins.respond-to(small-up) {
			.ctrl.ctrl-game {
				padding-right: 8px;
			}
		}

		@include mixins.respond-to(medium-up) {
			font-size: variables.$base-font-size * 1.2;
		}

		@include mixins.respond-to(large-up) {
			font-size: variables.$base-font-size * 1.3;
		}

		@include mixins.respond-to(huge-up) {
			font-size: variables.$base-font-size * 1.6;
		}

		@include mixins.respond-to(jumbo-up) {
			font-size: variables.$base-font-size * 2.3;
		}

		@include mixins.respond-to(ludicrous-up) {
			font-size: variables.$base-font-size * 4;
		}

		@include mixins.respond-to(large-down) {
			font-size: variables.$base-font-size * 1.3;

			.ctrl .link {
				padding: 0.2em;
			}
		}

		@include mixins.respond-to(medium-down) {
			span.label {
				display: none;
			}
		}

		@include mixins.respond-to(small-down) {
			padding: 0 6px;
		}

		@include mixins.respond-to(tiny-down) {
			.ctrl .link {
				padding: 0.2em;
				margin-left: 2px;
			}

			span.name {
				display: none;
			}

			.ctrl.ctrl-time .time {
				min-width: 80px;
			}

			.ctrl {
				span:first-of-type {
					margin-left: 0;
				}
			}
		}

		@include mixins.respond-to(pico-down) {
			font-size: 18px;

			.ctrl-game {
				.link {
					padding-left: 0.1em;
					padding-right: 0.1em;
				}
			}

			.ctrl.ctrl-time .time {
				min-width: 0;
			}

			span.name {
				display: none;
			}

			.ctrl.ctrl-stats {
				position: relative;

				.menu-button {
					display: block;
				}

				.menu {
					display: none;
					position: absolute;
					bottom: 100%;
					right: 0;
					background: var(--dialog-background-color);
					border: 1px solid var(--dialog-border-color);
					border-radius: 8px;
					flex-direction: column;
					z-index: 10;

					.button {
						padding: 0.5em;
						margin-left: 0;
					}
				}

				&:hover,
				&:focus-within {
					.menu {
						display: flex;
					}
				}
			}
		}
	}

	.controls-top {
		border-bottom: 1px solid var(--main-bg-color-lt);
	}

	.controls-bottom {
		border-top: 1px solid var(--main-bg-color-lt);
		margin-bottom: 4px;
	}

	.board {
		display: flex;
		flex-direction: row;
		flex: 1;
		overflow: hidden;
	}

	@include mixins.respond-to-horizontal-device(pad) {
		flex-direction: row;

		.controls {
			.ctrl {
				float: unset !important;
				text-align: center;

				i {
					font-size: 32px;
				}

				.link {
					display: block;
					margin-left: 0;
					margin-bottom: 10px;
					padding-left: 0;
					padding-right: 0;
				}

				.feature {
					display: none;

					&.enabled {
						display: block;
					}
				}

			}
		}

		padding-left: 52px;
		padding-right: 52px;

		.controls-top {
			min-width: unset;
			max-width: 52px;
			padding: 0;
			display: flex;
			flex-direction: column;
			height: 100%;
			position: absolute;
			left: 0;
			justify-content: space-between;

			.ctrl.ctrl-name {
				display: flex;
				flex-direction: column;
			}

			.ctrl.ctrl-game {
				display: flex;
				flex-direction: column-reverse;

				span:first-of-type {
					margin-bottom: 2px;
				}
			}

			span.name {
				display: none;
			}

			span.label {
				display: none;
			}
		}

		.controls-bottom {
			min-width: 98px;
			max-width: 98px;
			display: flex;
			flex-direction: column;
			height: 100%;
			position: absolute;
			right: 0;
			padding: 0;
			align-items: flex-end;

			.ctrl {
				flex: 1;
				display: flex;
				flex-direction: column;
				text-align: right;

				.label {
					margin-left: 0;
				}
			}

			.ctrl.ctrl-time {
				text-align: right;
				justify-content: flex-end;
				padding-right: 6px;
				padding-left: 6px;

				.time {
					text-align: right;
					min-width: 0;
				}

				.text {
					text-align: right;
					margin-right: 0;
					margin-bottom: 8px;

					small {
						display: block;
						margin-right: 0;
						line-height: 0.9em;
					}
				}
			}


		}
	}

	@include mixins.respond-to-horizontal-device(phone) {
		.controls .ctrl .link {
			margin-bottom: 0;
		}

		.controls {
			.ctrl {
				i {
					font-size: 20px;
				}
			}
		}
	}
}
