/* Structural phone styles apply in Standard and Naked/Divi modes. */
.prf-phone { position: relative; min-width: 0; width: 100%; }

.prf-phone--ready { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: stretch; }

/* Stretch to the input's height; separate vertical padding would enlarge the grid row.
   The gap leaves 3px extra between the flag and the indicator. */
.prf-phone .prf-phone__country {
	flex: 0 0 auto;
	box-sizing: border-box;
	min-height: 0;
	width: auto;
	margin: 0;
	padding: 0 .8em;
	font: inherit;
	font-size: var(--prf-input-size, 1em);
	line-height: var(--prf-input-line-height, 1.4);
	color: inherit;
	background: var(--prf-bg, #fff);
	border: var(--prf-border-width, 1px) solid var(--prf-border, #c3c4c7);
	border-radius: var(--prf-radius, 4px) 0 0 var(--prf-radius, 4px);
	cursor: pointer;
	white-space: nowrap;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: calc(.25em + 3px);
}

.prf-phone--ready > .prf-phone__country { grid-area: 1 / 1; }

.prf-phone.prf-phone--ready > input[type="tel"] {
	grid-area: 1 / 2;
	align-self: first baseline;
	box-sizing: border-box;
	min-width: 0;
	width: 100%;
	margin: 0;
	padding-inline-start:
		calc(max(12px, var(--prf-pad-x, .8em)) + var(--prf-phone-prefix-size, 3ch) + .25em + 2px) !important;
	border-start-start-radius: 0;
	border-end-start-radius: 0;

	/* Theme border shorthands must not restore a second divider. */
	border-inline-start-width: 0 !important;
}

/* Share the native input's text baseline instead of centering a separate line box. */
.prf-phone__prefix {
	grid-area: 1 / 2;
	align-self: first baseline;
	justify-self: start;
	z-index: 1;
	margin-inline-start: max(12px, var(--prf-pad-x, .8em));
	font: inherit;
	font-size: var(--prf-input-size, 1em);
	line-height: var(--prf-input-line-height, 1.4);
	white-space: nowrap;
	pointer-events: none;
	direction: ltr;
}

.prf-phone:has(input[type="tel"]:disabled) .prf-phone__prefix { opacity: .6; }

.prf-phone__country:focus-visible { outline: 2px solid var(--prf-focus, #2271b1); outline-offset: 1px; z-index: 1; }

.prf-phone .prf-phone__popup { position: absolute; inset-inline-start: 0; top: calc(100% + 4px); z-index: 100; box-sizing: border-box; width: min(24rem, calc(100vw - 2rem)); padding: .5rem; color: var(--prf-text, #1d2327); background: var(--prf-bg, #fff); border: 1px solid var(--prf-border, #c3c4c7); border-radius: var(--prf-radius, 4px); box-shadow: 0 4px 18px #0002; }

.prf-phone .prf-phone__popup--above { top: auto; bottom: calc(100% + 4px); }

.prf-phone .prf-phone__search { box-sizing: border-box; width: 100%; min-width: 0; min-height: 2.5em; margin: 0 0 .4rem; padding: .5em .65em; font: inherit; color: inherit; background: inherit; border: 1px solid var(--prf-border, #c3c4c7); border-radius: 2px; }

.prf-phone__list { max-height: min(16rem, 45vh); overflow-y: auto; overscroll-behavior: contain; }

.prf-phone__option { display: flex; align-items: center; gap: .65em; padding: .55em .6em; line-height: 1.4; cursor: pointer; }

.prf-phone__option > :nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.prf-phone__option:hover, .prf-phone__option.is-active { background: var(--prf-phone-highlight, #f0f0f1); }

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

.prf-phone__option--separated { border-top: 1px solid var(--prf-border, #c3c4c7); margin-top: .35em; padding-top: .8em; }

.prf-phone__code { margin-inline-start: auto; color: var(--prf-muted, #646970); white-space: nowrap; }

.prf-phone__empty { margin: .75em .5em; }

.prf-phone [hidden] { display: none !important; }

.prf-phone__country:disabled { cursor: default; opacity: .6; }

/* Native top-layer popovers escape clipping in WP modals, Divi and <dialog>. */
.prf-phone .prf-phone__popup[popover] { position: fixed; inset: auto; margin: 0; }

.prf-phone__search:focus-visible { outline: 2px solid var(--prf-focus, #2271b1); outline-offset: 1px; }

/* Official @wordpress/icons chevron-down. */
.prf-phone__country::after { content: ""; flex: 0 0 1.25em; width: 1.25em; height: 1.25em; background: currentcolor; mask: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 24 24%27%3E%3Cpath fill=%27%2350575e%27 d=%27M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z%27/%3E%3C/svg%3E") center / contain no-repeat; }
