/***
 * Copyright © 2026 Symmachus / Timothy A. Lee. All rights reserved.
 * Site language dialog: a grid of language cards, each with its flag
 */
.lang-dialog {
	box-sizing: border-box;
	width: min(720px, calc(100vw - 2rem));
	max-height: min(640px, calc(100dvh - 2rem));
	padding: 0;
	border: 0;
	border-radius: 16px;
	background: var(--base-clr);
	color: var(--text-clr);
	box-shadow: 0 20px 50px rgb(0 0 0 / 25%);
	overflow: hidden;
}
.lang-dialog[open] {
	display: flex;
	flex-direction: column;
}
.lang-dialog::backdrop {
	background: rgb(15 15 20 / 45%);
	backdrop-filter: blur(2px);
}

/* Title and close button */
.lang-dialog-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid var(--line-clr);
}
.lang-dialog-head h2 {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
	font-size: 1.2rem;
}
.lang-dialog-head h2 .svgImg {
	margin: 0;
}
.lang-dialog-close {
	flex: none;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--muted-clr);
	font-size: 1.6rem;
	line-height: 1;
	cursor: pointer;
}
.lang-dialog-close:hover {
	background: var(--hover-clr);
	color: var(--text-clr);
}

/* The cards */
.lang-dialog-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 0.6rem;
	padding: 1.1rem 1.25rem 1.25rem;
	overflow-y: auto;
	overscroll-behavior: contain;
}
.lang-dialog-list[aria-busy="true"]:empty {
	min-height: 160px;
	background:
		radial-gradient(circle at center, transparent 13px, var(--line-clr) 14px, var(--line-clr) 16px, transparent 17px)
		center / 40px 40px no-repeat;
	animation: lang-dialog-wait 1s ease-in-out infinite alternate;
}
@keyframes lang-dialog-wait {
	to { opacity: 0.35; }
}
.lang-option {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	min-width: 0;
	margin: 0;
	padding: 0.7rem 0.8rem;
	border: 1px solid var(--line-clr);
	border-radius: 12px;
	background: var(--base-clr);
	color: var(--text-clr);
	font: inherit;
	text-align: start;
	box-shadow: none;
	cursor: pointer;
	transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.lang-option:hover {
	border-color: var(--action-clr);
	background: var(--hover-clr);
}
.lang-option:focus-visible {
	outline: none;
	border-color: var(--action-clr);
	box-shadow: 0 0 0 3px light-dark(rgb(79 70 229 / 18%), rgb(129 140 248 / 28%));
}
.lang-option .flag {
	flex: none;
	width: 40px;
	height: 28px;
	margin: 0;
	border-radius: 5px;
	background-color: var(--surface-2-clr);
	box-shadow: 0 0 0 1px rgb(0 0 0 / 8%);
}
.lang-option .lang-option-noflag {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--muted-clr);
	font-size: 0.75rem;
	font-weight: 700;
	letter-spacing: 0.04em;
}
.lang-option-names {
	display: flex;
	flex-direction: column;
	min-width: 0;
	line-height: 1.3;
}
.lang-option-native,
.lang-option-current-name {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}
.lang-option-native {
	font-weight: 600;
}
.lang-option-current-name {
	color: var(--muted-clr);
	font-size: 0.85em;
}

/* The language in use: tinted, with a tick */
.lang-option-current {
	border-color: var(--action-clr);
	background: var(--selected-clr);
}
.lang-option-current::after {
	content: "";
	flex: none;
	width: 18px;
	height: 18px;
	margin-inline-start: auto;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* While saving: the chosen card pulses, the others step back */
.lang-dialog-list[aria-busy="true"] .lang-option {
	pointer-events: none;
	opacity: 0.5;
}
.lang-dialog-list[aria-busy="true"] .lang-option-saving {
	opacity: 1;
	border-color: var(--action-clr);
	animation: lang-dialog-wait 0.7s ease-in-out infinite alternate;
}
.lang-dialog-message {
	grid-column: 1 / -1;
	margin: 1rem 0;
	color: var(--muted-clr);
	text-align: center;
}

@media screen and (max-width: 500px) {
	.lang-dialog-list {
		grid-template-columns: 1fr;
	}
}
