/* Keep the previously rendered staff page visible until the destination is ready. */
::view-transition-group(root), ::view-transition-image-pair(root),
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
html:not([data-workspace-ready])::view-transition-old(root) {
  animation: keep-workspace-visible 8s linear;
  mix-blend-mode: normal;
}
html:not([data-workspace-ready])::view-transition-new(root) { opacity: 0; }
@keyframes keep-workspace-visible { from { opacity: 1; } to { opacity: 1; } }

.workspace-skeleton { display: none; }
html:not([data-workspace-ready]) body:has(> .workspace-loading-brand) > :is(header.top,#staff-menu){display:none!important}
html:not([data-workspace-ready]) body > .workspace-loading-brand[hidden]{
  display:flex!important;align-items:center;box-sizing:border-box;height:64px;padding:0 16px;
  color:white;font:700 18px/1.2 system-ui,sans-serif;
  background:var(--chrome-gradient,linear-gradient(112deg,#10285c,#0032c8)) left calc(0px - var(--chrome-inset,0px)) / var(--chrome-size,100% 100%) no-repeat #10285c;
}
@media(max-width:899px),(pointer:coarse) and (orientation:landscape){
  html:not([data-workspace-ready]) .workspace-loading-brand ~ .workspace-skeleton{
    animation:workspace-loading-delay 1800ms step-end both;
  }
  @keyframes workspace-loading-delay{
    from{visibility:hidden}
    to{visibility:visible}
  }
  html:has(#workspace-chrome) body{
    --workspace-chrome:#0032c8;
    --chrome-start:#10285c;
    --chrome-end:#0032c8;
    --chrome-inset:env(safe-area-inset-top,0px);
    --chrome-gradient:linear-gradient(112deg,var(--chrome-start),var(--chrome-end));
    --mobile-header-paint:linear-gradient(to bottom,var(--workspace-chrome) 3px,transparent 26px),var(--chrome-gradient);
    padding-top:var(--chrome-inset);
    padding-inline:max(0px,env(safe-area-inset-left,0px)) max(0px,env(safe-area-inset-right,0px));
  }
  html:has(#workspace-chrome) body[data-resort-theme=polyana]{--workspace-chrome:#63251f;--chrome-start:#63251f;--chrome-end:#cb3724}
  body:has(#app-panel:not(.hidden) > #operator-panel:not(.hidden,.screen-hidden)){
    --mobile-header-paint:linear-gradient(90deg,var(--chrome-start),var(--chrome-end));
    --status-bar-paint:var(--mobile-header-paint);
  }
  html[data-iphone-safari-tab] body:has(#app-panel:not(.hidden) > #operator-panel:not(.hidden,.screen-hidden)){
    --status-bar-paint:var(--workspace-chrome);
    --mobile-header-paint:linear-gradient(to bottom,var(--workspace-chrome) 3px,transparent 26px),
      linear-gradient(90deg,var(--chrome-start),var(--chrome-end));
  }
  html:has(#workspace-chrome) body::before{
    content:"";position:fixed;inset:0 0 auto;height:var(--chrome-inset);
    background:var(--status-bar-paint,var(--workspace-chrome));background-color:var(--workspace-chrome);z-index:100;pointer-events:none;
  }
  html:has(#workspace-chrome) body.crm-theme > header.top{top:var(--chrome-inset)}
  html:has(#workspace-chrome) body.crm-theme > header.top,
  html:not([data-workspace-ready]) body > .workspace-loading-brand[hidden]{background:var(--mobile-header-paint);background-color:var(--workspace-chrome)}
}
html:not([data-workspace-ready]) .workspace-skeleton {
  display: grid;
  gap: 1rem;
  max-width: 68rem;
  margin: 1.5rem auto;
  padding: 0 1rem;
  color: #476078;
}
html:not([data-workspace-ready]) .workspace-skeleton ~ main { display: none; }
.workspace-skeleton > p { margin: 0; font-size: 1rem; }
.skeleton-cards { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(15rem,100%),1fr)); gap: 1rem; }
.skeleton-cards > span {
  display: grid; align-content: center; gap: .8rem; min-height: 7rem;
  background: #fbfcfd; border: 1px solid #dae3eb; border-radius: .8rem; padding: 1rem;
}
.skeleton-cards > span::before, .skeleton-cards > span::after {
  content: ""; display: block; width: 42%; height: .8rem; border-radius: .25rem; background: #dce5ed;
}
.skeleton-cards > span::after { width: 76%; height: .6rem; background: #edf1f5; }
html[data-appearance=dark] .workspace-skeleton {color:#bdcee5}
html[data-appearance=dark] .skeleton-cards > span {background:#192f55;border-color:#415978}
html[data-appearance=dark] .skeleton-cards > span::before,
html[data-appearance=dark] .skeleton-cards > span::after {background:#365579}
@media (max-width: 540px) { .skeleton-cards > span:last-child { display: none; } }

@media(max-width:899px),(pointer:coarse) and (orientation:landscape){
  html:has(#workspace-chrome):not([data-workspace-ready]),
  html:has(#workspace-chrome):not([data-workspace-ready]) body.crm-theme{background:#fff}
  html:has(#workspace-chrome):not([data-workspace-ready])::before,
  html[data-launch-reveal]::before{
    content:"";position:fixed;inset:0;z-index:102;
    background:white url("/static/resort-brands/app-icons/arkhyz-192.png") center / 96px 96px no-repeat;
    pointer-events:none;
  }
  html[data-launch-reveal]::before{opacity:var(--launch-opacity,1);will-change:opacity}
  html:not([data-workspace-ready]) body > .workspace-loading-brand[hidden]{display:none!important}
  html:not([data-workspace-ready]) .workspace-loading-brand ~ .workspace-skeleton{
    position:fixed;z-index:103;top:calc(50% + 64px);left:0;right:0;
    margin:0 auto;text-align:center;color:#476078;
  }
  html:not([data-workspace-ready]) .workspace-loading-brand ~ .workspace-skeleton .skeleton-cards{display:none}
}

html:has(#workspace-chrome):not([data-workspace-ready]) body::before{background:#fff}

@media(max-width:899px),(pointer:coarse) and (orientation:landscape){
  html[data-workspace-ready] body.crm-theme:has(#app-panel.hidden):has(#login-panel:not(.hidden,[hidden])) > header.top{display:none}
  html[data-workspace-ready] body.crm-theme:has(#app-panel.hidden):has(#login-panel:not(.hidden,[hidden]))::before{background:var(--crm-page)}
  main.wrap:has(#app-panel.hidden):has(#login-panel:not(.hidden,[hidden])) > .workspace-login-name[hidden]{
    display:block;margin:0 0 16px;color:var(--crm-ink);font-size:22px;font-weight:700;line-height:1.25;
  }
  body.crm-theme main.wrap:has(#app-panel.hidden) #login-panel:not(.hidden,[hidden]){margin-block:0}
}

@media(max-width:899px),(pointer:coarse) and (orientation:landscape){
  html:has(#workspace-chrome)[data-installed-workspace]:is(:not([data-workspace-ready]),[data-launch-reveal])::before{
    background-image:none;
  }
  html:has(#workspace-chrome)[data-installed-workspace]:is(:not([data-workspace-ready]),[data-launch-reveal]) #launch-camera{
    display:block;position:fixed;inset:0;z-index:103;pointer-events:none;
    opacity:var(--launch-opacity,1);
  }
  #launch-camera > span{
    display:block;height:100%;
    background:url("/static/resort-brands/app-icons/arkhyz-192.png") center / 96px 96px no-repeat;
    animation:launch-camera-appear 200ms ease-out 450ms both;
  }
  @keyframes launch-camera-appear{from{opacity:0}to{opacity:1}}
}
@media(prefers-reduced-motion:reduce){
  #launch-camera > span{animation-timing-function:step-end;animation-duration:1ms}
}

/* A sidebar can initialise before the workspace. Anchor the loading state to the viewport. */
@media (min-width:900px) and (pointer:fine), (min-width:900px) and (orientation:portrait) {
  html:not([data-workspace-ready]) body:has(> .workspace-skeleton)
    > :is(.workspace-loading-brand[hidden], header.top, #staff-menu) {display:none!important}
  html:not([data-workspace-ready]) body > .workspace-skeleton {
    position:fixed;inset:0;z-index:100;max-width:none;margin:0;
    align-content:center;justify-items:center;text-align:center;
    background:var(--crm-page);color:var(--crm-ink);
  }
  html:not([data-workspace-ready]) body > .workspace-skeleton .skeleton-cards {display:none}
}

/* Keep the reload preview independent of sidebar padding in the new document. */
#workspace-reload-preview {position:fixed;inset:0;z-index:1000;overflow:hidden;background:var(--crm-page)}
html:has(#workspace-reload-preview):not([data-workspace-ready])::before {display:none}

/* Android already shows the installed app icon before the web page is painted. */
html[data-android-launch]:has(#workspace-chrome):not([data-workspace-ready])::before {background-image:none}
html[data-android-launch] #launch-camera {display:none!important}

html:has(#workspace-reload-preview) {scrollbar-gutter:stable}
