/**
 * block-sections.css — full-bleed section background, boxed content
 *
 * Pattern: any chn/* block can opt-in to a full-width section background
 * (color or image) while its content stays inside the 1280px container.
 * When neither backgroundColor nor backgroundImage is set, the block keeps
 * its current boxed-only layout (the wrapper is not emitted at all).
 *
 * The wrapper is `<section class="chn-block-section ...">` with an inner
 * `<div class="chn-block-section__inner chn-container">` carrying the
 * existing block-specific markup.
 *
 * Phase B3 (full-bleed section background pattern across all chn/* blocks).
 *
 * @package chn-theme
 */

/* Outer full-bleed wrapper. We rely on layout.css's
 * `body.chn-page main.site-main { max-width: none }` unwind so the section
 * spans 100% of the viewport on page-template-* pages. For the blocks.php
 * host template a separate clamp-escape rule lives further down — see the
 * `page-template-blocks` block at the bottom of this file. */
.chn-block-section {
	position: relative;
	width: 100%;
	box-sizing: border-box;
}

.chn-block-section--has-bg-image {
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}

/* Dark scrim used when an image background sits behind light text. Mirrors
 * the page-hero scrim so the visual language stays consistent. */
.chn-block-section__overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient( 180deg, rgba( 11, 59, 148, .65 ) 0%, rgba( 11, 59, 148, .85 ) 100% );
	pointer-events: none;
	z-index: 1;
}

/* Inner container — boxed at 1280px (matches .chn-container). The chn-container
 * class is also applied at render so existing container CSS keeps working.
 * Phase B4 Stage 0.2: consumes the same `--chn-container-max` + `--chn-container-pad`
 * vars as `.chn-container` and `.chn-section__inner` so every boxed surface
 * shares one source of truth. */
.chn-block-section__inner {
	position: relative;
	z-index: 2;
	max-width: var( --chn-container-max, 1280px );
	margin-inline: auto;
	padding-inline: var( --chn-container-pad, clamp( 20px, 4vw, 48px ) );
	box-sizing: border-box;
}

/* Padding scale — maps to the existing --chn-space-* token ladder. */
.chn-block-section--pt-none { padding-top: 0; }
.chn-block-section--pt-sm   { padding-top: var( --chn-space-4, 16px ); }
.chn-block-section--pt-md   { padding-top: var( --chn-space-6, 32px ); }
.chn-block-section--pt-lg   { padding-top: var( --chn-space-7, 48px ); }
.chn-block-section--pt-xl   { padding-top: var( --chn-space-8, 64px ); }
.chn-block-section--pb-none { padding-bottom: 0; }
.chn-block-section--pb-sm   { padding-bottom: var( --chn-space-4, 16px ); }
.chn-block-section--pb-md   { padding-bottom: var( --chn-space-6, 32px ); }
.chn-block-section--pb-lg   { padding-bottom: var( --chn-space-7, 48px ); }
.chn-block-section--pb-xl   { padding-bottom: var( --chn-space-8, 64px ); }

/* Inverse text — applied automatically when the background is one of the
 * dark navy slugs (primary, primary-700, text). Links inside the section
 * pick up a subtle underline for affordance unless they are .chn-button. */
.chn-block-section--inverse,
.chn-block-section--inverse :where( h1, h2, h3, h4, h5, h6, p, li, dt, dd, span, strong, em, blockquote ) {
	color: #fff;
}
.chn-block-section--inverse a:not( .chn-button ) {
	color: #fff;
	text-decoration: underline;
}
.chn-block-section--inverse a:not( .chn-button ):hover,
.chn-block-section--inverse a:not( .chn-button ):focus {
	color: var( --chn-color-accent-tint, #ffd8b8 );
}

/* Preset background colours — paired with theme.json palette slugs. We emit
 * `has-<slug>-background-color` in the render so WP's own preset CSS would
 * also resolve, but we ship explicit fallbacks here so the section paints
 * even when theme.json's auto-emitted styles are not present. */
.chn-block-section.has-primary-background-color      { background-color: var( --chn-color-primary, #0b3b94 ); }
.chn-block-section.has-primary-700-background-color  { background-color: var( --chn-color-primary-700, #082c6f ); }
.chn-block-section.has-accent-background-color       { background-color: var( --chn-color-accent, #f3802d ); }
.chn-block-section.has-accent-tint-background-color  { background-color: var( --chn-color-accent-tint, #ffd8b8 ); }
.chn-block-section.has-paper-background-color        { background-color: var( --chn-color-paper, #f5efe4 ); }
.chn-block-section.has-paper-deep-background-color   { background-color: var( --chn-color-paper-deep, #efe7d3 ); }
.chn-block-section.has-surface-background-color      { background-color: var( --chn-color-surface, #ffffff ); }
.chn-block-section.has-surface-alt-background-color  { background-color: var( --chn-color-surface-alt, #f8f9fb ); }

/* When the wrapper is emitted, neutralise the block-specific outer padding
 * that the legacy partials added at their own top level — the wrapper owns
 * vertical spacing now. Each block keeps inner element gaps via its own
 * style.css; only the outer block margin is unwound. */
.chn-block-section > .chn-block-section__inner > .chn-section-heading,
.chn-block-section > .chn-block-section__inner > .chn-checklist,
.chn-block-section > .chn-block-section__inner > .chn-comparison-table,
.chn-block-section > .chn-block-section__inner > .chn-step-tiles,
.chn-block-section > .chn-block-section__inner > .chn-stats-strip,
.chn-block-section > .chn-block-section__inner > .chn-pricing-grid,
.chn-block-section > .chn-block-section__inner > .chn-pricing-tier,
.chn-block-section > .chn-block-section__inner > .chn-icon-list,
.chn-block-section > .chn-block-section__inner > .chn-quote-card,
.chn-block-section > .chn-block-section__inner > .chn-feature-grid,
.chn-block-section > .chn-block-section__inner > .chn-related-reading,
.chn-block-section > .chn-block-section__inner > .chn-media-text,
.chn-block-section > .chn-block-section__inner > .chn-cta-band {
	margin-block: 0;
}
/* cta-band already paints its own background — when wrapped in a section the
 * inner band should not double-paint. The section bg wins, the inner band
 * goes transparent. */
.chn-block-section > .chn-block-section__inner > .chn-cta-band {
	background: transparent;
	padding-block: 0;
}

/* ---------------------------------------------------------------------------
 * Blocks.php host template — clamp escape
 * ---------------------------------------------------------------------------
 * The Phase B1 page-template `blocks.php` wraps content in
 * `<main class="site-main chn-marketing chn-marketing--blocks">`. Hello-
 * Elementor's CSS clamps `.site-main` to 1140px on its parent themes. The
 * theme already ships an unwind (layout.css `body.chn-page main.site-main
 * { max-width: none }`) but the page-template-blocks slug needs a belt-and-
 * braces escape so the full-bleed wrapper resolves correctly even when a
 * parent rule re-introduces a max-width.
 *
 * We use the 100vw / margin-left:-50vw escape trick — same approach F-CRIT-009
 * applied to archive pages — scoped strictly to the blocks.php template so
 * other pages are unaffected.
 *
 * Phase B3 selector correction: chn/page-hero + chn/cta-band render their
 * <section> with `wp-block-chn-*` applied DIRECTLY (via get_block_wrapper_-
 * attributes) — there is no outer wrapper div. The original `> .chn-page-hero`
 * descendant selectors never matched. We now target the element itself. */
body.page-template-blocks .chn-block-section,
body.page-template-blocks .chn-page-hero.wp-block-chn-page-hero,
body.page-template-blocks .chn-cta-band.wp-block-chn-cta-band,
body.page-template-blocks .wp-block-chn-page-hero,
body.page-template-blocks .wp-block-chn-cta-band {
	width: 100vw;
	max-width: 100vw;
	position: relative;
	left: 50%;
	right: 50%;
	margin-left: -50vw;
	margin-right: -50vw;
	box-sizing: border-box;
}
/* Prevent horizontal overflow caused by the 100vw escape on bodies that
 * include scrollbars — the 100vw trick reserves space for the scrollbar.
 * Clipping at body level keeps the page from horizontal-scrolling. */
body.page-template-blocks { overflow-x: hidden; }
/* Inner content still constrained at 1280px and gutter-padded — the inner
 * div carries .chn-container so the existing container CSS resolves. */
body.page-template-blocks .chn-block-section__inner {
	max-width: var( --chn-container, 1280px );
}

/* When a block is NOT wrapped (no bg, no image) on the blocks.php template,
 * keep its native boxed presentation. We do nothing here — the absence of
 * the `.chn-block-section` wrapper means the block renders inside .site-main
 * which is already cleared of the 1140px clamp by layout.css. */
