/* Shared by the frontend and Gutenberg. Legacy template tokens stay unchanged. */
:root,
.editor-styles-wrapper {
	--section-standard-width: 1280px;
	--section-narrow-width: 720px;
	--section-wide-width: 1440px;
	--section-gutter: clamp(16px, 4vw, 32px);
	--reading-width: 720px;
	--section-space-xsmall: clamp(12px, calc(9.6px + 0.5vw), 16px);
	--section-space-small: clamp(24px, calc(19.2px + 1vw), 32px);
	--section-space-medium: clamp(40px, calc(25.6px + 3vw), 64px);
	--section-space-large: clamp(56px, calc(32px + 5vw), 96px);
	--section-space-xlarge: clamp(72px, calc(38.4px + 7vw), 128px);
}

.bs-section,
.bs-section-editor {
	--section-limit: var(--section-standard-width);
	--section-top: var(--section-space-medium);
	--section-bottom: var(--section-space-medium);
	--content-width: var(--reading-width);
	--site-gutter: var(--section-gutter);
	box-sizing: border-box;
	min-width: 0;
}
.bs-section *,
.bs-section *::before,
.bs-section *::after {
	box-sizing: border-box;
}

.bs-section--narrow { --section-limit: var(--section-narrow-width); }
.bs-section--wide { --section-limit: var(--section-wide-width); }
.bs-section--full { --section-limit: 100%; }
.bs-space-top--none { --section-top: 0px; }
.bs-space-bottom--none { --section-bottom: 0px; }
.bs-space-top--xsmall { --section-top: var(--section-space-xsmall); }
.bs-space-top--small { --section-top: var(--section-space-small); }
.bs-space-top--medium { --section-top: var(--section-space-medium); }
.bs-space-top--large { --section-top: var(--section-space-large); }
.bs-space-top--xlarge { --section-top: var(--section-space-xlarge); }
.bs-space-bottom--xsmall { --section-bottom: var(--section-space-xsmall); }
.bs-space-bottom--small { --section-bottom: var(--section-space-small); }
.bs-space-bottom--medium { --section-bottom: var(--section-space-medium); }
.bs-space-bottom--large { --section-bottom: var(--section-space-large); }
.bs-space-bottom--xlarge { --section-bottom: var(--section-space-xlarge); }

/* The section paints its background; its child owns the content width. */
.bs-section.bs-section {
	width: 100%;
	max-width: none;
	margin-inline: 0;
	padding-inline: var(--section-gutter);
}
.bs-section.bs-section { padding-top: var(--section-top); }
.bs-section.bs-section { padding-bottom: var(--section-bottom); }


.bs-section.bs-section > [class$="__inner"] {
	width: min(100%, var(--section-limit));
	max-width: none;
	margin-inline: auto;
}
.bs-section.block-headline--width-content .block-headline__heading {
	max-width: var(--reading-width);
	margin-inline: auto;
}
.bs-section.block-hero--centered .block-hero__content {
	max-width: var(--reading-width);
	margin-inline: auto;
}

/* Full-width content hosts eliminate viewport-based breakout calculations. */
.entry:has(> .entry__content) {
	width: 100%;
}
.entry > .entry__header,
.entry > .entry__featured-image {
	width: min(calc(100% - 2 * var(--section-gutter)), var(--section-standard-width));
	margin-inline: auto;
}
.entry__content > :not(.bs-section) {
	width: min(calc(100% - 2 * var(--section-gutter)), var(--section-standard-width));
	margin-inline: auto;
}
.entry__content > .alignwide:not(.bs-section) {
	width: min(calc(100% - 2 * var(--section-gutter)), var(--section-wide-width));
	margin-inline: auto;
}
.entry__content > .alignfull:not(.bs-section) {
	width: calc(100% - 2 * var(--section-gutter));
	margin-inline: auto;
}
.entry__content > .bs-section.bs-section {
	width: 100%;
	margin-inline: 0;
}
.entry__content > .bs-section + .bs-section { margin-top: 0; }

/* Groups expose a content boundary while retaining their own background. */
.wp-block-group.bs-section {
	--wp--style--global--content-size: var(--section-limit);
	--wp--style--global--wide-size: var(--section-limit);
	padding-inline: max(var(--section-gutter), calc((100% - var(--section-limit)) / 2));
}
.wp-block-group.bs-section > :not(.bs-section),
.wp-block-group.bs-section > .wp-block-group__inner-container > * {
	max-width: min(100%, var(--section-limit));
	margin-inline: auto;
}
.wp-block-group.bs-section > .bs-section,
.wp-block-group.bs-section > .wp-block-group__inner-container > .bs-section,
.wp-block-group.bs-section > .bs-section-editor {
	width: min(100%, var(--section-limit));
	max-width: min(100%, var(--section-limit));
	margin-inline: auto;
	/* The parent already supplies the viewport gutter. */
	--section-gutter: 0px;
}

/* ACF's wrapper is outside the rendered section in the editor. */
.wp-block-group.bs-section > .bs-section-editor .bs-section {
	--section-gutter: 0px;
}

/* Carousel content stays within the selected boundary, with room for peeking. */
.bs-section.bs-section.block-services-carousel,
.bs-section.bs-section.block-testimonial--carousel {
	padding-inline: 0;
}
.bs-section.block-services-carousel > .block-services-carousel__inner {
	width: 100%;
}
.bs-section.block-services-carousel .block-services-carousel__track {
	padding-inline: max(var(--section-gutter), calc((100% - var(--section-limit)) / 2));
	scroll-padding-inline: max(var(--section-gutter), calc((100% - var(--section-limit)) / 2));
}
.bs-section.block-services-carousel .block-services-carousel__header,
.bs-section.block-testimonial--carousel .block-testimonial__header {
	width: min(calc(100% - 2 * var(--section-gutter)), var(--section-limit));
	max-width: none;
	margin-inline: auto;
}
.bs-section.block-services-carousel:not(.block-services-carousel--header-split) .block-services-carousel__header,
.bs-section.block-testimonial:not(.block-testimonial--header-split) .block-testimonial__header {
	max-width: var(--reading-width);
}
.bs-section.bs-section.block-testimonial--carousel {
	--testimonial-carousel-inset: max(var(--section-gutter), calc((100% - var(--section-limit)) / 2));
	--testimonial-carousel-slide-width: min(calc(100% - 2 * var(--section-gutter)), var(--section-limit));
}
.bs-section.block-testimonial--carousel .block-testimonial__carousel-slide {
	/* The track's content box has already had its gutters removed. */
	--testimonial-carousel-slide-width: 100%;
}
.bs-section.bs-section .block-portfolio-showcase__header {
	width: 100%;
	max-width: var(--reading-width);
}
@media (max-width: 760px) {
	.bs-section.bs-section.block-portfolio-showcase { padding-inline: 0; }
	.bs-section.block-portfolio-showcase > .block-portfolio-showcase__inner { width: 100%; }
	.bs-section.bs-section .block-portfolio-showcase__header {
		width: min(calc(100% - 2 * var(--section-gutter)), var(--section-limit));
	}
	.bs-section .block-portfolio-showcase__cards {
		--portfolio-mobile-card-width: min(82%, 23.4375rem);
		padding-inline: max(var(--section-gutter), calc((100% - var(--section-limit)) / 2));
		scroll-padding-inline: max(var(--section-gutter), calc((100% - var(--section-limit)) / 2));
	}
	.bs-section .block-portfolio-showcase__footer { padding-inline: var(--section-gutter); }
}

/* ACF previews have their own section element; the editor wrapper is neutral. */
.editor-styles-wrapper .wp-block[data-type^="acf/build-starter-"] {
	/* Native block support may also style the editor shell; the preview owns padding. */
	padding-block: 0 !important;
}
.editor-styles-wrapper .wp-block.bs-section-editor,
.editor-styles-wrapper .wp-block[data-type^="acf/build-starter-"] {
	width: 100%;
	max-width: none;
	margin-inline: 0;
}
.editor-styles-wrapper .bs-section-editor > .bs-section,
.editor-styles-wrapper .acf-block-preview > .bs-section {
	width: 100%;
	max-width: none;
}

/* Editor-specific legacy carousel rules must not substitute viewport geometry. */
.editor-styles-wrapper .bs-section.bs-section.block-testimonial--carousel {
	--testimonial-carousel-inset: max(var(--section-gutter), calc((100% - var(--section-limit)) / 2));
	--testimonial-carousel-slide-width: 100%;
}
.editor-styles-wrapper .bs-section.block-services-carousel .block-services-carousel__track {
	padding-inline: max(var(--section-gutter), calc((100% - var(--section-limit)) / 2));
	scroll-padding-inline: max(var(--section-gutter), calc((100% - var(--section-limit)) / 2));
}
.editor-styles-wrapper .bs-section .block-services-carousel__header,
.editor-styles-wrapper .bs-section .block-testimonial__header {
	margin-inline: auto;
}
.editor-styles-wrapper .bs-section .block-portfolio-showcase__header {
	max-width: var(--reading-width);
}
