/*
 * Celler Garnison-Museum – global layout guard
 * Purpose:
 * 1) no white strip below the custom navy footer
 * 2) custom footer edge-to-edge on mobile, independent of Big Picture #content padding
 * 3) item-title navy bar edge-to-edge on mobile
 *
 * This file is intentionally loaded LAST from common/header.php so later
 * page-specific regressions cannot undo these structural rules.
 */

/* Navy behind the complete document prevents a white browser/page tail. */
html {
    background: #061827;
}

/* Every CGM-designed page ends on navy. */
body.cgm-landing,
body.cgm-digital-page,
body.cgm-about-page,
body.cgm-impressum-page,
body.cgm-datenschutz-page,
body.cgm-panorama-page,
body.cgm-military-map-page,
body.cgm-items-page,
body.cgm-item-page,
body.cgm-collections-page,
body.cgm-collection-show-page,
body.cgm-exhibit-browse,
body.cgm-exhibit-summary,
body.cgm-exhibit-story {
    background: #061827 !important;
}

/*
 * Big Picture sets #wrap to white globally.  That is the source of the
 * recurring white strip after a custom CGM footer.  Content sections already
 * paint their own white/paper backgrounds, so the outer wrap can safely be
 * navy on all redesigned pages.
 */
body.cgm-landing #wrap,
body.cgm-digital-page #wrap,
body.cgm-about-page #wrap,
body.cgm-impressum-page #wrap,
body.cgm-datenschutz-page #wrap,
body.cgm-panorama-page #wrap,
body.cgm-military-map-page #wrap,
body.cgm-items-page #wrap,
body.cgm-item-page #wrap,
body.cgm-collections-page #wrap,
body.cgm-collection-show-page #wrap,
body.cgm-exhibit-browse #wrap,
body.cgm-exhibit-summary #wrap,
body.cgm-exhibit-story #wrap {
    background: #061827 !important;
}

/* Never let the stock Big Picture footer create a second light page ending. */
body.cgm-landing #wrap > footer,
body.cgm-digital-page #wrap > footer,
body.cgm-about-page #wrap > footer,
body.cgm-impressum-page #wrap > footer,
body.cgm-datenschutz-page #wrap > footer,
body.cgm-panorama-page #wrap > footer,
body.cgm-military-map-page #wrap > footer,
body.cgm-items-page #wrap > footer,
body.cgm-item-page #wrap > footer,
body.cgm-collections-page #wrap > footer,
body.cgm-collection-show-page #wrap > footer,
body.cgm-exhibit-browse #wrap > footer,
body.cgm-exhibit-summary #wrap > footer,
body.cgm-exhibit-story #wrap > footer {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

/* All custom CGM footers finish flush with the page. */
.cgm-site-footer,
body.cgm-landing .cgm-landing-footer {
    margin: 0 !important;
    background: #061827 !important;
}

/*
 * Item pages are the one redesigned page where Big Picture intentionally
 * retains #content's 21 px inset.  Keep the CONTENT white, not #wrap.
 * This preserves the desired white object page while allowing the footer
 * and the document tail to remain navy.
 */
body.cgm-item-page #content,
body.cgm-item-page .item-metadata,
body.cgm-item-page .item-metadata-content {
    background: #fff !important;
}

/* ==========================================================
   MOBILE FULL-BLEED GUARANTEES
   ========================================================== */
@media screen and (max-width: 800px) {

    /*
     * Object title bar: full viewport width regardless of parent padding.
     * This replaces the fragile fixed -21px correction with the standard
     * full-bleed calculation.
     */
    body.cgm-item-page .item-metadata > h1 {
        display: block !important;
        width: 100vw !important;
        max-width: none !important;
        box-sizing: border-box !important;
        margin-left: calc(50% - 50vw) !important;
        margin-right: calc(50% - 50vw) !important;
        padding-left: max(21px, env(safe-area-inset-left)) !important;
        padding-right: max(21px, env(safe-area-inset-right)) !important;
        background: #0b2c45 !important;
    }

    /*
     * Every compact CGM footer becomes viewport-wide even if it happens to
     * sit inside a padded #content container.
     */
    body.cgm-digital-page .cgm-site-footer,
    body.cgm-about-page .cgm-site-footer,
    body.cgm-impressum-page .cgm-site-footer,
    body.cgm-datenschutz-page .cgm-site-footer,
    body.cgm-panorama-page .cgm-site-footer,
    body.cgm-military-map-page .cgm-site-footer,
    body.cgm-items-page .cgm-site-footer,
    body.cgm-item-page .cgm-site-footer,
    body.cgm-collections-page .cgm-site-footer,
    body.cgm-collection-show-page .cgm-site-footer,
    body.cgm-exhibit-browse .cgm-site-footer,
    body.cgm-exhibit-summary .cgm-site-footer,
    body.cgm-exhibit-story .cgm-site-footer {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        width: 100vw !important;
        max-width: none !important;
        box-sizing: border-box !important;
        margin-left: calc(50% - 50vw) !important;
        margin-right: calc(50% - 50vw) !important;
    }

    /* Start page has its own richer footer but gets the same hard guarantee. */
    body.cgm-landing .cgm-landing-footer {
        width: 100vw !important;
        max-width: none !important;
        box-sizing: border-box !important;
        margin-left: calc(50% - 50vw) !important;
        margin-right: calc(50% - 50vw) !important;
    }

    /* Footer inner content remains comfortably inset on phones. */
    .cgm-site-footer-shell {
        width: min(1180px, calc(100% - 28px)) !important;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box !important;
    }
}

/*
 * Fallbacks for core Omeka page classes in case one custom body class is
 * accidentally lost in a future template edit. These only address the
 * page tail and do not alter content layout.
 */
body.items.show,
body.items.browse,
body.collections.show,
body.collections.browse,
body.exhibits.show,
body.exhibits.summary,
body.exhibits.browse {
    min-height: 100vh;
}

body.items.show:has(.cgm-site-footer),
body.items.browse:has(.cgm-site-footer),
body.collections.show:has(.cgm-site-footer),
body.collections.browse:has(.cgm-site-footer),
body.exhibits.show:has(.cgm-site-footer),
body.exhibits.summary:has(.cgm-site-footer),
body.exhibits.browse:has(.cgm-site-footer) {
    background: #061827 !important;
}

body.items.show:has(.cgm-site-footer) #wrap,
body.items.browse:has(.cgm-site-footer) #wrap,
body.collections.show:has(.cgm-site-footer) #wrap,
body.collections.browse:has(.cgm-site-footer) #wrap,
body.exhibits.show:has(.cgm-site-footer) #wrap,
body.exhibits.summary:has(.cgm-site-footer) #wrap,
body.exhibits.browse:has(.cgm-site-footer) #wrap {
    background: #061827 !important;
}
