/*
Theme Name:     TimberBLDR
Description:    Child theme for TimberBLDR — mass-timber construction. Built on Classic City Core. Palette: taupe-brown primary, amber CTA, sage + sky accents on a warm off-white canvas. Font: Arthura (self-hosted).
Author:         Classic City Core
Template:       classic-city-core
Version:        1.0.0
Text Domain:    sg-timberbldr
*/

/* ==================================================================
 * TimberBLDR — child-theme overrides
 * ------------------------------------------------------------------
 * Almost everything is driven by theme.json (palette, fonts, tokens)
 * and the parent's assets/blocks.css. Only client-specific CSS that
 * can't be expressed in theme.json belongs here.
 * ================================================================== */

body {
	background: var(--wp--preset--color--canvas);
	min-height: 100vh;
}

/* WP core positions cover video/image backgrounds from wp-block-library,
 * which the parent dequeues. Without these four rules a video cover flows
 * at intrinsic size (fake letterboxing). */
.wp-block-cover__video-background,
.wp-block-cover__image-background {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* Sticky frosted-glass header with a terracotta accent border, echoing the
 * BLDR Corp treatment. CTA and the decorative lines share the terracotta
 * cta slot per Chris's call. color-mix over canvas keeps it palette-driven. */
.wp-site-blocks > header {
	position: sticky;
	top: 0;
	z-index: 100;
	background: color-mix(in srgb, var(--wp--preset--color--canvas) 88%, transparent);
	backdrop-filter: blur(6px);
	border-bottom: calc(var(--wp--custom--border--default-width) * 4) solid var(--wp--preset--color--cta);
}

/* Anchor jumps must clear the sticky header. */
[id] {
	scroll-margin-top: 110px;
}

/* Pages that open with a plain H1 (Blog, Projects) start flush under the
 * sticky header; give the opening heading a section-gap of breathing room.
 * Pages that open with a hero (alignfull) are unaffected. */
.wp-block-post-content > h1:first-child {
	margin-block-start: var(--ccc-section-gap);
}

/* Decorative underline bar under h2s (BLDR family motif). Width/height off
 * the shared scale; color flips to currentColor on CTA surfaces. */
h2::after {
	content: "";
	display: block;
	width: 3rem;
	height: calc(var(--wp--custom--border--default-width) * 3);
	background: var(--wp--preset--color--cta);
	margin-top: var(--wp--preset--spacing--10);
}
.has-text-align-center > h2::after,
h2.has-text-align-center::after {
	margin-inline: auto;
}
.has-tertiary-background-color h2::after,
.has-cta-background-color h2::after {
	background: currentColor;
}

/* Card chrome — shared treatment for every card on the site (Chris's call):
 * a 1px border around the card, and a terracotta (cta) rule at the top of
 * the text body. For image cards the body rule doubles as the divider under
 * the image; a feature card has no image, so its body rule IS its top edge. */
.sg-block-card,
.is-style-feature-card {
	border: var(--wp--custom--border--default-width) solid var(--wp--custom--border--color);
}
.sg-block-card-body {
	border-top: var(--wp--custom--border--default-width) solid var(--wp--preset--color--cta);
}

/* Feature cards (3-up Purpose/Vision/Promise-style row). Equal height inside
 * core/columns; left-aligned content despite the constrained-layout centering. */
.is-style-feature-card {
	background: var(--wp--preset--color--panel);
	padding: var(--wp--preset--spacing--50) var(--wp--preset--spacing--40);
	border-top: var(--wp--custom--border--default-width) solid var(--wp--preset--color--cta);
	height: 100%;
	display: flex;
	flex-direction: column;
	box-shadow: var(--wp--preset--shadow--sm);
}
.is-style-feature-card :is(h2, h3, h4, p) {
	text-align: left;
	margin-inline: 0 !important;
	max-width: 100%;
}
.is-style-feature-card h2::after,
.is-style-feature-card h3::after {
	display: none;
}

/* QA round 2: on iPad the 3-up cards left ~170px of text width, so
 * uppercase "SUSTAINABLE" split mid-word ("SUSTAINABL / E"). Card headings
 * never break inside a word; feature-card rows stack until 1024px (core only
 * stacks below 782px); image-card headings shrink with their card. */
:is(.is-style-feature-card, .sg-block-card-body) :is(h2, h3, h4) {
	overflow-wrap: normal;
	word-break: normal;
	hyphens: manual;
}
@media (max-width: 1023px) {
	.wp-block-columns:has(> .wp-block-column > .is-style-feature-card) {
		flex-wrap: wrap !important;
	}
	.wp-block-columns:has(> .wp-block-column > .is-style-feature-card) > .wp-block-column {
		flex-basis: 100% !important;
	}
}
/* 3-up image cards stack where core columns do (the parent waits until
 * 600px, which leaves card headings at ~14px). */
@media (max-width: 781px) {
	.sg-block-columns[style*="--block-columns: 3"] {
		grid-template-columns: 1fr;
	}
}
/* Scale against the card's own width: "SUSTAINABLE" measures ~7em and
 * "PROCUREMENT" ~7.75em, so 13cqi / 11cqi always fit one word per line. */
.is-style-feature-card,
.sg-block-card-body {
	container-type: inline-size;
}
.is-style-feature-card h3 {
	font-size: min(clamp(var(--wp--custom--fs--h-3-min), calc(var(--wp--custom--heading--base-font-size) * 1.4 + 1.2vw), var(--wp--custom--fs--h-3)), 13cqi);
}
.sg-block-card-body h4 {
	font-size: min(clamp(var(--wp--custom--fs--h-4-min), calc(var(--wp--custom--heading--base-font-size) * 1.2 + 0.8vw), var(--wp--custom--fs--h-4)), 11cqi);
}

/* Escape hatch: let a child of a constrained group span the group's full
 * padded width (unlike alignfull, stays inside the gutters). Wins without
 * !important because the parent cap is a :where() rule. */
.is-layout-constrained > .is-full-container {
	max-width: none;
}

/* Headshot / tall-subject crop opt-in for image cards. */
.image-align-top .sg-block-card-image {
	background-position: top;
}

/* ==================================================================
 * Blog index card grid (TexBuilt pattern) — the /blog/ page uses a
 * core/latest-posts block; this regrids it into panel cards. Core emits
 * a float-based .columns-N layout; grid wins regardless of the block's
 * columns attribute.
 * ================================================================== */
/* Core styles this container/its li with `.is-grid:not(.is-layout-grid)`
 * selectors (specificity 0,3,0 / 0,3,1) — every rule here mirrors that
 * :not() plus the ul tag so the child treatment outranks core's flex+margin
 * layout deterministically. */
ul.wp-block-latest-posts.is-grid:not(.is-layout-grid) {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: var(--wp--style--block-gap, var(--wp--preset--spacing--30));
}
/* ul + :not() mirrors core's `.is-grid:not(.is-layout-grid) li` margin rule
 * (specificity 0,3,1) and outranks it — the grid gap does the spacing. */
ul.wp-block-latest-posts.is-grid:not(.is-layout-grid) > li {
	margin: 0;
	width: auto;
	display: flex;
	flex-direction: column;
	background: var(--wp--preset--color--panel);
	border: var(--wp--custom--border--default-width) solid var(--wp--custom--border--color);
	border-radius: var(--wp--custom--radius--default);
	box-shadow: var(--wp--preset--shadow--sm);
	overflow: hidden;
}
/* Divider above the card body = the shared terracotta body rule. */
.wp-block-latest-posts.is-grid .wp-block-latest-posts__featured-image {
	border-bottom: var(--wp--custom--border--default-width) solid var(--wp--preset--color--cta);
}
.wp-block-latest-posts.is-grid .wp-block-latest-posts__featured-image img {
	display: block;
	width: 100%;
	max-width: 100% !important; /* beat WP's inline max-width on sized thumbs */
	aspect-ratio: 4 / 3;
	object-fit: cover;
	height: auto;
}
.wp-block-latest-posts.is-grid > li > a.wp-block-latest-posts__post-title {
	display: block;
	padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--30) 0;
	font-family: var(--wp--preset--font-family--heading);
	font-size: clamp(var(--wp--custom--fs--h-4-min), calc(var(--wp--custom--heading--base-font-size) * 1.2 + 0.8vw), var(--wp--custom--fs--h-4));
	font-weight: 700;
	line-height: 1.15em;
	text-transform: uppercase;
	letter-spacing: var(--wp--custom--heading--letter-spacing);
	color: var(--wp--preset--color--ink);
	text-decoration: none;
}
.wp-block-latest-posts.is-grid > li > a.wp-block-latest-posts__post-title:hover {
	color: var(--wp--preset--color--primary);
}
.wp-block-latest-posts.is-grid .wp-block-latest-posts__post-excerpt {
	flex: 1;
	padding: var(--wp--preset--spacing--20) var(--wp--preset--spacing--30) var(--wp--preset--spacing--30);
	color: var(--wp--preset--color--ink-soft);
}
@media (max-width: 1024px) {
	ul.wp-block-latest-posts.is-grid:not(.is-layout-grid) {
		grid-template-columns: repeat(2, 1fr);
	}
}
@media (max-width: 640px) {
	ul.wp-block-latest-posts.is-grid:not(.is-layout-grid) {
		grid-template-columns: 1fr;
	}
}

/* Gravity Forms: inherit the surface's palette colors instead of GF's own
 * grays, and bold labels on the theme scale. */
.gform_wrapper,
.gform_wrapper .gfield_label,
.gform_wrapper legend.gfield_label,
.gform_wrapper .ginput_complex label {
	color: inherit;
}
.gform_wrapper .gfield_label {
	font-weight: 700;
}

/* Projects landing tiles — frame + CTA hover flip (TexBuilt pattern). */
.sg-block-image-tile {
	border: var(--wp--custom--border--default-width) solid var(--wp--custom--gray--40);
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.sg-block-image-tile:hover {
	border-color: var(--wp--preset--color--cta);
	box-shadow: var(--wp--preset--shadow--md);
}
.sg-block-image-tile:hover .sg-block-image-tile-blurb {
	color: var(--wp--preset--color--cta);
}
