/* Keep the navigation and sensory controls together, in normal document flow. */
html:has(> body.cr-site) {
  --cr-admin-bar-offset: 0px;
  scroll-padding-top: calc(184px + var(--cr-admin-bar-offset));
}

html:has(> body.cr-site.admin-bar) { --cr-admin-bar-offset: 32px; }

body.cr-site {
  /* Unlike hidden, clip does not create an ancestor scroll container. */
  overflow-x: clip;
  overflow-y: visible;
}

body.cr-site #wrapper { overflow: visible; }

body.cr-site .cr-header {
  position: sticky;
  top: var(--cr-admin-bar-offset, 0px);
  z-index: 1000;
  overflow: visible;
}

/* The document's scroll padding protects content from the complete header. */
body.cr-site #main,
body.cr-site #main [id] { scroll-margin-top: 0; }

body.cr-site .cr-skip-link:focus {
  top: calc(16px + var(--cr-admin-bar-offset, 0px));
}

@media (max-width: 860px) {
  body.cr-site .cr-header .cr-nav.cr-is-open {
    /* Leave the brand/Menu row and sensory strip visible while menus scroll. */
    max-height: calc(100vh - var(--cr-admin-bar-offset, 0px) - 190px);
    max-height: calc(100dvh - var(--cr-admin-bar-offset, 0px) - 190px);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
  }
}

@media (max-width: 782px) {
  html:has(> body.cr-site.admin-bar) { --cr-admin-bar-offset: 46px; }
}

@media (max-width: 600px) {
  /* WordPress normally makes this absolute on small screens; keep the offset valid. */
  body.cr-site.admin-bar #wpadminbar { position: fixed; top: 0; }
}

@media (min-width: 861px) and (max-height: 580px) {
  body.cr-site .cr-header .cr-mega-panel {
    max-height: calc(100vh - var(--cr-admin-bar-offset, 0px) - 115px);
    max-height: calc(100dvh - var(--cr-admin-bar-offset, 0px) - 115px);
    overflow-y: auto;
  }
}

@media print {
  html:has(> body.cr-site) { scroll-padding-top: 0; }
  body.cr-site .cr-header { position: static; }
}
