/**
 * Critical path: Figma-style boot splash (loads before login-screen.css).
 */

/* Login first paint: white shell + no hero flash before login-screen.css (mobile FOUC). */
html:not(.portal-boot-resume) body:not(.portal-authenticated) {
  background: #fff;
  overflow: hidden;
}

html:not(.portal-boot-resume) body:not(.portal-authenticated) .portal-shell {
  display: block;
  padding: 0;
  min-height: 100%;
  background: #fff;
}

html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-screen {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: block;
  background: #fff;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-split__visual {
  display: none !important;
}

html:not(.portal-boot-resume) body:not(.portal-authenticated) .portal-shell .app {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-remember-note,
html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-advanced,
html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-dev-btn,
html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-footer-links,
html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-hint {
  display: none !important;
}

@media (max-width: 900px) {
  html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-screen {
    position: static;
    inset: auto;
    z-index: 1;
    min-height: 100dvh;
  }

  html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-split__form {
    padding:
      calc(env(safe-area-inset-top, 0px) + 20px)
      max(20px, env(safe-area-inset-right, 0px))
      max(32px, env(safe-area-inset-bottom, 0px))
      max(20px, env(safe-area-inset-left, 0px));
  }

  html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-panel {
    width: min(370px, 100%);
    margin: 0 auto;
  }
}

@media (min-width: 901px) {
  html:not(.portal-boot-resume) body:not(.portal-authenticated) .login-split__visual[hidden] {
    display: flex !important;
  }
}

html.portal-boot-resume #loginScreen {
  display: none !important;
}

html.portal-boot-resume #portalBootSplash:not([hidden]) {
  display: flex !important;
}

.portal-boot-splash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10001;
  align-items: center;
  justify-content: center;
  background: #ebebeb;
}

.portal-boot-splash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 168px;
}

.portal-boot-splash-logo {
  display: block;
  width: 32px !important;
  height: 32px !important;
  max-width: 32px !important;
  object-fit: contain;
}

.portal-boot-progress {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.portal-boot-progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #e85d2c 0%, #f0a030 38%, #3d9a6a 100%);
  transition: width 0.14s ease-out;
}

/* Deep-link F5: keep splash path until viewer opens; hide main app chrome */
html.blg-toolbox-asset-deeplink body.portal-authenticated:not(.blg-toolbox-viewer-open) #app {
  visibility: hidden !important;
}

html.blg-toolbox-asset-deeplink body.portal-authenticated:not(.blg-toolbox-viewer-open) #portalBootSplash:not([hidden]) {
  display: flex !important;
}

/* Deep-link F5: skip toolbox/home flash until asset viewer opens */
html.blg-toolbox-asset-deeplink body.portal-authenticated:not(.blg-toolbox-viewer-open) #brandLiveHomeView,
html.blg-toolbox-asset-deeplink body.portal-authenticated:not(.blg-toolbox-viewer-open) #brandLiveGuidelinesView,
html.blg-toolbox-asset-deeplink body.portal-authenticated:not(.blg-toolbox-viewer-open) #brandLiveGuidelineDocView,
html.blg-toolbox-asset-deeplink body.portal-authenticated:not(.blg-toolbox-viewer-open) #brandLiveInspirationView,
html.blg-toolbox-asset-deeplink body.portal-authenticated:not(.blg-toolbox-viewer-open) #brandLiveStoryView,
html.blg-toolbox-asset-deeplink body.portal-authenticated:not(.blg-toolbox-viewer-open) #brandLiveSearchView,
html.blg-toolbox-asset-deeplink body.portal-authenticated:not(.blg-toolbox-viewer-open) #brandLiveProfileView,
html.blg-toolbox-asset-deeplink body.portal-authenticated:not(.blg-toolbox-viewer-open) #brandLiveToolboxView {
  visibility: hidden;
}

html.blg-toolbox-asset-deeplink body.blg-toolbox-viewer-open #brandLiveToolboxView {
  visibility: visible;
}

/* Collection deep-link F5: show detail chrome before portal.js paints hub grid */
html.blg-toolbox-collection-deeplink #brandLiveToolboxHero,
html.blg-toolbox-collection-deeplink #brandLiveToolboxCollections {
  display: none !important;
}

html.blg-toolbox-collection-deeplink #brandLiveToolboxCollectionDetail[hidden] {
  display: block !important;
}

/* F5 collection deep-link: show toolbox detail chrome before portal.js (desktop) */
html.blg-toolbox-collection-deeplink body.portal-authenticated #brandLiveHomeView,
html.blg-toolbox-collection-deeplink body.portal-authenticated #brandLiveGuidelinesView,
html.blg-toolbox-collection-deeplink body.portal-authenticated #brandLiveGuidelineDocView,
html.blg-toolbox-collection-deeplink body.portal-authenticated #brandLiveInspirationView,
html.blg-toolbox-collection-deeplink body.portal-authenticated #brandLiveStoryView,
html.blg-toolbox-collection-deeplink body.portal-authenticated #brandLiveSearchView,
html.blg-toolbox-collection-deeplink body.portal-authenticated #brandLiveProfileView {
  display: none !important;
}

html.blg-toolbox-collection-deeplink body.portal-authenticated #brandLiveToolboxView[hidden] {
  display: block !important;
}

html.blg-toolbox-collection-deeplink body.portal-authenticated:not(.blg-toolbox-collection-route-ready) #app {
  visibility: hidden !important;
}

html.blg-toolbox-collection-deeplink body.portal-authenticated:not(.blg-toolbox-collection-route-ready) #portalBootSplash:not([hidden]) {
  display: flex !important;
}

.portal-boot-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  body.portal-authenticated #brandLiveSiteChrome.blg-site-chrome,
  body.portal-authenticated #brandLiveSiteChrome.blg-site-chrome.is-scroll-hidden {
    transform: none !important;
    margin-bottom: 0 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  body.portal-authenticated #brandLiveSiteChrome.blg-site-chrome .blg-site-header-bar,
  body.portal-authenticated #brandLiveSiteChrome.blg-site-chrome.is-scroll-hidden .blg-site-header-bar {
    transform: none !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  html.portal-boot-resume body.portal-authenticated #app {
    visibility: hidden !important;
  }
}
