/* Space Gate Nova+ — definitive content-flow repair
   Loaded last. The MAUI WebView must render the real height of rails/cards;
   content-visibility intrinsic placeholders were creating large black gaps. */

html,
body,
#app,
.app-root,
.main-layout-shell,
.sg-route-frame,
.sg-route-surface {
    width: 100% !important;
    height: auto !important;
    min-height: 100dvh !important;
    overflow-x: hidden !important;
    background: #000000 !important;
}

/* Critical: Chromium WebView can leave contain-intrinsic-size placeholders
   behind when Blazor replaces horizontal rails. Always use measured content. */
:is(
    .oscar-section,
    .home-rail-section,
    .shahid-home-section,
    .target-home-rail,
    .catalog-section,
    .media-card,
    .poster-card,
    .catalog-card,
    .home-rail-card,
    .channel-card,
    .oscar-card,
    .nova-batch-loader,
    .catalog-landing-rail-skeleton,
    .home-rail-skeleton
) {
    content-visibility: visible !important;
    contain-intrinsic-size: auto !important;
    contain: none !important;
}

/* The layout owns the viewport. Pages and nested shells follow their actual
   content height, reserving the fixed bottom navigation only once. */
.sg-route-surface > :is(.oscar-app, .nova-app, .discover-page),
.home-app,
.home-main,
.target-home,
.target-home-reference,
.shahid-home-reference,
.catalog-landing-app,
.catalog-landing-main,
.catalog-landing-reference,
.nova-catalog-page,
.nova-live-page,
.favorites-page-app,
.favorites-page-shell,
.account-page-app,
.account-page-shell,
.notifications-page-app,
.notifications-page-shell,
.settings-page-app,
.settings-page-shell,
.discover-page,
.discover-shell {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    align-content: start !important;
    justify-content: start !important;
}

.home-app,
.catalog-landing-app,
.favorites-page-app,
.account-page-app,
.notifications-page-app,
.settings-page-app {
    padding-bottom: 0 !important;
}

.target-home,
.target-home-reference,
.shahid-home-reference,
.catalog-landing-reference,
.favorites-page-shell,
.account-page-shell,
.notifications-page-shell,
.settings-page-shell,
.discover-page,
.nova-live-page,
.nova-catalog-page {
    padding-bottom: calc(var(--bottom-nav-h, 78px) + var(--safe-bottom, env(safe-area-inset-bottom, 0px)) + 12px) !important;
}

.catalog-landing-main,
.home-main {
    padding-bottom: 0 !important;
}

/* Keep every rendered rail adjacent to the previous one. */
:is(.shahid-home-section, .home-rail-section, .oscar-section, .target-home-rail, .catalog-section) {
    margin-block-start: 0 !important;
}

:is(.shahid-home-section, .home-rail-section, .oscar-section, .target-home-rail, .catalog-section) +
:is(.shahid-home-section, .home-rail-section, .oscar-section, .target-home-rail, .catalog-section, .nova-batch-loader) {
    margin-top: 0 !important;
}

/* Sentinels participate in observation but never become a visual spacer. */
.home-lazy-sentinel,
.catalog-landing-lazy-sentinel,
.nova-infinite-sentinel,
.live-infinite-sentinel,
.nova-live-infinite-sentinel {
    display: block !important;
    width: 100% !important;
    min-height: 2px !important;
    height: 2px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #000000 !important;
}

.home-lazy-sentinel > *,
.catalog-landing-lazy-sentinel > *,
.nova-infinite-sentinel > *,
.live-infinite-sentinel > *,
.nova-live-infinite-sentinel > * {
    display: none !important;
}

/* A loader is shown only while a real request is running and starts directly
   after the existing content instead of being pushed toward the viewport end. */
.nova-batch-loader,
.home-rail-skeleton-batch,
.catalog-landing-rail-skeleton-batch {
    margin: 0 !important;
    align-self: start !important;
    justify-self: stretch !important;
}

.shahid-home-section:last-of-type,
.nova-card-grid:last-child,
.favorites-grid:last-child,
.notifications-list:last-child,
.discover-results-grid:last-child {
    margin-bottom: 0 !important;
}

@media (max-width: 680px) {
    .target-home,
    .target-home-reference,
    .shahid-home-reference,
    .catalog-landing-reference,
    .favorites-page-shell,
    .account-page-shell,
    .notifications-page-shell,
    .settings-page-shell,
    .discover-page,
    .nova-live-page,
    .nova-catalog-page {
        padding-bottom: calc(var(--bottom-nav-h, 72px) + var(--safe-bottom, env(safe-area-inset-bottom, 0px)) + 8px) !important;
    }
}


/* Home terminal spacing: reserve only the fixed navigation safe area. */
.home-app .target-home,
.home-app .target-home-reference,
.home-app .shahid-home-reference {
    min-height: 0 !important;
    padding-bottom: calc(var(--bottom-nav-h, 72px) + var(--safe-bottom, env(safe-area-inset-bottom, 0px)) + 6px) !important;
}
.home-app .home-lazy-sentinel {
    min-height: 1px !important;
    height: 1px !important;
    padding: 0 !important;
}
