/**
 * City selector — checkout and cart.
 *
 * Colours and radii follow the Woostify theme already in use (#1346af primary,
 * #2b2b2b text, 4px radius) so the control reads as part of the checkout rather
 * than as something bolted on. Sized for thumbs first.
 */

.sd-city-select {
	position: relative;
	width: 100%;
}

/* The native select stays in the DOM and stays authoritative. It is hidden
   from sight but not from the form, and it is what the browser validates and
   the Store API receives. */
.sd-city-select .sd-city-native {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* The wrapper we take over draws its own dropdown arrow — a pseudo-element on
   the container, or an SVG beside the select. Our trigger has one of its own,
   and two carets on one control reads as a rendering bug. Only wrappers that
   hold this single field carry this class; see markHost() in checkout-city.js. */
.sd-city-host::before,
.sd-city-host::after {
	content: none !important;
	background-image: none !important;
}

.sd-city-host > svg {
	display: none !important;
}

/* Belt and braces: WooCommerce Blocks renders its chevron as an SVG sibling of
   the select inside .wc-blocks-components-select__container. Matching on the
   structure means the arrow stays hidden even if React re-renders the
   container and drops the class added above. Kept as its own rule because a
   browser without :has() would otherwise discard the rule it shares. */
.wc-blocks-components-select__container:has( > .sd-city-select ) > svg {
	display: none !important;
}

.sd-city-trigger {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	width: 100%;
	min-height: 52px;
	padding: 12px 14px;
	background: #fff;
	border: 1px solid #d9dce3;
	border-radius: 4px;
	color: #8b8f99;
	font-size: 16px; /* 16px keeps iOS from zooming the page on focus. */
	font-family: inherit;
	line-height: 1.4;
	text-align: start;
	cursor: pointer;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.sd-city-trigger.has-value {
	color: #2b2b2b;
}

.sd-city-trigger:hover {
	border-color: #b9bec8;
}

.sd-city-trigger:focus-visible,
.sd-city-trigger[aria-expanded="true"] {
	outline: none;
	border-color: #1346af;
	box-shadow: 0 0 0 2px rgba(19, 70, 175, .18);
}

.sd-city-trigger__text {
	flex: 1 1 auto;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sd-city-trigger__caret {
	flex: 0 0 auto;
	width: 9px;
	height: 9px;
	margin-inline-start: 4px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: rotate(45deg) translate(-2px, -2px);
	opacity: .55;
}

.sd-city-trigger[aria-expanded="true"] .sd-city-trigger__caret {
	transform: rotate(225deg) translate(-3px, -3px);
}

.sd-city-panel {
	position: absolute;
	z-index: 60;
	inset-inline: 0;
	top: calc(100% + 6px);
	display: flex;
	flex-direction: column;
	max-height: 340px;
	background: #fff;
	border: 1px solid #d9dce3;
	border-radius: 4px;
	box-shadow: 0 12px 32px rgba(17, 17, 17, .14);
	overflow: hidden;
}

.sd-city-panel[hidden] {
	display: none;
}

.sd-city-search {
	flex: 0 0 auto;
	width: 100%;
	min-height: 48px;
	padding: 12px 14px;
	border: 0;
	border-bottom: 1px solid #eceef2;
	border-radius: 0;
	background: #fff;
	color: #2b2b2b;
	font-size: 16px;
	font-family: inherit;
}

.sd-city-search:focus {
	outline: none;
	box-shadow: inset 0 -2px 0 #1346af;
}

.sd-city-options {
	flex: 1 1 auto;
	margin: 0;
	padding: 4px 0;
	list-style: none;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.sd-city-option {
	display: flex;
	align-items: baseline;
	gap: 10px;
	min-height: 46px;
	margin: 0;
	padding: 11px 14px;
	cursor: pointer;
	line-height: 1.35;
}

.sd-city-option__ar {
	color: #2b2b2b;
	font-size: 15px;
}

.sd-city-option__fr {
	color: #8b8f99;
	font-size: 12.5px;
	direction: ltr;
	unicode-bidi: isolate;
}

.sd-city-option.is-active,
.sd-city-option:hover {
	background: #f1f4fb;
}

.sd-city-option.is-selected {
	background: #e8eefa;
}

.sd-city-option.is-selected .sd-city-option__ar {
	font-weight: 600;
	color: #1346af;
}

.sd-city-empty {
	margin: 0;
	padding: 18px 14px;
	color: #8b8f99;
	font-size: 14px;
	text-align: center;
}

/* Full-height list on phones: the panel is the interface, not a hint. */
@media (max-width: 600px) {
	.sd-city-panel {
		max-height: 62vh;
	}

	.sd-city-option {
		min-height: 50px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sd-city-trigger {
		transition: none;
	}
}
