/*
 * Renovise — shared component & pattern styles.
 * Only what theme.json cannot express. Keep this lean.
 */

/* Full-bleed sections (the plugin's blog hero, bands, etc.) are sized with
   100vw, which counts the vertical scrollbar while the content box does not —
   leaving ~15px of horizontal scroll on every page that scrolls. Clipping here
   absorbs it. `clip` rather than `hidden`: hidden would make this a scroll
   container and break the sticky header inside it. */
.wp-site-blocks {
	overflow-x: clip;
}

/* ---- Header ---------------------------------------------------------- */
/* Sticky lives on the header's OUTER wrapper: .site-header itself sits inside a
   wrapper only as tall as itself, so position:sticky on it has nothing to stick
   within. Owned by the theme — the header is a theme template part. */
.wp-site-blocks > *:has(.site-header),
.wp-site-blocks > .site-header {
	position: sticky;
	top: 0;
	z-index: 1000;
}

/* Same red as the logo's background box (#D2051E) — both come from the
   `primary` palette token, so they cannot drift apart.
   !important and the extra specificity are needed because WordPress core emits
   `.has-<slug>-background-color { background-color: ... !important }`, and a
   header template part saved in the database may still carry has-base-
   background-color from an earlier version. This wins either way. */
.wp-site-blocks .wp-block-group.site-header,
.site-header.has-background,
.site-header {
	background-color: var(--wp--preset--color--primary) !important;
}

.site-header {
	box-shadow: 0 2px 14px rgba(0, 0, 0, 0.12);
}

.site-header .wp-block-navigation {
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 600;
	font-size: 0.95rem;
	text-transform: uppercase;
	letter-spacing: 0.045em;
}

/* Core ships `.wp-block-navigation .wp-block-navigation-item__content
   .wp-block-navigation-item__content { color: inherit }` — the class is doubled
   deliberately to raise specificity, so the nav selector below has to match it. */
.site-header a,
.site-header .wp-block-navigation a,
.site-header .wp-block-site-title a,
.site-header .wp-block-navigation .wp-block-navigation-item__content.wp-block-navigation-item__content {
	color: var(--wp--preset--color--base);
	text-decoration: none;
}

.site-header .wp-block-navigation a:hover,
.site-header .wp-block-navigation-item__content:hover {
	opacity: 0.82;
}

.site-header .wp-block-navigation .current-menu-item > a,
.site-header .wp-block-navigation .current_page_item > a,
.site-header .wp-block-navigation [aria-current]:where(:not(.wp-element-button)) {
	box-shadow: inset 0 -2px 0 0 var(--wp--preset--color--base);
}

/* ---- Mobile menu (burger + overlay) ----------------------------------
   Why the overlay used to come up blank white: core gives the responsive
   container a white background of its own, while `.site-header a` above
   paints every link inside the header white. White on white — the links
   were there the whole time, just invisible.

   parts/header.html now sets overlayBackgroundColor/overlayTextColor on the
   navigation block, which is the correct fix. These rules are the guarantee:
   a header template part saved in the database before those attributes
   existed would otherwise keep rendering the blank overlay. */

/* The burger and the close X are painted by fill, not color. */
.site-header .wp-block-navigation__responsive-container-open,
.site-header .wp-block-navigation__responsive-container-close {
	color: var(--wp--preset--color--base);
	background: transparent;
}

.site-header .wp-block-navigation__responsive-container-open svg,
.site-header .wp-block-navigation__responsive-container-close svg {
	fill: currentColor;
}

/* Burger to the far right of the header row. The nav is a flex item next to
   the logo, so pushing the nav itself is enough — and it only applies while
   the burger is the nav's only visible part. */
@media (max-width: 599px) {
	.site-header .wp-block-navigation {
		margin-left: auto;
	}
}

/* The overlay background needs both the extra class AND !important. Core paints
   it with:

     .wp-block-navigation:not(.has-background)
     .wp-block-navigation__responsive-container.is-menu-open:not(.disable-default-overlay)
     { background-color: #fff }

   — five classes (0,5,0), printed after the theme stylesheet. A plainer
   selector here loses silently, and the result is white text on white: the
   menu renders, nothing is visible, and the close X vanishes with it.
   !important is how core itself applies palette colours
   (.has-primary-background-color carries it), so this is consistent, not a
   workaround. */
.site-header .wp-block-navigation .wp-block-navigation__responsive-container.is-menu-open {
	background-color: var(--wp--preset--color--primary) !important;
	color: var(--wp--preset--color--base) !important;
	padding: clamp(1.5rem, 7vw, 3rem);
}

.site-header .wp-block-navigation__responsive-container.is-menu-open a,
.site-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item__content.wp-block-navigation-item__content {
	color: var(--wp--preset--color--base);
	text-decoration: none;
}

.site-header .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation__container {
	gap: 1.15rem;
	font-size: 1.5rem;
	line-height: 1.2;
}

/* The desktop underline on the current page is a 2px inset shadow, which is
   lost against 1.5rem type in the overlay. A left bar reads better and reuses
   the same accent-bar language as the teaser cards. */
.site-header .wp-block-navigation__responsive-container.is-menu-open .current-menu-item > a,
.site-header .wp-block-navigation__responsive-container.is-menu-open [aria-current]:where(:not(.wp-element-button)) {
	box-shadow: none;
	padding-left: 0.65rem;
	border-left: 4px solid var(--wp--preset--color--base);
}

/* Inline brand logo (header white-on-red / footer red box) */
.renovise-logo-link {
	display: inline-flex;
	align-items: center;
	line-height: 0;
}

/* 28px, not 46px, and the two are the same visual size.
   The FOOTER logo is the padded artwork (viewBox 0 0 886 196) — the wordmark is
   only 120 of those 196 units tall, the rest is the red box around it. The
   HEADER logo is the cropped mark (viewBox 36 38 814 120), so its height is all
   wordmark. Setting both to the same number makes the header one 1.63x larger.
   46 x 120/196 = 28.2. Change this and the footer's height together, or they
   drift apart again. */
.site-header .renovise-logo-img {
	height: 28px;
	width: auto;
	display: block;
}

.site-footer .renovise-logo-img {
	height: 54px;
	width: auto;
	display: block;
	margin-bottom: 18px;
}

/* ---- Footer ---------------------------------------------------------- */
.site-footer a {
	color: var(--wp--preset--color--base);
	text-decoration: none;
	opacity: 0.85;
}

.site-footer a:hover {
	opacity: 1;
	text-decoration: underline;
}

/* Legal links: brand red, lightening to the same hue at 30% tint on hover.
   Spacing replaces the separator character between them. */
.site-footer .footer-legal a {
	color: var(--wp--preset--color--primary);
	opacity: 1;
	text-decoration: none;
}

.site-footer .footer-legal a + a {
	margin-left: 1.25rem;
}

.site-footer .footer-legal a:hover,
.site-footer .footer-legal a:focus-visible {
	color: #E05062;
	text-decoration: underline;
}

.site-footer .footer-links {
	list-style: none;
	margin: 0;
	padding: 0;
}

.site-footer .footer-links li {
	margin-block: 0.4rem;
}

/* ---- Page head (blog index) -------------------------------------------
   Same overline / rule / title / subtitle rhythm as the plugin's section
   blocks, built from core blocks so it stays editable in the Site Editor. */
.renovise-pagehead {
	margin-bottom: var(--wp--preset--spacing--60);
}

.renovise-pagehead > * {
	margin-block: 0;
}

.renovise-pagehead__overline {
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 700;
	font-size: 0.8125rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--wp--preset--color--primary);
}

/* Two class selectors, not one: core prints `.wp-block-separator{margin-left:auto}`
   in an inline <style> AFTER this file's <link>, so at equal specificity core wins
   and the rule centres itself. Core also sets its width with
   `.wp-block-separator:not(.is-style-wide):not(.is-style-dots)` (0,3,0), hence the
   element + :not() here — anything lighter loses and the rule stays 100px. */
.renovise-pagehead hr.renovise-pagehead__rule:not(.is-style-wide) {
	width: 64px;
	height: 4px;
	border: 0;
	opacity: 1;
	background: var(--wp--preset--color--primary);
	margin: 0.9rem auto 1.25rem 0;
}

/* Same reason: a constrained group gives every child `margin-inline: auto`, which
   centres anything carrying a max-width (the subtitle). The group is flow layout
   now, and this pins the edge regardless. */
.renovise-pagehead > * {
	margin-inline: 0;
}

.renovise-pagehead__title {
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: -0.01em;
	line-height: 0.98;
	font-size: var(--wp--preset--font-size--xx-large);
	color: var(--wp--preset--color--contrast);
	margin-bottom: 1rem;
}

.renovise-pagehead__subtitle {
	max-width: 60ch;
	color: var(--wp--preset--color--muted);
	line-height: 1.6;
}

/* ---- Blog intro (between the banner and the first post row) -----------
   A short lead-in so the archive does not start cold on a date and a
   headline. The heading reuses the plugin's Blog Title block for a single
   source of truth, but that block self-constrains to 70ch and centres
   itself — sized for article body copy, not for a full-width archive. Left
   alone it would float in the middle of the page, out of line with the post
   rows below. Undo that here rather than with an inline <style> in the
   template: page-level layout is the theme's job. */
.renovise-blogintro .renovise-blogtitle {
	max-width: none;
	margin-inline: 0;
	padding-block: 0;
}

/* Uppercase to match every other section title on the site. Done here rather
   than by typing the heading in caps, so the text stays readable in the
   editor and searchable as normal words. */
.renovise-blogintro .renovise-blogtitle__heading {
	text-transform: uppercase;
}

/* margin-inline:0 is doing real work: WordPress's constrained layout puts
   `margin-left:auto; margin-right:auto` on every child of the group, so any
   child narrower than the container gets centred. With a max-width set, that
   pushed this paragraph into the middle of the page, out of line with the
   heading above it. */
.renovise-blogintro__text {
	max-width: 68ch;
	margin-top: 1rem;
	margin-bottom: 0;
	margin-inline: 0;
	color: var(--wp--preset--color--muted);
	line-height: 1.65;
}

/* ---- Post list (blog index, category, tag, search) --------------------
   One row per post: image left, date + title + excerpt + read-more right,
   separated by hairlines. Lives in the theme because index.html renders it —
   the plugin's blog-list block stays a "latest N posts" teaser with its own
   query and no pagination, which is the wrong tool for an archive. */
.renovise-postlist .wp-block-post-template {
	list-style: none;
	margin: 0;
	padding: 0;
}

.renovise-postlist .wp-block-post {
	display: grid;
	gap: 1.25rem;
	padding-block: var(--wp--preset--spacing--50);
	border-top: 1px solid var(--wp--preset--color--border);
}

.renovise-postlist .wp-block-post:first-child {
	border-top: 0;
	padding-top: 0;
}

@media (min-width: 782px) {
	.renovise-postlist .wp-block-post {
		grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
		gap: 2.5rem;
		align-items: start;
	}
}

.renovise-postlist__thumb {
	margin: 0;
}

.renovise-postlist__thumb img {
	display: block;
	width: 100%;
	height: auto;
	object-fit: cover;
}

.renovise-postlist__body > * {
	margin-block: 0;
}

.renovise-postlist__date {
	color: var(--wp--preset--color--muted);
	margin-bottom: 0.5rem;
}

.renovise-postlist__title {
	font-family: var(--wp--preset--font-family--heading);
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: -0.005em;
	line-height: 1.15;
	font-size: var(--wp--preset--font-size--x-large);
	margin-bottom: 0.75rem;
}

.renovise-postlist__title a {
	color: var(--wp--preset--color--contrast);
	text-decoration: none;
}

.renovise-postlist__title a:hover {
	color: var(--wp--preset--color--primary);
}

.renovise-postlist__excerpt {
	color: var(--wp--preset--color--muted);
	margin-bottom: 1rem;
}

/* Read-more: brand red with a chevron, matching the reference layout. */
.renovise-postlist__more {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	color: var(--wp--preset--color--primary);
	font-weight: 600;
	font-size: 0.9375rem;
	text-decoration: none;
	border: 0;
	padding: 0;
}

.renovise-postlist__more::before {
	content: "";
	width: 0.45em;
	height: 0.45em;
	border-top: 2px solid currentColor;
	border-right: 2px solid currentColor;
	transform: rotate(45deg);
}

.renovise-postlist__more:hover {
	text-decoration: underline;
}

.renovise-postlist__pagination {
	border-top: 1px solid var(--wp--preset--color--border);
	padding-top: var(--wp--preset--spacing--40);
}

/* ---- Back to blog (single post, template level) -----------------------
   Hardcoded to /blog/ because block templates are static HTML — there is no
   PHP here to resolve the posts page. If that slug ever changes, edit this one
   link in Appearance > Editor > Templates > Single Posts. */
.renovise-backlink {
	/* Appended after the post-content block by inc/blog-backlink.php, so it is
	   raw HTML rather than a block and gets no layout treatment from WordPress.
	   Constrain it here so it lines up with the article above it. */
	max-width: var(--wp--style--global--content-size);
	margin-top: var(--wp--preset--spacing--60);
	margin-inline: auto;
	padding-top: var(--wp--preset--spacing--40);
	border-top: 1px solid var(--wp--preset--color--border);
}

.renovise-backlink a {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	color: var(--wp--preset--color--primary);
	font-weight: 600;
	font-size: 0.9375rem;
	text-decoration: none;
}

.renovise-backlink a::before {
	content: "";
	width: 0.45em;
	height: 0.45em;
	border-bottom: 2px solid currentColor;
	border-left: 2px solid currentColor;
	transform: rotate(45deg);
}

.renovise-backlink a:hover {
	text-decoration: underline;
}

/* ---- Main column ------------------------------------------------------
   The outer margins live here rather than in the templates' inline styles, so
   the full-bleed rule below can cancel them without !important. */
.renovise-main {
	margin-top: var(--wp--preset--spacing--60);
	margin-bottom: var(--wp--preset--spacing--70);
}

/* A full-bleed section as the first or last block should meet the header and
   footer edge to edge — the margin is there for prose pages, and turns into a
   white band in front of a hero or banner. Keep this list in sync with the
   full-bleed selectors in renovise-components/assets/css/layout.css.

   The second selector in each pair is for templates that put a section block
   straight into <main> instead of inside post-content — index.html does this
   with the blog banner. On page/single the first child is .wp-block-post-content,
   which is not in the list, so it can never match there by accident. */
.renovise-main:has(> .wp-block-post-content > :first-child:is(.alignfull, .renovise-hero, .renovise-bloghero, .renovise-banner, .renovise-brands, .renovise-steps, .renovise-highlight, .renovise-teasers)),
.renovise-main:has(> :first-child:is(.alignfull, .renovise-hero, .renovise-bloghero, .renovise-banner, .renovise-brands, .renovise-steps, .renovise-highlight, .renovise-teasers)) {
	margin-top: 0;
}

.renovise-main:has(> .wp-block-post-content > :last-child:is(.alignfull, .renovise-hero, .renovise-bloghero, .renovise-banner, .renovise-brands, .renovise-steps, .renovise-highlight, .renovise-teasers)),
.renovise-main:has(> :last-child:is(.alignfull, .renovise-hero, .renovise-bloghero, .renovise-banner, .renovise-brands, .renovise-steps, .renovise-highlight, .renovise-teasers)),
/* An empty paragraph left at the end of the page — easy to create in the
   editor by pressing Enter after the last block, and invisible there — would
   otherwise take the :last-child slot above, so the section stops being
   treated as full-bleed and the footer gap comes back. Look past one. */
.renovise-main:has(> .wp-block-post-content > :is(.alignfull, .renovise-hero, .renovise-bloghero, .renovise-banner, .renovise-brands, .renovise-steps, .renovise-highlight, .renovise-teasers) + p:empty:last-child),
.renovise-main:has(> :is(.alignfull, .renovise-hero, .renovise-bloghero, .renovise-banner, .renovise-brands, .renovise-steps, .renovise-highlight, .renovise-teasers) + p:empty:last-child) {
	margin-bottom: 0;
}

/* Zeroing main's bottom margin is only half the job. WordPress also puts the
   global block gap on every .wp-site-blocks child after the first — as
   margin-block-start — so the FOOTER carries a top margin of its own. Adjacent
   margins collapse to the larger of the two, so with main's set to 0 the
   footer's survives and a thin white strip stays under the full-bleed section.
   That strip is what was left after the empty paragraph was deleted.
   Same conditions as above; there is no shorthand for "the previous rule's
   subject", so the selectors repeat. */
.renovise-main:has(> .wp-block-post-content > :last-child:is(.alignfull, .renovise-hero, .renovise-bloghero, .renovise-banner, .renovise-brands, .renovise-steps, .renovise-highlight, .renovise-teasers)) + footer,
.renovise-main:has(> :last-child:is(.alignfull, .renovise-hero, .renovise-bloghero, .renovise-banner, .renovise-brands, .renovise-steps, .renovise-highlight, .renovise-teasers)) + footer,
.renovise-main:has(> .wp-block-post-content > :is(.alignfull, .renovise-hero, .renovise-bloghero, .renovise-banner, .renovise-brands, .renovise-steps, .renovise-highlight, .renovise-teasers) + p:empty:last-child) + footer,
.renovise-main:has(> :is(.alignfull, .renovise-hero, .renovise-bloghero, .renovise-banner, .renovise-brands, .renovise-steps, .renovise-highlight, .renovise-teasers) + p:empty:last-child) + footer {
	margin-block-start: 0;
}

/* …and collapse that stray paragraph itself, so it contributes no height.
   Only a trailing empty one: an empty paragraph elsewhere in a page may be
   deliberate spacing someone added by hand. */
.renovise-main > .wp-block-post-content > p:empty:last-child {
	display: none;
}

/* ---- Fluent Forms: brand-red submit button ----------------------------
   Opt-in, not automatic. In the form editor open the Submit button →
   Advanced Options and type  rnv-btn  into EITHER field:
     Element Class   → lands on the <button> itself
     Container Class → lands on the wrapping .ff-el-group
   Both spellings are covered below, so it doesn't matter which one is used.

   Specificity note: Fluent paints the button from a <style> block it prints
   AFTER the theme stylesheet —
     form.fluent_form_N .ff-btn-submit:not(.ff_btn_no_style){background-color:...}
   which is (0,3,1). A tie would lose on source order, so these selectors are
   deliberately (0,4,1). No !important needed. */
.fluentform form .ff-btn.ff-btn-submit.rnv-btn,
.fluentform form .rnv-btn .ff-btn.ff-btn-submit {
	background-color: var(--wp--preset--color--primary);
	border-color: var(--wp--preset--color--primary);
}

.fluentform form .ff-btn.ff-btn-submit.rnv-btn:hover,
.fluentform form .ff-btn.ff-btn-submit.rnv-btn:focus-visible,
.fluentform form .rnv-btn .ff-btn.ff-btn-submit:hover,
.fluentform form .rnv-btn .ff-btn.ff-btn-submit:focus-visible {
	background-color: var(--wp--preset--color--primary-hover);
	border-color: var(--wp--preset--color--primary-hover);
}

/* ---- CTA band -------------------------------------------------------- */
.renovise-cta {
	border-radius: var(--wp--custom--radius--lg);
}

/* ---- Scroll-to-top --------------------------------------------------- */
.renovise-scroll-top {
	position: fixed;
	right: clamp(1rem, 3vw, 2rem);
	bottom: clamp(1rem, 3vw, 2rem);
	z-index: 90;
	display: grid;
	place-items: center;
	width: 3rem;
	height: 3rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
	cursor: pointer;
	opacity: 0;
	visibility: hidden;
	transform: translateY(0.5rem);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease, background 0.2s ease;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.renovise-scroll-top:hover {
	background: var(--wp--preset--color--primary-hover);
}

.renovise-scroll-top.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.renovise-scroll-top svg {
	width: 1.25rem;
	height: 1.25rem;
	fill: currentColor;
}

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