/*
 * Q-243 — product pages (.oo-product, single-agency_product.html) and the /products/ catalog
 * (.wp-block-agency-product-catalog). Mobile-first. Tokens only (var(--wp--preset--…), theme.json is
 * not touched — docs/q243-product-pages-spec.md §1/§2). No gradients, no JS, no third-party requests.
 */

/* ---------------------------------------------------------------------------------------------
 * 0. Breadcrumbs — last Yoast crumb overflows its row at 320px (production follow-up,
 * .organicops-breadcrumbs--entity in single-agency_product.html). Root cause (confirmed via CDP
 * computed-style/cascade inspection against a local Docker render of this exact template):
 * theme.json ships two conflicting rulesets for the same selectors at the same specificity —
 * the accepted Q-180 ellipsis design (.breadcrumb_last { display:inline-block; max-width:100%;
 * overflow:hidden; text-overflow:ellipsis } and a normally-wrapping .organicops-breadcrumbs) and
 * an older, superseded horizontal-scroll design (nav white-space:nowrap + .breadcrumb_last
 * display:inline; max-width:none — tools/theme-css/mobile-v1.css). The old block sits later in
 * theme.json's generated stylesheet, so on mobile it wins the tie and silently cancels Q-180's
 * truncation: the whole crumb row stops wrapping and the last crumb is no longer capped, so it
 * runs past the nav's own box. Not fixed in theme.json (out of scope here) — reasserted at higher
 * specificity in .oo-product only, restoring exactly the accepted Q-180 behaviour for product
 * pages: crumbs wrap normally, the last one truncates with an ellipsis, nothing scrolls.
 * ------------------------------------------------------------------------------------------- */

.oo-product .organicops-breadcrumbs {
	white-space: normal;
}

.oo-product .organicops-breadcrumbs .breadcrumb_last {
	display: inline-block;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	vertical-align: bottom;
}

/* ---------------------------------------------------------------------------------------------
 * 1. Section rhythm, numbering, eyebrow split
 * ------------------------------------------------------------------------------------------- */

.oo-product {
	counter-reset: oo-section;
}

.oo-product .is-style-oo-section {
	border-top: 1px solid var(--wp--preset--color--border);
	padding-block: clamp(4rem, 3rem + 6vw, 9rem);
}

.oo-product .is-style-oo-section.oo-section--hero {
	border-top: 0;
	padding-top: clamp(3rem, 2rem + 5vw, 6rem);
}

.oo-product .is-style-oo-section:not(.oo-section--hero):not(.oo-section--cta) {
	counter-increment: oo-section;
}

.oo-product .is-style-oo-section:not(.oo-section--hero):not(.oo-section--cta) .is-style-organicops-eyebrow::before {
	content: "(" counter(oo-section, decimal-leading-zero) ") \00b7\00a0";
	font-family: var(--wp--preset--font-family--sans);
	/* The theme eyebrow is a flex row with a square marker in ::before — replace the marker, never shrink. */
	display: inline-block;
	flex: 0 0 auto;
	width: auto;
	height: auto;
	background: none;
	white-space: pre;
}

.oo-product .is-style-organicops-eyebrow {
	letter-spacing: 0.06em;
	overflow-wrap: normal;
}

/* Editorial split heading/text on wide screens: heading rail 5, body 7. */
@media (min-width: 64rem) {
	.oo-product .is-style-oo-section > .wp-block-group > .oo-section__split {
		display: grid;
		grid-template-columns: 5fr 7fr;
		gap: var(--wp--preset--spacing--xl);
		align-items: start;
	}
}

/* ---------------------------------------------------------------------------------------------
 * 2. Typography
 * ------------------------------------------------------------------------------------------- */

.oo-product h1,
.oo-product .is-style-oo-section h2 {
	font-weight: 300;
	line-height: 1.05;
	text-wrap: balance;
	hyphens: auto;
}

/* !important: core preset classes (.has-*-font-size) are !important; scoped to product pages only. */
.oo-product h1 {
	font-size: clamp(2.25rem, 1.2rem + 4vw, 4.5rem) !important;
	letter-spacing: -0.02em;
}

.oo-product .is-style-oo-section h2 {
	font-size: clamp(1.75rem, 1rem + 3vw, 3.5rem) !important;
	letter-spacing: -0.01em;
}

.oo-product p,
.oo-product li {
	font-size: max(1rem, 16px);
	line-height: 1.6;
	overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------------------------------
 * 3. Hero — mobile: title / promise / CTA before the visual (markup order); desktop 7/5 split.
 * ------------------------------------------------------------------------------------------- */

.oo-product .oo-section--hero .wp-block-columns {
	align-items: center;
}

@media (min-width: 64rem) {
	.oo-product .oo-section--hero .wp-block-column:first-child {
		flex-basis: 58% !important;
	}

	.oo-product .oo-section--hero .wp-block-column:last-child {
		flex-basis: 42% !important;
	}
}

.oo-hero-visual {
	position: relative;
	overflow: hidden;
	min-height: 12rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--md);
	background: var(--wp--preset--color--surface);
}

.oo-hero-visual__texture {
	position: absolute;
	inset: 0;
	margin: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	font-family: var(--wp--preset--font-family--sans);
	font-weight: 300;
	font-size: clamp(2rem, 1rem + 6vw, 5rem);
	line-height: 1;
	letter-spacing: -0.02em;
	color: var(--wp--preset--color--accent);
	opacity: 0.16;
	text-align: center;
	text-transform: uppercase;
	overflow-wrap: anywhere;
	user-select: none;
}

/* ---------------------------------------------------------------------------------------------
 * 4. Stat cards (is-style-oo-stat) — bento via auto-fit.
 * ------------------------------------------------------------------------------------------- */

.oo-product .oo-stat-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
	gap: var(--wp--preset--spacing--md);
}

.oo-product .is-style-oo-stat {
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--xs);
	background: var(--wp--preset--color--surface);
	padding: clamp(1.5rem, 1rem + 1vw, 2rem);
	transition: border-color 0.18s ease;
}

.oo-product .is-style-oo-stat:hover {
	border-color: var(--wp--preset--color--accent);
}

.oo-product .is-style-oo-stat .oo-stat__value,
.oo-product .is-style-oo-stat > p:first-of-type {
	font-size: clamp(2.5rem, 2rem + 2.5vw, 4rem);
	font-weight: 300;
	line-height: 1.05;
	color: var(--wp--preset--color--accent);
	margin: 0 0 0.25em;
}

/* ---------------------------------------------------------------------------------------------
 * 5. "Как работает" — bracket-numbered steps, vertical list on mobile.
 * ------------------------------------------------------------------------------------------- */

.oo-product .oo-section--how .organicops-step-number::before {
	content: "(";
}

.oo-product .oo-section--how .organicops-step-number::after {
	content: ")";
}

.oo-product .oo-section--how [class*="wp-block-group"] > .wp-block-group + .wp-block-group {
	border-top: 1px solid var(--wp--preset--color--border);
}

/* ---------------------------------------------------------------------------------------------
 * 6. Demonstration — media grid 2x2 to 1 column.
 * ------------------------------------------------------------------------------------------- */

.oo-product .oo-section--demo .wp-block-gallery {
	grid-template-columns: 1fr;
}

@media (min-width: 48rem) {
	.oo-product .oo-section--demo .wp-block-gallery {
		grid-template-columns: repeat(2, 1fr);
	}
}

/* ---------------------------------------------------------------------------------------------
 * 7. Pricing — accent-bordered panel.
 * ------------------------------------------------------------------------------------------- */

.oo-product .oo-section--pricing .is-style-organicops-card,
.oo-product .oo-section--pricing .is-style-organicops-card-accent {
	border: 1px solid var(--wp--preset--color--accent);
}

/* ---------------------------------------------------------------------------------------------
 * 8. Final CTA — the one light plane on the page.
 * ------------------------------------------------------------------------------------------- */

.oo-product .oo-section--cta {
	border-top: 0;
	background: var(--wp--preset--color--text);
	color: var(--wp--preset--color--background);
}

.oo-product .oo-section--cta h2,
.oo-product .oo-section--cta p {
	color: var(--wp--preset--color--background);
}

.oo-product .oo-section--cta .wp-block-button__link {
	background: var(--wp--preset--color--accent);
	color: var(--wp--preset--color--background);
}

/* ---------------------------------------------------------------------------------------------
 * 9. Catalog cards (/products/, agency/product-catalog → ProductCard).
 * ------------------------------------------------------------------------------------------- */

/* Hub /products/: display-scale page title (catalog stays on the page's content column). */
body:has(.wp-block-agency-product-catalog) main h1 {
	font-size: clamp(2.25rem, 1.2rem + 4vw, 4.5rem) !important;
	font-weight: 300;
	line-height: 1.05;
	letter-spacing: -0.02em;
}

.wp-block-agency-product-catalog .agency-product-catalog__grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: var(--wp--preset--spacing--md);
	list-style: none;
	margin: 0;
	padding: 0;
}

@media (min-width: 48rem) {
	.wp-block-agency-product-catalog .agency-product-catalog__grid {
		grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
	}
}

.wp-block-agency-product-catalog .agency-product-card {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--xs);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--xs);
	background: var(--wp--preset--color--surface);
	padding: clamp(1.5rem, 1rem + 1vw, 2rem);
	transition: border-color 0.18s ease;
}

.wp-block-agency-product-catalog .agency-product-card:hover {
	border-color: var(--wp--preset--color--accent);
}

.wp-block-agency-product-catalog .agency-product-card__marker {
	display: block;
	font-family: var(--wp--preset--font-family--sans);
	font-size: clamp(1.5rem, 1rem + 1.5vw, 2.25rem);
	font-weight: 300;
	color: var(--wp--preset--color--accent);
}

.wp-block-agency-product-catalog .agency-product-card__image {
	width: 100%;
	height: auto;
	border-radius: var(--wp--custom--radius--xs);
}

.wp-block-agency-product-catalog .agency-product-card__label {
	margin: 0;
	font-family: var(--wp--preset--font-family--sans);
	font-size: 0.8125rem;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: var(--wp--preset--color--muted);
}

.wp-block-agency-product-catalog .agency-product-card__title {
	margin: 0;
}

.wp-block-agency-product-catalog .agency-product-card__title a {
	color: var(--wp--preset--color--text);
	text-decoration: none;
}

.wp-block-agency-product-catalog .agency-product-card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.wp-block-agency-product-catalog .agency-product-card {
	position: relative;
}

.wp-block-agency-product-catalog .agency-product-card__summary {
	margin: 0;
	color: var(--wp--preset--color--muted);
}

.wp-block-agency-product-catalog .agency-product-card__outcomes {
	margin: 0;
}

.wp-block-agency-product-catalog .agency-product-card__outcomes-title {
	margin: 0 0 0.25em;
	font-size: 0.8125rem;
	color: var(--wp--preset--color--muted);
}

.wp-block-agency-product-catalog .agency-product-card__outcomes ul {
	margin: 0;
	padding-inline-start: 1.1em;
}

.wp-block-agency-product-catalog .agency-product-card__footer {
	margin-top: auto;
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--xs);
	padding-top: var(--wp--preset--spacing--xs);
	border-top: 1px solid var(--wp--preset--color--border);
}

.wp-block-agency-product-catalog .agency-product-card__price {
	margin: 0;
	font-size: clamp(1.5rem, 1rem + 1vw, 2rem);
	font-weight: 300;
	color: var(--wp--preset--color--accent);
}

.wp-block-agency-product-catalog .agency-product-card__cta {
	font-size: 0.875rem;
	color: var(--wp--preset--color--muted);
}

/* ---------------------------------------------------------------------------------------------
 * 10. Motion — CSS only, opacity/transform, scroll-driven; off by default under reduced motion.
 * ------------------------------------------------------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
	@supports (animation-timeline: view()) {
		.oo-product .is-style-oo-section:not(.oo-section--hero) {
			animation: oo-section-in linear both;
			animation-timeline: view();
			animation-range: entry 0% cover 25%;
		}

		@keyframes oo-section-in {
			from {
				opacity: 0;
				transform: translateY(1rem);
			}

			to {
				opacity: 1;
				transform: translateY(0);
			}
		}
	}
}

@media (prefers-reduced-motion: reduce) {
	.oo-product .is-style-oo-section,
	.oo-product .is-style-oo-stat,
	.wp-block-agency-product-catalog .agency-product-card {
		animation: none !important;
		animation-duration: 0s !important;
		transition: none !important;
	}
}

/* ---------------------------------------------------------------------------------------------
 * 11. Accessibility — focus, touch targets.
 * ------------------------------------------------------------------------------------------- */

.oo-product a:focus-visible,
.oo-product button:focus-visible,
.wp-block-agency-product-catalog a:focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 3px;
}

.oo-product .wp-block-button__link,
.oo-product .wp-block-buttons .wp-block-button__link,
.wp-block-agency-product-catalog .agency-product-card__title a {
	min-height: 44px;
}

.oo-product .wp-block-button__link {
	display: inline-flex;
	align-items: center;
	min-width: 44px;
}
