/**
 * Country selector: header dropdown and drawer accordion
 * (template-parts/components/country-selector.php, js/country-selector.js).
 *
 * The footer context still uses its footer.css classes (country-toggle,
 * country-panel) until the footer batch. All values come from tokens.css.
 *
 * @package cartrack
 */

.country-selector__toggle {
	display: inline-flex;
	align-items: center;
	gap: var(--space-xs);
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: none;
	cursor: pointer;
}

span.country-selector__toggle {
	cursor: default;
}

.country-selector__toggle .icon {
	flex: none;
	width: 1.25em;
	height: 1.25em;
}

.country-selector__toggle .icon--caret {
	width: 1em;
	height: 1em;
	transition: transform var(--transition-fast);
}

.country-selector__toggle[aria-expanded="true"] .icon--caret {
	transform: rotate(180deg);
}

.country-selector__panel[hidden] {
	display: none;
}

.country-selector__regions {
	display: grid;
	gap: var(--space-lg);
}

.country-selector__title {
	margin: 0 0 var(--space-sm);
	padding-bottom: var(--space-xs);
	border-bottom: 1px solid var(--color-border);
	color: var(--color-text);
	font-family: var(--t-small-bold-family);
	font-size: var(--t-small-bold-size);
	font-weight: var(--t-small-bold-weight);
	line-height: var(--t-small-bold-line-height);
}

.country-selector__list {
	display: grid;
	gap: var(--space-xs);
	margin: 0;
	padding: 0;
	list-style: none;
}

.country-selector__link {
	display: inline-flex;
	align-items: center;
	gap: var(--space-xs);
	color: var(--color-text);
	font-family: var(--t-small-family);
	font-size: var(--t-small-size);
	font-weight: var(--t-small-weight);
	line-height: var(--t-small-line-height);
	text-decoration: none;
}

.country-selector__link:hover {
	color: var(--country-link-hover); /* TODO: hover state not in the frames. */
}

.country-selector__link:focus-visible {
	outline: 2px solid var(--color-focus-dark);
	outline-offset: 2px;
}

.country-selector__flag {
	flex: none;
	width: var(--country-flag-width);
	height: auto;
	border-radius: 1px;
}

/* ---------- Header: dropdown under the utility bar (placeholder proposal) ---------- */

/* Shown from --bp-nav (header.css); the mobile bar has the language label only. */
.utility-items--bar .utility-items__country {
	position: relative;
	align-items: center;
	align-self: stretch;
}

.country-selector__toggle--header {
	height: 100%;
}

.country-selector__toggle--header:hover {
	color: var(--color-primary);
}

.country-selector__panel--header {
	position: absolute;
	top: 100%;
	inset-inline-start: 0;
	z-index: 101;
	width: min(var(--country-panel-width), calc(100vw - 2 * var(--container-gutter)));
	padding: var(--country-panel-padding);
	background-color: var(--color-bg);
	box-shadow: var(--country-panel-shadow);
	color: var(--color-text);
}

.country-selector__panel--header .country-selector__regions {
	grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ---------- Drawer: accordion row ---------- */

.country-selector__toggle--drawer {
	justify-content: flex-start;
	width: 100%;
	min-height: var(--nav-row-height);
	padding-inline: var(--container-gutter);
	font-family: var(--t-body-family);
	font-size: var(--t-body-size);
	font-weight: var(--t-body-weight);
}

.country-selector__toggle--drawer .icon--caret {
	margin-inline-start: auto;
}

.country-selector__panel--drawer {
	padding: 0 var(--container-gutter) var(--space-lg);
}

.country-selector__panel--drawer .country-selector__regions {
	grid-template-columns: repeat(2, minmax(0, 1fr));
}

.country-selector__panel--drawer .country-selector__link {
	min-height: 2.75rem; /* Tap target. */
}

@media (prefers-reduced-motion: reduce) {
	.country-selector__toggle .icon--caret {
		transition: none;
	}
}
