/*
Theme Name: Small Back Yard
Theme URI: https://smallbackyardideas.com
Author: Small Back Yard
Description: Motion-led block theme for a digital marketing agency serving landscaping and hardscaping companies. Site-plan documentation aesthetic, scroll-driven CSS motion, WCAG 2.2 AA.
Version: 2.0.0
Requires at least: 6.5
Tested up to: 6.8
Requires PHP: 8.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: sby
Tags: business, blog, one-column, block-patterns, full-site-editing, wide-blocks, accessibility-ready
*/

/* Design tokens live in theme.json. This file holds motion, the rule-index
   affordance, and the few compositions block markup cannot express. */

:root {
	--sby-ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
	--sby-ease-quart: cubic-bezier(0.25, 1, 0.5, 1);
	--sby-dur-fast: 180ms;
	--sby-dur-mid: 420ms;
	--sby-dur-slow: 760ms;

	/* Hairlines derive from the ground so the palette cannot drift. */
	--sby-hair: color-mix(in oklab, var(--wp--preset--color--ivory) 16%, transparent);
	--sby-hair-strong: color-mix(in oklab, var(--wp--preset--color--ivory) 34%, transparent);

	/* Semantic z-scale. Never arbitrary values. */
	--z-sticky: 100;
	--z-header: 200;
	--z-overlay: 300;
	--z-skip: 400;
}

/* Paper sections invert the hairline so it stays visible on ivory. */
.sby-paper {
	--sby-hair: color-mix(in oklab, var(--wp--preset--color--charcoal) 14%, transparent);
	--sby-hair-strong: color-mix(in oklab, var(--wp--preset--color--charcoal) 30%, transparent);
}

/* -------------------------------------------------------------- header -- */

.sby-header {
	z-index: var(--z-header);
	/* The sticky bar is a surface, not a floating panel: no shadow, no blur. */
	background: var(--wp--preset--color--evergreen);
}

/* Nav links inherit the global lime link colour, which is too loud for a nav.
   Ivory at rest, marker on hover, with the underline drawn rather than toggled. */
.sby-header .wp-block-navigation a:where(:not(.wp-element-button)) {
	color: var(--wp--preset--color--ivory);
	text-decoration: none;
	position: relative;
	padding-block: 0.35rem;
}

.sby-header .wp-block-navigation a:where(:not(.wp-element-button))::after {
	content: "";
	position: absolute;
	inset-inline: 0;
	bottom: 0;
	height: 1px;
	background: var(--wp--preset--color--lime);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform var(--sby-dur-fast) var(--sby-ease-expo);
}

.sby-header .wp-block-navigation a:where(:not(.wp-element-button)):hover::after,
.sby-header .wp-block-navigation a:where(:not(.wp-element-button)):focus-visible::after,
.sby-header .wp-block-navigation .current-menu-item > a::after {
	transform: scaleX(1);
}

.sby-topbar a {
	color: inherit;
	text-decoration: none;
}

.sby-topbar a:hover {
	color: var(--wp--preset--color--lime);
}

/* ---------------------------------------------------------------- a11y -- */

.skip-link.screen-reader-text:focus {
	z-index: var(--z-skip);
	padding: 0.85rem 1.4rem;
	background: var(--wp--preset--color--lime);
	color: var(--wp--preset--color--charcoal);
	font-family: var(--wp--preset--font-family--display);
	font-weight: 700;
	text-decoration: none;
	clip: auto;
	clip-path: none;
	width: auto;
	height: auto;
}

/* Two-tone focus so it survives on both the evergreen ground and paper insets. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline: 2px solid var(--wp--preset--color--lime);
	outline-offset: 3px;
	box-shadow: 0 0 0 5px color-mix(in oklab, var(--wp--preset--color--charcoal) 55%, transparent);
	border-radius: 2px;
}

.sby-paper :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
	outline-color: var(--wp--preset--color--charcoal);
	box-shadow: 0 0 0 5px var(--wp--preset--color--lime);
}

/* ------------------------------------------------------------ structure -- */

.sby-section {
	padding-block: var(--wp--preset--spacing--60);
}

/* One page-type label per template. Wayfinding, not section grammar — an eyebrow
   above every heading is the tell this theme was rebuilt to remove. */
.sby-eyebrow {
	font-family: var(--wp--preset--font-family--data);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 500;
	letter-spacing: 0.01em;
	color: var(--wp--preset--color--lime);
	margin: 0 0 var(--wp--preset--spacing--20);
}

.sby-paper .sby-eyebrow {
	color: color-mix(in oklab, var(--wp--preset--color--charcoal) 70%, transparent);
}

.sby-lede {
	max-width: 34ch;
}

.sby-prose {
	max-width: 68ch;
}

/* ------------------------------------------------- the rule-index row --- */

/* The primary list affordance. Replaces the identical-card grid: a hairline, a
   mono index, a heading, and supporting copy. Reads as a drawing-sheet parts list. */

.sby-rows {
	list-style: none;
	margin: 0;
	padding: 0;
	counter-reset: sby-row;
}

.sby-row {
	position: relative;
	counter-increment: sby-row;
	border-top: 1px solid var(--sby-hair);
	padding-block: clamp(1.5rem, 3.2vw, 2.6rem);
	display: grid;
	grid-template-columns: 4.5rem minmax(0, 1fr) minmax(0, 1.1fr);
	gap: clamp(1rem, 3vw, 3rem);
	align-items: start;
}

.sby-rows > .sby-row:last-child {
	border-bottom: 1px solid var(--sby-hair);
}

@media (max-width: 47.9375rem) {
	.sby-row {
		grid-template-columns: 3rem minmax(0, 1fr);
	}
	.sby-row__body {
		grid-column: 2;
	}
}

.sby-row__index {
	font-family: var(--wp--preset--font-family--data);
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--lime);
	padding-top: 0.55em;
	font-variant-numeric: tabular-nums;
}

.sby-row__index::before {
	content: counter(sby-row, decimal-leading-zero);
}

.sby-row__title {
	margin: 0;
}

.sby-row__title a {
	color: inherit;
	text-decoration: none;
	/* Full-row hit area without nesting the whole row in an anchor. */
}

.sby-row__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.sby-row__body {
	margin: 0;
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--small);
	max-width: 60ch;
}

.sby-paper .sby-row__body {
	color: color-mix(in oklab, var(--wp--preset--color--charcoal) 78%, transparent);
}

/* Hover: the rule brightens and the row shifts a hair. No card lift, no shadow. */
.sby-row--link {
	transition: background-color var(--sby-dur-fast) var(--sby-ease-quart);
}

.sby-row--link:hover,
.sby-row--link:focus-within {
	background-color: color-mix(in oklab, var(--wp--preset--color--ivory) 5%, transparent);
}

.sby-row--link .sby-row__title {
	transition: transform var(--sby-dur-fast) var(--sby-ease-expo);
}

.sby-row--link:hover .sby-row__title,
.sby-row--link:focus-within .sby-row__title {
	transform: translateX(0.4rem);
}

/* The rule itself draws in on hover, left to right. */
.sby-row--link::before {
	content: "";
	position: absolute;
	inset-inline: 0;
	top: -1px;
	height: 1px;
	background: var(--wp--preset--color--lime);
	transform: scaleX(0);
	transform-origin: left;
	transition: transform var(--sby-dur-mid) var(--sby-ease-expo);
}

.sby-row--link:hover::before,
.sby-row--link:focus-within::before {
	transform: scaleX(1);
}

/* ----------------------------------------------------------- figure cell -- */

.sby-figures {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
	border-top: 1px solid var(--sby-hair);
	border-left: 1px solid var(--sby-hair);
}

.sby-figure {
	border-right: 1px solid var(--sby-hair);
	border-bottom: 1px solid var(--sby-hair);
	padding: clamp(1.25rem, 2.5vw, 2rem);
}

.sby-figure__value {
	font-family: var(--wp--preset--font-family--data);
	font-size: var(--wp--preset--font-size--x-large);
	font-weight: 500;
	color: var(--wp--preset--color--lime);
	font-variant-numeric: tabular-nums;
	display: block;
}

.sby-figure__label {
	font-size: var(--wp--preset--font-size--small);
	margin: 0.4rem 0 0;
}

.sby-figure__source {
	font-family: var(--wp--preset--font-family--data);
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--muted);
	margin: 0.6rem 0 0;
}

/* ---------------------------------------------------------- placeholder -- */

/* Anything awaiting real client data. Provisional on sight, in the editor and
   on the front end, so it can never be mistaken for evidence. */
.sby-placeholder {
	border: 1px dashed var(--sby-hair-strong);
	padding: clamp(1.25rem, 2.5vw, 2rem);
	background: repeating-linear-gradient(
		135deg,
		transparent 0 10px,
		color-mix(in oklab, var(--wp--preset--color--ivory) 4%, transparent) 10px 20px
	);
}

.sby-paper .sby-placeholder {
	background: repeating-linear-gradient(
		135deg,
		transparent 0 10px,
		color-mix(in oklab, var(--wp--preset--color--charcoal) 5%, transparent) 10px 20px
	);
}

.sby-placeholder::before {
	content: "Awaiting client evidence";
	display: block;
	font-family: var(--wp--preset--font-family--data);
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--lime);
	margin-bottom: var(--wp--preset--spacing--20);
}

.sby-paper .sby-placeholder::before {
	color: color-mix(in oklab, var(--wp--preset--color--charcoal) 75%, transparent);
}

/* ----------------------------------------------------------- breadcrumb -- */

.sby-breadcrumb {
	font-family: var(--wp--preset--font-family--data);
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--muted);
	padding-block: var(--wp--preset--spacing--30);
}

.sby-breadcrumb ol {
	list-style: none;
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
}

.sby-breadcrumb li + li::before {
	content: "/";
	margin-right: 0.5rem;
	color: var(--sby-hair-strong);
}

.sby-breadcrumb a {
	color: inherit;
	text-decoration: none;
}

.sby-breadcrumb a:hover {
	color: var(--wp--preset--color--lime);
}

/* ----------------------------------------------------------------- FAQ -- */

.sby-faq details {
	border-top: 1px solid var(--sby-hair);
	padding-block: var(--wp--preset--spacing--30);
}

.sby-faq details:last-of-type {
	border-bottom: 1px solid var(--sby-hair);
}

.sby-faq summary {
	cursor: pointer;
	list-style: none;
	display: flex;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--30);
	font-family: var(--wp--preset--font-family--display);
	font-weight: 700;
	font-size: var(--wp--preset--font-size--large);
	letter-spacing: -0.025em;
}

.sby-faq summary::-webkit-details-marker {
	display: none;
}

.sby-faq summary::after {
	content: "";
	flex: 0 0 auto;
	width: 0.85em;
	height: 0.85em;
	margin-top: 0.3em;
	background: currentColor;
	/* Plus sign drawn as a mask so it rotates cleanly without a font glyph. */
	-webkit-mask: linear-gradient(currentColor, currentColor) center/100% 1.5px no-repeat,
		linear-gradient(currentColor, currentColor) center/1.5px 100% no-repeat;
	mask: linear-gradient(currentColor, currentColor) center/100% 1.5px no-repeat,
		linear-gradient(currentColor, currentColor) center/1.5px 100% no-repeat;
	color: var(--wp--preset--color--lime);
	transition: transform var(--sby-dur-mid) var(--sby-ease-expo);
}

.sby-faq details[open] summary::after {
	transform: rotate(135deg);
}

.sby-faq details > :not(summary) {
	margin-top: var(--wp--preset--spacing--20);
	max-width: 68ch;
	color: var(--wp--preset--color--muted);
}

.sby-paper .sby-faq details > :not(summary) {
	color: color-mix(in oklab, var(--wp--preset--color--charcoal) 80%, transparent);
}

/* Answer slides open where the browser supports interpolating to auto. */
@supports (interpolate-size: allow-keywords) {
	@media (prefers-reduced-motion: no-preference) {
		:root {
			interpolate-size: allow-keywords;
		}
		.sby-faq details::details-content {
			block-size: 0;
			overflow: clip;
			transition: block-size var(--sby-dur-mid) var(--sby-ease-expo),
				content-visibility var(--sby-dur-mid) allow-discrete;
		}
		.sby-faq details[open]::details-content {
			block-size: auto;
		}
	}
}

/* ---------------------------------------------------------------- form -- */

.sby-form {
	display: grid;
	gap: var(--wp--preset--spacing--30);
	max-width: 34rem;
}

.sby-form label {
	display: block;
	font-family: var(--wp--preset--font-family--data);
	font-size: var(--wp--preset--font-size--x-small);
	margin-bottom: 0.45rem;
}

.sby-form :is(input, select, textarea) {
	width: 100%;
	padding: 0.8rem 0.95rem;
	border: 1px solid var(--sby-hair-strong);
	border-radius: 2px;
	background: color-mix(in oklab, var(--wp--preset--color--ivory) 6%, transparent);
	color: inherit;
	font: inherit;
	/* High-frequency, keyboard-driven. No entrance motion — colour only. */
	transition: border-color var(--sby-dur-fast) var(--sby-ease-quart);
}

.sby-paper .sby-form :is(input, select, textarea) {
	background: var(--wp--preset--color--white);
}

.sby-form :is(input, select, textarea):hover {
	border-color: var(--wp--preset--color--lime);
}

.sby-form ::placeholder {
	color: var(--wp--preset--color--muted);
	opacity: 1;
}

.sby-form .sby-hint {
	font-family: var(--wp--preset--font-family--data);
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--muted);
	margin-top: 0.35rem;
}

/* Errors carry an icon and text, never colour alone. */
.sby-form .sby-error {
	color: #ffb4a8;
	font-size: var(--wp--preset--font-size--small);
}

.sby-paper .sby-form .sby-error {
	color: #8c1d18;
}

.sby-form .sby-error::before {
	content: "\26A0\FE0E  ";
}

.sby-status[role="status"],
.sby-status[role="alert"] {
	padding: var(--wp--preset--spacing--30);
	border: 1px solid var(--sby-hair-strong);
	border-left-width: 1px;
}

.sby-hp {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* --------------------------------------------------------------- media -- */

.sby-media {
	position: relative;
	overflow: hidden;
}

.sby-media img,
.wp-block-post-featured-image img {
	width: 100%;
	height: auto;
	object-fit: cover;
	display: block;
}

/* --------------------------------------------------------------- cards -- */

/* Retained only for the post grid, where a link target genuinely needs bounds.
   Everywhere else the rule-index row is the affordance. */
.sby-grid {
	display: grid;
	gap: 1px;
	grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
	background: var(--sby-hair);
	border: 1px solid var(--sby-hair);
}

.sby-card {
	background: var(--wp--preset--color--evergreen);
	padding: clamp(1.5rem, 3vw, 2.25rem);
	transition: background-color var(--sby-dur-fast) var(--sby-ease-quart);
}

.sby-paper .sby-card {
	background: var(--wp--preset--color--ivory);
}

.sby-card:hover,
.sby-card:focus-within {
	background: color-mix(in oklab, var(--wp--preset--color--ivory) 6%, var(--wp--preset--color--evergreen));
}

/* =========================================================== MOTION ===== */

/*
 * Two rules govern everything below.
 *
 * 1. The base state is always visible. Reveals are additive and gated behind
 *    @supports, so a browser without scroll-driven animation, a headless
 *    renderer, or a background tab still paints the content.
 * 2. Every animation is wrapped in prefers-reduced-motion: no-preference. When
 *    reduced motion is set, none of these rules exist at all.
 *
 * No JavaScript, no IntersectionObserver, no library.
 */

@media (prefers-reduced-motion: no-preference) {

	/* --- Hero: one orchestrated arrival, not a per-section fade ---------- */

	@keyframes sby-rise {
		from {
			opacity: 0;
			transform: translateY(1.4rem);
		}
	}

	@keyframes sby-draw {
		from {
			transform: scaleX(0);
		}
	}

	@keyframes sby-settle {
		from {
			opacity: 0;
			transform: scale(1.06);
			filter: blur(6px);
		}
	}

	.sby-hero__line {
		animation: sby-rise var(--sby-dur-slow) var(--sby-ease-expo) backwards;
	}

	.sby-hero__line:nth-child(1) { animation-delay: 40ms; }
	.sby-hero__line:nth-child(2) { animation-delay: 120ms; }
	.sby-hero__line:nth-child(3) { animation-delay: 200ms; }

	.sby-hero__rule {
		animation: sby-draw var(--sby-dur-slow) var(--sby-ease-expo) 280ms backwards;
		transform-origin: left;
	}

	.sby-hero__media img {
		animation: sby-settle 1.1s var(--sby-ease-expo) 120ms backwards;
	}

	/* --- Scroll-driven reveals, per section type ------------------------ */

	@supports (animation-timeline: view()) {

		/* Rule-index rows stagger along their own rules as the list enters.
		   The delay comes from the row's position, not a JS stagger. */
		.sby-reveal-rows > * {
			animation: sby-rise var(--sby-dur-mid) var(--sby-ease-expo) both;
			animation-timeline: view();
			animation-range: entry 8% entry 62%;
		}

		/* A single block that lifts once. Used sparingly, not on every section. */
		.sby-reveal {
			animation: sby-rise var(--sby-dur-mid) var(--sby-ease-expo) both;
			animation-timeline: view();
			animation-range: entry 10% entry 55%;
		}

		/* The process rule fills with scroll position. This is orientation,
		   not decoration: it shows how far through the sequence you are. */
		.sby-progress__fill {
			transform-origin: left;
			animation: sby-draw linear both;
			animation-timeline: view(block);
			animation-range: cover 12% cover 82%;
		}
	}
}

/* Sticky progress rail for the process sequence. */
.sby-progress {
	position: sticky;
	top: 0;
	z-index: var(--z-sticky);
	height: 2px;
	background: var(--sby-hair);
}

.sby-progress__fill {
	height: 100%;
	background: var(--wp--preset--color--lime);
	transform: scaleX(0);
	transform-origin: left;
}

/* Without scroll-driven animation the rail would sit permanently empty, which
   reads as broken. Hide it rather than ship a dead element. */
@supports not (animation-timeline: view()) {
	.sby-progress {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sby-progress {
		display: none;
	}
}

/* Belt and braces: kill any transition or animation the editor injects. */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
