/* Shared structure and tokens for frontend, Naked/Divi and builder. */
.prf-titles {
	position: relative;
	min-width: 0;
	width: 100%;
}

.prf-titles__native {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
	clip-path: inset(50%);
	opacity: 0;
	pointer-events: none;
}

.prf-titles__control {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.4em;
	min-width: 0;
	box-sizing: border-box;
	font-size: var(--prf-input-size, 1em);
	line-height: var(--prf-input-line-height, 1.4);
	min-height: var(--prf-input-min-height, 2.75em);
	padding: var(--prf-pad-y, 0.65em) var(--prf-pad-x, 0.8em);
	border: var(--prf-border-width, 1px) solid var(--prf-border, #949494);
	border-radius: var(--prf-radius, 4px);
	background: var(--prf-bg, #fff);
	color: var(--prf-text, #1d2327);
}

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

.prf-titles .prf-titles__search {
	flex: 1 1 12rem;
	min-width: min(12rem, 100%);
	width: 0;
	max-width: 100%;
	border: 0 !important;
	outline: 0 !important;
	box-shadow: none !important;
	background: transparent !important;
	color: inherit;
	padding: 0 !important;
	margin: 0;
	font: inherit !important;
	height: 1lh !important;
	min-height: 0 !important;
}

/* Leave room for the caret without reserving a full search row after selection. */
.prf-titles .prf-titles__search[placeholder='']:placeholder-shown {
	flex-basis: 2ch;
	min-width: min(2ch, 100%);
}

.prf-titles__chips {
	display: contents;
}

.prf-titles__chip {
	display: inline-flex;
	align-items: center;
	gap: 0.1em;
	max-width: 100%;
	overflow-wrap: anywhere;
	border-radius: 0.3em;
	padding: 0.12em 0.5em;
	margin-block: -0.12em;
	background: var(--prf-option-selected-bg, #e8f0f7);
	color: inherit;
}

.prf-titles .prf-titles__remove {
	display: inline-flex;
	justify-content: center;
	align-items: center;
	flex: 0 0 auto;
	border: 0;
	border-radius: 3px;
	background: transparent;
	color: inherit;
	padding: 0;
	margin: 0;
	position: relative;
	width: 1em;
	height: 1lh;
	min-width: 0;
	min-height: 0;
	font: inherit;
	cursor: pointer;
	line-height: inherit;
}

.prf-titles__remove::before {
	content: '';
	width: 1em;
	height: 1em;
	background: currentcolor;
	mask: url('../icons/wordpress/close-small.svg') center / contain no-repeat;
}

/* Expand the pointer target without adding visible space inside the badge. */
.prf-titles__remove::after {
	content: '';
	position: absolute;
	inset: 50% auto auto 50%;
	width: max(100%, 24px);
	height: max(100%, 24px);
	transform: translate(-50%, -50%);
}

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

.prf-titles__popup {
	position: absolute;
	z-index: 100;
	top: 100%;
	inset-inline: 0;
	margin-top: 4px;
	max-height: none;
	overflow: visible;
	border: 1px solid var(--prf-border, #949494);
	border-radius: var(--prf-radius, 4px);
	background: var(--prf-bg, #fff);
	color: var(--prf-text, #1d2327);
	box-shadow: 0 4px 16px #0002;
}

.prf-titles__list[hidden] {
	display: none;
}

.prf-titles__option {
	display: flex;
	flex-direction: column;
	gap: 0.15em;
	padding: 0.55em 0.8em;
	cursor: pointer;
	overflow-wrap: anywhere;
}

.prf-titles__option small {
	font-size: 0.85em;
}

.prf-titles__option:hover,
.prf-titles__option[aria-selected='true'] {
	background: var(--prf-option-selected-bg, #e8f0f7);
}

.prf-titles__status {
	display: block;
	font-size: 0.8em;
	color: var(--prf-muted, #646970);
	margin-top: 0.35em;
}

.prf-has-error .prf-titles__control {
	border-color: var(--prf-error, #d63638);
}

/* Explicit create action belongs to the listbox and stays visible while scrolling. */
.prf-titles__option.prf-titles__create {
	position: sticky;
	bottom: 0;
	border-top: 1px solid #ececec;
	background: #f5f5f5;
	text-align: center;
	padding: 0.8em;
	min-height: 44px;
	box-sizing: border-box;
	justify-content: center;
}

.prf-titles__create strong {
	font-weight: 500;
}

.prf-titles__option.prf-titles__create:hover {
	background: #ebebeb;
}

.prf-titles__option.prf-titles__create[aria-selected='true'] {
	background: #ebebeb;
	box-shadow: inset 0 0 0 2px var(--prf-focus, #2271b1);
}

.prf-titles__announcement {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

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

.prf-titles__popup .prf-titles__status {
	margin: 0.5em 0.8em;
}

.prf-titles__status:empty {
	display: none;
}

.prf-titles__list {
	max-height: min(16rem, 35vh);
	overflow-y: auto;
}

.prf-titles .prf-titles__browse {
	display: block;
	width: 100%;
	padding: .65em .8em;
	border: 0;
	border-top: 1px solid var(--prf-border, #ddd);
	background: #f5f5f5;
	color: inherit;
	font: inherit;
	text-align: center;
	cursor: pointer;
}

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