/* The document fills the screen. Only interactive controls need a safe inset. */
body > header:has(> .nav) {
  padding-top:env(safe-area-inset-top, 0px);
}
@media (max-width:760px) {
  /* Keep the status area outside the sticky header's painted rectangle. */
  html body > header:has(> .nav) {
    --nav-safe-top:calc(12px + env(safe-area-inset-top, 0px));
    top:var(--nav-safe-top);
    margin-top:var(--nav-safe-top);
    padding-top:0;
  }
  html body.q-active-immersive-page > header:has(> .nav) { margin-top:0; }
  html body > header > .nav {
    height:60px;
    padding-block:0 12px;
  }
  body.architecture-page .architecture-switch-wrap {
    width:max-content;
    max-width:100%;
    margin-inline:auto;
  }
  body > header .nav > .links.open {
    max-height:calc(100dvh - 88px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
  body.privacy-page > .privacy-header {
    top:calc(10px + env(safe-area-inset-top, 0px));
    margin-top:calc(16px + env(safe-area-inset-top, 0px));
  }
  body > .privacy-consent {
    bottom:calc(12px + env(safe-area-inset-bottom, 0px));
    max-height:calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
}

/* Clip wide galleries at the content boundary, leaving the native page
   scroller free to paint through Safari's expanding and collapsing bars. */
@supports (overflow:clip) {
  @media (max-width:760px), (orientation:landscape) and (max-height:600px) and (max-width:1100px) {
    html:has(body > header .nav):not(.internal-login-open),
    html:not(.internal-login-open) > body:has(> header .nav) { overflow-x:visible; }
    body:has(> header .nav) main#main { overflow-x:clip; }
  }
}

/* Keep the product handoff inside the page while Safari moves its own bars. */
@media (max-width:760px), (orientation:landscape) and (max-height:600px) and (max-width:1100px) {
  html body > .product-subnav {
    --liquid-shadow:0 6px 14px var(--floating-nav-shadow, rgba(0,0,0,.10));
  }

  /* Only the centred stack is pinned. The swipe area still spans the page. */
  .projects-page #main #projects-collection.is-stacked,
  #main #panel-navrhy > .design-photo-stack.is-stacked {
    width:var(--design-slide-width);
    margin-inline:auto;
  }
  #main .design-photo-stack.is-stacked > .gallery-window {
    width:100vw;
    margin-inline:calc((100% - 100vw) / 2);
  }
  body.q-active-immersive-page #main .q-active-immersive-hero {
    height:100vh;
    height:100dvh;
    min-height:0;
  }
  body.pcon-configurator-page > .configurator-main { position:relative; }
}

@media (max-width:760px) {
  body .office-catalogue-toolbar {
    top:calc(74px + env(safe-area-inset-top, 0px));
  }
}

body.product-detail-page:has(> header :is(.links.open,.products-nav.is-open)) .product-detail-top-back {
  visibility:hidden;
  pointer-events:none;
}

@media (min-width:761px) and (max-width:1100px) and (orientation:landscape) and (max-height:600px) {
  html body > header:has(> .nav) { top:max(8px, env(safe-area-inset-top, 0px)); }
}

/* Leave page content visible beside pinned filters as they enter and leave
   the screen. Wide sticky controls can tint Safari's entire toolbar. */
@media (max-width:760px), (orientation:landscape) and (max-height:600px) and (max-width:1100px) {
  body :is(.office-catalogue-toolbar,.blog-library-toolbar) {
    max-inline-size:86vw;
    margin-inline:auto;
  }
}

@media screen and (min-width:1101px) {
  :root body > footer,
  :root body > nav.floating-actions {
    width:calc(100% - 2 * clamp(16px, 1.5vw, 24px));
    max-width:none;
  }
}
