/* These Gutenberg headers put the main links inside .hn-top and wrap each link in a paragraph. */
/* Reserve the desktop scrollbar while the incoming page's first blocks are still loading. */
html:has(> body:is(.page-id-1077, .page-id-816, .page-id-1599, .page-id-858, .page-id-16, .page-id-159, .woocommerce-shop, .page-id-153, .page-id-1382)) {
  scrollbar-gutter: stable;
}

@layer physicum-kopfabstaende {
  /* Use one full-width link row in both navigation templates on narrow tablets. */
  @media (min-width: 768px) and (max-width: 820px) {
    :is(
      #pc-desktop-consistent, #pc-page-start.hn-header:not(:has(> #pc-desktop-consistent)),
      #pc-page-start.pc-simple-header, #pc-membership-page > .pc-membership-header, #pc-product-header
    ) :is(.pcd-main, .hn-main, .pc-simple-nav, .pc-membership-nav, .pc-product-nav) {
      & a[href] { padding-inline: 6px !important; }
      & :is(.pcd-trial, .hn-trial > a, a[href$="/probetraining/"]) {
        margin-left: 8px !important;
        padding-left: 14px !important;
      }
      & > a:last-child, & > p:last-child > a { padding-right: 0 !important; }
    }
  }
  @media (min-width: 768px) {
    #pc-page-start.hn-header:not(:has(> #pc-desktop-consistent)):has(> .hn-sub) {
      & > .hn-sub {
        animation: none !important;
        transition: none !important;
      }

      /* The existing disclosure opens for these same two entry URLs at DOMContentLoaded. */
      :root:not(:has(:target)) &:not(.hn-js) > .hn-sub:not([hidden]),
      &:not(.hn-js):target > .hn-sub:not([hidden]) {
        display: flex !important;
      }

      @supports (grid-template-columns: subgrid) {
        &:has(> .hn-top > .hn-main > .hn-selected):not(:has(> .hn-top > .hn-main > :nth-child(9))) {
          grid-template-columns: minmax(0, 1fr) repeat(8, max-content) !important;
          column-gap: 0 !important;
          --pc-submenu-end: 3;

          &:has(> .hn-top > .hn-main > .hn-selected:nth-child(2)) { --pc-submenu-end: 4; }
          &:has(> .hn-top > .hn-main > .hn-selected:nth-child(3)) { --pc-submenu-end: 5; }
          &:has(> .hn-top > .hn-main > .hn-selected:nth-child(4)) { --pc-submenu-end: 6; }
          &:has(> .hn-top > .hn-main > .hn-selected:nth-child(5)) { --pc-submenu-end: 7; }
          &:has(> .hn-top > .hn-main > .hn-selected:nth-child(6)) { --pc-submenu-end: 8; }
          &:has(> .hn-top > .hn-main > .hn-selected:nth-child(7)) { --pc-submenu-end: 9; }
          &:has(> .hn-top > .hn-main > .hn-selected:nth-child(8)) { --pc-submenu-end: 10; }

          & > .hn-top > .hn-main {
            display: grid !important;
            grid-template-columns: subgrid !important;
            grid-column: 2 / -1 !important;
            justify-content: stretch !important;
            column-gap: 0 !important;
          }

          /* Earlier templates number these paragraphs from column three.
             In the subgrid the first link occupies the first track. */
          & > .hn-top > .hn-main > p { grid-area: auto !important; }

          & > .hn-sub {
            grid-column: 1 / var(--pc-submenu-end) !important;
            contain: inline-size;
            --pc-submenu-native: 1;
          }

          @media (max-width: 1150px) {
            & > .hn-top > figure { grid-column: 1 / -1 !important; }
          }
        }
      }
    }
  }
}
