:root {
	--color-background: rgb(71 26 38);
}

html, body {
	height: 100%;
	width: 100%;
}

* {
	box-sizing: border-box;
	position: relative;
}

.visually-hidden {
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	height: 1px;
	overflow: hidden;
	position: absolute;
	white-space: nowrap;
	width: 1px;
}

body {
	background: var(--color-background) url('../img/bg-pattern.png') no-repeat 50% 100% / contain;
	font-family: 'Montserrat', sans-serif;
	margin: 0;
	overflow: hidden;
	padding: 0;
}

main {
	display: flex;
	flex-direction: column;
	height: 100%;
	width: 100%;
}

header {
	--bg-dot-color: var(--color-background);
	--bg-dot-size: 1px;
	--bg-dot-gap: 3px;

	background:
		linear-gradient(to top, transparent, var(--color-background)),
		radial-gradient(var(--bg-dot-color) var(--bg-dot-size), transparent var(--bg-dot-size)) repeat top left / var(--bg-dot-gap) var(--bg-dot-gap);
	color: white;
	left: 0;
	padding: 0 30px;
	position: fixed;
	top: 0;
	width: 100%;
	z-index: 2;

	.inner {
		align-items: center;
		border-bottom: 1px solid white;
		display: flex;
		justify-content: space-between;
		margin: auto;
		max-width: 1200px;
		padding: 30px 0;
		width: 100%;
	}

	#logo {
		aspect-ratio: 3 / 1;
		background: url('../img/automated-logic-logo.svg') no-repeat 0 0 / contain;
		display: block;
		height: 60px;
	}

	#filters {
		display: flex;
		gap: 0.5em;

		ui-dropdown {
			width: 240px;
		}
	}

	.country-filter {
		display: block;
		min-width: 270px;

		&::after {
			border-bottom: 2px solid white;
			border-right: 2px solid white;
			content: '';
			height: 13px;
			pointer-events: none;
			position: absolute;
			right: 22px;
			top: 15px;
			transform: rotate(45deg);
			width: 13px;
		}

		.country-filter-toggle {
			background: transparent;
			border: 1px solid white;
			border-radius: 18px;
			color: white;
			cursor: pointer;
			font: inherit;
			font-size: 0.85rem;
			font-weight: 600;
			height: 46px;
			overflow: hidden;
			padding: 0 58px 0 28px;
			text-align: left;
			text-overflow: ellipsis;
			text-transform: uppercase;
			white-space: nowrap;
			width: 100%;
		}

		&.open::after {
			top: 19px;
			transform: rotate(225deg);
		}

		.country-filter-menu {
			--padding: 12px;

			background: white;
			border-radius: 12px;
			box-shadow: 0 8px 28px rgb(20 0 8 / 24%);
			position: absolute;
			right: 0;
			top: calc(100% + 8px);
			width: 100%;
			z-index: 3;

			&[hidden] {
				display: none;
			}

			.country-search {
				display: block;
				padding: var(--padding) var(--padding) 0 var(--padding);

				input {
					border: 1px solid #d3c7ca;
					border-radius: 8px;
					color: var(--color-background);
					font: inherit;
					font-size: 0.85rem;
					outline: none;
					padding: 10px 12px;
					width: 100%;

					&:focus {
						border-color: var(--color-background);
					}
				}
			}

			.country-options {
				list-style: none;
				margin: 0;
				max-height: 230px;
				overflow-y: auto;
				padding: var(--padding);

				li[hidden] {
					display: none;
				}

				button {
					background: transparent;
					border: 0;
					border-radius: 6px;
					color: var(--color-background);
					cursor: pointer;
					font: inherit;
					font-size: 0.85rem;
					padding: 9px 10px;
					text-align: left;
					width: 100%;

					&:hover,
					&:focus-visible {
						background: #f3edef;
						outline: none;
					}
				}
			}
		}
	}
}

#map {
	flex: 1;
	height: 100%;
	width: 100%;

	.project-marker {
		aspect-ratio: 2 / 1;
		background: url('../img/marker.svg') no-repeat center / contain;
		cursor: pointer;
		height: 32px;
		width: 32px;

		&.selected {
			background-image: url('../img/marker-selected.svg');
		}
	}

	.mapboxgl-control-container {
		height: 100%;
		pointer-events: none;
	}
}

#details {
	--details-accent: #ed261a;
	--details-heading: #471a26;
	--details-text: #898589;

	background-color: white;
	border-radius: 9px;
	bottom: 30px;
	box-shadow: 0 6px 24px rgb(20 0 8 / 16%);
	left: 40px;
	max-height: calc(100vh - 180px);
	max-width: 390px;
	overflow: auto;
	padding: 24px 25px 26px;
	position: fixed;
	width: calc(100% - 80px);
	z-index: 2;

	&[hidden] {
		display: none;
	}

	h2 {
		color: var(--details-heading);
		font-size: 1.25rem;
		font-weight: 700;
		letter-spacing: 0.01em;
		line-height: 1.2;
		margin: 0 0 20px;
		text-transform: uppercase;
	}

	.project-details {
		display: flex;
		flex-direction: column;
		gap: 15px;

		span {
			color: var(--details-text);
			display: block;
			font-size: 1.05rem;
			font-weight: 300;
			line-height: 1.25;
			padding-left: 30px;

			&.location {
				background: url('../img/marker-red.svg') no-repeat 0 50% / contain;
			}

			&.technical {
				background: url('../img/wrench.svg') no-repeat 0 50% / contain;
			}
		}
	}

	:empty {
		display: none;
	}
}

ui-dropdown {
	all: revert;
	box-sizing: border-box;
	position: relative;

	* {
		all: revert;
		box-sizing: border-box;
		position: relative;
	}

	button {
		appearance: none;
		background: transparent;
		border: 1px solid white;
		border-radius: 18px;
		color: white;
		cursor: pointer;
		display: block;
		font: inherit;
		font-size: 0.85rem;
		font-weight: 600;
		height: 46px;
		overflow: hidden;
		padding: 0 58px 0 28px;
		text-align: left;
		text-overflow: ellipsis;
		text-transform: uppercase;
		white-space: nowrap;
		width: 100%;

		&::after {
			border-bottom: 2px solid white;
			border-right: 2px solid white;
			content: '';
			height: 13px;
			pointer-events: none;
			position: absolute;
			right: 22px;
			top: 15px;
			transform: rotate(45deg);
			transition: top 200ms ease-in-out, transform 200ms ease-in-out;
			width: 13px;
		}
	}

	.popover {
		--padding: 12px;
		background: white;
		border: 0;
		border-radius: 12px;
		box-shadow: 0 8px 28px rgb(20 0 8 / 24%);
		margin-top: 8px;
		padding: 0;
		position-area: center bottom;
		width: anchor-size(inline);

		&[hidden] {
			display: none;
		}

		input {
			border: 1px solid #d3c7ca;
			border-radius: 8px;
			color: var(--color-background);
			display: block;
			font: inherit;
			font-size: 0.85rem;
			margin: var(--padding) var(--padding) 0 var(--padding);
			outline: none;
			padding: 10px 12px;
			width: calc(100% - var(--padding) * 2);

			&:focus {
				border-color: var(--color-background);
			}
		}

		ul {
			list-style: none;
			margin: 0;
			max-height: 230px;
			overflow-y: auto;
			padding: var(--padding);

			li {
				background: transparent;
				border: 0;
				border-radius: 6px;
				color: var(--color-background);
				cursor: pointer;
				font: inherit;
				font-size: 0.85rem;
				padding: 9px 10px;
				text-align: left;
				width: 100%;

				&:hover,
				&:focus-visible {
					background: #f3edef;
					outline: none;
				}
			}

			li[hidden] {
				display: none;
			}
		}
	}

	&:has(:popover-open) {
		button {
			&::after {
				top: 19px;
				transform: rotate(225deg);
			}
		}
	}
}

@media (max-width: 600px) {
	header {
		padding: 0 20px;

		.inner {
			gap: 20px;
			padding: 20px 0;
		}

		#logo {
			height: 44px;
		}

			.country-filter {
			min-width: 0;
			width: min(210px, 55vw);

				.country-filter-toggle {
					padding-left: 18px;
			}
		}
	}

	#details {
		bottom: 20px;
		left: 20px;
		padding: 20px;
		width: calc(100% - 40px);
	}
}
