/* ==========================================================================
   Country picker

   Only .bs-cc lives here. The rows the picker sits in -- .bsi__phone in the
   questionnaire and .bs-phone-row on the contact form -- are already laid out
   in bs-itin.css and bs-extra.css, and are left alone apart from the one
   override at the bottom.

   The popup is a fixed-position layer rather than an absolutely positioned
   child, because the control sits inside cards and form rows that clip their
   overflow and a dropdown cut off halfway is worse than no dropdown.
   ========================================================================== */

.bs-cc {
	--cc-ink:    #0B1230;
	--cc-muted:  #5A6488;
	--cc-line:   #DCE4F5;
	--cc-line-2: #E8ECF6;
	--cc-brand:  #2872FA;
	--cc-hover:  #F1F5FF;

	position: relative;
	flex: 0 0 auto;
}

/* ------------------------------------------------------------- the button */

.bs-cc__btn {
	display: inline-flex;
	align-items: center;
	gap: .45rem;
	height: 100%;
	min-height: 2.9rem;
	padding: 0 .7rem;
	font-family: Manrope, -apple-system, "Segoe UI", system-ui, sans-serif;
	font-size: .95rem;
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	color: var(--cc-ink);
	background: #FFFFFF;
	border: 1px solid var(--cc-line);
	border-radius: 10px;
	cursor: pointer;
	white-space: nowrap;
	transition: border-color .15s ease, box-shadow .15s ease;
}

.bs-cc__btn:hover { border-color: #B9C4DF; }

.bs-cc__btn:focus-visible,
.bs-cc.is-open .bs-cc__btn {
	outline: none;
	border-color: var(--cc-brand);
	box-shadow: 0 0 0 3px rgba(40, 114, 250, .18);
}

.bs-cc__flag {
	display: block;
	width: 20px;
	height: 15px;
	object-fit: cover;
	border-radius: 2px;
	/* A hairline keeps the mostly white flags -- Japan, Finland -- from
	   dissolving into the row, and holds the box while the image loads. */
	box-shadow: 0 0 0 1px rgba(11, 18, 48, .12);
	background: var(--cc-line-2);
	flex: 0 0 auto;
}

.bs-cc__caret {
	font-size: .7rem;
	line-height: 1;
	color: var(--cc-muted);
	transition: transform .15s ease;
}

.bs-cc.is-open .bs-cc__caret { transform: rotate(180deg); }

/* -------------------------------------------------------------- the popup */

.bs-cc__pop {
	position: fixed;
	z-index: 10000;
	display: flex;
	flex-direction: column;
	min-width: 16rem;
	background: #FFFFFF;
	border: 1px solid var(--cc-line);
	border-radius: 12px;
	box-shadow: 0 24px 48px -20px rgba(11, 18, 48, .35);
	overflow: hidden;
}

.bs-cc__pop[hidden] { display: none; }

.bs-cc__search {
	flex: 0 0 auto;
	margin: .55rem;
	padding: .55rem .7rem;
	font-family: inherit;
	font-size: .95rem;
	color: var(--cc-ink);
	background: #F7F9FF;
	border: 1px solid var(--cc-line-2);
	border-radius: 8px;
}

.bs-cc__search:focus {
	outline: none;
	border-color: var(--cc-brand);
	background: #FFFFFF;
}

.bs-cc__list {
	flex: 1 1 auto;
	list-style: none;
	margin: 0;
	padding: 0 0 .4rem;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.bs-cc__head {
	padding: .55rem .8rem .3rem;
	font-size: .7rem;
	font-weight: 700;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: var(--cc-muted);
}

/* The heading that opens the alphabetical run gets a rule above it, so the
   shortcut list and the full list read as two things rather than one long
   one that happens to mention Venezuela twice. */
.bs-cc__opt + .bs-cc__head {
	margin-top: .35rem;
	border-top: 1px solid var(--cc-line-2);
	padding-top: .6rem;
}

.bs-cc__opt {
	display: flex;
	align-items: center;
	gap: .6rem;
	padding: .5rem .8rem;
	font-size: .95rem;
	line-height: 1.3;
	color: var(--cc-ink);
	cursor: pointer;
}

.bs-cc__opt.is-active { background: var(--cc-hover); }

.bs-cc__opt[aria-selected="true"] {
	font-weight: 700;
	box-shadow: inset 2px 0 0 var(--cc-brand);
}

.bs-cc__name {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bs-cc__code {
	flex: 0 0 auto;
	font-size: .85rem;
	font-variant-numeric: tabular-nums;
	color: var(--cc-muted);
}

.bs-cc__empty {
	margin: 0;
	padding: .9rem .8rem 1.1rem;
	font-size: .9rem;
	color: var(--cc-muted);
}

.bs-cc__empty[hidden] { display: none; }

@media (max-width: 30rem) {
	.bs-cc__btn {
		min-height: 2.75rem;
		padding: 0 .5rem;
		gap: .35rem;
		font-size: .9rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.bs-cc__btn,
	.bs-cc__caret { transition: none; }
}
