@layer core, module, icons;
/* icons are in the top layer so that they take priority ALWAYS */

/* color scheme */

:root {
	--primary:   oklch(48% 0.139 135);  /* brontosaurus green */
	--secondary: oklch(52% 0.160 262);  /* plesiosaurus blue */
	--accent:    oklch(65% 0.140 70);   /* pterosaur amber */
	--danger:    oklch(50% 0.203 28);

	--text-light: oklch(from var(--primary) 95% calc(c * 0.2) h);
	--text-dark:  oklch(from var(--primary)  5% calc(c * 0.2) h);

	--primary-light:   oklch(from var(--primary) calc(l + 0.2) c h);
	--primary-dark:    oklch(from var(--primary) calc(l - 0.2) c h);
	--secondary-light: oklch(from var(--secondary) calc(l + 0.2) c h);
	--secondary-dark:  oklch(from var(--secondary) calc(l - 0.2) c h);
	--accent-light:    oklch(from var(--accent) calc(l + 0.2) c h);
	--accent-dark:     oklch(from var(--accent) calc(l - 0.2) c h);
	--danger-light:    oklch(from var(--danger) calc(l + 0.2) c h);
	--danger-dark:     oklch(from var(--danger) calc(l - 0.2) c h);

	color-scheme: light dark;
}

@media (prefers-color-scheme: light) {
	:root {
		--bg-1: oklch(from var(--primary)   90% calc(c * 0.2) h);
		--bg-2: oklch(from var(--secondary) 90% calc(c * 0.2) h);
		--bg-a: oklch(from var(--accent)    90% calc(c * 0.2) h);
		--text: var(--text-dark);
		--line: oklch(from var(--primary)   7.5% calc(c * 0.2) h);
		--primary-line:   var(--primary-dark);
		--secondary-line: var(--secondary-dark);
		--accent-line:    var(--accent-dark);
		--danger-line:    var(--danger-dark);
		--primary-faded:   var(--primary-light);
		--secondary-faded: var(--secondary-light);
		--accent-faded:    var(--accent-light);
		--danger-faded:    var(--danger-light);

		--disabled: oklch(from var(--line) 70% c h);
	}
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg-1: oklch(from var(--primary)   10% calc(c * 0.3) h);
		--bg-2: oklch(from var(--secondary) 10% calc(c * 0.3) h);
		--bg-a: oklch(from var(--accent)    10% calc(c * 0.3) h);
		--text: var(--text-light);
		--line: oklch(from var(--primary)   85% calc(c * 0.3) h);
		--primary-line:   var(--primary-light);
		--secondary-line: var(--secondary-light);
		--accent-line:    var(--accent-light);
		--danger-line:    var(--danger-light);
		--primary-faded:   var(--primary-dark);
		--secondary-faded: var(--secondary-dark);
		--accent-faded:    var(--accent-dark);
		--danger-faded:    var(--danger-dark);

		--disabled: oklch(from var(--line) 30% c h);
	}
}

:root {
	--bg-12: color-mix(in oklab, var(--bg-1), var(--bg-2));
	--text-20: oklch(from var(--text) l c h / 20%);
	--text-50: oklch(from var(--text) l c h / 50%);
	--text-80: oklch(from var(--text) l c h / 80%);
	--primary-highlight: color-mix(in oklab, var(--bg-1), var(--primary) 20%);
	--secondary-highlight: color-mix(in oklab, var(--bg-2), var(--secondary) 20%);
	--accent-highlight: color-mix(in oklab, var(--bg-a), var(--accent) 20%);
}

@layer core {

/* general styles */

body {
	background-color: var(--bg-1);
	color: var(--text);
	margin: 0;
	overflow-y: scroll;

	font-family: "Cabin", sans-serif;
	font-weight: normal;

	display: flex;
	flex-flow: column nowrap;
	align-items: center;
	min-height: 100vh;
}

main {
	margin: 0.5rem;
	flex: 1;

	&:not(.full) {
		max-width: 80ch;
	}

	&.full {
		align-self: stretch;
	}

	& > p {
		text-align: justify;
	}
}

footer {
	border-top: var(--text-20);
	margin: 0.5rem;
	font-family: serif;
	font-size: 0.6rem;
	font-style: italic;
	color: var(--text-50);
	text-align: center;
}

:where(h1, h2, h3, h4, h5, h6) {
	font-family: "Philosopher", serif;
	font-weight: bold;
	text-align: center;
}

:where(h1) {
	font-size: 1.75rem;
	margin-block: 0.3rem;

	&:has(+ h2) {
		margin-block-end: 0;
	}
}

:where(h2) {
	font-size: 1.5rem;
	margin-block: 0.2rem;

	h1 + & {
		margin-block-start: 0;
	}

	&:has(+ h3) {
		margin-block-end: 0;
	}
}

:where(h3) {
	font-size: 1.25rem;
	margin-block: 0.15rem;

	h2 + & {
		margin-block-start: 0;
	}

	&:has(+ h4) {
		margin-block-end: 0;
	}
}

:where(h4) {
	font-size: 1.1rem;
	margin-block: 0.1rem;

	h3 + & {
		margin-block-start: 0;
	}
}

:where(h5, h6) {
	font-size: 1rem;
	margin-block: 0.05rem;
}

a {
	color: var(--secondary);

	&:link {
		text-decoration: none;
	}

	&:hover {
		color: var(--accent);
	}
}

kbd {
	font-family: "Azeret Mono". monospace;
	font-weight: bold;
	font-style: normal;
	font-size: 0.9em;
	text-transform: capitalize;

	background-color: var(--bg-a);
	border: 1px solid var(--text-80);
	border-radius: 0.1em;
	color: var(--text);

	display: inline-block;
	min-width: 1lh;
}

:where(button, input[type="submit"], input[type="button"]) {
	li > & {
		margin: 0;
	}

	menu & {
		font-size: 1rem;
	}

	font-family: "Saira", monospace;
	font-weight: 700;

	border-radius: 0.75em;
	border: 3px solid var(--line);
	padding: 0.1em 0.4em;
	background: none;
	color: var(--text);

	&:disabled {
		border-color: oklch(from var(--primary) l 0.02 h);
		background-color: oklch(from var(--primary-faded) l 0.02 h);
		color: var(--text-50);
	}

	&:where(:not(.danger, .outline)):not(:disabled) {
		border-color: var(--primary);
		background-color: var(--primary-faded);
		color: var(--text);

		&:hover:not(:active) {
			border-color: var(--accent);
			background-color: var(--accent-faded);
			color: var(--accent-line);
		}

		&:active {
			border-color: var(--secondary-line);
			background-color: var(--secondary);
		}
	}

	&.outline:enabled {
		border-color: var(--primary);
		color: var(--primary-line);

		&:hover:not(:active) {
			border-color: var(--accent);
			color: var(--accent);
		}

		&:active {
			border-color: var(--secondary);
			color: var(--secondary);
		}
	}

	&.danger:enabled {
		border-color: var(--danger);
		background-color: var(--danger-faded);
		color: var(--text);

		&:hover:not(:active) {
			border-color: var(--danger-line);
			background-color: var(--danger);
			color: var(--danger-light);
		}

		&:active {
			border-color: var(--danger);
			background-color: var(--danger-line);
			color: var(--danger);
		}
	}

	:root:not(:has(dialog[open])) &.attention:enabled {
		position: relative;
		z-index: 2;
		outline-style: solid;
		outline-width: 3px;
		outline-offset: -1px;
		animation: 0.75s ease-in-out infinite alternate pulse-size,
			1.2s linear infinite rainbow-outline;
	}

	.compound-button:not(.vertical) > & {
		&:not(:last-child) {
			margin-right: -3px;
			border-top-right-radius: 0;
			border-bottom-right-radius: 0;

			&:is(:hover, :active) {
				z-index: 1;
			}
		}

		&:not(:first-child) {
			margin-left: 0;
			border-top-left-radius: 0;
			border-bottom-left-radius: 0;
		}
	}

	.compound-button.vertical > & {
		&:not(:last-child) {
			margin-bottom: -3px;
			border-bottom-left-radius: 0;
			border-bottom-right-radius: 0;

			&:is(:hover, :active) {
				z-index: 1;
			}
		}

		&:not(:first-child) {
			margin-top: 0;
			border-top-left-radius: 0;
			border-top-right-radius: 0;
		}
	}
}

.button-row {
	display: flex;
	flex-flow: row nowrap;
	justify-content: center;
	align-items: flex-start;
	gap: 0.25em;
}

.compound-button:not(.vertical) {
	display: flex;
	flex-flow: row nowrap;
	gap: 0;
}

.compound-button.vertical {
	display: flex;
	flex-flow: column nowrap;
	align-items: stretch;
	gap: 0;
}

input:not([type="button"], [type="submit"], [type="reset"]) {
	background-color: var(--bg-2);
	color: var(--text);
	border: 2px solid var(--secondary);
	border-radius: 0.4em;

	&::placeholder {
		color: var(--text-50);
	}

	&:focus {
		border-color: var(--secondary-line);
		outline: none;
		box-shadow: none;
	}

	&:autofill {
		/* browsers typically don't let these styles through no matter what you do, but maybe one day they will... */
		background-color: var(--primary-faded);
		color: var(--primary-line);
	}

	&:invalid {
		border-color: var(--danger-line);
		background-color: var(--danger-faded);
	}
}

.drawer {
	position: relative;
}

.drawer-handle {
	display: block;
	box-sizing: border-box;
	width: 100%;
	text-align: center;

	&::after {
		content: " ▽";
		font-size: 0.75em;
	}

	&:has(+ input[type="checkbox"]:checked), .drawer.hover-open:hover > & {
		border-bottom-left-radius: 0;
		border-bottom-right-radius: 0;

		&::after {
			content: " ▼";
		}
	}
}

.drawer-contents {
	position: absolute;
	z-index: 10;
	padding: 0;
	top: 100%;

	display: none;

	:checked ~ &, .drawer.hover-open:hover > & {
		display: block flex;
		flex-flow: row nowrap;

		list-style: none;
	}
}

.nowrap {
	text-wrap: nowrap;
}

.scrollable-x {
	max-width: 100%;
	overflow-x: auto;
}

.scrollable-y {
	max-height: 100%;
	overflow-y: auto;
}

:where(:has(> .badge)) {
	position: relative;
}

.badge {
	display: block;

	font-family: "Electrolize";
	font-size: 0.75em;
	line-height: 1.5;
	text-align: center;

	min-width: 1lh;
	height: 1lh;
	border-radius: 0.5lh;

	position: absolute;
	right: -0.1em;
	top: -0.1em;

	background-color: var(--danger);
	color: var(--text-light);

	user-select: none;
}
i.notice {

	color: var(--text-50);
}

i.notice.small {
	font-size: 0.75em;
}

header#top-bar {
	position: sticky;
	top: 0;
	left: 0;
	width: 100vw;
	z-index: 100;
}

#main-nav {
	background: linear-gradient(to top in oklab, var(--primary), var(--primary-faded));
	margin: 0;
	padding-top: 1rem;
	padding-bottom: 0;
	padding-left: 3rem;
	padding-right: 3rem;
	border-bottom: 2px solid var(--primary-line);

	text-align: center;
	font-family: "Saira", sans-serif;
	font-size: 1.2rem;
	font-weight: bold;

	& > :where(ul, ol, menu) {
		margin: 0;
		padding: 0;

		display: flex;
		flex-flow: row nowrap;
		justify-content: center;
		gap: 1rem;

		list-style: none;

		& > li {
			box-sizing: border-box;
			flex: 1 1 0;
			border-top-left-radius: 0.3rem;
			border-top-right-radius: 0.3rem;
			border: 1px solid var(--primary-line);
			border-bottom: 0;
			background-color: var(--primary);
			color: var(--text-light);
			max-width: 12ch;
		}
	}


	& li:hover:not(:has(.block-hover:hover, .block-hover :hover)) {
		background-color: var(--accent);
		border-color: var(--accent-line);
	}

	& a {
		display: inline-block;
		width: 100%;
		height: 100%;
		color: var(--text-light);

		&:link {
			text-decoration: none;
		}
	}

	& .drawer {
		&:is(.hover-open:not(:hover), :not(:has(> :checked))) .drawer-contents {
			display: none;
		}

		&:is(.hover-open:hover, :has(> :checked)) .drawer-contents {
			display: flex;
		}

		& .drawer-contents {
			flex-flow: column nowrap;
			align-items: stretch;
			gap: 0;

			box-sizing: border-box;
			min-width: calc(100% + 2px);

			&:not(.flush-right) {
				left: -1px;
			}

			&.flush-right {
				right: -1px;
			}

			background-color: var(--accent);
			border: 2px solid var(--accent-line);
			border-bottom-left-radius: 0.3rem;
			border-bottom-right-radius: 0.3rem;

			& > :not(:first-child) {
				border-top: 1px solid var(--accent-line);
			}

			& a:hover {
				background-color: var(--secondary);
				outline: 1px solid var(--secondary-line);
			}

			&#main-nav--login-drawer {
				background-color: var(--accent-faded);
				color: var(--text);
				& > * {
					border: none;
				}

				& .legal {
					color: var(--text-50);
					font-size: 0.6em;
					font-family: "Cabin", sans-serif;
					text-wrap: balance;
				}
			}
		}
	}
}

dialog {
	font-family: "Cabin", sans-serif;

	background-color: var(--bg-a);
	border: 4px solid var(--accent-line);
	padding: 0;
	border-radius: 1rem;
	color: var(--text);
	min-width: 12rem;

	position: fixed;
	z-index: 100;

	overflow: hidden;
	overscroll-behavior: contain;

	&::backdrop {
		background: linear-gradient(to bottom, var(--text-20), var(--text-50));
		backdrop-filter: blur(4px);
	}

	& h2 {
		text-align: center;
		box-sizing: border-box;
		width: 100%;
		margin: 0;
		margin-bottom: 0.25rem;
		padding: 0.25rem;
		border-bottom: 2px solid var(--accent-line);
		font-size: 1.5rem;
		background: linear-gradient(to right in oklch, var(--accent), color-mix(in oklab, var(--accent), var(--accent-line)));
		color: black;
		user-select: none;
	}

	& p {
		font-size: 1.2rem;
		margin: 0.5em;
	}

	& .button-row {
		padding: 0.25em;
		width: calc(100% - 0.5rem);
		margin: auto;
		margin-top: 0;
		margin-bottom: 0;

		& > button {
			flex-grow: 1;
		}
	}

	& button {
		font-size: 1.15rem;
	}
}

table.header-rows {
	border-collapse: collapse;

	& th {
		text-align: center;
		border-bottom: 1px solid var(--line);
		padding-left: 1em;
		padding-right: 1em;
	}

	& td:not(.numeric) {
		text-align: center;
	}

	& td.numeric {
		text-align: right;
		padding-right: 0.5em;
	}
}

table.header-cols {
	border-collapse: collapse;

	& th {
		text-align: right;
		border-right: 1px solid var(--line);
		padding-right: 0.25em;
	}

	& td:first-of-type {
		padding-left: 0.5ch;
	}
}

td.numeric {
	font-family: "Azeret Mono", monospace;
}

table.player-list tr.current-turn {
	background-color: var(--accent-highlight);
	font-weight: bold;
}

*[data-tooltip]::before {
	content: attr(data-tooltip);
}

*[data-tooltip], .tooltip-container {
	position: relative;

	&::before, & .tooltip {
		pointer-events: none;
		display: block;

		background-color: var(--bg-a);
		border: 1px solid var(--accent-faded);
		color: var(--text);
		opacity: 0%;

		padding: 0.2em;
		text-wrap: nowrap;
		z-index: 20;

		position: absolute;
		bottom: calc(100% + 0.25em);
		left: 50%;
		min-width: 8ch;
		max-width: 40ch;
		translate: -50% 0;

		font-family: "Cabin", sans-serif;
		font-style: italic;
		font-weight: 300;
		font-size: min(0.8rem, 0.9em);

		&:hover {
			opacity: 100%;
		}
	}

	&:hover::before, &:hover .tooltip {
		opacity: 80%;

		transition: opacity 0.25s ease-out 0.5s;
	}
}

.card {
	border: 2px solid var(--secondary-line);
	border-radius: 0.5rem;
	background-color: var(--bg-2);
	font-size: 1rem;
	font-family: "Cabin", sans-serif;
	margin: 0.2rem;

	& h2 {
		margin: 0.2em;
		padding-left: 0.3em;
		padding-right: 0.3em;
		font-size: 1.15em;
		border-bottom: 1px solid var(--line);
	}

	& .card-cols {
		display: flex;
		flex-flow: row nowrap;

		& > * {
			flex-grow: 1;
		}
	}
}

.wait-dots {
	display: flex;
	flex-flow: row nowrap;
	justify-content: center;
	align-items: center;
	gap: 0.35em;

	& > div {
		background-color: var(--text);
		color: var(--bg-a);

		font-size: 0.6rem;
		font-family: "Saira", monospace;
		font-weight: bold;

		text-align: center;
		padding: 0;
		line-height: 1.2em;

		width: 1.2em;
		height: 1.2em;
		border-radius: 0.6em;

		&:empty {
			border-bottom-right-radius: 0.1em;
		}

		animation: 2s linear infinite wait-dot;

		&:nth-child(8n + 2) {
			animation-delay: 0.25s;
		}
		&:nth-child(8n + 3) {
			animation-delay: 0.5s;
		}
		&:nth-child(8n + 4) {
			animation-delay: 0.75s;
		}
		&:nth-child(8n + 5) {
			animation-delay: 1.0s;
		}
		&:nth-child(8n + 6) {
			animation-delay: 1.25s;
		}
		&:nth-child(8n + 7) {
			animation-delay: 1.50s;
		}
		&:nth-child(8n + 0) {
			animation-delay: 1.75s;
		}
	}
}

.color-swatch {
	display: inline-block;
	height: 1lh;
	width: 1lh;
	border-radius: 0;
}

/* --- ANIMATIONS --- */

@keyframes pulse-size {
	from {
		scale: 95%;
	}

	to {
		scale: 115%;
	}
}

@keyframes rainbow-outline {
	0% {
		outline-color: oklch(75% 0.125 0);
	}

	16.7% {
		outline-color: oklch(75% 0.125 60);
	}

	33.3% {
		outline-color: oklch(75% 0.125 120);
	}

	50% {
		outline-color: oklch(75% 0.125 180);
	}

	66.7% {
		outline-color: oklch(75% 0.125 240);
	}

	83.3% {
		outline-color: oklch(75% 0.125 300);
	}

	100% {
		outline-color: oklch(75% 0.125 360);
	}
}

@keyframes wait-dot {
	0% {
		rotate: 0deg;
		translate: 0 0;
		scale: 100%;
	}

	5% {
		rotate: -30deg;
		translate: 0 0.1em;
		scale: 90%;
	}

	30% {
		translate: 0 -0.3em;
		scale: 150%;
	}

	55% {
		rotate: 390deg;
		translate: 0 0.1em;
		scale: 90%;
	}

	60% {
		rotate: 360deg;
		translate: 0 0;
		scale: 100%;
	}

	100% {
		rotate: 360deg;
	}
}

}  /* @layer core */

@layer icons {

@font-face {
	font-family: "Material Icons";
	src: url(https://fonts.gstatic.com/s/materialicons/v143/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2');
	font-weight: 400;
	font-style: normal;
	font-display: block;
}

.icon {
	font-family: 'Material Icons';
	font-weight: normal;
	font-style: normal;
	display: inline-block;
	font-size: 1em;
	line-height: 1;
	max-width: 1lh;
	vertical-align: middle;
	text-transform: none;
	letter-spacing: normal;
	word-wrap: normal;
	white-space: nowrap;
	direction: ltr;
	overflow-x: hidden;

	/* Support for all WebKit browsers. */
	-webkit-font-smoothing: antialiased;
	/* Support for Safari and Chrome. */
	text-rendering: optimizeLegibility;

	/* Support for Firefox. */
	-moz-osx-font-smoothing: grayscale;

	/* Support for IE. */
	font-feature-settings: 'liga';
}

.icon.xsmall {
	font-size: 0.5em;
}

.icon.small {
	font-size: 0.75em;
}

.icon.large {
	font-size: 1.5em;
}

.icon.xlarge {
	font-size: 2em;
}

}
