/**
 * Ako language switcher.
 *
 * Values come from the Figma "Switcher" variable collection (Light mode).
 * Everything sits inside :where() so any theme rule wins without !important.
 * Override the --ako-switcher-* properties to restyle; the Dark values are
 * listed at the end as a ready-made example.
 */

:where(.ako-switcher) {
	--ako-switcher-bg: #fff;
	--ako-switcher-bg-hover: #f0f0ec;
	--ako-switcher-surface: #fff;
	--ako-switcher-accent: #181815;
	--ako-switcher-on-accent: #fff;
	--ako-switcher-fg: #2c2c28;
	--ako-switcher-fg-muted: #73736f;
	--ako-switcher-fg-disabled: #cececa;
	--ako-switcher-border: #e3e3df;
	--ako-switcher-focus-ring: #3d8c64;
	--ako-switcher-radius: 999px;
	--ako-switcher-menu-radius: 12px;
	--ako-switcher-padding-x: 12px;
	--ako-switcher-padding-y: 6px;
	--ako-switcher-gap: 6px;
	--ako-switcher-font-size: 14px;
	--ako-switcher-icon-size: 16px;
	--ako-switcher-border-width: 1px;
	--ako-switcher-focus-width: 2px;
	--ako-switcher-container-padding: 4px;
	--ako-switcher-item-gap: 2px;
	--ako-switcher-menu-offset: 6px;

	position: relative;
	display: inline-block;
	color: var(--ako-switcher-fg);
	font-family: inherit;
	font-size: var(--ako-switcher-font-size);
	font-weight: 500;
	line-height: 20px;
}

:where(.ako-switcher) :where(*, *::before, *::after) {
	box-sizing: border-box;
}

:where(.ako-switcher--rounded) {
	--ako-switcher-radius: 8px;
}

:where(.ako-switcher--square) {
	--ako-switcher-radius: 0;
	--ako-switcher-menu-radius: 0;
}

:where(.ako-switcher) :where(.ako-switcher__list, .ako-switcher__menu) {
	display: flex;
	gap: var(--ako-switcher-item-gap);
	margin: 0;
	padding: 0;
	list-style: none;
}

:where(.ako-switcher) :where(.ako-switcher__entry) {
	margin: 0;
	padding: 0;
}

/* Item (Figma: .Building blocks/Switcher item) */

:where(.ako-switcher) :where(.ako-switcher__item, .ako-switcher__toggle) {
	display: inline-flex;
	align-items: center;
	gap: var(--ako-switcher-gap);
	padding: var(--ako-switcher-padding-y) var(--ako-switcher-padding-x);
	border-radius: var(--ako-switcher-radius);
	color: inherit;
	text-decoration: none;
	white-space: nowrap;
}

:where(.ako-switcher) :where(a.ako-switcher__item:hover, .ako-switcher__toggle:hover) {
	background: var(--ako-switcher-bg-hover);
}

:where(.ako-switcher) :where(a, summary):focus-visible {
	outline: var(--ako-switcher-focus-width) solid var(--ako-switcher-focus-ring);
	outline-offset: 1px;
}

:where(.ako-switcher) :where(.is-current) {
	background: var(--ako-switcher-accent);
	color: var(--ako-switcher-on-accent);
}

:where(.ako-switcher) :where(.is-disabled) {
	position: relative;
	color: var(--ako-switcher-fg-disabled);
	cursor: default;
}

:where(.ako-switcher) :where(.is-disabled[data-tooltip]:hover)::after {
	content: attr(data-tooltip);
	position: absolute;
	z-index: 10;
	inset-block-end: calc(100% + var(--ako-switcher-menu-offset));
	inset-inline-start: 0;
	padding: var(--ako-switcher-padding-y) var(--ako-switcher-padding-x);
	border-radius: var(--ako-switcher-menu-radius);
	background: var(--ako-switcher-accent);
	color: var(--ako-switcher-on-accent);
	font-size: 12px;
	white-space: nowrap;
}

:where(.ako-switcher) :where(.ako-switcher__icon) {
	flex: none;
	inline-size: var(--ako-switcher-icon-size);
	block-size: var(--ako-switcher-icon-size);
}

:where(.ako-switcher) :where(.ako-switcher__code) {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.6px;
}

/* What each label shows. The native name stays readable by screen readers. */

:where(.ako-switcher--show-code) :where(.ako-switcher__toggle, .ako-switcher__list) :where(.ako-switcher__name),
:where(.ako-switcher__sr) {
	position: absolute;
	inline-size: 1px;
	block-size: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

:where(.ako-switcher--show-native) :where(.ako-switcher__code) {
	display: none;
}

@media (max-width: 600px) {

	:where(.ako-switcher--sm-code, .ako-switcher--sm-icon) :where(.ako-switcher__name) {
		position: absolute;
		inline-size: 1px;
		block-size: 1px;
		overflow: hidden;
		clip-path: inset(50%);
	}

	:where(.ako-switcher--sm-code) :where(.ako-switcher__code) {
		display: inline;
	}

	:where(.ako-switcher--sm-icon) :where(.ako-switcher__code) {
		display: none;
	}
}

/* Link (Figma: Switcher/Link — Plain, Outline, Soft, Solid) */

:where(.ako-switcher--look-outline) :where(.ako-switcher__item) {
	box-shadow: inset 0 0 0 var(--ako-switcher-border-width) var(--ako-switcher-border);
}

:where(.ako-switcher--look-soft) :where(.ako-switcher__item) {
	background: var(--ako-switcher-bg-hover);
}

:where(.ako-switcher--look-solid) :where(.ako-switcher__item) {
	background: var(--ako-switcher-accent);
	color: var(--ako-switcher-on-accent);
}

/* Segmented (Figma: Switcher/Segmented) */

:where(.ako-switcher--segmented) :where(.ako-switcher__list) {
	padding: var(--ako-switcher-container-padding);
	border: var(--ako-switcher-border-width) solid var(--ako-switcher-border);
	border-radius: var(--ako-switcher-radius);
	background: var(--ako-switcher-bg);
}

:where(.ako-switcher--segmented) :where(.ako-switcher__item) {
	padding-block: 4px;
}

/* Dropdown & Floating (Figma: Switcher/Dropdown, Switcher/Floating) */

:where(.ako-switcher) :where(.ako-switcher__details) {
	position: relative;
}

:where(.ako-switcher) :where(.ako-switcher__toggle) {
	border: var(--ako-switcher-border-width) solid var(--ako-switcher-border);
	background: var(--ako-switcher-bg);
	cursor: pointer;
	list-style: none;
}

:where(.ako-switcher) :where(.ako-switcher__toggle)::-webkit-details-marker {
	display: none;
}

:where(.ako-switcher) :where(.ako-switcher__chevron) {
	transition: transform 120ms ease;
}

:where(.ako-switcher) :where(details[open] .ako-switcher__chevron) {
	transform: rotate(180deg);
}

:where(.ako-switcher) :where(.ako-switcher__menu) {
	position: absolute;
	z-index: 1000;
	inset-block-start: calc(100% + var(--ako-switcher-menu-offset));
	inset-inline-start: 0;
	flex-direction: column;
	min-inline-size: 200px;
	padding: var(--ako-switcher-container-padding);
	border: var(--ako-switcher-border-width) solid var(--ako-switcher-border);
	border-radius: var(--ako-switcher-menu-radius);
	background: var(--ako-switcher-surface);
	box-shadow: 0 2px 4px rgb(0 0 0 / 8%), 0 12px 24px -4px rgb(0 0 0 / 12%);
}

:where(.ako-switcher) :where(.ako-switcher__menu.is-end) {
	inset-inline-start: auto;
	inset-inline-end: 0;
}

:where(.ako-switcher) :where(.ako-switcher__menu .ako-switcher__item) {
	justify-content: space-between;
	inline-size: 100%;
}

:where(.ako-switcher) :where(.ako-switcher__menu .is-current) {
	background: var(--ako-switcher-bg-hover);
	color: var(--ako-switcher-fg);
}

:where(.ako-switcher) :where(.ako-switcher__menu .ako-switcher__code) {
	color: var(--ako-switcher-fg-muted);
}

:where(.ako-switcher--floating) {
	position: fixed;
	z-index: 9999;
	inset-block-end: 24px;
	inset-inline-end: 24px;
}

:where(.ako-switcher--floating) :where(.ako-switcher__toggle) {
	border-color: transparent;
	background: var(--ako-switcher-accent);
	color: var(--ako-switcher-on-accent);
	box-shadow: 0 4px 8px rgb(0 0 0 / 10%), 0 16px 32px -8px rgb(0 0 0 / 16%);
}

:where(.ako-switcher--floating) :where(.ako-switcher__menu) {
	inset-block: auto calc(100% + 8px);
	inset-inline: auto 0;
}

/* Inherit from theme: structure only; theme colors and fonts show. */

:where(.ako-switcher--inherit) {
	color: inherit;
	font: inherit;
}

:where(.ako-switcher--inherit) :where(.ako-switcher__item, .ako-switcher__toggle, .is-current, .ako-switcher__menu) {
	border: 0;
	background: none;
	box-shadow: none;
	color: inherit;
}

:where(.ako-switcher--inherit) :where(.is-current) {
	font-weight: 700;
}

:where(.ako-switcher--inherit) :where(.ako-switcher__menu) {
	background: var(--ako-switcher-surface);
}

/*
 * Dark mode values (Figma: Switcher / Dark). Example for a theme:
 *
 * .dark .ako-switcher {
 *   --ako-switcher-bg: #181815;
 *   --ako-switcher-bg-hover: #2c2c28;
 *   --ako-switcher-surface: #2c2c28;
 *   --ako-switcher-accent: #fff;
 *   --ako-switcher-on-accent: #181815;
 *   --ako-switcher-fg: #f0f0ec;
 *   --ako-switcher-fg-muted: #a5a5a1;
 *   --ako-switcher-fg-disabled: #585854;
 *   --ako-switcher-border: #41413e;
 *   --ako-switcher-focus-ring: #91ceab;
 * }
 */

/*
 * Layout layer. Theme resets and menu styles (`summary { display: list-item }`,
 * `.menu a { display: block }`, `.dropdown-menu * { padding: 0 }`, rules
 * that hide nested menus) would otherwise break the switcher's structure.
 * These rules carry real specificity but only set layout; colors, borders
 * and radii above stay easy to override. `display` is !important because
 * some mobile menus style links by ID (`#mobile-dropdown ul li a`).
 */
.ako-switcher,
.ako-switcher *,
.ako-switcher *::before,
.ako-switcher *::after {
	box-sizing: border-box;
}

.ako-switcher .ako-switcher__list {
	display: flex !important;
	gap: var(--ako-switcher-item-gap);
	margin: 0;
	padding: 0;
	list-style: none;
	visibility: visible;
	opacity: 1;
}

.ako-switcher.ako-switcher--segmented .ako-switcher__list {
	padding: var(--ako-switcher-container-padding);
}

.ako-switcher .ako-switcher__details[open] > .ako-switcher__menu {
	display: flex !important;
	flex-direction: column;
	gap: var(--ako-switcher-item-gap);
	margin: 0;
	padding: var(--ako-switcher-container-padding);
	list-style: none;
	visibility: visible;
	opacity: 1;
	transform: none;
	pointer-events: auto;
}

.ako-switcher .ako-switcher__entry {
	margin: 0;
	padding: 0;
}

/* Three classes, so theme menu link rules (two classes) don't win. */
.ako-switcher .ako-switcher__list .ako-switcher__item,
.ako-switcher .ako-switcher__menu .ako-switcher__item,
.ako-switcher .ako-switcher__details .ako-switcher__toggle {
	display: inline-flex !important;
	align-items: center;
	gap: var(--ako-switcher-gap);
	margin: 0;
	padding: var(--ako-switcher-padding-y) var(--ako-switcher-padding-x);
	white-space: nowrap;
}

.ako-switcher.ako-switcher--segmented .ako-switcher__list .ako-switcher__item {
	padding-block: 4px;
}

.ako-switcher .ako-switcher__menu .ako-switcher__item {
	display: flex !important;
	justify-content: space-between;
	inline-size: 100%;
}

/* Ako style keeps its own type size inside theme menus. */
.ako-switcher:not(.ako-switcher--inherit) .ako-switcher__item,
.ako-switcher:not(.ako-switcher--inherit) .ako-switcher__toggle {
	font: inherit;
	line-height: 20px;
}

.ako-switcher .ako-switcher__icon {
	flex: none;
	margin: 0;
}
