/*
Author: Vera Konigin
Contact: vera@groundedwren.com
File Description: Index.html styles
*/

:root {
	--cell-size: 80px;
}

@media (width <= 942px) or (height <= 810px) {
	:root {
		--cell-size: 60px;
	}
}

@media (width <= 782px) or (height <= 650px) {
	:root {
		--cell-size: 44px;
	}
}

html {
	height: 100vh;
}

header {
	display: grid;
	grid-template-columns: 1fr 1fr 1fr;
	align-items: center;
	text-align: center;
	gap: 10px;
	padding-block-end: 10px;
	border-block-end: 1px solid var(--border-color);
	padding: 5px;

	> *:first-child {
		width: fit-content;
		justify-self: flex-start;
	}

	> *:nth-child(2) {
		display: flex;
		justify-content: center;
		h1 {
			width: fit-content;
			background-color: var(--accent-color);
			border-radius: 20px;
			padding: 4px;
		}
	}

	> *:last-child {
		width: fit-content;
		justify-self: flex-end;

		display: grid;
		grid-template-columns: auto auto auto;
		gap: 4px;

		.bubble {
			display: flex;
			flex-direction: column;
			gap: 4px;

			> label {
				min-height: 30px;
			}
		}
	}
}

body {
	height: 100vh;
	max-height: 100vh;
	width: 100%;
	max-width: 1920px;

	display: grid;
	grid-template-rows: auto 1fr auto;
}

main {
	max-height: 1000px;
	max-width: 1600px;
	height: 100%;
	padding-block: 5px;
	margin-block: auto;
	margin-inline: auto;

	display: grid;
	grid-template-areas: 
		"x g i";
	grid-template-columns: minmax(0, 300px) auto minmax(300px, auto);

	&:not([data-ToMove]) {
		&[data-winning="w"] {
			#strBtm {
				display: none;
			}
		}
		&[data-winning="b"] {
			#strWtm {
				display: none;
			}
		}

		#spnToMove {
			display: none;
		}
	}
	&[data-toMove] {
		#spnWins {
			display: none;
		}
	}

	&[data-ToMove="w"] {
		#strBtm {
			display: none;
		}

		&:has(#radPpcB:checked) {
			gw-cell button {
				display: none;
			}
		}
	}

	&[data-ToMove="b"] {
		#strWtm {
			display: none;
		}

		&:has(#radPpcW:checked) {
			gw-cell button {
				display: none;
			}
		}
	}

	&[data-ppcLocked] {
		#olbPpc {
			display: none;
		}
		&:has(#radPpcB:checked) {
			#strLockedPpcWhite {
				display: none;
			}
		}
		&:has(#radPpcW:checked) {
			#strLockedPpcBlack {
				display: none;
			}
		}
	}
	&:not([data-ppcLocked]) {
		#spnLockedPpc {
			display: none;
		}
	}

	&[data-initial="false"] {
		#frmHost {
			display: none;
		}
	}

	gw-option-listbox {
		fieldset {
			display: grid;
			grid-template-columns: 1fr 1fr;

			padding: 0;
			border: none;

			--radius: 20px;
			border-radius: var(--radius);
			border-start-start-radius: 0;

			legend {
				border-end-start-radius: 0;
			}

			[role="option"] {
				min-height: 44px;
				min-width: 44px;

				display: flex;
				justify-content: center;

				--full-border: 2px solid var(--link-color);
				--partial-border: 0.5px solid var(--link-color);

				border-block: var(--full-border);

				&:has(+ [role="option"]) {
					border-start-start-radius: var(--radius);
					border-end-start-radius: var(--radius);
					border-inline-start: var(--full-border);
					border-inline-end: var(--partial-border);
				}
				+ [role="option"] {
					border-start-end-radius: var(--radius);
					border-end-end-radius: var(--radius);
					border-inline-start: var(--partial-border);
					border-inline-end: var(--full-border);
				}

				&[tabindex="-1"] {
					outline: none !important;
				}
			}
		}

		svg {
			display: none;
		}
	}
}

#shortsGame {
	grid-area: g;
	display: grid;
	grid-template-rows: 0fr auto;
	justify-items: center;
}

#tblBoard {
	display: grid;
	grid-template-columns: repeat(8, 1fr);
	grid-template-rows: repeat(8, auto);

	--link-color: var(--border-color);

	max-height: 1000px;

	background: var(--board-bkg-gradient);

	tbody, tr {
		display: contents;
	}

	td {
		aspect-ratio: 1 / 1;
		width: var(--cell-size);
		display: grid;
		grid-template-columns: 1fr;
		grid-template-rows: 1fr;
		padding: 0;
		border: 0;
		box-shadow: 0px 0px 0px 1px var(--border-color);

		position: relative;
	}
}

#asiGame {
	display: flex;
	align-items: flex-end;
	height: min-content;
	justify-content: center;
}

#leftArticles {
	grid-area: i;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 10px;

	> article {
		min-width: 200px;
		margin-inline: 5px;
	}
}

#artInfo {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	gap: 5px;

	strong {
		padding: 2px;
		border-radius: 20%;
	}

	table {
		border: none;

		th, td {
			border: none;
		}

		th {
			width: 0;
			word-break: keep-all;
			padding-inline: 2px;
			text-align: end;
		}

		td {
			width: 100%;
		}
	}
}

#artOnline {
	display: flex;
	flex-direction: column;
	gap: 5px;

	form {
		display: flex;
		flex-direction: column;
		gap: 5px;
	}
}

.black-callout {
	background-color: black;
	color: white;
}

.white-callout {
	background-color: white;
	color: black;
}

footer {
	figure {
		text-align: center;
		margin: 5px;
	}
	img {
		display: inline;
	}
}

form, article {
	padding: 4px;
	background-color: var(--background-color-2);

	h1, h2, h3, h4, h5, h6 {
		margin-block: 0;
		margin-block-start: -4px;
		margin-inline: -4px;
		padding-inline: 5px;
		background-color: var(--accent-color);
		word-break: keep-all;
		text-align: start;
	}

	.input-grid {
		display: grid;
		grid-template-columns: 1fr auto;
		row-gap: 5px;
		user-select: none;

		> label {
			text-align: end;
			display: contents;

			&:has(input[type="checkbox"]) {
				&:has(:focus) {
					&::before {
						background-color: var(--mark-color);
					}
				}
				&::before {
					content: "";

				}
				> span {
					&:has(input:checked) {
						background-color: var(--selected-color);
					}
				}
			}

			&:has(:focus-within) {
				> span {
					background-color: var(--mark-color);
				}
				input {
					outline-width: 2px !important;
					outline-color: var(--focus-color) !important;
					outline-style: solid !important;
					outline-offset: 1px !important;
					position: relative !important;
					z-index: 100 !important;
				}
			}
		}
	}

	footer {
		border-block-start: none;
		width: 100%;
		margin-top: 4px;

		display: flex;
		flex-direction: row;
		justify-content: flex-end;
		gap: 5px;
	}
}

dialog {
	border: 1px solid var(--border-color);
	padding: 0;

	&::backdrop {
		background-color: var(--background-color-2);
		opacity: 0.75;
	}
}

#diaInfo > article {
	max-width: 900px;
	padding-block-end: 0px;

	display: grid;
	grid-template-columns: 30px 1fr;
	grid-template-rows: 1fr auto;
	column-gap: 5px;

	gw-icon {
		grid-column: 1;
		grid-row: 1 / span 2;

		&:focus {
			outline: none !important;
			background-color: var(--selected-color);
		}

		.gw-icon {
			width: initial;
			height: initial;
		}
	}
	article {
		grid-column: 2;
		grid-row: 1;

		:is(h1, h2, h3, h4, h5, h6) + p {
			margin-block-start: 0;
		}
	}
	footer {
		grid-row: 2;
		grid-column: 2;

		border: none;
		position: sticky;
		bottom: 0;

		display: flex;
		justify-content: flex-end;
		gap: 10px;
	}
}

button {
	display: flex;
	align-items: center;
	justify-content: center;
}

gw-switch {
	min-width: 20px;
}

@media (width <= 654px) {
	:root {
		--cell-size: 100%;
	}
	header {
		display: flex;
		flex-direction: column;
	}

	main {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: min(100%, 575px);
		padding-inline: 10px;
	}

	#shortsGame {
		width: 100%;
		display: block;
	}

	#divBoardContainer {
		display: contents;
	}
}