/*
 * BuenTheme — layout-v2.css (2.7.0 · 2.7.1)
 * Un solo sistema de márgenes. Valores: variables --bt-* que imprime inc/layout-v2.php
 * por breakpoint (móvil ≤781 · tablet 782–1079 · escritorio ≥1080).
 *
 *  - <main>: sin padding lateral (salvo WooCommerce y barras laterales); arriba
 *    --bt-content-top y abajo --bt-content-bottom.
 *  - Hijos limitados (título, imagen destacada, contenido, bloques sueltos):
 *    max-width = min(ancho, 100% − 2 × --bt-gutter). Igual en páginas, entradas y plantillas.
 *  - Ancho completo (alignfull, filas a todo el ancho): de borde a borde. Las filas de
 *    BuenTheme Blocks solo usan su propio padding (2.7.1: sin margen lateral automático).
 *  - Margen lateral por página: inc/layout-v2.php redefine --bt-gutter y --bt-limit en main.
 */

/* 1. Main: aire vertical (gana a las clases buentheme-spacing-* viejas; la cabecera
 * transparente en modo «overlay» sigue poniendo padding-top 0 desde menus.css). */
body.bt-layout-v2 .wp-site-blocks > main {
	padding-top: var(--bt-content-top, var(--wp--preset--spacing--50, 3rem)) !important;
	padding-bottom: var(--bt-content-bottom, var(--wp--preset--spacing--50, 3rem)) !important;
}

/* Cabecera transparente en modo «offset»: el contenido empieza debajo de la cabecera. */
body.has-transparent-header.bt-header-offset:not(.buentheme-header-in-flow) .wp-site-blocks > main {
	padding-top: calc(var(--buentheme-header-height, 0px) + var(--bt-content-top, 0px)) !important;
}

/* 2. Hijos limitados. */
:root {
	--bt-limit: min(var(--bt-content-width, 1290px), calc(100% - 2 * var(--bt-gutter, 15px)));
	--bt-limit-wide: min(var(--bt-wide-width, 1290px), calc(100% - 2 * var(--bt-gutter, 15px)));
}

/* Ámbito: plantillas que no son de WooCommerce ni con barra lateral. */
body.bt-layout-v2:not(.buentheme-layout-left_sidebar):not(.buentheme-layout-right_sidebar):not(.single-product):not(.buentheme-wc-single-product):not(.woocommerce-cart):not(.woocommerce-checkout):not(.woocommerce-order-received):not(.buentheme-wc-catalog):not(.woocommerce-shop):not(.post-type-archive-product):not(.tax-product_cat):not(.tax-product_tag):not(.tax-product_brand):not(.search-results.woocommerce) .wp-site-blocks > main:not(.buentheme-wc-catalog-main):not(.buentheme-wc-cart-main):not(.buentheme-wc-checkout-main):not(.buentheme-wc-order-confirmation-main):not(.buentheme-wc-product-search-main):not(.buentheme-single-product-main):not(.buentheme-service-main) > :where(:not(.alignfull):not(.alignwide):not(.alignleft):not(.alignright):not(.bt-fi--layout-full):not(.bt-fi-hero):not(.wp-block-post-content):not(.entry-content):not(.bt-entry-header):not(.buentheme-row):not(.buentheme-row-container):not(.wp-block-buentheme-advanced-grid):not(.buentheme-section):not(.buentheme-dynamic-sidebar):not(.wp-block-template-part):not(script):not(style)),
body.bt-layout-v2:not(.buentheme-layout-left_sidebar):not(.buentheme-layout-right_sidebar):not(.single-product):not(.buentheme-wc-single-product):not(.woocommerce-cart):not(.woocommerce-checkout):not(.woocommerce-order-received):not(.buentheme-wc-catalog):not(.woocommerce-shop):not(.post-type-archive-product):not(.tax-product_cat):not(.tax-product_tag):not(.tax-product_brand):not(.search-results.woocommerce) .wp-site-blocks > main > .bt-entry-header > :where(:not(.alignfull):not(.alignwide):not(.bt-fi--layout-full):not(.bt-fi-hero)),
body.bt-layout-v2:not(.buentheme-layout-left_sidebar):not(.buentheme-layout-right_sidebar):not(.single-product):not(.buentheme-wc-single-product):not(.woocommerce-cart):not(.woocommerce-checkout):not(.woocommerce-order-received):not(.buentheme-wc-catalog):not(.woocommerce-shop):not(.post-type-archive-product):not(.tax-product_cat):not(.tax-product_tag):not(.tax-product_brand):not(.search-results.woocommerce) .wp-site-blocks > main:not(.buentheme-wc-catalog-main):not(.buentheme-wc-cart-main):not(.buentheme-wc-checkout-main):not(.buentheme-wc-order-confirmation-main):not(.buentheme-wc-product-search-main):not(.buentheme-single-product-main):not(.buentheme-service-main) > .wp-block-post-content > :where(:not(.alignfull):not(.alignwide):not(.alignleft):not(.alignright):not(.buentheme-row):not(.buentheme-row-container):not(.wp-block-buentheme-advanced-grid):not(.buentheme-section)) {
	max-width: var(--bt-limit) !important;
	margin-left: auto !important;
	margin-right: auto !important;
	box-sizing: border-box;
}

body.bt-layout-v2:not(.single-product) .wp-site-blocks > main > .wp-block-post-content > .alignwide,
body.bt-layout-v2:not(.single-product) .wp-site-blocks > main > .bt-entry-header > .alignwide {
	max-width: var(--bt-limit-wide) !important;
	margin-left: auto !important;
	margin-right: auto !important;
}

/* Estrecho (lectura): el mismo esquema con --bt-narrow-width. */
body.bt-layout-v2.buentheme-layout-narrow,
body.buentheme-editor-layout-narrow {
	--bt-limit: min(var(--bt-narrow-width, 720px), calc(100% - 2 * var(--bt-gutter, 15px)));
	--bt-limit-wide: var(--bt-limit);
}
body.bt-layout-v2.buentheme-layout-narrow .wp-site-blocks > main {
	max-width: none !important;
}

/* Contenedores de contenido: el ancho lo ponen sus hijos (sin tope ni padding propio). */
body.bt-layout-v2:not(.single-product) .wp-site-blocks > main > .wp-block-post-content,
body.bt-layout-v2 .wp-site-blocks > main > .bt-entry-header {
	max-width: none !important;
	padding-left: 0 !important;
	padding-right: 0 !important;
}

/* Título en «Ancho completo»: limitado como el resto (antes iba a todo el ancho con padding). */
body.bt-layout-v2.buentheme-layout-full_width .wp-site-blocks > main > .wp-block-post-title,
body.bt-layout-v2.buentheme-layout-full_width .wp-site-blocks > main > .bt-entry-header > .wp-block-post-title {
	padding-left: 0 !important;
	padding-right: 0 !important;
}

/* 3. Filas de BuenTheme Blocks: sin padding propio NO reciben margen lateral (decisión 2.7.1:
 * las variables de padding de fila siguen en 0 por defecto, como antes de 2.7.0). Una fila con
 * padding propio no cambia. Solo se acotan (ancho, no padding) las filas del diseño «Limitado». */

/* Filas que no son de ancho completo (diseño Normal): se limitan como cualquier hijo. */
body.bt-layout-v2:not(.buentheme-layout-full_width):not(.buentheme-layout-left_sidebar):not(.buentheme-layout-right_sidebar):not(.single-product) .wp-site-blocks > main > .wp-block-post-content > :is(.buentheme-row, .buentheme-row-container):not(.alignfull):not(.alignwide):not(.has-custom-content-width) {
	max-width: var(--bt-limit) !important;
	margin-left: auto !important;
	margin-right: auto !important;
}

/* 4. Barras laterales: el main es la cuadrícula y lleva el gutter. */
body.bt-layout-v2.buentheme-layout-left_sidebar .wp-site-blocks > main,
body.bt-layout-v2.buentheme-layout-right_sidebar .wp-site-blocks > main {
	padding-left: var(--bt-gutter, 15px) !important;
	padding-right: var(--bt-gutter, 15px) !important;
}

/* ==========================================================================
   Editor: misma regla (las variables llegan por block_editor_settings_all;
   el título se ajusta en editor-layout.css).
   ========================================================================== */
body.buentheme-editor-layout-normal .is-root-container.block-editor-block-list__layout > :where(:not(.alignfull):not(.alignwide):not(.alignleft):not(.alignright)),
body.buentheme-editor-layout-narrow .is-root-container.block-editor-block-list__layout > :where(:not(.alignfull):not(.alignwide):not(.alignleft):not(.alignright)),
body.buentheme-editor-layout-full_width .is-root-container.block-editor-block-list__layout > :where(:not(.alignfull):not(.alignwide):not(.alignleft):not(.alignright):not(.buentheme-row):not(.buentheme-row-container):not(.wp-block-buentheme-advanced-grid)) {
	max-width: var(--bt-limit) !important;
	margin-left: auto !important;
	margin-right: auto !important;
}
body.buentheme-editor-layout-normal .is-root-container.block-editor-block-list__layout > .alignwide,
body.buentheme-editor-layout-narrow .is-root-container.block-editor-block-list__layout > .alignwide,
body.buentheme-editor-layout-full_width .is-root-container.block-editor-block-list__layout > .alignwide {
	max-width: var(--bt-limit-wide) !important;
}
/* Estrecho en el editor: el lienzo no se acota; se acotan sus hijos (como en el sitio). */
body.buentheme-editor-layout-narrow.buentheme-editor-layout-narrow,
body.buentheme-editor-layout-narrow .is-root-container.block-editor-block-list__layout {
	max-width: none !important;
}
/* Margen lateral de esta página en el editor (2.7.1): el JS pone --bt-gutter en línea y
 * la clase bt-page-gutter; --bt-limit se vuelve a calcular aquí (se resuelve donde se declara). */
.editor-styles-wrapper.bt-page-gutter {
	--bt-limit: min(var(--bt-content-width, 1290px), calc(100% - 2 * var(--bt-gutter, 15px)));
	--bt-limit-wide: min(var(--bt-wide-width, 1290px), calc(100% - 2 * var(--bt-gutter, 15px)));
}
.editor-styles-wrapper.bt-page-gutter.buentheme-editor-layout-narrow {
	--bt-limit: min(var(--bt-narrow-width, 720px), calc(100% - 2 * var(--bt-gutter, 15px)));
	--bt-limit-wide: var(--bt-limit);
}

/* Carrito y checkout (2.8.2): los bloques de WooCommerce vienen con alignwide en las plantillas
 * y tomaban el ancho «Amplio». Siguen el ancho de «Contenido», como el título de la página.
 * Solo en la plantilla Limitada (o sin clase de plantilla); «Lectura» conserva sus reglas. */
body.bt-layout-v2:is(.buentheme-layout-normal, :not([class*="buentheme-layout-"])) .wp-site-blocks > main:is(.buentheme-wc-cart-main, .buentheme-wc-checkout-main) > :is(.wp-block-woocommerce-cart, .wp-block-woocommerce-checkout).alignwide {
	max-width: var(--wp--style--global--content-size, 1290px) !important;
}
