/*
 * CAHA Site Layout Framework
 * Applies only to the Home page and standard WordPress pages.
 */

body.caha-unified-page-layout {
    --caha-page-max-width: 1600px;
    --caha-page-width: 96%;
    --caha-page-gutter: clamp(18px, 2.4vw, 42px);
    --caha-section-gap: clamp(28px, 4vw, 64px);
}

/* Keep the overall Divi page centered and remove unused sidebar space on pages. */
body.caha-unified-page-layout #main-content .container,
body.caha-unified-page-layout #main-content > .container,
body.caha-unified-page-layout .et-l--body > .et_builder_inner_content,
body.caha-unified-page-layout .et_pb_pagebuilder_layout .entry-content {
    width: var(--caha-page-width) !important;
    max-width: var(--caha-page-max-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Divi often reserves room for a sidebar on ordinary pages. */
body.caha-unified-page-layout #left-area {
    width: 100% !important;
    float: none !important;
    padding-right: 0 !important;
}

body.caha-unified-page-layout #sidebar,
body.caha-unified-page-layout .et_right_sidebar #sidebar,
body.caha-unified-page-layout .et_left_sidebar #sidebar {
    display: none !important;
}

body.caha-unified-page-layout #main-content .container::before {
    display: none !important;
}

/* Standard Divi rows use the same generous width. Full-width sections remain full-width. */
body.caha-unified-page-layout .et_pb_section:not(.et_pb_fullwidth_section) > .et_pb_row,
body.caha-unified-page-layout .et_pb_section:not(.et_pb_fullwidth_section) > .et_pb_row_fullwidth,
body.caha-unified-page-layout .et_pb_section:not(.et_pb_fullwidth_section) > .et_pb_specialty_fullwidth,
body.caha-unified-page-layout .entry-content > .et_pb_section:not(.et_pb_fullwidth_section) > .et_pb_row {
    width: var(--caha-page-width) !important;
    max-width: var(--caha-page-max-width) !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Keep ordinary article/page content from sitting directly against the viewport edge. */
body.caha-unified-page-layout:not(.et_pb_pagebuilder_layout) #main-content .container,
body.caha-unified-page-layout .entry-content > :not(.et_pb_section):not(.alignfull) {
    box-sizing: border-box;
}

/* Shared spacing and safer sizing for CAHA custom page plugins. */
body.caha-unified-page-layout [class*="caha-"] {
    box-sizing: border-box;
}

body.caha-unified-page-layout [class*="caha-"][class*="page"],
body.caha-unified-page-layout [class*="caha-"][class*="wrapper"],
body.caha-unified-page-layout [class*="caha-"][class*="container"] {
    max-width: var(--caha-page-max-width);
}

body.caha-unified-page-layout img,
body.caha-unified-page-layout video,
body.caha-unified-page-layout iframe {
    max-width: 100%;
}

/* Prevent wide grids and cards from causing horizontal clipping. */
body.caha-unified-page-layout .et_pb_row,
body.caha-unified-page-layout .et_pb_column,
body.caha-unified-page-layout [class*="grid"],
body.caha-unified-page-layout [class*="card"] {
    min-width: 0;
}

body.caha-unified-page-layout {
    overflow-x: hidden;
}

/* Tablet */
@media (max-width: 980px) {
    body.caha-unified-page-layout {
        --caha-page-width: calc(100% - 36px);
    }

    body.caha-unified-page-layout .et_pb_section:not(.et_pb_fullwidth_section) > .et_pb_row,
    body.caha-unified-page-layout #main-content .container,
    body.caha-unified-page-layout .et-l--body > .et_builder_inner_content,
    body.caha-unified-page-layout .et_pb_pagebuilder_layout .entry-content {
        width: var(--caha-page-width) !important;
    }
}

/* Mobile */
@media (max-width: 767px) {
    body.caha-unified-page-layout {
        --caha-page-width: calc(100% - 24px);
        --caha-section-gap: 28px;
    }

    body.caha-unified-page-layout .et_pb_section:not(.et_pb_fullwidth_section) > .et_pb_row,
    body.caha-unified-page-layout #main-content .container,
    body.caha-unified-page-layout .et-l--body > .et_builder_inner_content,
    body.caha-unified-page-layout .et_pb_pagebuilder_layout .entry-content {
        width: var(--caha-page-width) !important;
    }
}


/*
 * Hockey Programs exception
 * Keep the outer WordPress/Divi shell fluid, then constrain the actual
 * CAHA program wrapper once. This prevents nested 96% widths and guarantees
 * the live Girls Hockey subpage uses the intended centered margins.
 */
body.caha-unified-page-layout.caha-hockey-program-layout #main-content .container,
body.caha-unified-page-layout.caha-hockey-program-layout #main-content > .container,
body.caha-unified-page-layout.caha-hockey-program-layout .et_pb_pagebuilder_layout .entry-content,
body.caha-unified-page-layout.caha-hockey-program-layout .entry-content {
    width: 100% !important;
    max-width: none !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

body.caha-unified-page-layout.caha-hockey-program-layout .caha-program-page,
body.caha-unified-page-layout:has(.caha-program-page) .caha-program-page {
    width: 92% !important;
    max-width: 1400px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

@media (max-width: 980px) {
    body.caha-unified-page-layout.caha-hockey-program-layout .caha-program-page,
    body.caha-unified-page-layout:has(.caha-program-page) .caha-program-page {
        width: calc(100% - 36px) !important;
    }
}

@media (max-width: 767px) {
    body.caha-unified-page-layout.caha-hockey-program-layout .caha-program-page,
    body.caha-unified-page-layout:has(.caha-program-page) .caha-program-page {
        width: calc(100% - 24px) !important;
    }
}
