/*
 * page-sections.css - section backgrounds for the standard page editor
 *
 * Location: $master_path/styles/page-sections.css (one central copy).
 * Each site serves it through /styles/page-sections.php.
 * A skin can replace it completely with /skins/<skindir>/styles/page-sections.css
 * (index.php / members.php / the editor link the skin copy when it exists).
 *
 * Version 1.02.0  (01/12/2026)
 *
 * ChangeLog:
 * 1.02.0 01/12/2026 - Section Height (.has-bg-height): a minimum height from
 *   --section-bg-height, with --section-bg-height-mobile on screens under
 *   768px, so a background shows even when the section has no text. Content
 *   is centred vertically. Sections without a height are unchanged.
 * 1.01.1 13/11/2026 - .section-bg is display:flow-root, so a last paragraph's
 *   or list's bottom margin stays inside the band instead of collapsing out
 *   as a white strip between two background sections (seen on mojo_montessori).
 * 1.01.0 14/10/2026 - Colour overlay: the overlay colour comes from
 *   --section-bg-overlay-color (black when not set, so existing overlays
 *   look the same) and its strength from --section-bg-overlay (opacity).
 * 1.00.1 13/10/2026 - Header only: now lives in $master_path/styles,
 *   served to sites by /styles/page-sections.php.
 * 1.00.0 13/10/2026 - First release (Claude, for Gary).
 *
 * Markup (from page_section_open() in includes/functions/page_sections.inc):
 *   <div class="section-bg has-bg-image has-bg-overlay section-bg-parallax
 *               has-bg-color section-text-light section-bg-centered centeredText section-bg_N"
 *        style="--section-bg-image:url('...'); --section-bg-position:center top;
 *               --section-bg-overlay:0.40; --section-bg-overlay-color:#0b3d91;
 *               --section-bg-color:#1d3557;
 *               --section-bg-height:500px; --section-bg-height-mobile:300px">
 *     ...the section's existing ID / Class / .section divs...
 *   </div>
 *
 * Also loaded into the page editor (TinyMCE content_css) so Light Text and
 * Center preview correctly while editing.
 */

/* ---- wrapper ---------------------------------------------------- */
.section-bg {
    position: relative;
    isolation: isolate;               /* keeps the overlay / parallax layers inside this section */
    display: flow-root;               /* children's top/bottom margins stay inside the band (no white strip between sections) */
}

.section-bg.has-bg-color {
    background-color: var(--section-bg-color);
}

.section-bg.has-bg-image {
    background-image: var(--section-bg-image);
    background-size: cover;
    background-position: var(--section-bg-position, center center);
    background-repeat: no-repeat;
}

/* ---- section height (1.02.0) -------------------------------------
 * A MINIMUM height, so the section still grows if its content needs more
 * room. Flex keeps margins inside the band just like flow-root does, and
 * centres the content vertically. width:100% stops a child with
 * margin:0 auto (e.g. a skin's .section / .container) shrinking to its
 * content inside the flex column; its own max-width still applies. The
 * "stretch" width counts the child's padding, so its box is the same size
 * as without a height set.
 * An unset variable falls back to min-height:auto (fits the content).
 * ---------------------------------------------------------------- */
.section-bg.has-bg-height {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: var(--section-bg-height, auto);
}

.section-bg.has-bg-height > * {
    width: 100%;                      /* fallback */
    width: -webkit-fill-available;    /* Chrome, Edge, Safari */
    width: -moz-available;            /* Firefox */
    width: stretch;                   /* standard - full width less the child's own margins/padding */
}

@media (max-width: 767.98px) {
    .section-bg.has-bg-height {
        min-height: var(--section-bg-height-mobile, var(--section-bg-height, auto));
    }
}

/* ---- colour overlay (above the image, below the content) -------- */
.section-bg.has-bg-overlay::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-color: var(--section-bg-overlay-color, #000);
    opacity: var(--section-bg-overlay, 0);
    pointer-events: none;
}

/* ---- parallax ----------------------------------------------------
 * The image sits on a position:fixed layer, and clip-path makes the
 * section a window onto it, so the image stays still while the content
 * scrolls. Unlike background-attachment:fixed this also works on iOS.
 * If a skin puts a transform / filter on an element AROUND the content,
 * the fixed layer can't escape it and the image simply scrolls with the
 * section instead - nothing breaks.
 * ---------------------------------------------------------------- */
.section-bg.section-bg-parallax.has-bg-image {
    background-image: none;
    clip-path: inset(0);
}

.section-bg.section-bg-parallax.has-bg-image::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image: var(--section-bg-image);
    background-size: cover;
    background-position: var(--section-bg-position, center center);
    background-repeat: no-repeat;
    pointer-events: none;
}

/* ---- light text -------------------------------------------------- */
.section-text-light,
.section-text-light h1,
.section-text-light h2,
.section-text-light h3,
.section-text-light h4,
.section-text-light h5,
.section-text-light h6,
.section-text-light p,
.section-text-light li,
.section-text-light blockquote {
    color: #fff;
}

.section-text-light a:not(.btn) {
    color: #fff;
    text-decoration: underline;
}

/* ---- centred ----------------------------------------------------- */
.section-bg-centered {
    text-align: center;
}
