/*
Theme Name: Platform Chassis
Theme URI: https://wp.philiprehberger.com
Author: Philip Rehberger
Author URI: https://philiprehberger.com
Description: Parent theme for the WordPress portfolio platform. Provides all templates, parts, patterns, structural CSS, and the gotcha-busting fixes that every demo benefits from. Child themes (forge, atrium, volt, or per-demo custom) override theme.json palette + typography while inheriting everything else.
Requires at least: 6.5
Tested up to: 6.7
Requires PHP: 8.1
Version: 1.0.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: chassis
Tags: block-theme, full-site-editing, parent-theme
*/

/* =============================================================================
 * WooCommerce product collection fixes
 *
 * Every rule below took ~30 minutes to debug on shop.philiprehberger.com.
 * They ship in the chassis so future demos don't re-discover them.
 * ============================================================================= */

/*
 * Lock product card image to 4:3 — prevents card-height variance from cropping
 * different amounts of the title text. Caveat: source images should be 4:3 for
 * best results; 1:1 sources will letterbox.
 */
.wc-block-product .wc-block-components-product-image {
	aspect-ratio: 4 / 3;
	width: 100%;
	overflow: hidden;
	display: block;
}
.wc-block-product .wc-block-components-product-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/*
 * Hide empty WC notice-banner template that otherwise inflates the first card
 * in a product collection grid. WC attaches a cart-action notification region
 * to the first card; the empty template still consumes a sibling slot in WP's
 * block-gap rule (`> * + *`), pushing the image down by one block-gap.
 *
 * `display: none` alone isn't enough — the element stays in the sibling chain.
 * Pair with `+ *` margin-block-start: 0 to neutralize the layout gap.
 */
.wc-block-product .wc-block-components-notices {
	display: none !important;
}
.wc-block-product .wc-block-components-notices:has(.is-success),
.wc-block-product .wc-block-components-notices:has(.is-error),
.wc-block-product .wc-block-components-notices:has(.is-info),
.wc-block-product .wc-block-components-notices:has(.is-warning) {
	display: block !important;
}
.wc-block-product .wc-block-components-notices + * {
	margin-block-start: 0 !important;
}

/*
 * Reserve a two-line title height on every product card so the button anchors
 * to the same Y across cards — cards with 1-line titles otherwise position
 * the button HIGHER than cards with 2-line titles in the same equalized row.
 *
 * Combined with flex-column + margin-top:auto on the button as a backstop
 * for titles that wrap to 3+ lines.
 */
.wc-block-product h3.wp-block-post-title {
	min-height: 2.7em;
	display: flex;
	align-items: flex-start;
}
.wc-block-product > .wp-block-group {
	display: flex !important;
	flex-direction: column !important;
}
.wc-block-product > .wp-block-group > .wp-block-button {
	margin-top: auto !important;
	margin-block-start: auto !important;
}

/* =============================================================================
 * Class collision: .has-border-color used as both a marker AND a utility
 *
 * WP's block-borders support adds `.has-border-color` as a marker class
 * whenever a block has a custom border color (paired with `border-style:solid`).
 *
 * Independently, WP's palette-to-utility CSS pipeline emits one color rule per
 * palette slug: `.has-<slug>-color { color: var(--wp--preset--color--<slug>) !important; }`.
 * Because the chassis palette includes a slug literally named `border`, the
 * utility class is ALSO `.has-border-color` — and it forces `color:` to the
 * border hex (#E5E7EB) on every descendant text element.
 *
 * Net effect: any block using a palette border-color (pricing tier cards, FAQ
 * <details>, bordered group blocks) renders its inner text in near-white,
 * making the content invisible against light backgrounds.
 *
 * Fix: cancel the utility side of the collision and restore inherited color.
 * Exclude blocks that ALSO carry `.has-text-color` (deliberate text-color
 * choice via the Editor color picker) — those should keep their intent.
 *
 * Long-term: consider renaming the slug `border` to something that can't
 * collide with WP's marker class names (e.g., `outline`). Documented in
 * the platform guide's gotchas appendix.
 * ============================================================================= */
.has-border-color:not(.has-text-color) {
	color: inherit !important;
}
