/* Signed-in portal bar. The bar used to sit in normal flow, so any page
   that scrolled the document moved it off the top. Full-screen layers
   (photo viewers, drawers, dialogs) were position:fixed from the viewport
   top and painted over it. portal-bar.js keeps the bar as the first row
   and scrolls the rest in .portal-scroll, so in-page sticky toolbars stick
   to that region and sit below the bar. --portal-bar-h is the measured
   bar height, used to start overlays below it. */

:root { --portal-bar-h: 0px; }

#screen-app > header.topbar,
.scp-host > header.topbar,
.scp-host header.topbar {
  position: sticky;
  top: 0;
  z-index: 16000;
  flex-shrink: 0;
}

html:has(body.portal-bar-ready),
body.portal-bar-ready {
  height: 100%;
  overflow: hidden;
}

body.portal-bar-ready #screen-app {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.portal-bar-ready #screen-app > header.topbar {
  position: relative;
  flex: 0 0 auto;
  z-index: 16000;
  width: 100%;
  max-width: none;
  margin-inline: 0;
}

body.portal-bar-ready #screen-app > .portal-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

/* These pages already scroll inside .main. A second scroller would clip them. */
body.project-page.portal-bar-ready #screen-app > .portal-scroll,
body.page-personnel.portal-bar-ready #screen-app > .portal-scroll {
  overflow: hidden;
}

/* Full-screen layers start under the bar so the nav stays visible and
   their close controls are not hidden behind it. */
body.portal-bar-ready .modal-back,
body.portal-bar-ready .lightbox-backdrop,
body.portal-bar-ready .modal-backdrop,
body.portal-bar-ready .viewer-backdrop,
body.portal-bar-ready .gr-mb,
body.portal-bar-ready #pinconf,
body.portal-bar-ready .ml-photo-full,
body.portal-bar-ready .ml-scrim,
body.portal-bar-ready .rv-photo-lightbox,
body.portal-bar-ready .ck-overlay,
body.portal-bar-ready .ml-overlay,
body.portal-bar-ready .nn-overlay,
body.portal-bar-ready .dup-scrim {
  top: var(--portal-bar-h, 0px);
}

body.portal-bar-ready .ml-drawer,
body.portal-bar-ready .dup-drawer {
  top: var(--portal-bar-h, 0px);
}

body.portal-bar-ready .alert-toast,
body.portal-bar-ready .hhsrs-alerts-paused.is-fixed {
  top: calc(var(--portal-bar-h, 0px) + 12px);
}

body.portal-bar-ready .photos-page .lightbox {
  max-height: calc(100vh - var(--portal-bar-h, 0px) - 48px);
}

@media (max-width: 640px) {
  body.portal-bar-ready .alert-toast { top: auto; }
}

@media print {
  html:has(body.portal-bar-ready),
  body.portal-bar-ready,
  body.portal-bar-ready #screen-app,
  body.portal-bar-ready .portal-scroll {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}
