/* Keep scrolling inside the enhanced list without changing the sidebar layout. */
.faces-comments-widget {
	position: relative;
	min-width: 0;
}

.faces-comments-widget.is-ready .widget-comments-list {
	max-height: min(var(--faces-comments-height, 480px), 70vh);
	overflow-y: auto;
	overflow-x: hidden;
	overscroll-behavior-y: contain;
	overflow-anchor: none;
	scrollbar-gutter: stable;
	padding-inline-end: 8px;
}

/* Make keyboard access and the loading boundary visible without adding content. */
.faces-comments-widget .widget-comments-list:focus-visible {
	outline: 2px solid var(--wpsc-link-hover-color, #3366ff);
	outline-offset: 3px;
}

.faces-comments-widget__sentinel {
	flex: 0 0 1px;
	width: 100%;
}

/* Error and completion messages sit below the scrolling list. */
.faces-comments-widget__feedback {
	margin-top: 4px;
	font-size: .85em;
}

.faces-comments-widget__status {
	margin: 0;
	line-height: 1.4;
}

/* Keep the empty live region available without reserving space. */
.faces-comments-widget__feedback:has(.faces-comments-widget__status:empty),
.faces-comments-widget .widget-comments-list[aria-busy="true"] + .faces-comments-widget__feedback {
	position: absolute;
	inset-inline: 0;
	margin: 0;
	pointer-events: none;
}

/* Position the loading label above its normal starting point at the list edge. */
.faces-comments-widget .widget-comments-list[aria-busy="true"] + .faces-comments-widget__feedback {
	z-index: 1;
	transform: translateY(-100%);
}

.faces-comments-widget .widget-comments-list[aria-busy="true"] + .faces-comments-widget__feedback .faces-comments-widget__status {
	box-sizing: border-box;
	width: fit-content;
	max-width: calc(100% - 24px);
	margin-inline: auto;
	padding: 4px 10px;
	border-radius: 6px;
	background: rgba(255, 255, 255, .92);
	color: #212529;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

html[theme="dark"] .faces-comments-widget .widget-comments-list[aria-busy="true"] + .faces-comments-widget__feedback .faces-comments-widget__status {
	background: rgba(33, 37, 41, .92);
	color: #f2f3f5;
}

.faces-comments-widget__retry {
	margin-top: 8px;
}

.faces-comments-widget:not(.is-ready) .faces-comments-widget__feedback,
.faces-comments-widget__feedback[hidden],
.faces-comments-widget__retry[hidden] {
	display: none;
}

/* Reuse post quote styling with compact sidebar spacing. */
.faces-comments-widget .widget-comments-item__excerpt {
	display: block;
	overflow-wrap: anywhere;
}

.faces-comments-widget .widget-comments-item__excerpt > p {
	margin: 0;
}

.faces-comments-widget .comment-quote {
	margin: 8px 0;
	padding: 8px 10px;
	overflow-wrap: anywhere;
}
