/* ============================================================
   Cuspan Pro for Booknetic — Theme Lock
   Lets the panel break out of constrained WordPress theme content
   containers and render full-width, consistently across themes.
   Scoped to pages that actually contain the panel via :has().
   ============================================================ */

/* Prevent the 100vw breakout from introducing a horizontal scrollbar. */
body:has(#cuspan-pro-root) {
    overflow-x: clip;
}

/* Hide theme sidebars/widget areas on the panel page. */
body:has(#cuspan-pro-root) :is(#right-sidebar, #secondary, .sidebar, .sidebar-primary, .sidebar-container, .widget-area) {
    display: none !important;
}

/* Hide the theme page title / post header (e.g. the big "Cuspan" heading). */
body:has(#cuspan-pro-root) :is(.page-header, .entry-header, .page-title, .wp-block-post-title) {
    display: none !important;
}

/* Neutralise the max-width / padding of common classic + block theme content wrappers. */
body:has(#cuspan-pro-root) :is(
    #main, .site-main, #primary, .content-area, #content, #content-wrap, .content-wrapper,
    .site-content, .entry, .entry-content, article,
    .wp-block-post-content, .is-layout-constrained, .is-layout-flow
) {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    float: none !important;
    border: 0 !important;
}

/* Full-bleed the panel root to the viewport width regardless of the container. */
#cuspan-pro-root {
    position: relative;
    left: 50%;
    right: 50%;
    width: 100vw;
    max-width: 100vw;
    margin-left: -50vw !important;
    margin-right: -50vw !important;
}

/* ---- Full-screen mode (Panel Designer toggle, default on) ----
   Hide the theme header & footer AND make the panel a fixed, viewport-covering overlay.
   Scoped to the .cuspan-fullscreen root so a tenant can turn it off and keep their chrome.
   The fixed overlay is robust against any theme white-space (root padding, header/footer
   wrappers our selectors might miss) because it physically covers the whole viewport. */
body:has(#cuspan-pro-root.cuspan-fullscreen) > :is(header, footer),
body:has(#cuspan-pro-root.cuspan-fullscreen) .wp-site-blocks > :is(header, footer),
body:has(#cuspan-pro-root.cuspan-fullscreen) :is(
    #masthead, #colophon, #site-header, #site-footer, .site-header, .site-footer,
    #header, #footer, header.wp-block-template-part, footer.wp-block-template-part,
    [role="banner"], [role="contentinfo"]
) {
    display: none !important;
}

/* Lock the page behind the fixed overlay so only the panel scrolls. */
body:has(#cuspan-pro-root.cuspan-fullscreen) {
    overflow: hidden !important;
}

/* The panel becomes a fixed overlay covering the entire viewport. Overrides the
   relative full-bleed rule above (id+class beats id; margins forced with !important). */
#cuspan-pro-root.cuspan-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto !important;
    max-width: none !important;
    min-height: 0;
    margin: 0 !important;
    z-index: 99990;            /* below the WP admin bar (99999) and the drawers (99998+) */
    overflow: hidden;          /* the root itself never scrolls — only the content shell does,
                                  so the sidebar + its footer (Logout) stay pinned in view */
    background: var(--cuspan-bg, #F7F8FA);
}

/* Sit below the WP admin bar for logged-in admins. */
body.admin-bar #cuspan-pro-root.cuspan-fullscreen {
    top: 32px;
}
@media screen and (max-width: 782px) {
    body.admin-bar #cuspan-pro-root.cuspan-fullscreen {
        top: 46px;
    }
}
