/*
 * Suburban Plenty: base typography and block/component styles.
 *
 * Loaded on the front end and as an editor style (add_editor_style), so the
 * editor matches the site. Values come from theme.json tokens.
 *
 * Why this file exists alongside theme.json: theme.json global styles use
 * zero-specificity :where() selectors, and GeneratePress ships its own
 * element styles (headings, buttons), which would otherwise win.
 */

/* ---------------------------------------------------------------
 * Base
 * ------------------------------------------------------------- */
body {
	background-color: var(--wp--preset--color--paper);
	color: var(--wp--preset--color--ink);
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--medium);
	line-height: var(--wp--custom--line-height--body);
}

body,
button,
input,
select,
textarea {
	font-family: var(--wp--preset--font-family--sans);
}

h1,
h2,
h3 {
	color: var(--wp--preset--color--ink);
	font-family: var(--wp--preset--font-family--serif);
	font-weight: 650;
	line-height: var(--wp--custom--line-height--heading);
	text-wrap: balance;
}

h1 {
	font-size: var(--wp--preset--font-size--xxx-large);
	font-weight: 700;
}

h2 {
	font-size: var(--wp--preset--font-size--xx-large);
}

h3 {
	font-size: var(--wp--preset--font-size--x-large);
}

h4 {
	color: var(--wp--preset--color--ink);
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	line-height: 1.3;
}

a {
	color: var(--wp--preset--color--primary);
	text-underline-offset: 0.15em;
}

a:hover {
	color: var(--wp--preset--color--primary-dark);
}

/*
 * Links in running text are underlined, so color is never the only signal.
 * Scoped to content areas only (post content, landing pages, editor canvas),
 * so site chrome (header, nav, wordmark, footer) is never affected.
 * Buttons, card links and arrow (text-action) links keep their own styles.
 */
:where(.entry-content, .sp-landing__content, .is-root-container) :where(p, li, figcaption, td) > a:not(.wp-block-button__link):not(:where(.is-style-card, .is-style-card-sage, .is-style-arrow-link) a) {
	text-decoration: underline;
}

:focus-visible {
	outline: 3px solid var(--wp--preset--color--primary);
	outline-offset: 2px;
}

.has-small-font-size {
	line-height: 1.5;
}

/* ---------------------------------------------------------------
 * Buttons (core/button). Primary = accent fill, one per view.
 * Secondary = "Outline" style, primary-colored 2px outline.
 *
 * :not(.has-background) mirrors GeneratePress's own button selector
 * (a.wp-block-button__link:not(.has-background), specificity 0,2,1) and
 * lifts ours to 0,3,0 so the approved styles win without !important.
 * It also leaves buttons with an explicitly chosen palette background alone.
 * ------------------------------------------------------------- */
.wp-block-button .wp-block-button__link:not(.has-background) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: var(--wp--custom--tap-target);
	padding: 0.75rem var(--wp--preset--spacing--40);
	border: 2px solid transparent;
	border-radius: var(--wp--custom--radius--button);
	background-color: var(--wp--preset--color--accent);
	box-shadow: none;
	color: var(--wp--preset--color--paper);
	font-family: var(--wp--preset--font-family--sans);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
}

.wp-block-button .wp-block-button__link:not(.has-background):hover,
.wp-block-button .wp-block-button__link:not(.has-background):focus {
	background-color: color-mix(in srgb, var(--wp--preset--color--accent) 85%, var(--wp--preset--color--ink));
	color: var(--wp--preset--color--paper);
	text-decoration: underline;
}

.wp-block-button.is-style-outline .wp-block-button__link:not(.has-background) {
	border-color: var(--wp--preset--color--primary);
	background-color: transparent;
	color: var(--wp--preset--color--primary);
}

.wp-block-button.is-style-outline .wp-block-button__link:not(.has-background):hover,
.wp-block-button.is-style-outline .wp-block-button__link:not(.has-background):focus {
	border-color: var(--wp--preset--color--primary-dark);
	background-color: var(--wp--preset--color--sage);
	color: var(--wp--preset--color--primary-dark);
}

/* ---------------------------------------------------------------
 * Paragraph styles: arrow link, badge
 * ------------------------------------------------------------- */
.is-style-arrow-link a {
	display: inline-flex;
	align-items: center;
	min-height: var(--wp--custom--tap-target);
	font-weight: 600;
	text-decoration: none;
}

.is-style-arrow-link a::after {
	content: "\2192";
	content: "\2192" / "";
	margin-left: 0.4em;
	transition: transform 0.15s ease;
}

.is-style-arrow-link a:hover,
.is-style-arrow-link a:focus {
	text-decoration: underline;
}

.is-style-arrow-link a:hover::after {
	transform: translateX(3px);
}

.is-style-badge {
	width: fit-content;
	padding: 0.2rem 0.75rem;
	border-radius: var(--wp--custom--radius--pill);
	background-color: var(--wp--preset--color--marigold);
	color: var(--wp--preset--color--ink);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
	line-height: 1.5;
}

/* ---------------------------------------------------------------
 * Cards (core/group styles "Card" and "Card (sage)").
 * The heading link is stretched over the card: one link per card.
 * ------------------------------------------------------------- */
.is-style-card,
.is-style-card-sage {
	position: relative;
	padding: var(--wp--preset--spacing--40);
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--card);
	background-color: var(--wp--preset--color--paper);
	transition: box-shadow 0.2s ease;
}

.is-style-card-sage {
	border-color: transparent;
	background-color: var(--wp--preset--color--sage);
}

/* Doubled class beats the zero-to-one specificity layout gap rules. */
.wp-block-group.is-style-card > *,
.wp-block-group.is-style-card-sage > * {
	margin-block: 0;
}

.wp-block-group.is-style-card > * + *,
.wp-block-group.is-style-card-sage > * + * {
	margin-block-start: var(--wp--preset--spacing--20);
}

.is-style-card:hover,
.is-style-card:focus-within,
.is-style-card-sage:hover,
.is-style-card-sage:focus-within {
	box-shadow: var(--wp--custom--shadow--card-hover);
}

.is-style-card :is(h2, h3, h4) a,
.is-style-card-sage :is(h2, h3, h4) a {
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}

.is-style-card :is(h2, h3, h4) a::after,
.is-style-card-sage :is(h2, h3, h4) a::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
}

.is-style-card :is(h2, h3, h4) a:hover,
.is-style-card :is(h2, h3, h4) a:focus,
.is-style-card-sage :is(h2, h3, h4) a:hover,
.is-style-card-sage :is(h2, h3, h4) a:focus {
	color: var(--wp--preset--color--primary);
	text-decoration: underline;
}

/*
 * Space between a section heading and its Query Loop.
 * Kept in CSS, not as a block margin style: in WP 7.1 a margin style on
 * core/query makes the editor reset the Post Template grid layout to
 * "default" when the page is re-saved.
 */
.wp-block-query.sp-hub-query,
.wp-block-query.sp-featured-guides-query {
	margin-top: var(--wp--preset--spacing--50);
}

/* Post cards (featured guides query). */
.sp-post-card {
	padding: var(--wp--preset--spacing--30);
}

.sp-post-card .wp-block-post-featured-image {
	margin: 0 0 var(--wp--preset--spacing--20);
}

.sp-post-card .wp-block-post-featured-image img {
	width: 100%;
	height: auto;
	aspect-ratio: 3 / 2;
	border-radius: var(--wp--custom--radius--image);
	object-fit: cover;
}

.sp-card-label {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	font-weight: 700;
}

.sp-post-card .wp-block-post-excerpt__excerpt {
	margin: 0;
}

/* ---------------------------------------------------------------
 * Sections
 * ------------------------------------------------------------- */
/*
 * Readable intro/lead paragraphs that stay left-aligned with their heading.
 *
 * The constrained layout centers each child at the section's content width,
 * so a smaller max-width would center (indent) the paragraph. Instead the
 * paragraph keeps the full content width (same left edge as the heading) and
 * end padding trims the text to the measure. Percentages resolve against the
 * section's inner width; min() mirrors the content width the layout applies.
 * On narrow screens the padding is 0.
 */
.sp-hero {
	--sp-hero-content-size: 900px; /* = the hero pattern's layout contentSize */
}

.sp-hero .sp-hero__lead {
	padding-inline-end: max(0px, min(100%, var(--sp-hero-content-size)) - var(--sp-measure));
}

.sp-section-intro {
	padding-inline-end: max(0px, min(100%, var(--wp--style--global--wide-size, 1200px)) - var(--sp-measure));
}

.sp-hero,
.sp-topic-hubs {
	--sp-measure: 40rem;
}

/* "How we work": collapse empty tracks so three items fill the row (no empty 4th column). */
.sp-how-we-work .is-layout-grid {
	grid-template-columns: repeat(auto-fit, minmax(min(16rem, 100%), 1fr));
}

/*
 * Lead magnet → How we work share the surface background and only meet when
 * Featured Guides is hidden (it normally sits between them). Drop the second
 * section's top padding so the two don't stack into one oversized empty band.
 * !important is required: the section padding is an inline block style.
 */
.sp-lead-magnet + .sp-how-we-work {
	padding-top: 0 !important;
}

.sp-lead-magnet .wp-block-group.is-style-card-sage > * + * {
	margin-block-start: var(--wp--preset--spacing--30);
}

/* Hub "Start here" numbered steps. */
.sp-steps {
	padding-left: 1.5em;
}

.sp-steps > li + li {
	margin-top: var(--wp--preset--spacing--30);
}

.sp-steps > li::marker {
	color: var(--wp--preset--color--primary);
	font-family: var(--wp--preset--font-family--serif);
	font-weight: 700;
}

/* Free-guide typographic cover (placeholder until real cover art exists). */
.sp-guide-cover {
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	gap: var(--wp--preset--spacing--30);
	max-width: 20rem;
	aspect-ratio: 3 / 4;
	margin-inline: auto;
	padding: var(--wp--preset--spacing--50) var(--wp--preset--spacing--40);
	border-radius: var(--wp--custom--radius--card);
}

.sp-guide-cover > * {
	margin: 0;
}

.sp-guide-cover__title {
	font-family: var(--wp--preset--font-family--serif);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 700;
	line-height: var(--wp--custom--line-height--heading);
}

/* Sign-up area before the MailerLite embed exists: clearly not a form. */
.sp-signup-placeholder {
	padding: var(--wp--preset--spacing--40);
	border: 2px dashed var(--wp--preset--color--muted);
	border-radius: var(--wp--custom--radius--card);
	background-color: var(--wp--preset--color--paper);
}

.sp-signup-placeholder > * {
	margin-block: 0;
}

.sp-signup-placeholder > * + * {
	margin-block-start: var(--wp--preset--spacing--20);
}

.sp-lead-magnet .sp-microcopy {
	color: var(--wp--preset--color--muted);
}

/* Single articles: readable line length now that posts have no sidebar (theme.json contentSize). */
.single-post .inside-article {
	max-width: calc(var(--wp--style--global--content-size, 720px) + 2 * var(--wp--preset--spacing--50));
	margin-inline: auto;
}

/* First-party Free Plant Guide sign-up card (block suburban-plenty/guide-signup). */
.sp-signup-card {
	max-width: 32rem;
	overflow: hidden;
	border: 1px solid var(--wp--preset--color--line);
	border-radius: var(--wp--custom--radius--card);
	background-color: var(--wp--preset--color--paper);
}

.sp-signup-card__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 3 / 1;
	object-fit: cover;
}

.sp-signup-card__body {
	padding: var(--wp--preset--spacing--40);
}

.sp-signup-card__body :where(h3, p, fieldset, legend) {
	margin: 0;
}

.sp-signup-card__title {
	font-size: var(--wp--preset--font-size--x-large);
}

.sp-signup-card__lead {
	margin-block: var(--wp--preset--spacing--20) var(--wp--preset--spacing--40);
	color: var(--wp--preset--color--muted);
}

.sp-signup-form > * + * {
	margin-block-start: var(--wp--preset--spacing--40);
}

.sp-signup-form__field label {
	display: block;
	margin-block-end: var(--wp--preset--spacing--10);
	font-weight: 600;
}

.sp-signup-form__field input {
	box-sizing: border-box;
	width: 100%;
	min-height: var(--wp--custom--tap-target);
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--wp--preset--color--muted);
	border-radius: var(--wp--custom--radius--button);
	background-color: #fff;
	color: var(--wp--preset--color--ink);
	font-size: var(--wp--preset--font-size--medium);
}

.sp-signup-form__field input[aria-invalid="true"] {
	border-color: var(--wp--preset--color--accent);
}

.sp-signup-form__optin {
	padding: 0;
	border: 0;
}

.sp-signup-form__optin legend {
	padding: 0;
	font-weight: 700;
}

.sp-signup-form__optin > * + * {
	margin-block-start: var(--wp--preset--spacing--20);
}

.sp-signup-form__note,
.sp-signup-form__privacy {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.5;
}

.sp-signup-form__check {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--20);
	min-height: var(--wp--custom--tap-target);
}

.sp-signup-form__check input {
	flex: none;
	width: 1.25rem;
	height: 1.25rem;
	margin: 0;
	accent-color: var(--wp--preset--color--primary);
}

.sp-signup-form__check label {
	font-weight: 600;
}

.sp-signup-form__privacy a {
	color: var(--wp--preset--color--primary);
	text-decoration: underline;
	overflow-wrap: anywhere;
}

/* Visible to logged-in administrators only (launch QA), placed after the form. */
.sp-signup-form__admin-warning {
	margin: var(--wp--preset--spacing--30) 0 0;
	font-size: var(--wp--preset--font-size--small);
	padding: var(--wp--preset--spacing--20);
	border: 2px dashed currentColor;
	font-weight: 600;
}

.sp-signup-form__submit {
	width: 100%;
	cursor: pointer;
	white-space: normal;
}

.sp-signup-form__submit:disabled {
	cursor: progress;
	opacity: 0.7;
}

.sp-signup-form__status:empty {
	display: none;
}

.sp-signup-form__status {
	color: var(--wp--preset--color--ink);
	font-weight: 600;
}

/* Honeypot: out of view and out of the tab order; aria-hidden in the markup. */
.sp-signup-form__hp {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.sp-signup-card__success > * + * {
	margin-block-start: var(--wp--preset--spacing--20);
}

.sp-signup-card__success:focus {
	outline: none;
}

/* ---------------------------------------------------------------
 * Motion
 * ------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
