/**
 * Button styling.
 *
 * Every value that the settings screen exposes is read from a custom property
 * with a sensible fallback, so the stylesheet works on its own and the inline
 * block only has to override what the site owner actually changed.
 *
 * Deliberately neutral: Google's official artwork is trademarked and is not
 * imitated here. Site owners who want it pick the image variant.
 */

.psbtn {
	--psbtn-bg: #ffffff;
	--psbtn-fg: #1f2328;
	--psbtn-border: #c8ccd2;
	--psbtn-bg-hover: #f3f4f6;
	--psbtn-fg-hover: var( --psbtn-fg );
	--psbtn-focus: #1a73e8;
	--psbtn-hint: #5c6570;

	/*
	 * Alignment runs through flexbox, not text-align. Plenty of themes set
	 * text-align on content elements, which would silently override it.
	 */
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	/*
	 * Only the vertical margins - never the horizontal ones. Many themes build
	 * their content column by giving every child of the content area
	 * "margin-left/right: auto" plus a max-width. A margin shorthand would reset
	 * those to 0 and shove the button out of the column to the left.
	 */
	margin-top: var( --psbtn-margin-top, 20px );
	margin-bottom: var( --psbtn-margin-bottom, 20px );
	font-size: inherit;
	line-height: 1.4;
}

.psbtn--align-center {
	align-items: center;
	text-align: center;
}

.psbtn--align-right {
	align-items: flex-end;
	text-align: right;
}

/* At full width there is nothing left to align. */
.psbtn--full {
	align-items: stretch;
}

/*
 * Two class selectors, so the alignment survives themes that set text-align on
 * every element inside the content area.
 */
.psbtn--align-center .psbtn__hint,
.psbtn--align-center .psbtn__status,
.psbtn--align-center .psbtn__label {
	text-align: center;
}

.psbtn--align-right .psbtn__hint,
.psbtn--align-right .psbtn__status,
.psbtn--align-right .psbtn__label {
	text-align: right;
}

.psbtn--theme-dark {
	--psbtn-bg: #1f2328;
	--psbtn-fg: #f4f6f8;
	--psbtn-border: #3d444d;
	--psbtn-bg-hover: #2b3138;
	--psbtn-focus: #8ab4f8;
	--psbtn-hint: #a8b0b9;
}

@media ( prefers-color-scheme: dark ) {
	.psbtn--theme-auto {
		--psbtn-bg: #1f2328;
		--psbtn-fg: #f4f6f8;
		--psbtn-border: #3d444d;
		--psbtn-bg-hover: #2b3138;
		--psbtn-focus: #8ab4f8;
		--psbtn-hint: #a8b0b9;
	}
}

/*
 * Two-class selectors on purpose: themes routinely style anchors inside the
 * content area with rules like ".entry-content a" (specificity 0,1,1), which
 * would beat a single class and turn the button into a full-width block link.
 */
.psbtn .psbtn__btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	/*
	 * Explicit width, because themes routinely set "a { width: 100% }" inside
	 * the content area. Without our own declaration that rule wins silently,
	 * the pill spans the container and the alignment setting looks broken.
	 */
	width: fit-content;
	max-width: 100%;
	/* Not every theme sets border-box globally. Without it the full-width
	   button would grow past its container by its padding and border. */
	box-sizing: border-box;
	padding: var( --psbtn-padding-y, 10px ) var( --psbtn-padding-x, 18px );
	border: var( --psbtn-border-width, 1px ) solid var( --psbtn-border );
	border-radius: var( --psbtn-radius, 999px );
	background: var( --psbtn-bg );
	box-shadow: var( --psbtn-shadow, none );
	color: var( --psbtn-fg );
	font-family: inherit;
	font-size: var( --psbtn-font-size, 15px );
	font-weight: var( --psbtn-font-weight, 500 );
	line-height: 1.3;
	text-align: left;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.psbtn .psbtn__btn:hover,
.psbtn .psbtn__btn:focus {
	background: var( --psbtn-bg-hover );
	color: var( --psbtn-fg-hover );
	text-decoration: none;
}

.psbtn .psbtn__btn:focus-visible {
	outline: 2px solid var( --psbtn-focus );
	outline-offset: 2px;
}

.psbtn .psbtn__btn[ aria-busy='true' ] {
	cursor: progress;
	opacity: 0.75;
}

/*
 * At full width the alignment setting keeps a job: it positions the content
 * inside the stretched button. Hiding or ignoring the setting here confused
 * people, so it stays meaningful in every combination.
 */
.psbtn.psbtn--full .psbtn__btn {
	display: flex;
	width: 100%;
	justify-content: flex-start;
}

.psbtn.psbtn--full.psbtn--align-center .psbtn__btn {
	justify-content: center;
}

.psbtn.psbtn--full.psbtn--align-right .psbtn__btn {
	justify-content: flex-end;
}

.psbtn .psbtn__btn--plain {
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font-weight: inherit;
	text-decoration: underline;
}

.psbtn .psbtn__btn--plain:hover,
.psbtn .psbtn__btn--plain:focus {
	background: none;
	color: inherit;
	text-decoration: none;
}

.psbtn .psbtn__btn--image {
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
}

.psbtn__icon {
	flex: 0 0 auto;
	width: 1.15em;
	height: 1.15em;
}

.psbtn__label {
	min-width: 0;
}

.psbtn__image {
	display: block;
	max-width: 100%;
	height: auto;
}

.psbtn__hint,
.psbtn__status {
	align-self: stretch;
	margin: 0.5em 0 0;
	color: var( --psbtn-hint );
	font-size: 0.8125em;
	line-height: 1.45;
}

.psbtn__status:empty {
	display: none;
}

.psbtn__status a {
	color: inherit;
}

.psbtn__widget {
	display: inline-block;
	min-height: 1px;
}

.psbtn noscript {
	display: contents;
}

.psbtn [ hidden ],
.psbtn-bar[ hidden ] {
	display: none !important;
}

.psbtn .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect( 1px, 1px, 1px, 1px );
	clip-path: inset( 50% );
	border: 0;
	white-space: nowrap;
}

/* ---------- Floating bar ---------- */

.psbtn-bar {
	box-sizing: border-box;
	position: fixed;
	z-index: 9990;
	display: flex;
	align-items: center;
	gap: 0.5em;
	max-width: calc( 100vw - 2rem );
	padding: 0.75rem;
	border: 1px solid var( --psbtn-border, #c8ccd2 );
	border-radius: 12px;
	background: var( --psbtn-bg, #fff );
	box-shadow: 0 6px 24px rgba( 0, 0, 0, 0.16 );
}

.psbtn-bar--bottom_left {
	bottom: 1rem;
	left: 1rem;
}

.psbtn-bar--bottom_right {
	bottom: 1rem;
	right: 1rem;
}

.psbtn-bar--bottom_center {
	bottom: 1rem;
	left: 50%;
	transform: translateX( -50% );
}

.psbtn-bar .psbtn {
	margin: 0;
}

.psbtn-bar__close {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: var( --psbtn-hint, #5c6570 );
	cursor: pointer;
}

.psbtn-bar__close:hover,
.psbtn-bar__close:focus-visible {
	background: var( --psbtn-bg-hover, #f3f4f6 );
	color: var( --psbtn-fg, #1f2328 );
}

@media ( max-width: 480px ) {
	.psbtn-bar {
		left: 1rem;
		right: 1rem;
		transform: none;
		justify-content: space-between;
	}
}

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