/* Sticky Footer Solution - OS 01-Sep-2025
 * Ensures footer stays at bottom of viewport on pages with minimal content
 * Updated to handle mobile viewport and sticky header issues
 */

/* Make html and body full height */
html {
    height: 100%;
}

body {
    /* Use dynamic viewport height with fallbacks for better mobile support */
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height - accounts for browser chrome */
    display: flex;
    flex-direction: column;
    /* Account for sticky header on mobile */
    position: relative;
}

/* Make main element grow to fill available space */
main,
.site-main,
.den-main-sanctuary,
.wtd-start-here-main,
.wtd-monarch-main,
.about-page,
.watch-main,
.practice-main,
.monarch-landing,
.wtd-search-page,
#read-landing,
#main {
    flex: 1 0 auto;
}

/* Ensure footer doesn't grow */
footer {
    flex-shrink: 0;
}

/* Additional wrapper fixes for specific page templates */
#primary.content-area {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
}

.wtd-start-here-wrapper,
.wtd-monarch-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
}

/* Handle admin bar offset */
body.admin-bar {
    min-height: calc(100vh - 32px);
    min-height: calc(100dvh - 32px);
}

@media screen and (max-width: 782px) {
    body.admin-bar {
        min-height: calc(100vh - 46px);
        min-height: calc(100dvh - 46px);
    }
}

/* Mobile-specific fixes for sticky footer */
@media screen and (max-width: 768px) {
    /* Ensure body takes full height on mobile */
    body {
        /* Use smaller viewport height to account for mobile browser chrome */
        min-height: 100vh;
        min-height: -webkit-fill-available; /* iOS Safari fix */
        min-height: 100dvh;
    }
    
    /* Ensure main content area has minimum height on mobile */
    main,
    .site-main,
    #main,
    #primary.content-area {
        min-height: 60vh; /* Minimum height to push footer down */
        min-height: 60dvh;
    }
    
    /* Fix for authentication required pages */
    .wtd-auth-required {
        min-height: 50vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        text-align: center;
        padding: 2rem;
    }
}

/* Ensure proper stacking with live stream bar */
body.has-live-stream {
    padding-top: 44px; /* Height of live stream bar */
}

body.admin-bar.has-live-stream {
    padding-top: 76px; /* 32px admin bar + 44px live stream */
}

@media screen and (max-width: 782px) {
    body.admin-bar.has-live-stream {
        padding-top: 90px; /* 46px admin bar + 44px live stream */
    }
}
