/*
 * PlugPress Insight: the card and the feedback on Deactivate. No colour of
 * its own: buttons are WordPress's, and the one accent is the admin colour
 * scheme's (--wp-admin-theme-color; #3858e9 is WordPress 7's default).
 */

.plugpress-insight-bar,
.plugpress-insight-dialog {
	--plugpress-insight-ink: var(--wp-admin-theme-color, #3858e9);
}

/* The card: one row, icon, text, then the controls. On a narrow card the
   controls wrap under the text, lined up with it. */

.plugpress-insight-bar {
	container: plugpress-insight / inline-size;
	margin: 16px 0 !important;
	padding: 0 !important;
	border: 1px solid #dcdcde !important;
	border-radius: 8px;
	background: #fff !important;
	box-shadow: none !important;
	color: #1d2327;
	font-size: 13px;
	line-height: 20px;
	transition: opacity 0.3s;
}

/* Waiting for its place in the plugin's own page. */
.plugpress-insight-bar[data-slot]:not(.is-placed) {
	display: none;
}

/* In the plugin's own page: the first card of its content. The slot spaces
   its children, as Saddle's content grid does. */
.plugpress-insight-bar.is-placed {
	margin: 0 !important;
}

/* Left outside a .wrap, keep wp-admin's gutter. */
#wpbody-content > .plugpress-insight-bar {
	margin: 16px 20px !important;
}

.plugpress-insight-bar.is-gone {
	opacity: 0;
}

.plugpress-insight-bar form {
	margin: 0;
}

.plugpress-insight-bar__main {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	align-items: center;
	padding: 16px;
}

.plugpress-insight-bar__icon {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 8px;
	background: #f0f0f1;
	color: #1d2327;
}

.plugpress-insight-bar__text {
	display: flex;
	flex: 1 1 0;
	flex-direction: column;
	min-width: 0;
}

.plugpress-insight-bar__text strong {
	font-size: 14px;
	font-weight: 600;
}

.plugpress-insight-bar__text span {
	color: #646970;
}

/* "What is shared": a link inside the line. */
.plugpress-insight-bar__what {
	margin: 0 0 0 4px;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
}

.plugpress-insight-bar__what:hover {
	color: #1d2327;
}

.plugpress-insight-bar__actions {
	display: flex;
	flex: none;
	gap: 8px;
	align-items: center;
}

/* The news box and its address, one control. */
.plugpress-insight-bar__news {
	display: flex;
	gap: 8px;
	align-items: center;
	color: #1d2327;
	white-space: nowrap;
	cursor: pointer;
}

.plugpress-insight-bar__news input[type="checkbox"] {
	margin: 0;
}

.plugpress-insight-bar__actions input[type="email"] {
	width: 220px;
	margin: 0 8px 0 0;
}

/* What is shared: a popover under its link. Without popovers it opens in
   place, under the row. */
.plugpress-insight-bar__list {
	flex-direction: column;
	gap: 4px;
	box-sizing: border-box;
	padding: 12px 16px;
	color: #646970;
	font-size: 12px;
	line-height: 18px;
}

.plugpress-insight-bar__list:not([hidden]) {
	display: flex;
}

.plugpress-insight-bar__list[popover] {
	inset: auto;
	width: min(360px, calc(100vw - 32px));
	margin: 0;
	border: 1px solid #dcdcde;
	border-radius: 8px;
	background: #fff;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.plugpress-insight-bar__list[popover]:not(:popover-open) {
	display: none;
}

.plugpress-insight-bar__list:not([popover]) {
	padding: 0 16px 16px 72px;
}

.plugpress-insight-bar__list b {
	display: inline-block;
	min-width: 80px;
	color: #1d2327;
	font-weight: 600;
}

/* The news card's ×. */
.plugpress-insight-bar button.plugpress-insight-bar__close {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	margin-right: -4px;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: none;
	color: #646970;
	cursor: pointer;
}

.plugpress-insight-bar button.plugpress-insight-bar__close:hover {
	background: #f0f0f1;
	color: #1d2327;
}

.plugpress-insight-bar__what:focus-visible,
.plugpress-insight-bar button.plugpress-insight-bar__close:focus-visible {
	outline: 2px solid var(--plugpress-insight-ink);
	outline-offset: 2px;
	box-shadow: none;
}

.plugpress-insight-bar.is-done .plugpress-insight-bar__actions,
.plugpress-insight-bar.is-done .plugpress-insight-bar__what {
	display: none;
}

/* A narrow card: the controls go under the text, lined up with it. */
@container plugpress-insight (max-width: 1000px) {
	.plugpress-insight-bar__text {
		flex-basis: calc(100% - 56px);
	}

	.plugpress-insight-bar__actions {
		flex-basis: 100%;
		flex-wrap: wrap;
		padding-left: 56px;
	}
}

/* A phone: the news box and its address on one line, the buttons under. */
@container plugpress-insight (max-width: 560px) {
	.plugpress-insight-bar__actions {
		padding-left: 0;
	}

	.plugpress-insight-bar__actions input[type="email"] {
		flex: 1 1 140px;
		width: auto;
		min-width: 0;
		margin-right: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.plugpress-insight-bar {
		transition: none;
	}
}

/* Feedback on Deactivate. Its top stays put, so the question opening below
   doesn't move the choice just tapped. */

.plugpress-insight-dialog {
	--plugpress-insight-top: max(16px, calc(50vh - 220px));
	width: min(480px, calc(100vw - 32px));
	max-height: calc(100vh - var(--plugpress-insight-top) - 16px);
	margin: var(--plugpress-insight-top) auto auto;
	padding: 0;
	border: 0;
	border-radius: 8px;
	background: #fff;
	box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08), 0 15px 27px rgba(0, 0, 0, 0.07), 0 30px 36px rgba(0, 0, 0, 0.04), 0 50px 43px rgba(0, 0, 0, 0.02);
	color: #1d2327;
	font-size: 13px;
	line-height: 20px;
}

.plugpress-insight-dialog::backdrop {
	background: rgba(0, 0, 0, 0.35);
}

.plugpress-insight-dialog form {
	position: relative;
	margin: 0;
	padding: 24px;
}

.plugpress-insight-dialog h2 {
	margin: 0 40px 24px 0;
	padding: 0;
	color: #1d2327;
	font-size: 18px;
	font-weight: 600;
	line-height: 24px;
}

.plugpress-insight-dialog__close {
	position: absolute;
	top: 20px;
	right: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 0;
	border-radius: 4px;
	background: none;
	color: #646970;
	cursor: pointer;
}

.plugpress-insight-dialog__close:hover {
	background: #f0f0f1;
	color: #1d2327;
}

.plugpress-insight-dialog__close:focus-visible {
	outline: 2px solid var(--plugpress-insight-ink);
	outline-offset: 0;
}

/* The choices, two to a row. */
.plugpress-insight-dialog__reasons {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
}

.plugpress-insight-dialog__reasons label {
	position: relative;
	display: flex;
	align-items: center;
	min-height: 40px;
	box-sizing: border-box;
	padding: 8px 12px;
	border: 1px solid #dcdcde;
	border-radius: 4px;
	background: #fff;
	color: #1d2327;
	font-size: 13px;
	line-height: 20px;
	cursor: pointer;
	transition: border-color 0.1s, background-color 0.1s;
}

.plugpress-insight-dialog__reasons label:hover {
	border-color: #8c8f94;
}

.plugpress-insight-dialog__reasons label:has(:checked) {
	border-color: var(--plugpress-insight-ink);
	background: #f6f7f7;
	background: color-mix(in srgb, var(--plugpress-insight-ink) 6%, #fff);
	box-shadow: inset 0 0 0 1px var(--plugpress-insight-ink);
}

.plugpress-insight-dialog__reasons label:has(:focus-visible) {
	outline: 2px solid var(--plugpress-insight-ink);
	outline-offset: 2px;
}

/* The radio stays for keyboards and screen readers, out of sight. */
.plugpress-insight-dialog__reasons input[type="radio"] {
	position: absolute;
	width: 1px;
	min-width: 0;
	height: 1px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	clip-path: inset(50%);
	appearance: none;
	white-space: nowrap;
}

/* The picked choice's question and the reply box, only with a question. */
.plugpress-insight-dialog__more {
	margin-top: 24px;
}

.plugpress-insight-dialog__more label[data-for] {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.plugpress-insight-dialog__more label[data-for][hidden] {
	display: none;
}

.plugpress-insight-dialog__more label[data-for] span {
	color: #1d2327;
	font-weight: 600;
}

.plugpress-insight-dialog__more small {
	color: #646970;
	font-size: inherit;
	font-weight: 400;
}

.plugpress-insight-dialog__more input[type="text"] {
	width: 100%;
	margin: 0;
}

.plugpress-insight-dialog__reply {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-top: 16px;
	color: #1d2327;
	cursor: pointer;
}

.plugpress-insight-dialog__reply input[type="checkbox"] {
	margin: 0;
}

.plugpress-insight-dialog__foot {
	display: flex;
	gap: 8px;
	justify-content: flex-end;
	margin-top: 24px;
}

/* A phone: one choice to a row, the buttons full width. */
@media (max-width: 480px) {
	.plugpress-insight-dialog__reasons {
		grid-template-columns: 1fr;
	}

	.plugpress-insight-dialog__foot .button {
		flex: 1;
		justify-content: center;
	}
}

@media (prefers-reduced-motion: reduce) {
	.plugpress-insight-dialog__reasons label {
		transition: none;
	}
}
