/**
 * Persis Core — Currency Switcher.
 *
 * The modal is a bottom sheet, visually identical to the retired
 * custom-currency-country plugin (ccc.css) so the switchover changes nothing
 * for visitors. If you change the look, change it on purpose — not here by
 * accident: sizes, colours and breakpoints below mirror the old file 1:1.
 *
 * The button colour comes from the module settings as --persis-cs-accent
 * (default #000, same as the old #save-selection).
 */

/* ------------------------------------------------------------------ modal */

.persis-cs-backdrop {
	position: fixed;
	inset: 0;
	z-index: 7;
	background-color: rgba( 0, 0, 0, 0.8 );
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s;
}

.persis-cs-backdrop.is-open {
	opacity: 1;
	pointer-events: auto;
}

.persis-cs-modal {
	position: fixed;
	z-index: 9999999;
	left: 0;
	right: 0;
	bottom: 0;
	margin: 0 auto;
	padding: 20px;
	background-color: #fefefe;
	text-align: center;
	transform: translateY( 100% );
	transition: transform 0.5s;
}

.persis-cs-modal.is-open {
	transform: translateY( 0 );
}

.persis-cs-close {
	position: absolute;
	top: 8px;
	right: 8px;
	padding: 0;
	border: 0;
	background: none;
	color: #aaa;
	font-size: 28px;
	font-weight: bold;
	line-height: 1;
	cursor: pointer;
}

.persis-cs-close:hover,
.persis-cs-close:focus {
	color: #000;
	text-decoration: none;
}

.persis-cs-title {
	display: block;
	font-size: 14px;
	font-weight: 700;
	line-height: 22px;
	padding-bottom: 0.5rem;
}

.persis-cs-form {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 1rem;
}

/* The select keeps the browser/theme default look, exactly like before. */
.persis-cs-select {
	min-width: 0;
}

.persis-cs-save {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 0.5rem;
	border: 0;
	background: var( --persis-cs-accent, #000 );
	color: #fff;
	cursor: pointer;
}

.persis-cs-save:disabled {
	opacity: 0.7;
	cursor: default;
}

/* display on the class would defeat the hidden attribute, so scope it. */
.persis-cs-spinner[hidden] {
	display: none;
}

.persis-cs-spinner {
	display: inline-block;
	width: 20px;
	height: 20px;
	border: 3px solid rgba( 255, 255, 255, 0.35 );
	border-radius: 50%;
	border-top-color: #fff;
	animation: persis-cs-spin 1s ease-in-out infinite;
}

@keyframes persis-cs-spin {
	to {
		transform: rotate( 360deg );
	}
}

/* ------------------------------------------------------- delivery notes */

.persis-cs-notes {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: start;
	gap: 12px;
	padding: 12px 0 0;
	font-size: 14px;
}

.persis-cs-notes:empty {
	padding: 0;
}

.persis-cs-notes span {
	display: flex;
	align-items: center;
	gap: 8px;
}

.persis-cs-notes img {
	width: 24px;
	height: 24px;
}

/* -------------------------------------------------------------- header */

/*
 * This markup lives in the theme (partials/header/nav/...), but it was styled
 * from the old custom-currency-country plugin. Ported here so deactivating
 * that plugin does not break the header.
 */

.toggle-currency {
	font-size: 13px;
}

.currency-flag-img {
	width: 20px;
	border-radius: 50%;
}

/* YITH prints its own switcher; ours replaces it. */
.yith-wcmcs-shortcode {
	display: none !important;
}

.toggle-currency-txt {
	text-decoration: underline;
}

.mobile__nav-first-child {
	display: block !important;
}

.toggle-currency-mobile {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.toggle-currency-mobile-icon {
	display: flex;
	align-items: center;
	column-gap: 5px;
}

.toggle-currency-mobile-icon span {
	margin-top: 3px;
}

/* -------------------------------------------------------- breakpoints */

@media ( min-width: 768px ) {

	.persis-cs-notes {
		align-items: center;
		font-size: 16px;
	}

	.persis-cs-form {
		gap: 0.5rem;
	}
}

@media ( min-width: 992px ) {

	.persis-cs-form {
		flex-direction: row;
	}

	.toggle-currency {
		display: flex;
		align-items: center;
		column-gap: 10px;
	}

	.currency-flag-img {
		width: 30px;
	}

	.toggle-currency-txt {
		display: none;
	}
}

@media ( prefers-reduced-motion: reduce ) {

	.persis-cs-backdrop,
	.persis-cs-modal,
	.persis-cs-spinner {
		transition: none;
		animation: none;
	}
}
