/* Two row main menu (menuTheme = tworow)
   1st level: top row, 2nd level: second row (always visible), 3rd level: hover menu */

.tworow ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tworow a {
  display: block;
  padding: var(--base-size-quarter) var(--gutter);
  color: var(--menu-link-color);
  font-family: var(--menu-font-family);
  text-decoration: none;
}

.tworow a:hover,
.tworow a:focus {
  color: var(--menu-link-hover-color);
}

.header-tworow .tworow .tworow-level3 li.is-active > a,
.tworow ul.tworow-level3 a:hover,
.tworow ul.tworow-level3 a:focus {
    color: var(--menu-link-hover-color);
    margin-left: 4px;
    padding-right: 16px;
    background-color: #f7f8f9;
    border-radius: 4px;
}

.tworow li.is-active > a {
  color: var(--menu-link-hover-color);
  font-weight: bold;
}

/* Below 1466px the menu is the offcanvas menu (TwoRowOffcanvas.fluid.html, offcanvas.css) */
@media screen and (min-width: 1466px) {
  .tworow-main {
    display: flex;
    flex-wrap: wrap;
  }

  /* li of the 1st level is transparent, so that its 2nd level list can wrap into the second row */
  .tworow-main > li {
    display: contents;
  }

  /* both rows have the height of the navigation bar */
  .tworow-main > li > a,
  .tworow-level2 > li > a {
    display: flex;
    align-items: center;
    box-sizing: border-box;
    height: var(--nav-header-height);
    padding-top: 0;
    padding-bottom: 0;
  }

  .tworow-main > li > a {
    order: 1;
    border-bottom: var(--base-size-eighth) solid transparent;
  }

  .tworow-main > li:first-child > a {
    padding-left: 0;
  }

  .tworow-main > li.is-active > a {
    border-bottom-color: var(--blue);
  }

  /* 2nd level: second row, only for the active 1st level item */
  .tworow-level2 {
    display: none;
    order: 2;
    flex: 0 0 100%;
    padding-left: 0;
    border-top: 1px solid var(--desktop-submenu-border-color);
    background: var(--white);
  }

  .tworow-main > li.is-active > .tworow-level2 {
    display: flex;
    flex-wrap: wrap;
  }

  .tworow-level2 > li {
    position: relative;
  }

  .tworow-level2 > li:first-child > a {
    padding-left: 0;
  }

  .tworow-level2 > li.has-children > a > span::after {
    content: "\25BE";
    margin-left: var(--base-size-quarter);
  }

  /* 3rd level: hover menu */
  .tworow ul.tworow-level3 {
    display: none;
    position: absolute;
    z-index: 100;
    top: 100%;
    left: 0;
    min-width: calc(var(--base-size) * 12);
    padding: 20px 11px;
    border: none;
    background: var(--white);
    box-shadow: 0px 5px 10px rgba(0, 106, 179, .1);
  }

  .tworow-level2 > li:hover > .tworow-level3,
  .tworow-level2 > li:focus-within > .tworow-level3 {
    display: block;
  }

  .tworow-level3 a:hover,
  .tworow-level3 a:focus {
    background: var(--submenu-hover-bg);
  }
}

/* Header layout (menuTheme = tworow): logo left, menu levels 1 and 2 plus
   language, contrast and search on the right (template: www.sw-bb.de) */
.header-tworow {
  --tworow-service-width: calc(var(--base-size) * 8);
  display: flex;
  align-items: center;
}

.header-tworow .wrapper-logo {
  flex: 0 0 auto;
}

.header-tworow-menu {
  flex: 1 1 auto;
  min-width: 0;
}

.header-tworow .wrapper-topmenu,
.header-tworow .main-nav {
  background: transparent;
}

.header-tworow .tworow-main > li > a {
  border-bottom: 0;
}

.header-tworow .search-hide-btn {
  width: auto;
  padding: 0;
  text-align: center;
  line-height: 1.2;
}

.header-tworow .search-hide-btn .fa-search {
  display: block;
  color: var(--orange);
}

.header-tworow .contrast-label,
.header-tworow .search-label {
  display: block;
  margin-top: var(--base-size-eighth);
  font-size: .75rem;
  color: var(--font-color);
}

.header-tworow .btn-contrast {
  background: transparent;
  border-color: transparent;
}

/* forms.css gives every button "transition: all", the sizes and paddings of these buttons change at the
   breakpoint 1466px and would be animated, only the hover effects are animated */
.header-tworow .btn-contrast,
.header-tworow .search-hide-btn {
  transition-property: color, background-color, border-color, opacity;
}

@media screen and (min-width: 1466px) {
  /* light blue gradient behind the first row, across the full page width */
  .content-header:has(.header-tworow) {
    background-image: linear-gradient(90deg, var(--white) 35%, #e3eef9 100%);
    background-repeat: no-repeat;
    background-size: 100% calc(var(--base-size) * 2.2);
  }

  .content-header:has(.header-tworow) {
    background-color: var(--white);
  }

  .header-tworow {
    min-height: calc(var(--header-service-height) + var(--base-size) * 2);
  }

  .header-tworow .wrapper-logo {
    padding: var(--base-size) var(--gutter) 0 0;
  }

  /* the height of both rows is reserved: pages outside of the menu (e.g. the search pages) have no active
     1st level item and so no second row, the service icons at the bottom would slide over the first row,
     5.7 = first row 2.2 + second row 3 + padding of the li 0.5 */
  .header-tworow-menu {
    min-height: calc(var(--base-size) * 5.7);
    position: relative;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .header-tworow .wrapper-topmenu {
    flex: 1 1 auto;
  }

  .header-tworow .main-nav,
  .header-tworow .tworow {
    height: 100%;
  }

  .header-tworow .tworow-main {
    height: 100%;
    align-content: flex-start;
    justify-content: flex-end;
  }

  /* 1st level: small links in the top row */
  .header-tworow .tworow-main > li > a {
    height: calc(var(--base-size) * 2.2);
    padding: 0 var(--base-size-half);
    margin: 0 var(--base-size-quarter);
    font-size: .8125rem;
    color: var(--font-color-light);
  }

  .header-tworow .tworow-main > li.is-active > a {
    box-shadow: inset 0 0 0 1px var(--blue);
    color: var(--blue);
    font-weight: normal;
  }

  /* 2nd level: bold links in the second row, space left for the service icons */
  .header-tworow .tworow-level2 {
    flex: 0 0 calc(100% - var(--tworow-service-width));
    margin-right: var(--tworow-service-width);
    justify-content: flex-end;
    border-top: 0;
    background: transparent;
  }

  .header-tworow .tworow-level2 > li > a {
    height: calc(var(--base-size) * 3);
    padding: 0 var(--base-size);
    font-weight: bold;
    color: var(--font-color);
  }

  .header-tworow .tworow-level2 > li:first-child > a {
    padding-left: var(--base-size);
  }

  .header-tworow .tworow-level2 li.is-active > a,
  .header-tworow .tworow-level2 > li > a:hover {
    color: var(--blue);
  }

  .header-tworow .tworow-level3 {
    right: 0;
  }

  /* service icons: right of the second row */
  .header-tworow-service {
    position: absolute;
    right: var(--gutter);
    bottom: 0;
    width: var(--tworow-service-width);
    height: calc(var(--base-size) * 3);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--base-size-half);
  }

  .header-tworow-service .btn-contrast {
    max-width: calc(var(--base-size) * 2);
    padding-top: 0;
    padding-bottom: 0;
  }

  /* fixed header after scrolling (custom.js sets .scroll-fixed): the menu stays visible like on the
     template, the header only gets lower (smaller logo, lower second row) */
  .header-fixed.scroll-fixed .header-tworow {
    min-height: 0;
  }

  /* first row 2.2 + lower second row 2.2 + padding of the li 0.5 */
  .header-fixed.scroll-fixed .header-tworow-menu {
    min-height: calc(var(--base-size) * 4.9);
  }

  .header-fixed.scroll-fixed .header-tworow .wrapper-logo {
    height: auto;
    padding-top: var(--base-size-half);
  }

  .header-fixed.scroll-fixed .header-tworow .wrapper-logo img {
    height: calc(var(--base-size) * 2);
  }

  .header-fixed.scroll-fixed .header-tworow .tworow-level2 > li > a,
  .header-fixed.scroll-fixed .header-tworow-service {
    height: calc(var(--base-size) * 2.2);
  }

  /* fixedheader.css changes the size and padding of the contrast button after scrolling, the button and
     its label would jump, it keeps the values from above (.header-tworow-service .btn-contrast, forms.css) */
  .header-fixed.scroll-fixed .header-tworow-service .btn-contrast {
    max-width: calc(var(--base-size) * 2);
    padding: 0 var(--gutter-half);
  }
}

/* search layer (all widths): covers the header from the left up to the search button (custom.js sets
   --search-toggle-offset to the distance of the button from the right edge), slides in from above like on the
   jweiland template, visibility keeps the closed form out of the tab order */
.header-tworow ~ .wrapper-search {
  top: -100%;
  right: var(--search-toggle-offset, var(--base-size-triple));
  height: 100%;
  align-items: center;
  visibility: hidden;
  transition: top var(--transition), visibility 0s linear .3s;
}

.header-tworow ~ .wrapper-search .frame {
  margin-top: 0;
  margin-bottom: 0;
}

.header-tworow ~ .wrapper-search.visible {
  top: 0;
  visibility: visible;
  transition: top var(--transition);
}

/* fixedheader.css gives the search a fixed height after scrolling */
.header-fixed.scroll-fixed .header-tworow ~ .wrapper-search {
  height: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .header-tworow ~ .wrapper-search,
  .header-tworow ~ .wrapper-search.visible {
    transition: none;
  }
}

/* shortcuts and the button of the offcanvas menu are only used below 1466px */
@media screen and (min-width: 1466px) {
  .header-shortcuts,
  .offcanvas-toggle {
    display: none;
  }
}

/* Mobile header (template: www.sw-bb.de): logo left, shortcuts, contrast, search and menu button right */
@media screen and (max-width: 1465px) {
  .header-tworow {
    --tworow-mobile-header-height: calc(var(--base-size) * 4);
    justify-content: space-between;
    gap: var(--gutter-half);
    min-height: var(--tworow-mobile-header-height);
    padding: 0 var(--gutter-half);
  }

  /* layout.css centres the logo below 1466px for all menu themes */
  .header-tworow .wrapper-logo {
    flex: 0 1 auto;
    min-width: 0;
    margin: 0;
    text-align: left;
  }

  .header-tworow .wrapper-logo img {
    display: block;
    width: auto;
    max-width: 100%;
    height: calc(var(--base-size) * 3);
  }

  /* stretch: shortcuts, contrast and search get the same height and start at the same top edge */
  .header-tworow-menu {
    flex: 0 0 auto;
    display: flex;
    align-items: stretch;
  }

  /* the desktop menu is replaced by the offcanvas menu */
  .header-tworow .wrapper-topmenu {
    display: none;
  }

  /* shortcuts, contrast and search share one structure: a 32px icon box, the same gap and the label below,
     so the icons, the labels and the dividing lines are on the same lines */
  .header-shortcuts,
  .header-tworow .header-tworow-service {
    display: flex;
    align-items: stretch;
    margin: 0;
    padding: 0;
    background: transparent;
  }

  .header-shortcuts {
    list-style: none;
  }

  /* layout.css gives .header-service a fixed height, fixedheader.css a smaller one while scrolling */
  .wrapper-content .content-header .header-tworow-menu > .header-tworow-service {
    height: auto;
  }

  /* the general list styles add a margin to li */
  .header-shortcuts li {
    display: flex;
    margin: 0;
    padding: 0;
  }

  .header-shortcuts a,
  .header-tworow-service .wrapper-contrastbtn,
  .header-tworow-service .search-hide-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    box-sizing: border-box;
    min-width: calc(var(--base-size) * 2.7);
    margin: 0;
    padding: 0 var(--base-size-half);
    border: 0;
    border-right: 1px solid #ccdfee;
    border-radius: 0;
    background: transparent;
    color: #000;
    font-size: .75rem;
    line-height: 1.2;
    text-decoration: none;
  }

  .header-tworow-service .search-hide-btn {
    border-right: 0;
  }

  .header-shortcuts a:hover,
  .header-shortcuts a:focus {
    color: var(--blue);
  }

  /* icon box */
  .header-shortcut-icon,
  .header-tworow-service .btn-contrast,
  .header-tworow-service .search-hide-btn .fa-search {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    line-height: 32px;
  }

  .header-shortcut-icon svg {
    display: block;
    width: auto;
    height: 100%;
  }

  .header-tworow-service .btn-contrast img {
    display: block;
    width: 32px;
    height: 32px;
  }

  .header-tworow-service .search-hide-btn .fa-search {
    font-size: 1.6rem;
  }

  /* label below the icon */
  .header-shortcut-label,
  .header-tworow .contrast-label,
  .header-tworow .search-label {
    display: block;
    margin-top: var(--base-size-quarter);
    font-size: .75rem;
    line-height: 1.2;
  }

  /* menu button: blue box with burger icon and label */
  .offcanvas-toggle {
    align-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    width: 65px;
    height: 56px;
    margin-left: var(--base-size-half);
    padding: 8px 4px 6px;
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: var(--white);
    font-family: var(--menu-font-family);
    font-size: .75rem;
    line-height: 1;
    cursor: pointer;
  }

  .offcanvas-toggle:hover,
  .offcanvas-toggle:focus-visible {
    background: var(--orange);
  }

  .offcanvas-toggle-icon {
    width: 28px;
    height: 28px;
  }
}

/* fixed header: like the template the mobile header stays at the top on all widths (fixedheader.css only
   fixes it from 769px) and does not change while scrolling, the content starts below it */
@media screen and (max-width: 1465px) {
  .wrapper-content.header-fixed .content-header:has(.header-tworow) {
    position: fixed;
    z-index: 1000;
    left: 0;
    right: 0;
    box-shadow: 0 5px 10px 0 rgba(0, 106, 179, .1);
  }

  .wrapper-content.header-fixed:has(.header-tworow) main {
    padding-top: calc(var(--base-size) * 4);
  }

  /* fixedheader.css shrinks the logo and the contrast button after scrolling */
  .header-fixed.scroll-fixed .header-tworow .wrapper-logo {
    height: auto;
  }

  .header-fixed.scroll-fixed .header-tworow .wrapper-logo img {
    height: calc(var(--base-size) * 3);
  }

  .header-fixed.scroll-fixed .header-tworow .btn-contrast {
    padding: 0;
  }
}

/* fixed header from 1466px: fixedheader.css uses --header-height (5 x base-size) as space above the content,
   the two row header is 5.7 x base-size high (.header-tworow-menu), the rootline would be covered */
@media screen and (min-width: 1466px) {
  .wrapper-content.header-fixed:has(.header-tworow) main {
    padding-top: calc(var(--base-size) * 5.7);
  }
}

/* small screens: only icons, the labels stay for screen readers */
@media screen and (max-width: 480px) {
  .header-tworow {
    padding: 0 var(--base-size-quarter);
  }

  .header-tworow .wrapper-logo img,
  .header-fixed.scroll-fixed .header-tworow .wrapper-logo img {
    height: calc(var(--base-size) * 1.8);
  }

  .header-shortcuts a,
  .header-tworow-service .wrapper-contrastbtn,
  .header-tworow-service .search-hide-btn {
    min-width: 0;
    padding: 0 var(--base-size-quarter);
    border-right: 0;
  }

  .header-shortcut-label,
  .header-tworow .contrast-label,
  .header-tworow .search-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .header-shortcut-icon {
    margin-bottom: 0;
  }

  .offcanvas-toggle {
    width: 56px;
    height: 50px;
    margin-left: var(--base-size-quarter);
  }
}
