/**
 * Выбор города: кнопка в шапке (.city-btn) и диалог со списком городов (#city-dialog).
 */

.city-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 32px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--primary, #208d79);
	font: 500 15px/1.2 var(--ff, "Manrope", sans-serif);
	cursor: pointer;
}

.city-btn__pin {
	flex: none;
	width: 16px;
	height: 16px;
}

.city-btn__arrow {
	flex: none;
	width: 12px;
	height: 12px;
}

.city-btn:hover .city-btn__name {
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* Копия кнопки в бургер-меню телефона — отступы как у пунктов меню */
.header__dropdown .city-btn {
	gap: 8px;
	min-height: 48px;
	padding: 0 24px;
	color: #fff;
	font-size: 20px;
	font-weight: 600;
}

.header__dropdown .city-btn__pin {
	width: 20px;
	height: 20px;
}

/* Диалог */
html:has(.city-dialog[open]) {
	overflow: hidden;
}

.city-dialog {
	/* margin: auto — центр модального <dialog>; общий сброс * { margin: 0 } в main.min.css его убирает */
	margin: auto;
	width: min(880px, calc(100% - 32px));
	max-width: none;
	/* Высота постоянная — при поиске окно не прыгает */
	height: min(720px, calc(100dvh - 64px));
	max-height: none;
	padding: 0;
	border: 0;
	border-radius: 24px;
	background: #fff;
	box-shadow: 0 24px 64px rgba(17, 24, 28, 0.24);
	color: #1a1a1a;
	font-family: var(--ff, "Manrope", sans-serif);
	overflow: hidden;
}

.city-dialog[open] {
	display: flex;
	flex-direction: column;
}

.city-dialog:focus {
	outline: none;
}

.city-dialog::backdrop {
	background: rgba(17, 24, 28, 0.5);
}

.city-dialog [hidden] {
	display: none !important;
}

.city-dialog__head {
	position: relative;
	display: grid;
	gap: 16px;
	padding: 28px 32px 20px;
	border-bottom: 1px solid #e1e7e6;
}

.city-dialog__title {
	margin: 0;
	padding-right: 48px;
	font-size: 24px;
	font-weight: 700;
	line-height: 1.2;
}

.city-dialog__close {
	position: absolute;
	top: 20px;
	right: 20px;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #f2f5f4;
	cursor: pointer;
	transition: background-color 0.2s;
}

.city-dialog__close::before,
.city-dialog__close::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 16px;
	height: 2px;
	border-radius: 1px;
	background: #1a1a1a;
	transform: translate(-50%, -50%) rotate(45deg);
}

.city-dialog__close::after {
	transform: translate(-50%, -50%) rotate(-45deg);
}

.city-dialog__close:hover {
	background: #e1e7e6;
}

.city-dialog__search {
	width: 100%;
	height: 52px;
	padding: 0 16px 0 48px;
	border: 1px solid #e1e7e6;
	border-radius: 14px;
	background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") 16px center / 20px no-repeat;
	color: #1a1a1a;
	font: 16px var(--ff, "Manrope", sans-serif);
	transition: border-color 0.2s, box-shadow 0.2s;
}

.city-dialog__search::placeholder {
	color: #9aa3a1;
}

.city-dialog__search::-webkit-search-cancel-button {
	width: 20px;
	height: 20px;
	background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 4l8 8M12 4l-8 8'/%3E%3C/svg%3E") center / 14px no-repeat;
	cursor: pointer;
	-webkit-appearance: none;
}

.city-dialog__search:focus {
	border-color: var(--primary, #208d79);
	box-shadow: 0 0 0 3px #e8f4f1;
	outline: none;
}

.city-dialog__body {
	min-height: 0;
	padding: 24px 32px 32px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.city-dialog__list {
	column-count: 4;
	column-gap: 24px;
}

.city-dialog__group {
	display: grid;
	grid-template-columns: 22px minmax(0, 1fr);
	margin-bottom: 12px;
	break-inside: avoid;
}

.city-dialog__letter {
	color: var(--primary, #208d79);
	font-size: 15px;
	font-weight: 700;
	line-height: 30px;
}

.city-dialog ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.city-dialog__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 0;
	color: inherit;
	font-size: 15px;
	line-height: 20px;
	text-decoration: none;
	transition: color 0.2s;
}

.city-dialog__link:hover {
	color: var(--primary, #208d79);
}

.city-dialog__link.is-current {
	color: var(--primary, #208d79);
	font-weight: 700;
}

.city-dialog__link.is-current::after {
	content: "";
	width: 14px;
	height: 14px;
	background: currentColor;
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 8.5 6.5 11.5 12.5 4.5' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%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 16 16'%3E%3Cpath d='M3.5 8.5 6.5 11.5 12.5 4.5' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.city-dialog__abroad {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 12px 24px;
	margin-top: 12px;
	padding-top: 20px;
	border-top: 1px solid #e1e7e6;
}

.city-dialog__country-name {
	margin: 0 0 4px;
	color: #6b6b6b;
	font-size: 13px;
	font-weight: 600;
}

.city-dialog__empty {
	margin: 0;
	color: #6b6b6b;
	font-size: 15px;
}

@media (max-width: 991px) {
	.city-dialog__list {
		column-count: 3;
	}

	.city-dialog__abroad {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (max-width: 767px) {
	.city-dialog {
		width: 100%;
		height: 100dvh;
		border-radius: 0;
	}

	.city-dialog__head {
		gap: 12px;
		padding: 16px 16px 12px;
	}

	.city-dialog__title {
		font-size: 20px;
		line-height: 44px;
	}

	.city-dialog__close {
		top: 16px;
		right: 12px;
	}

	.city-dialog__body {
		padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
	}

	.city-dialog__list {
		column-count: 2;
		column-gap: 16px;
	}

	.city-dialog__link {
		padding: 8px 0;
	}

	.city-dialog__letter {
		line-height: 36px;
	}

	.city-dialog__abroad {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 12px 16px;
	}
}
