/* =====================================================================
 * The currency switcher a customer sees.
 *
 * A small button in the header — an exchange mark and the current code —
 * opening a dialog with the currencies this shop can honestly price. It is
 * deliberately quiet: a shop that sells in one currency to almost everyone
 * should not have a currency control shouting at every visitor.
 *
 * Everything is scoped under `.fils-*` and uses its own custom properties, so a
 * theme can restyle it by setting three variables rather than fighting
 * specificity.
 * ===================================================================== */

.fils-switch {
	--fils-fg: currentColor;
	--fils-bg: transparent;
	--fils-border: rgba(0, 0, 0, .18);
	--fils-radius: 999px;

	align-items: center;
	background: var(--fils-bg);
	border: 1px solid var(--fils-border);
	border-radius: var(--fils-radius);
	color: var(--fils-fg);
	cursor: pointer;
	display: inline-flex;
	font: inherit;
	font-size: 13px;
	font-weight: 600;
	gap: 6px;
	line-height: 1;
	padding: 7px 12px;
}
.fils-switch:hover,
.fils-switch:focus-visible { border-color: var(--fils-fg); }
.fils-switch svg { flex: 0 0 auto; height: 15px; width: 15px; }
.fils-switch__code { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* The dialog. `dialog` where the browser has it, and the same markup still
   works as a plain overlay where it does not. */
.fils-dialog {
	background: #fff;
	border: 0;
	border-radius: 14px;
	box-shadow: 0 18px 48px rgba(16, 24, 40, .18);
	color: #1d2327;
	max-width: 340px;
	padding: 0;
	width: calc(100vw - 32px);
}
.fils-dialog::backdrop { background: rgba(16, 24, 40, .45); }

.fils-dialog__head {
	align-items: center;
	border-bottom: 1px solid #e9ecef;
	display: flex;
	justify-content: space-between;
	padding: 16px 18px;
}
.fils-dialog__head h2 { font-size: 15px; font-weight: 700; margin: 0; }
.fils-dialog__close {
	background: none;
	border: 0;
	border-radius: 8px;
	color: #646970;
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	padding: 4px 8px;
}
.fils-dialog__close:hover { background: #f1f3f5; color: #1d2327; }

.fils-dialog__list { display: grid; margin: 0; max-height: 60vh; overflow-y: auto; padding: 8px; }

.fils-option {
	align-items: center;
	background: none;
	border: 0;
	border-radius: 10px;
	color: inherit;
	cursor: pointer;
	display: flex;
	font: inherit;
	gap: 10px;
	padding: 11px 12px;
	text-align: left;
	text-decoration: none;
	width: 100%;
}
.fils-option:hover,
.fils-option:focus-visible { background: #f6f7f7; }
.fils-option[aria-current="true"] { background: #eef5fc; font-weight: 700; }

.fils-option__code { flex: 0 0 3.2em; font-variant-numeric: tabular-nums; font-weight: 700; }
.fils-option__name { color: #646970; flex: 1 1 auto; font-size: 13px; }
.fils-option__symbol { color: #646970; flex: 0 0 auto; font-size: 13px; }
.fils-option[aria-current="true"] .fils-option__name { color: inherit; }

@media (prefers-color-scheme: dark) {
	.fils-dialog { background: #1f2124; color: #e8eaed; }
	.fils-dialog__head { border-bottom-color: #33363a; }
	.fils-option:hover, .fils-option:focus-visible { background: #2a2d31; }
	.fils-option[aria-current="true"] { background: #24303d; }
	.fils-option__name, .fils-option__symbol, .fils-dialog__close { color: #a8adb3; }
}

/* While a currency is being fetched. The prices stay readable and stay put —
   they are about to be replaced, not removed, and collapsing the layout under a
   customer mid-click is worse than a moment of grey. */
.fils-busy .woocommerce-Price-amount {
	opacity: .45;
	transition: opacity .12s ease-out;
}

/* The button: mark, then what this page is priced in, then what it is written
   in. The language half is display only for now — the same mark will open a
   language chooser once there is one. */

.fils-switch__sign {
	font-weight: 600;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
	direction: ltr;
	unicode-bidi: isolate;
}

.fils-switch__lang {
	font-size: .82em;
	opacity: .6;
	letter-spacing: .04em;
	white-space: nowrap;
}

.fils-switch__lang::before {
	content: "";
	display: inline-block;
	width: 1px;
	height: .85em;
	margin-inline-end: .5em;
	vertical-align: -.08em;
	background: currentColor;
	opacity: .35;
}

.fils-busy .fils-switch {
	cursor: progress;
}

@media (prefers-reduced-motion: reduce) {
	.fils-busy .woocommerce-Price-amount { transition: none; }
}
