/*
 * Country Code Phone Field
 *
 * The button sits inside the phone input's own border and inherits its font and
 * colour, so the field keeps whatever design the theme, Elementor or CF7 styler
 * gives it. Override any of these variables in your theme to restyle the list.
 */
:root {
	--ccpf-accent: #2563eb;
	--ccpf-dd-radius: 10px;
	--ccpf-dd-shadow: 0 12px 32px rgba(15, 23, 42, .16), 0 2px 6px rgba(15, 23, 42, .08);
	--ccpf-dd-z: 2147483000;
	--ccpf-flag-size: 1.25em;
}

.ccpf-theme-light {
	--ccpf-dd-bg: #fff;
	--ccpf-dd-text: #111827;
	--ccpf-dd-muted: #5b6270;
	--ccpf-dd-border: rgba(15, 23, 42, .12);
	--ccpf-dd-hover: rgba(15, 23, 42, .06);
	--ccpf-dd-input-bg: rgba(15, 23, 42, .04);
}

.ccpf-theme-dark {
	--ccpf-dd-bg: #1c1f26;
	--ccpf-dd-text: #f3f4f6;
	--ccpf-dd-muted: #9ca3af;
	--ccpf-dd-border: rgba(255, 255, 255, .12);
	--ccpf-dd-hover: rgba(255, 255, 255, .08);
	--ccpf-dd-input-bg: rgba(255, 255, 255, .06);
	--ccpf-dd-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}

/* ---------------------------------------------------------------- field */

.ccpf {
	position: relative;
	box-sizing: border-box;
	max-width: 100%;
	padding: 0 !important;
	border: 0 !important;
	background: none !important;
}

.ccpf--block {
	display: block;
	width: 100%;
}

.ccpf--inline {
	display: inline-block;
}

.ccpf > .ccpf-input {
	box-sizing: border-box;
	max-width: 100%;
}

.ccpf-btn {
	position: absolute;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: .4em;
	margin: 0;
	padding-block: 0;
	padding-inline-end: .55em;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: inherit;
	font-weight: inherit;
	letter-spacing: normal;
	text-transform: none;
	cursor: pointer;
	white-space: nowrap;
	min-width: 0;
	min-height: 0;
	width: auto;
	height: auto;
	-webkit-appearance: none;
	appearance: none;
	transition: background-color .15s ease;
}

.ccpf--rtl .ccpf-btn {
	padding-inline-end: .55em;
}

/* Theme button styles (hover colours, borders, shadows) must not leak in. */
.ccpf-btn:hover,
.ccpf-btn:focus,
.ccpf-btn:active {
	background: transparent;
	color: inherit;
	border: 0;
	box-shadow: none;
	transform: none;
}

.ccpf-btn:hover:not(:disabled),
.ccpf-open .ccpf-btn {
	background: rgba(127, 127, 127, .1);
}

.ccpf-btn:focus-visible {
	outline: 2px solid var(--ccpf-accent);
	outline-offset: -2px;
}

.ccpf-btn:disabled {
	cursor: default;
	opacity: .7;
}

/* Divider between the button and the number on boxed inputs. */
.ccpf--boxed .ccpf-btn::after {
	content: "";
	position: absolute;
	inset-block: 22%;
	inset-inline-end: 0;
	border-inline-end: 1px solid currentColor;
	opacity: .2;
}

.ccpf-btn-flag:empty {
	display: none;
}

.ccpf-btn-dial {
	font-variant-numeric: tabular-nums;
	opacity: .9;
}

.ccpf-btn-dial[hidden] {
	display: none;
}

.ccpf-arrow {
	width: .38em;
	height: .38em;
	margin-inline-start: .05em;
	margin-top: -.2em;
	border-right: 1.5px solid currentColor;
	border-bottom: 1.5px solid currentColor;
	opacity: .55;
	transform: rotate(45deg);
	transition: transform .15s ease, margin .15s ease;
}

.ccpf-open .ccpf-arrow {
	margin-top: .2em;
	transform: rotate(-135deg);
}

.ccpf-invalid > .ccpf-input:not(:focus) {
	border-color: #dc3232;
}

/* ---------------------------------------------------------------- flags */

.ccpf-flag {
	flex: none;
	display: inline-block;
	line-height: 1;
}

.ccpf-flag--emoji {
	font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla", sans-serif;
	font-size: var(--ccpf-flag-size);
}

.ccpf-flag--img {
	width: 1.35em;
	height: auto;
	aspect-ratio: 4 / 3;
	object-fit: cover;
	border-radius: 2px;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
}

.ccpf-flag--code {
	min-width: 2em;
	padding: .2em .3em;
	border-radius: 4px;
	background: rgba(127, 127, 127, .16);
	font-size: .72em;
	font-weight: 600;
	letter-spacing: .03em;
	text-align: center;
}

/* --------------------------------------------- CF7 no-JS fallback select */

.ccpf-native {
	margin-inline-end: .5em;
	max-width: 100%;
}

.ccpf-native--hidden {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	border: 0 !important;
	white-space: nowrap !important;
	opacity: 0 !important;
	pointer-events: none !important;
}

/* ------------------------------------------------------------- dropdown */

.ccpf-dd {
	position: fixed;
	z-index: var(--ccpf-dd-z);
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	overflow: hidden;
	min-height: 0;
	border: 1px solid var(--ccpf-dd-border);
	border-radius: var(--ccpf-dd-radius);
	background: var(--ccpf-dd-bg);
	box-shadow: var(--ccpf-dd-shadow);
	color: var(--ccpf-dd-text);
	font-size: 15px;
	line-height: 1.4;
	text-align: start;
	animation: ccpf-in .14s ease-out;
}

.ccpf-dd--up {
	animation-name: ccpf-in-up;
}

.ccpf-dd *,
.ccpf-dd *::before,
.ccpf-dd *::after {
	box-sizing: border-box;
}

@keyframes ccpf-in {
	from { opacity: 0; transform: translateY(-4px); }
}

@keyframes ccpf-in-up {
	from { opacity: 0; transform: translateY(4px); }
}

.ccpf-dd-search {
	flex: none;
	padding: 8px;
	border-bottom: 1px solid var(--ccpf-dd-border);
}

.ccpf-dd .ccpf-dd-search input {
	display: block;
	width: 100%;
	height: 38px;
	margin: 0;
	padding: 0 12px;
	border: 1px solid transparent;
	border-radius: calc(var(--ccpf-dd-radius) - 4px);
	background: var(--ccpf-dd-input-bg);
	box-shadow: none;
	color: inherit;
	font: inherit;
	font-size: 15px;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.ccpf-dd .ccpf-dd-search input:focus {
	border-color: var(--ccpf-accent);
	background: var(--ccpf-dd-bg);
}

.ccpf-dd .ccpf-dd-search input::placeholder {
	color: var(--ccpf-dd-muted);
	opacity: 1;
}

.ccpf-list {
	flex: 1 1 auto;
	min-height: 0;
	margin: 0;
	padding: 4px;
	overflow-y: auto;
	overscroll-behavior: contain;
	list-style: none;
	outline: none;
}

.ccpf-list li {
	margin: 0;
	list-style: none;
}

.ccpf-list li::before,
.ccpf-list li::marker {
	content: none;
}

.ccpf-opt {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 10px;
	border-radius: calc(var(--ccpf-dd-radius) - 4px);
	cursor: pointer;
	user-select: none;
}

.ccpf-opt.ccpf-active {
	background: var(--ccpf-dd-hover);
}

.ccpf-opt[aria-selected="true"] {
	font-weight: 600;
}

.ccpf-opt[aria-selected="true"] {
	box-shadow: inset 3px 0 0 var(--ccpf-accent);
}

[dir="rtl"] .ccpf-opt[aria-selected="true"] {
	box-shadow: inset -3px 0 0 var(--ccpf-accent);
}

/* Text stays in the list's own colours so any accent keeps WCAG contrast. */
.ccpf-opt[aria-selected="true"] .ccpf-code {
	color: var(--ccpf-dd-text);
}

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

.ccpf-code {
	flex: none;
	color: var(--ccpf-dd-muted);
	font-variant-numeric: tabular-nums;
}

.ccpf-sep {
	height: 1px;
	margin: 4px 6px !important;
	background: var(--ccpf-dd-border);
}

.ccpf-empty {
	padding: 18px 12px;
	color: var(--ccpf-dd-muted);
	text-align: center;
}

.ccpf-empty[hidden] {
	display: none;
}

/* Phones: bottom sheet. */
.ccpf-backdrop {
	position: fixed;
	inset: 0;
	z-index: calc(var(--ccpf-dd-z) - 1);
	background: rgba(0, 0, 0, .35);
	animation: ccpf-fade .15s ease-out;
}

@keyframes ccpf-fade {
	from { opacity: 0; }
}

.ccpf-dd--sheet {
	inset: auto 0 0 0;
	width: auto !important;
	max-height: 75vh;
	max-height: 75dvh;
	border-width: 1px 0 0;
	border-radius: 16px 16px 0 0;
	padding-bottom: env(safe-area-inset-bottom);
	animation: ccpf-sheet .2s ease-out;
}

@keyframes ccpf-sheet {
	from { transform: translateY(100%); }
}

.ccpf-dd-head {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: space-between;
	padding: 12px 12px 4px 16px;
	font-weight: 600;
}

.ccpf-dd .ccpf-dd-close {
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--ccpf-dd-hover);
	color: inherit;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
}

.ccpf-dd--sheet .ccpf-dd-search {
	border-bottom: 0;
}

.ccpf-dd--sheet .ccpf-opt {
	padding: 12px 10px;
}

.ccpf-dd--sheet .ccpf-dd-search input {
	font-size: 16px; /* stops iOS zooming in */
}

@media (prefers-reduced-motion: reduce) {
	.ccpf-dd,
	.ccpf-backdrop,
	.ccpf-arrow,
	.ccpf-btn {
		animation: none;
		transition: none;
	}
}
