/* WOA Nodes — structural CSS (proof slice).
   Tiny + shared: structure only, every styleable value is a var() with a
   default so the walk overrides ONLY what a node sets. Depth adds no CSS. */

/* Height comes via the --woa-h custom prop (not a direct inline height) so a
   mobile @media rule can release it; default auto = unchanged. The custom props
   are RESET to initial here so they don't INHERIT to descendant nodes — otherwise a
   floating card inside a fixed-height panel would pick up the panel's --woa-h and
   render full-height. An element that sets one inline still wins (inline > rule). */
.woa-node { --woa-h: initial; --woa-basis: initial; --woa-content-gap: initial; position: relative; box-sizing: border-box; height: var(--woa-h, auto); }

/* leaf media: fill the cell and cover-crop by default */
.woa-node > img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* TOP-LEVEL WIDE ALIGNMENT. The root node is rendered via pre_render_block, so it is
   NOT a direct child of a constrained-layout container — WP's `.is-layout-constrained
   > .alignwide { max-width }` rule never matches it, and a Wide block would otherwise
   span the full width. Self-constrain it to the theme's wide size, keeping the root
   gutter on narrow viewports (same min() band the flow lane uses). `.alignfull` stays
   full via the theme's global rule.
   NOTE: the two min() operands are lifted into custom props so the min() literal carries
   only bare var()s — no var() FALLBACK comma inside min(). LiteSpeed's CSS minifier
   miscounts parens when a var(--x, fallback) sits as a min()/clamp() argument and corrupts
   the value to invalid `min(...) calc(...)` (drops the whole max-width → full-bleed). Keeping
   the fallbacks in standalone declarations sidesteps it. Don't re-inline these into min(). */
.wp-block-woa-node-root.alignwide {
	--woa-wide:  var(--wp--style--global--wide-size, 1340px);
	--woa-avail: calc(100% - var(--wp--style--root--padding-left, 0px) - var(--wp--style--root--padding-right, 0px));
	max-width: min( var(--woa-wide), var(--woa-avail) );
	margin-inline: auto;
}

/* Standard outer space — the theme's has-top-space / has-bottom-space parity: one
   consistent design-system value (spacing step 60), toggled per edge; default none. */
.woa-space-top    { margin-top:    var(--wp--preset--spacing--60, clamp(2.25rem, 6vw, 4rem)); }
.woa-space-bottom { margin-bottom: var(--wp--preset--spacing--60, clamp(2.25rem, 6vw, 4rem)); }

/* BACKGROUND MEDIA: a node that owns an image AND has content/children (class set by
   the engine) lays the image as a full-bleed layer BEHIND, so the content/flow sits
   on top — a full-width image with text on the side, no floating card needed. The
   overlay lane keeps its own absolute positioning + z, so it's excluded here. */
.woa-bg > img { position: absolute; inset: 0; z-index: 0; }
.woa-bg > :not(img):not(.woa-overlay) { position: relative; z-index: 1; }

/* ---- layout registry: the flow lane ---- */
/* Content width via --woa-cw (default none): caps + centres the lane; releasable
   on mobile. margin-inline:auto is inert at full width. */
.woa-flow { --woa-cw: initial; --woa-gap: initial; display: flex; gap: var(--woa-gap, 0); height: 100%; max-width: var(--woa-cw, none); margin-inline: auto; }
.woa-flow--row   { flex-direction: row; }
.woa-flow--stack { flex-direction: column; }

/* MAIN-AXIS division — set by the AXIS, independent of cropping:
   a ROW always splits its width into equal columns; a STACK shares its height
   equally only when banded (a determinate height to divide), otherwise each child
   takes its natural size (a plain stack). `min-height:0` lets a banded stack child
   shrink below its image's intrinsic height (else the panel Height is ignored and
   the stack overflows). A set Width inline-overrides the equal share. */
.woa-flow--row                     > .woa-node { flex: 1 1 0;   min-width: 0; min-height: 0; }
.woa-flow--stack.woa-flow--banded  > .woa-node { flex: 1 1 0;   min-width: 0; min-height: 0; }
.woa-flow--stack.woa-flow--natural > .woa-node { flex: 0 0 auto; min-width: 0; }

/* A BANDED row has a determinate height (the panel Height), and flex STRETCHES each
   child to fill it. Make the child height explicit so a child image's `height:100%`
   resolves against the band. AND re-assert the image fill at higher specificity: on a
   WooCommerce page (e.g. ACE Shop) `.woocommerce img { height:auto }` ties `.woa-node
   > img`'s specificity and wins by source order, leaving the image at its natural
   aspect height — which overflows a shorter panel. (Natural rows keep auto via
   `.woa-flow--natural > .woa-node > img`.) */
.woa-flow--row.woa-flow--banded > .woa-node { height: 100%; }
.woa-flow--row.woa-flow--banded > .woa-node.woa-p-image > img { height: 100%; }

/* CROSS-AXIS fit — images cover-crop ONLY in a banded lane (a determinate height to
   fill); a natural lane keeps each image's aspect ratio so it scales with its column
   width and never clips. This is the old hero blocks' Auto-height behaviour: a row
   with Height = Auto shows full, fluid images instead of an equal cropped band. */
.woa-flow--natural > .woa-node > img { height: auto; }

/* Explicit Width/Height % share (the flex-basis) via --woa-basis. A stylesheet
   rule (not inline) so a mobile @media rule can override the flex when stacking. */
.woa-flow > .woa-node.woa-has-basis { flex: 0 1 var(--woa-basis, auto); }

/* ---- overlay lane: floating cards ---- */
/* position/anchor/offset/z come inline from the walk. A card OWNS its height, but
   as a MIN-height (it still grows with content so text never clips) — so override
   the node's fixed `height:var(--woa-h)` with auto + min-height here. */
.woa-overlay { height: auto; min-height: var(--woa-h, 0); }

/* ---- surface: schema-driven panel (self-owned, token-consuming) ----
   Consumes the THEME's schema TOKENS (--woa-s-* from schemas.css) but paints its
   OWN background / text / buttons, so opacity works WITHOUT depending on — or
   fighting — the theme's legacy `.woa-card-panel` !important applicator. We control
   the Panel markup, so plain specificity + inheritance win; no !important needed.
   --woa-op is reset so a nested surface doesn't inherit a parent's opacity. */
.woa-surface {
	--woa-op: initial;
	background: var(--woa-s-bg, #fff);
	color: var(--woa-s-text, #1a1a1a);
	box-shadow: 0 8px 30px rgba(0,0,0,.18);
}
/* Shadow toggle (default on); off = a flush panel with no drop shadow. */
.woa-surface.woa-no-shadow { box-shadow: none; }
@supports (background: color-mix(in srgb, red, blue)) {
	.woa-surface {
		background: color-mix(in srgb, var(--woa-s-bg, #fff) calc(var(--woa-op, 1) * 100%), transparent);
	}
}
/* Buttons inside a surface take the schema's button tokens (was the theme applicator). */
.woa-surface .wp-block-button__link {
	background-color: var(--woa-s-btn-bg, var(--woa-s-text, #1a1a1a));
	color: var(--woa-s-btn-text, var(--woa-s-bg, #fff));
	border-radius: 0;
}
.woa-surface .wp-block-button__link:hover,
.woa-surface .wp-block-button__link:focus {
	background-color: var(--woa-s-hover, var(--woa-s-text, #1a1a1a));
	color: var(--woa-s-hover-text, var(--woa-s-bg, #fff));
}
/* Headings, paragraphs and inline links take the schema text colour. The theme
   assigns heading typography (and a root text colour) that beats plain inheritance,
   so we set it explicitly — the scoped, !important-free replacement for the old
   schemas.css applicator that no longer matches `woa-surface`. */
.woa-surface :is(h1,h2,h3,h4,h5,h6),
.woa-surface p,
.woa-surface :is(h1,h2,h3,h4,h5,h6) a,
.woa-surface p a {
	color: var(--woa-s-text, #1a1a1a);
}

/* ---- content alignment ----
   A panel governs the alignment of its OWN content — text (inherits) AND buttons
   (flex items, so they need justify-content; plain text-align can't move them). Set
   it on the Panel rather than per block. `-m-` variants override at ≤640 so a panel
   can be left on desktop and centred on mobile (the classic media+text need). */
.woa-ta-left   { text-align: left; }
.woa-ta-center { text-align: center; }
.woa-ta-right  { text-align: right; }
.woa-ta-left   .wp-block-buttons { justify-content: flex-start; }
.woa-ta-center .wp-block-buttons { justify-content: center; }
.woa-ta-right  .wp-block-buttons { justify-content: flex-end; }
@media (max-width: 640px) {
	.woa-ta-m-left   { text-align: left; }
	.woa-ta-m-center { text-align: center; }
	.woa-ta-m-right  { text-align: right; }
	.woa-ta-m-left   .wp-block-buttons { justify-content: flex-start; }
	.woa-ta-m-center .wp-block-buttons { justify-content: center; }
	.woa-ta-m-right  .wp-block-buttons { justify-content: flex-end; }
	/* A child block with its OWN alignment (has-text-align-*) sets text-align
	   explicitly, which beats the panel's inherited value — so the panel's mobile
	   override couldn't move it. Re-assert the panel's mobile intent over any such
	   child (higher specificity, no !important) so "panel governs its content" holds. */
	.woa-ta-m-left   :is(.has-text-align-center, .has-text-align-right) { text-align: left; }
	.woa-ta-m-center :is(.has-text-align-left, .has-text-align-right)   { text-align: center; }
	.woa-ta-m-right  :is(.has-text-align-left, .has-text-align-center)  { text-align: right; }
}

/* ---- mobile text-contrast helper (opt-in class on a heading) ----
   An overlay heading takes its schema's text colour (e.g. schema-5 = base/cream),
   which only reads against the image it floats over. On phones the photo area behind
   it can be light, leaving cream-on-cream. This flips such a heading to the dark brand
   colour on mobile. More specific than the schema applicator (.woa-surface :is(h1..h6),
   0,1,1) so it wins on plain specificity — no !important. */
@media (max-width: 640px) {
	.woa-surface .woa-mobile-text-contrast { color: var(--wp--preset--color--contrast, #694973); }
}

/* ---- content rhythm: our STANDARD vertical spacing for authored content ----
   A node holding authored content (heading / paragraph / buttons) spaces them on a
   designed vertical rhythm grounded in the Gestalt Proximity principle: blocks that
   belong together sit closer. ONE base unit drives it all — the Panel's native Block
   spacing (--woa-content-gap, default = the theme's Small step) — so a single knob
   scales the whole rhythm proportionally. A paragraph directly after a heading is its
   sub-text, so it tucks tighter (½ base by default, tunable via --woa-rhythm-tight).
   Implemented as sibling margins, not flex `gap`: reliable in the editor + normal
   flow + a flex column, and able to carry a ratio a single gap cannot. The blocks'
   own default margins are zeroed so this rhythm is the single source of truth.
   `!important` is the deliberate, scoped exception: per-block Margin set in the
   editor's Dimensions panel lands as an INLINE style, which would otherwise beat
   these class rules and silently break both the rhythm and vertical-align (e.g.
   an inline margin-top on the buttons cancels Split's `margin-top:auto`). The
   rhythm OWNS vertical spacing — the author tunes it via the Block-spacing knob. */
.woa-content { --woa-rhythm: var(--woa-content-gap, var(--wp--preset--spacing--40, 1.5rem)); }
.woa-content > * { margin-top: 0 !important; margin-bottom: 0 !important; }
.woa-content > * + * { margin-top: var(--woa-rhythm) !important; }
.woa-content > :where(h1,h2,h3,h4,h5,h6) + p { margin-top: calc(var(--woa-rhythm) * var(--woa-rhythm-tight, .5)) !important; }

/* ---- vertical alignment: positions the content GROUP against the cell edges ----
   Owns only the outer placement (the inner rhythm above is untouched). The node
   becomes a flex column so the group can sit centred / bottom, or split (first
   block(s) at the top, the last — the buttons — pinned to the bottom). Harmless on a
   media leaf / flow arranger (its image / `.woa-flow` lane fills the height). */
.woa-va-center, .woa-va-bottom, .woa-va-split { display: flex; flex-direction: column; }
.woa-va-center { justify-content: center; }
.woa-va-bottom { justify-content: flex-end; }
.woa-va-split  { justify-content: flex-start; }
.woa-va-split > :last-child { margin-top: auto !important; }
/* Editor only: Gutenberg renders the block appender ("+") as a TRAILING flex sibling,
   so it becomes :last-child and steals Split's margin-top:auto — the content clusters
   at the top and the "+" gets pinned to the bottom. `.block-list-appender` and the
   `[data-block]` attribute exist ONLY in the editor (server HTML has neither), so these
   two rules are inert on the front end: cancel the appender's auto and pin the last
   REAL block instead (the last child carrying a data-block attribute). */
.woa-va-split > .block-list-appender { margin-top: 0 !important; }
.woa-va-split > :nth-last-child(1 of [data-block]:not(.block-list-appender)) { margin-top: auto !important; }

/* ---- font scale ----
   Base hook: scales em-relative text by the surface's --woa-font-scale. */
.woa-node { font-size: calc(1rem * var(--woa-font-scale, 1)); }

/* But the theme sizes headings via the WP preset font-size VARIABLES (h1=massive,
   h3=huge, …) in rem — those ignore a parent font-size, so the base hook alone can't
   scale a heading. So, within any node that carries a font-scale, redefine every
   preset var as (theme base × scale): a heading with a preset size then scales
   proportionally. At scale 1 these equal theme.json, so nothing changes by default.
   Base clamps mirror the theme's fluid presets — keep in sync with theme.json. */
.woa-node[style*="--woa-font-scale"] {
	--wp--preset--font-size--small:    calc(0.875rem * var(--woa-font-scale));
	--wp--preset--font-size--medium:   calc(clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.156), 1rem)     * var(--woa-font-scale));
	--wp--preset--font-size--large:    calc(clamp(1.05rem,  1.05rem  + ((1vw - 0.2rem) * 0.25),  1.25rem)  * var(--woa-font-scale));
	--wp--preset--font-size--x-large:  calc(clamp(1.2rem,   1.2rem   + ((1vw - 0.2rem) * 0.375), 1.5rem)   * var(--woa-font-scale));
	--wp--preset--font-size--xx-large: calc(clamp(1.5rem,   1.5rem   + ((1vw - 0.2rem) * 0.625), 2rem)     * var(--woa-font-scale));
	--wp--preset--font-size--huge:     calc(clamp(1.75rem,  1.75rem  + ((1vw - 0.2rem) * 0.938), 2.5rem)   * var(--woa-font-scale));
	--wp--preset--font-size--gigantic: calc(clamp(2rem,     2rem     + ((1vw - 0.2rem) * 1.875), 3.5rem)   * var(--woa-font-scale));
	--wp--preset--font-size--massive:  calc(clamp(2.5rem,   2.5rem   + ((1vw - 0.2rem) * 3.125), 5rem)     * var(--woa-font-scale));
}

/* ---- mobile heading hierarchy inside surfaces ----
   The theme's fluid clamps compress hard on phones, so a card's h1/h2/h3 end up
   nearly the same (small) size — the flat look vs the old hero blocks. Re-tune the
   preset vars inside a surface on mobile so the hierarchy stays clear and headings
   keep presence. Unconditional (no font-scale needed); composes with the scale remap
   above (which restates these same vars × scale under the same query). */
@media (max-width: 640px) {
	.woa-surface {
		--wp--preset--font-size--massive:  clamp(2rem,    1.6rem + 2.5vw,   3rem);
		--wp--preset--font-size--gigantic: clamp(1.6rem,  1.3rem + 1.875vw, 2.25rem);
		--wp--preset--font-size--huge:     clamp(1.3rem,  1.1rem + 1.25vw,  1.75rem);
		--wp--preset--font-size--xx-large: clamp(1.15rem, 1rem + 0.9375vw,  1.5rem);
		--wp--preset--font-size--x-large:  clamp(1rem,    0.9rem + 0.625vw, 1.25rem);
	}
	.woa-surface[style*="--woa-font-scale"] {
		--wp--preset--font-size--massive:  calc(clamp(2rem,    1.6rem + 2.5vw,   3rem)    * var(--woa-font-scale));
		--wp--preset--font-size--gigantic: calc(clamp(1.6rem,  1.3rem + 1.875vw, 2.25rem) * var(--woa-font-scale));
		--wp--preset--font-size--huge:     calc(clamp(1.3rem,  1.1rem + 1.25vw,  1.75rem) * var(--woa-font-scale));
		--wp--preset--font-size--xx-large: calc(clamp(1.15rem, 1rem + 0.9375vw,  1.5rem)  * var(--woa-font-scale));
		--wp--preset--font-size--x-large:  calc(clamp(1rem,    0.9rem + 0.625vw, 1.25rem) * var(--woa-font-scale));
	}
}

/* ---- entrance animation ----
   The START displacement comes from inline custom props (--woa-ex/--woa-ey);
   the CLASS rule turns them into `translate`, so .is-in (added by the shared
   observer on scroll-in) overrides cleanly WITHOUT !important. `translate`
   composes with the anchor-centring `transform`. */
.woa-enter        { translate: var(--woa-ex, 0) var(--woa-ey, 0); }
.woa-enter--fade  { opacity: 0; }
.woa-enter.is-in       { translate: 0 0; }
.woa-enter--fade.is-in { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
	.woa-enter { translate: 0 0 !important; transition: none !important; }
	.woa-enter--fade { opacity: 1 !important; }
}

/* ---- responsive tiers: mobile ≤640 · tablet 641–1024 · desktop ≥1025 ----
   All the responsive overrides live HERE (one controlled place) rather than in
   per-block CSS. They work because the engine emits the responsive values as
   custom props / classes, never as direct inline declarations a query can't beat. */
/* Per-tier visibility */
@media (max-width: 640px)                            { .woa-hide-mobile  { display: none; } }
@media (min-width: 641px) and (max-width: 1024px)    { .woa-hide-tablet  { display: none; } }
@media (min-width: 1025px)                           { .woa-hide-desktop { display: none; } }

/* Stack threshold: collapse a row to a NATURAL full-width column at or below the
   chosen width — release the fixed panel height, content width, per-item basis and
   cover-band so items sit naturally. "tablet" (≤1024) also covers phones; "mobile"
   (≤640) is phones only. Same ruleset per threshold (the only var is the breakpoint). */
@media (max-width: 1024px) {
	/* aspect-ratio:auto (!important — it's set inline) so a panel with an aspect ratio
	   can GROW to fit its stacked / un-floated content instead of staying its ratio. */
	.woa-stack-tablet { height: auto; aspect-ratio: auto !important; }
	.woa-flow--stack-tablet { flex-direction: column; max-width: none; }
	.woa-flow--stack-tablet.woa-rev-stack { flex-direction: column-reverse; }
	.woa-flow--stack-tablet > .woa-node,
	.woa-flow--stack-tablet > .woa-node.woa-has-basis { flex: 0 0 auto; }
	.woa-flow--stack-tablet > .woa-node > img { height: auto; }
	.woa-unfloat-tablet { position: static !important; inset: auto !important; transform: none !important; translate: none !important; width: auto !important; max-width: none !important; margin-top: var(--woa-unfloat-gap, 1rem) !important; box-shadow: none !important; }
	/* A Split panel pins its last block (buttons) to the bottom via margin-top:auto —
	   which needs SPARE height. Once the panel stacks/un-floats it's content-height, so
	   auto collapses to 0 and eats the gap before the buttons. Pinning is meaningless
	   without spare height → fall back to the normal rhythm gap. */
	.woa-flow--stack-tablet > .woa-va-split > :last-child,
	.woa-stack-tablet.woa-va-split   > :last-child,
	.woa-unfloat-tablet.woa-va-split > :last-child { margin-top: var(--woa-rhythm) !important; }
}
@media (max-width: 640px) {
	.woa-stack-mobile { height: auto; aspect-ratio: auto !important; }
	.woa-flow--stack-mobile { flex-direction: column; max-width: none; }
	.woa-flow--stack-mobile.woa-rev-stack { flex-direction: column-reverse; }
	.woa-flow--stack-mobile > .woa-node,
	.woa-flow--stack-mobile > .woa-node.woa-has-basis { flex: 0 0 auto; }
	.woa-flow--stack-mobile > .woa-node > img { height: auto; }
	.woa-unfloat-mobile { position: static !important; inset: auto !important; transform: none !important; translate: none !important; width: auto !important; max-width: none !important; margin-top: var(--woa-unfloat-gap, 1rem) !important; box-shadow: none !important; }
	/* Split-panel pin collapses once stacked/un-floated (content-height) — restore the
	   rhythm gap before the buttons (see the matching tablet rule above). */
	.woa-flow--stack-mobile > .woa-va-split > :last-child,
	.woa-stack-mobile.woa-va-split   > :last-child,
	.woa-unfloat-mobile.woa-va-split > :last-child { margin-top: var(--woa-rhythm) !important; }
	/* Mobile scale: shrink the whole node proportionally on phones. zoom (not transform)
	   so the layout box scales too and surrounding content reflows; padding/font/gaps/
	   image all scale as one. Default (no class) leaves the node untouched. */
	.woa-mscale { zoom: var(--woa-mscale, 1); }
}

/* Un-float: a floating card drops below the panel content (image) at its tier. The
   reset uses !important ONLY to override the card's INLINE absolute positioning at a
   breakpoint — the one legitimate use; it's our own scoped, intentional override, not
   a cross-component fight. The panel releases its height via .woa-stack-* above. */

/* Flush stacked bands: adjacent full-bleed sections tagged `woa-flush` butt together —
   collapse the post-content block-gap between them so schema-coloured bands read as one
   continuous ribbon. Opt-in per node (untagged roots keep the standard gap); the gap
   only collapses where two flush bands meet, so a flush band still spaces off an
   untagged neighbour. Each band's own top/bottom padding keeps the internal breathing
   room, so content never touches the seam. */
.wp-block-woa-node-root.woa-flush + .wp-block-woa-node-root.woa-flush { margin-block-start: 0; }
