/* Shared document and block-editor content boundaries. Local scrolling for wide tables and code; article decks expand naturally. */

/* Native block alignments are allowed within the document, never across the sidebar. */
:is(.hsdeck-entry-content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) {
	min-inline-size: 0;
	max-inline-size: 100%;
}

:is(.hsdeck-entry-content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) > * {
	box-sizing: border-box;
	min-inline-size: 0;
	max-inline-size: 100%;
}

.hsdeck-entry-content > * {
	max-inline-size: 100% !important;
}

:is(.editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) > :where(.wp-block, [data-block]):not(.hsdeck-document-shell) {
	max-inline-size: min(100%, var(--hsdeck-content-width));
}

:is(.hsdeck-entry-content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) :where(.alignwide, .alignfull):not(:where(.hscard-deck-list *, .hscard-deck-layout *, .hscard-card-surface *)) {
	box-sizing: border-box;
	min-inline-size: 0;
	max-inline-size: 100% !important;
	margin-inline: 0 !important;
}

/* Editor and frontend use the same width, including aligned blocks. */
:is(.editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) > :where(.alignwide, .alignfull):not(.hsdeck-document-shell) {
	max-inline-size: min(100%, var(--hsdeck-content-width)) !important;
	margin-inline: auto !important;
}

/* Contain authored nested layouts, including raw HTML and core Columns/Group blocks. */
:is(.hsdeck-entry-content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) :where(div, section, article, figure, aside, header, footer, blockquote, .wp-block-column, .wp-block-media-text__content, .is-layout-flex > *, .is-layout-grid > *):not(:where(.hscard-deck-list *, .hscard-deck-layout *, .hscard-card-surface *, .hsdeck-footnote-popover *)) {
	box-sizing: border-box;
	min-inline-size: 0;
	max-inline-size: 100%;
}

/* Keep authored media within its own parent; preserve intrinsic aspect ratios. */
:is(.hsdeck-entry-content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) :where(img, video, iframe, object, embed, canvas):not(:where(.hscard-deck-list *, .hscard-deck-layout *, .hscard-card-surface *)) {
	max-inline-size: 100%;
}

/* If content is inherently wider, scroll only the relevant component. */
:is(.hsdeck-entry-content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) :where(.wp-block-table, .hsdeck-table-scroll, pre) {
	box-sizing: border-box;
	min-inline-size: 0;
	max-inline-size: 100%;
	overflow-x: auto;
}

:is(.hsdeck-entry-content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) :where(table):not(:where(.wp-block-table table, .hsdeck-table-scroll table, .hscard-deck-list *, .hscard-deck-layout *, .hscard-card-surface *)) {
	display: block;
	max-inline-size: 100%;
	overflow-x: auto;
}

:is(.hsdeck-entry-content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) :where(p, li, td, th, figcaption, h1, h2, h3, h4, h5, h6):not(:where(.hscard-deck-list *, .hscard-deck-layout *, .hscard-card-surface *)) {
	overflow-wrap: anywhere;
}

/* Form controls are replaced elements with intrinsic widths. Let them shrink within authored content. */
:is(.hsdeck-entry-content, .editor-styles-wrapper .is-root-container, .editor-styles-wrapper.is-root-container) :where(input:not([type="checkbox"]):not([type="radio"]), textarea, select, button, fieldset, form, audio, svg):not(:where(.hscard-deck-list *, .hscard-deck-layout *, .hscard-card-surface *, .hsdeck-footnote-popover *)) {
	box-sizing: border-box;
	min-inline-size: 0;
	max-inline-size: 100%;
}

/* Article decks are document content, not nested scrolling panels.
   Limit the override to deck layout wrappers, not card artwork or the builder. */
.hsdeck-entry-content :is(.hscard-deck-list, .hscard-deck-list--v2, .hscard-deck-layout, .hscard-deck-layout--v2, .hscard-deck-cards) {
	min-inline-size: 0;
	max-inline-size: 100%;
	block-size: auto !important;
	max-block-size: none !important;
	overflow: visible !important;
	overscroll-behavior: auto;
}
