/**
 * Legacy ContentBox grid bridge (issue #3645, Defect 2)
 *
 * The cb-prefixing migration renamed ContentBox's grid classes (.row/.column →
 * .cb-row/.cb-column) in content-prefixed.css, but the premade-section template
 * files (templates-simple, templates-quick, templates-animated) and pages saved
 * before the migration still use the unprefixed names. With Bootstrap 5 loaded,
 * `.row > *` forces every child to width:100% / flex-shrink:0 and nothing at all
 * styles `.column`, so multi-column ContentBox sections stack full-width.
 *
 * This bridge restores stock ContentBox grid behavior for rows that are
 * ContentBox rows — identified as `.row` elements whose direct children include
 * a `.column` (Bootstrap rows contain `.col-*` children instead, so they are
 * unaffected). The rules mirror the .cb-row/.cb-column rules generated in
 * content-prefixed.css.
 *
 * Load AFTER Bootstrap and content-prefixed.css, in BOTH the editor iframe
 * (page-editor-blank.blade.php) and the published page (page.blade.php), so the
 * two render identically.
 */

/* Base column behavior (all viewports) — mirrors .cb-column.
   Also covers mixed-flavor markup saved before the source files were made
   consistent: legacy .row parents holding .cb-column children, and .cb-row
   parents holding bare .column children. */
.is-wrapper .row > .column,
.is-wrapper .row > .cb-column,
.is-wrapper .cb-row > .column {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    flex-shrink: 1;
    padding-left: 0;
    padding-right: 0;
    margin-top: 0;
}

/* ContentBox rows: neutralize Bootstrap's wrap + negative margins */
.is-wrapper .row:has(> .column),
.is-wrapper .row:has(> .cb-column) {
    flex-wrap: nowrap;
    margin-left: 0;
    margin-right: 0;
}

/* Every child of a ContentBox-flavored row must be shrinkable, or fixed
   inline widths on sibling cells (e.g. a col-md-* next to a cb-column, as the
   editor's resize tool can produce) overflow the nowrap row. Bootstrap-only
   rows are untouched. */
.is-wrapper .row:has(> .cb-column) > *,
.is-wrapper .row:has(> .column) > * {
    flex-shrink: 1;
}

@media (min-width: 761px) {
    /* mirrors .cb-row { display: flex } */
    .is-wrapper .row:has(> .column),
    .is-wrapper .row:has(> .cb-column) {
        display: flex;
    }
    /* mirrors .cb-column desktop padding */
    .is-wrapper .row > .column,
    .is-wrapper .row > .cb-column,
    .is-wrapper .cb-row > .column {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

@media (min-width: 761px) {
    /* mirrors .cb-column fraction widths for saved pages that still use them */
    .is-wrapper .row > .column.full { width: 100%; }
    .is-wrapper .row > .column.two-third { width: 66.7%; }
    .is-wrapper .row > .column.two-fourth { width: 75%; }
    .is-wrapper .row > .column.two-fifth { width: 80%; }
    .is-wrapper .row > .column.two-sixth { width: 83.3%; }
    .is-wrapper .row > .column.half { width: 50%; }
    .is-wrapper .row > .column.third { width: 33.3%; }
    .is-wrapper .row > .column.fourth { width: 25%; }
    .is-wrapper .row > .column.fifth { width: 20%; }
    .is-wrapper .row > .column.sixth { width: 16.6%; }
    .is-wrapper .row > .column.seventh { width: 14.285714285714286%; }
    .is-wrapper .row > .column.eighth { width: 12.5%; }
    .is-wrapper .row > .column.ninth { width: 11.111111111111111%; }
    .is-wrapper .row > .column.tenth { width: 10%; }
    .is-wrapper .row > .column.eleventh { width: 9.090909090909091%; }
    .is-wrapper .row > .column.twelfth { width: 8.333333333333333%; }
    .is-wrapper .row > .column.flow-opposite { float: right; }
}

@media (max-width: 760px) {
    /* mirrors stock mobile stacking: row is a plain block, columns full width */
    .is-wrapper .row:has(> .column),
    .is-wrapper .row:has(> .cb-column) {
        display: block;
    }
    .is-wrapper .row > .column,
    .is-wrapper .row > .cb-column,
    .is-wrapper .cb-row > .column {
        min-width: 100%;
        min-height: unset !important;
    }
}
