/*
 * Interactivity API blocks from gardenermind-core. Presets only; every block
 * works without these.
 */

/* hidden must win over the display set by layout classes. */
.gm-pricing-toggle[hidden],
.gm-plan[hidden],
.gm-feedback [hidden],
.gm-doc-search [hidden],
.gm-code__copy[hidden] {
	display: none !important;
}

/* With the toggle running, the "both prices shown" note no longer applies. */
.is-enhanced .gm-js-hide {
	display: none;
}

/*
 * ---- Pricing toggle and site picker: one segmented control, native radios
 * underneath.
 */
.gm-pricing-toggle {
	display: inline-flex;
}

.gm-pricing-toggle__group {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 4px;
	padding: 4px;
	border: 1px solid var(--wp--preset--color--stone);
	border-radius: var(--wp--custom--radius--pill);
	background: var(--wp--preset--color--sand);
}

.gm-pricing-toggle__option {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 16px;
	border-radius: var(--wp--custom--radius--pill);
	color: var(--wp--preset--color--soil);
	cursor: pointer;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 500;
}

/*
 * The input fills the label so the whole pill is the target, and stays visible
 * to assistive tech.
 */
.gm-pricing-toggle__input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.gm-pricing-toggle__option:has(:checked) {
	background: var(--wp--preset--color--moss);
	color: var(--wp--preset--color--on-moss);
}

.gm-pricing-toggle__option:has(:focus-visible) {
	outline: 2px solid var(--wp--preset--color--moss);
	outline-offset: 2px;
}

.gm-pill {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	border-radius: var(--wp--custom--radius--pill);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	line-height: 1.4;
}

.gm-pill--moss {
	background: var(--wp--preset--color--moss-tint);
	color: var(--wp--preset--color--moss-deep);
}

/*
 * Moss tint on Moss would vanish in the selected state, so the pill flips to
 * the surface.
 */
.gm-pricing-toggle__option:has(:checked) .gm-pill--moss {
	background: var(--wp--preset--color--moss-tint);
	color: var(--wp--preset--color--moss-deep);
}

.gm-pricing-product .gm-section-head .gm-pricing-toggle {
	margin: 0;
}

/* ---- On this page */
.gm-toc__list a.is-active {
	border-inline-start-color: var(--wp--preset--color--moss);
	color: var(--wp--preset--color--soil);
	font-weight: 500;
}

.gm-post-content :is(h2, h3),
.gm-doc-content :is(h2, h3) {
	scroll-margin-top: 96px;
}

.gm-post-content :is(h2, h3):focus,
.gm-doc-content :is(h2, h3):focus {
	outline: none;
}

/* ---- Copy button on code blocks */
.gm-code {
	display: flex;
	flex-direction: column;
	margin-block: var(--wp--preset--spacing--30);
}

.gm-code .wp-block-code {
	margin: 0;
}

.gm-code__copy {
	order: -1;
	align-self: flex-end;
	min-width: 44px;
	min-height: 44px;
	margin-bottom: 4px;
	padding: 0 12px;
	border: 1px solid var(--wp--preset--color--field);
	border-radius: var(--wp--custom--radius--button);
	background: var(--wp--preset--color--surface);
	color: var(--wp--preset--color--soil);
	cursor: pointer;
	font-family: var(--wp--preset--font-family--jetbrains-mono);
	font-size: var(--wp--preset--font-size--x-small);
}

.gm-code__copy:hover {
	border-color: var(--wp--preset--color--moss);
	color: var(--wp--preset--color--moss);
}

/* ---- Live docs search */
.gm-doc-search--live {
	position: relative;
}

.gm-doc-search__list {
	position: absolute;
	z-index: 20;
	inset-inline: 0;
	margin: 6px 0 0;
	padding: 6px;
	border: 1px solid var(--wp--preset--color--stone);
	border-radius: var(--wp--custom--radius--card);
	background: var(--wp--preset--color--surface);
	box-shadow: var(--wp--preset--shadow--soft);
	list-style: none;
}

.gm-doc-search__item {
	margin: 0;
	border-radius: var(--wp--custom--radius--button);
	cursor: pointer;
}

.gm-doc-search__link {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: 44px;
	padding: 8px 14px;
	color: var(--wp--preset--color--soil);
	text-decoration: none;
}

.gm-doc-search__title {
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 500;
}

.gm-doc-search__meta {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--x-small);
}

.gm-doc-search__item.is-active {
	background: var(--wp--preset--color--moss-tint);
	outline: 2px solid var(--wp--preset--color--moss);
	outline-offset: -2px;
}

/* ---- Doc feedback */
.gm-feedback__actions {
	display: flex;
	gap: 8px;
}

.gm-feedback__btn[aria-pressed="true"] {
	background: var(--wp--preset--color--moss-tint);
	border-color: var(--wp--preset--color--moss);
	color: var(--wp--preset--color--moss-deep);
}

.gm-feedback__message:empty {
	display: none;
}

@media (prefers-reduced-motion: reduce) {

	.gm-toc__list a,
	.gm-pricing-toggle__option {
		transition: none;
	}
}

/*
 * Core's Search block styles only load with that block, so the live search
 * carries its own layout.
 */
.gm-doc-search--live .wp-block-search__inside-wrapper {
	display: flex;
	flex-wrap: nowrap;
}

.gm-doc-search--live .wp-block-search__input {
	flex: 1 1 auto;
	min-width: 0;
}

.gm-doc-search--live .wp-block-search__button {
	flex: none;
}

/* ---- Pricing section on a product page */

/* A free-only app: one card, no wider than a plan card in a row of three. */
.gm-grid-1.gm-grid-1 {
	grid-template-columns: minmax(0, 1fr);
	max-width: 384px;
}

/* The reassurance row follows the number of items it holds. */
.gm-reassurance.gm-grid-3,
.gm-reassurance.gm-grid-4 {
	margin-top: var(--wp--preset--spacing--60);
}

.gm-reassurance.gm-grid-3.gm-grid-3 {
	grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 959px) {

	.gm-reassurance.gm-grid-3.gm-grid-3 {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 599px) {

	.gm-reassurance.gm-grid-3.gm-grid-3 {
		grid-template-columns: minmax(0, 1fr);
	}
}

/*
 * Comparison table: on narrow screens each row becomes a small stack. The
 * feature name leads and every value says which plan it belongs to.
 */
@media (max-width: 700px) {

	.gm-table-scroll .gm-compare table {
		min-width: 0;
	}

	.gm-compare table,
	.gm-compare thead,
	.gm-compare tbody,
	.gm-compare tr,
	.gm-compare td {
		display: block;
		box-sizing: border-box;
		width: 100%;
	}

	.gm-compare thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip-path: inset(50%);
	}

	.gm-compare tr {
		padding-block: 12px;
		border-bottom: 1px solid var(--wp--preset--color--stone);
	}

	.gm-compare td {
		display: flex;
		justify-content: space-between;
		gap: 16px;
		padding: 4px 16px;
		border: 0;
		text-align: end;
	}

	.gm-compare td:first-child {
		justify-content: flex-start;
		padding-block-end: 8px;
		text-align: start;
	}

	.gm-compare td:empty {
		display: none;
	}

	.gm-compare td:not(:first-child)::before {
		content: attr(data-label);
		color: var(--wp--preset--color--muted);
		text-align: start;
	}
}

/* ---- Price line on a product card: a link to that app's pricing. */
.gm-price-link {
	position: relative;
	z-index: 2;
}

.gm-price-link .wp-block-button__link {
	display: inline-flex;
	align-items: center;
	justify-content: flex-end;
	min-width: 44px;
	min-height: 44px;
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 400;
	text-decoration: underline;
	text-underline-offset: 4px;
}

.gm-price-link .wp-block-button__link:hover {
	background: none;
	color: var(--wp--preset--color--moss);
}

/* ---- Sticky bar on a product page */
.gm-sticky-bar {
	position: fixed;
	z-index: 40;
	inset: auto 0 0;
	border-top: 1px solid var(--wp--preset--color--stone);
	background: var(--wp--preset--color--surface);
	box-shadow: var(--wp--preset--shadow--soft);
	transform: translateY(100%);
	transition: transform 0.2s ease;
}

.gm-sticky-bar.is-visible {
	transform: translateY(0);
}

.gm-sticky-bar[hidden] {
	display: none;
}

/* Room under the footer so its bottom row can scroll above the bar. */
body:has(.gm-sticky-bar) {
	padding-bottom: 80px;
}

.gm-sticky-bar__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	max-width: 1200px;
	margin-inline: auto;
	padding: 8px clamp(20px, 4vw, 32px);
}

.gm-sticky-bar__name {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 0;
	font-family: var(--wp--preset--font-family--fraunces);
	font-size: var(--wp--preset--font-size--h-5);
	font-weight: 500;
}

.gm-sticky-bar__icon {
	display: inline-flex;
	width: 32px;
	height: 32px;
	overflow: hidden;
	border-radius: 8px;
	background: var(--wp--preset--color--moss-tint);
}

.gm-sticky-bar__icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.gm-sticky-bar__actions {
	display: flex;
	align-items: center;
	gap: 16px;
}

.gm-sticky-bar__link {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding-inline: 4px;
	color: var(--wp--preset--color--moss);
	font-weight: 500;
	text-underline-offset: 4px;
}

.gm-sticky-bar__button {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	white-space: nowrap;
	padding: 0 20px;
	border-radius: var(--wp--custom--radius--button);
	background: var(--wp--preset--color--moss);
	color: var(--wp--preset--color--on-moss);
	font-weight: 500;
	text-decoration: none;
}

.gm-sticky-bar__button:hover {
	background: var(--wp--preset--color--moss-deep);
	color: var(--wp--preset--color--on-moss);
}

@media (max-width: 599px) {

	.gm-sticky-bar__name span:last-child {
		max-width: 11ch;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.gm-sticky-bar__button {
		padding-inline: 14px;
	}
}

@media (prefers-reduced-motion: reduce) {

	.gm-sticky-bar {
		transition: none;
	}
}

html {
	scroll-padding-top: 96px;
}
