/*
 * Fluentare Kadence Legacy Compatibility v0.1.3
 * Scope: recognized Fluentare course section pages only.
 * Goal: restore specific Kadence 0.9.9 layout behavior lost after the modern theme upgrade.
 * No selectors here modify saved Gutenberg content.
 */

/* Kadence 0.9.9 explicitly gave core Columns a 2rem top margin and no bottom margin. */
body.sf-kcompat-course .single-content .wp-block-columns {
    margin-top: 2rem;
    margin-bottom: 0;
}

/* Kadence 0.9.9 gave Advanced Buttons the normal content-block top spacing. */
body.sf-kcompat-course .single-content .wp-block-kadence-advancedbtn {
    margin-top: 1rem;
    margin-bottom: 0;
}

/*
 * Grammar pages that relied on the old theme's left-aligned default should stay left aligned.
 * Explicit child alignment classes (for intentionally centered text) continue to win on those children.
 */
body.sf-kcompat-course.sf-kcompat-grammar .kt-accordion-panel-inner,
body.sf-kcompat-course.sf-kcompat-grammar .kt-accordion-panel-inner .wp-block-columns,
body.sf-kcompat-course.sf-kcompat-grammar .kt-accordion-panel-inner .wp-block-column {
    text-align: left;
}

/*
 * Restore the old internal spacing of the blue section heading: Lesson number immediately followed
 * by the Kadence Advanced Heading's explicit 7px top margin, without a new theme block-gap/margin.
 */
body.sf-kcompat-course .sf-kcompat-section-heading > .kt-inside-inner-col > p:first-child {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}
body.sf-kcompat-course .sf-kcompat-section-heading > .kt-inside-inner-col > p:first-child + .wp-block-kadence-advancedheading {
    margin-top: 7px !important;
}

/*
 * Legacy Vocabulary family (Lesson 2 and Lessons 13-30 in the audited baseline):
 * the heading is in the first top-level Row Layout while the content column is the next top-level block.
 * Make both occupy the same content-box width under modern Kadence.
 */
body.sf-kcompat-course.sf-kcompat-vocab-legacy .sf-kcompat-vocab-legacy-row > .kt-row-column-wrap {
    grid-template-columns: minmax(0, 1fr) !important;
}
body.sf-kcompat-course.sf-kcompat-vocab-legacy .sf-kcompat-vocab-legacy-row > .kt-row-column-wrap > .wp-block-kadence-column {
    grid-column: 1 / -1 !important;
    width: 100%;
    max-width: 100%;
}

/*
 * Legacy Vocabulary heading row: modern Kadence can constrain the nested centered row
 * differently from the sibling content column. Force only that first nested heading row
 * and its inner grid to occupy the full width of the legacy outer row.
 */
body.sf-kcompat-course.sf-kcompat-vocab-legacy
.sf-kcompat-vocab-legacy-row > .kt-row-column-wrap > .wp-block-kadence-column:first-child > .kt-inside-inner-col > .wp-block-kadence-rowlayout {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}
body.sf-kcompat-course.sf-kcompat-vocab-legacy
.sf-kcompat-vocab-legacy-row > .kt-row-column-wrap > .wp-block-kadence-column:first-child > .kt-inside-inner-col > .wp-block-kadence-rowlayout > .kt-row-column-wrap {
    width: 100% !important;
    max-width: none !important;
}
body.sf-kcompat-course.sf-kcompat-vocab-legacy
.sf-kcompat-vocab-legacy-row > .kt-row-column-wrap > .wp-block-kadence-column:first-child > .kt-inside-inner-col > .wp-block-kadence-rowlayout .sf-kcompat-section-heading {
    width: 100% !important;
    max-width: 100% !important;
}
