/*
 * BuenTheme — sections.css
 * Secciones inyectadas por el gestor. Pueden aparecer en cualquier plantilla.
 * Extraído de style.css en 2.6.148. No se borró ninguna regla.
 */

/* ==========================================================================
   Secciones (gestor de secciones — placements)
   ========================================================================== */
/*
 * Las secciones se inyectan a menudo FUERA de main constrained (p. ej. after_header
 * o antes/después del bloque main). Sin layout constrained, el contenido iba a
 * 100% del viewport y no respetaba el content-size del tema.
 *
 * Solución: el wrapper .buentheme-section lleva is-layout-constrained (PHP) y aquí
 * reforzamos max-width de hijos + padding de borde como el resto de plantillas.
 */
.buentheme-section {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
	clear: both;
	padding: 0;
}

/* El wrapper no es un Grupo de WP: no heredar gap/padding de .wp-block-group. */
.buentheme-section.is-layout-constrained {
	gap: 0;
}

/* Hijos directos (no full/wide/float): acotados al content-size del tema */
.buentheme-section.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull):not(.alignwide)),
.buentheme-section > :where(
	.buentheme-row:not(.alignfull):not(.alignwide):not(.has-custom-content-width),
	.buentheme-row-container:not(.alignfull):not(.alignwide):not(.has-custom-content-width),
	.wp-block-group:not(.alignfull):not(.alignwide),
	.wp-block-columns:not(.alignfull):not(.alignwide),
	.wp-block-heading:not(.alignfull):not(.alignwide),
	.wp-block-paragraph:not(.alignfull),
	.wp-block-image:not(.alignfull):not(.alignwide)
) {
	max-width: var(--wp--style--global--content-size, 1290px) !important;
	width: 100% !important;
	margin-left: auto !important;
	margin-right: auto !important;
	box-sizing: border-box !important;
}

/*
 * Padding lateral de secciones inyectadas:
 * - Páginas normales → content_padding (--buentheme-global-padding).
 * - Contextos WC → template_padding (--buentheme-template-edge-padding).
 * Antes usaba siempre template_padding y la home heredaba el aire de WC/pie.
 */
.buentheme-section.is-layout-constrained > :where(:not(.alignfull)) {
	padding-left: var(--buentheme-global-padding, 0px);
	padding-right: var(--buentheme-global-padding, 0px);
	box-sizing: border-box;
}

body.buentheme-wc-catalog .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.woocommerce-shop .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.post-type-archive-product .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.tax-product_cat .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.tax-product_tag .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.tax-product_brand .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.single-product .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.buentheme-wc-single-product .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.woocommerce-cart .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.woocommerce-checkout .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.woocommerce-order-received .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.search-results.woocommerce .buentheme-section.is-layout-constrained > :where(:not(.alignfull)) {
	padding-left: var(--buentheme-template-edge-padding, 15px);
	padding-right: var(--buentheme-template-edge-padding, 15px);
}

/*
 * Dentro de un <main> que YA tiene padding (páginas, ficha, carrito, checkout,
 * thank you): no volver a padear los hijos. El catálogo deja main a 0 y
 * las secciones siguen usando template_padding (reglas de arriba).
 */
body:not(.buentheme-layout-full_width):not(.buentheme-wc-catalog):not(.woocommerce-shop):not(.post-type-archive-product):not(.tax-product_cat):not(.tax-product_tag):not(.tax-product_brand) main .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.single-product main .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.buentheme-wc-single-product main .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.woocommerce-cart main .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.woocommerce-checkout main .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
body.woocommerce-order-received main .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
main.buentheme-single-product-main .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
main.buentheme-wc-cart-main .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
main.buentheme-wc-checkout-main .buentheme-section.is-layout-constrained > :where(:not(.alignfull)),
main.buentheme-wc-order-confirmation-main .buentheme-section.is-layout-constrained > :where(:not(.alignfull)) {
	padding-left: 0;
	padding-right: 0;
}

/* alignwide → wide-size del tema */
.buentheme-section.is-layout-constrained > .alignwide,
.buentheme-section > .alignwide {
	max-width: var(--wp--style--global--wide-size, var(--wp--style--global--content-size, 1290px)) !important;
	width: 100% !important;
	margin-left: auto !important;
	margin-right: auto !important;
	box-sizing: border-box !important;
}

/* alignfull / filas full-bleed: edge-to-edge (el INNER con has-inherit-width se acota solo) */
.buentheme-section.is-layout-constrained > .alignfull,
.buentheme-section > .alignfull,
.buentheme-section > .buentheme-row.alignfull,
.buentheme-section > .buentheme-row-container.alignfull {
	max-width: 100% !important;
	width: 100% !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
	padding-left: 0;
	padding-right: 0;
}

/* Diseño estrecho del dashboard */
body.buentheme-layout-narrow .buentheme-section.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull):not(.alignwide)) {
	max-width: var(--buentheme-narrow-width, 720px) !important;
}

/* Filas con «Heredar ancho del tema» dentro de la sección */
.buentheme-section .buentheme-row-inner-wrapper.has-inherit-width,
.buentheme-section .buentheme-row__inner.has-inherit-width {
	max-width: var(--wp--style--global--content-size, 1290px) !important;
	width: 100% !important;
	margin-left: auto !important;
	margin-right: auto !important;
	box-sizing: border-box !important;
}

body.buentheme-layout-narrow .buentheme-section .buentheme-row-inner-wrapper.has-inherit-width,
body.buentheme-layout-narrow .buentheme-section .buentheme-row__inner.has-inherit-width {
	max-width: var(--buentheme-narrow-width, 720px) !important;
}

.buentheme-section > .buentheme-row,
.buentheme-section > .buentheme-row-container {
	width: 100%;
}

/* Secciones de reemplazo WC: sin márgenes fantasma del bloque original */
.buentheme-section--replace {
	margin-top: 0;
	margin-bottom: 0;
}
