/* Responsive overrides on top of fixed.css. */

/* Modernize the sticky-sidebar trick: the original relies on html/body being
   height:100% with overflow-y:auto, so #fixiert (position:absolute) stays put
   while the *body* scrolls internally. That nested-scroll-container hack is
   fragile on mobile browsers, so replace it with plain position:fixed and let
   the document scroll normally, at every width — same visual result. */
html, body {
  height: auto;
  min-height: 100%;
  overflow-x: visible;
  overflow-y: visible;
}

#fixiert {
  position: fixed;
  top: 0.5em;
  /* #page reserves a 195px-wide column (margin-left:195px in fixed.css);
     center this 170px-wide sidebar box within it instead of the old
     "left: 1em" (~19px), which sat off-center and left barely 6px on the
     right before the divider. */
  left: 12px;
  /* the original "width: 12em" is relative to #fixiert's own font-size
     (1.4em); bumping the v2 root font-size for Source Sans 3's smaller
     x-height inflated that too, growing the sidebar past #page's
     margin-left:195px reservation and overlapping the content column.
     Pin it to a fixed px value so it no longer scales with text size. */
  width: 170px;
  /* with a submenu expanded (hover on desktop), the sidebar's content can
     exceed the viewport height; being position:fixed it has no page scroll
     to fall back on, so without this the overflow was simply unreachable */
  max-height: calc(100vh - 1em);
  overflow-y: auto;
}

/* the markup carries a leftover inline "margin-left:-45px" on <nav id="menu_box">
   from the original design; !important is required to beat an inline style */
nav#menu_box {
  margin-left: 0 !important;
}

#nav-toggle {
  display: none;
}

#mobile-brand {
  display: none;
}

@media (max-width: 780px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: visible;
  }

  /* the original stylesheet pins html/body to 14px, which every "rem" value
     below is relative to — raise the root size so 1rem lands at a readable
     mobile text size instead of redoing every rule in px. Also compensates
     for Source Sans 3's smaller x-height vs. Verdana (~12% at equal size). */
  html, body {
    font-size: 19px;
  }

  /* ---- Fixed top bar: brand left, hamburger pinned top-right ---- */
  #fixiert {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 56px;
    margin: 0;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fcfcfc;
    border-top: 3px solid #006666;
    border-bottom: 1px solid #e2e2e2;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
    z-index: 1000;
    font-variant: normal;
    transition: transform 0.25s ease;
  }

  /* hidden on scroll-down, revealed on scroll-up — see nav.js */
  #fixiert.hide-bar {
    transform: translateY(-100%);
  }

  /* the desktop sidebar content (long brand block, line breaks, BDP seal)
     doesn't belong in a slim mobile bar; #mobile-brand stands in for it */
  #desktop-brand {
    display: none !important;
  }

  #mobile-brand {
    display: inline-block;
    font-variant: small-caps;
    font-variant-caps: small-caps;
    font-feature-settings: "smcp" 1;
    font-family: "Source Sans 3", Verdana, Arial, Helvetica, sans-serif;
    font-size: 1.15rem;
    font-weight: bold;
    color: #006666;
    text-decoration: none;
  }

  #nav-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    padding: 0;
    flex-shrink: 0;
    background: transparent;
    border: 0;
    border-radius: 6px;
  }

  #nav-toggle:active {
    background: #eef2f2;
  }

  .hamburger-bar {
    display: block;
    width: 22px;
    height: 2px;
    background: #006666;
    border-radius: 2px;
  }

  /* ---- Dropdown nav panel, opens below the fixed bar ---- */
  nav#menu_box {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    width: 100%;
    /* the markup carries a leftover inline "margin-left:-45px" meant for the
       desktop absolute-positioned sidebar; !important is required here to
       actually beat it, a plain override can't win against an inline style */
    margin: 0 !important;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    background: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
    z-index: 999;
    box-sizing: border-box;
  }

  nav#menu_box.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .menu {
    width: 100% !important;
    margin: 8px 0;
    padding: 0;
    box-sizing: border-box;
  }

  /* the desktop rule ".menu li { font-size: 0.7em }" compounds with every
     nesting level (a submenu link ends up at 0.7 * 0.7 of the body size,
     ~10px) — pin every level to a fixed rem value instead */
  .menu li {
    font-size: 1rem !important;
  }

  .menu li a {
    width: 100% !important;
    margin-left: 0 !important;
    padding: 14px 20px;
    font-size: 1.05rem;
    line-height: 1.3;
    box-sizing: border-box;
  }

  /* hover-based submenus don't work on touch; nav.js toggles .submenu-open on click */
  .menu li ul {
    position: static !important;
    display: none !important;
    height: auto !important;
    width: auto !important;
    margin: 0 !important;
  }

  .menu li.submenu-open > ul {
    display: block !important;
  }

  .menu li > a[href="#"] {
    position: relative;
    padding-right: 44px !important;
  }

  .menu li > a[href="#"]::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 20px;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-65%) rotate(45deg);
    transition: transform 0.2s ease;
  }

  .menu li.submenu-open > a[href="#"]::after {
    transform: translateY(-35%) rotate(225deg);
  }

  .menu li ul li a {
    display: block !important;
    height: auto !important;
    width: auto !important;
    font-size: 1rem !important;
    padding: 13px 20px 13px 36px !important;
    background: #eef5f4 !important;
    color: #1F3D39 !important;
  }

  /* ---- Page content: full width, one consistent gutter ---- */
  #page {
    margin: 0;
    border-left: none;
    width: 100%;
    max-width: 100%;
    height: auto;
    padding: 72px 20px 60px 20px;
    box-sizing: border-box;
    font-size: 19px;
  }

  #page h1 {
    margin: 0 0 20px 0;
    padding-left: 0;
    font-size: 1.6em;
    line-height: 1.3;
  }

  #page p {
    line-height: 1.6;
  }

  #page p,
  #page ul,
  #page div {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  #page ul {
    padding-left: 20px;
    line-height: 1.6;
  }

  /* boxes used as visual/graphic elements (photo frames, contact card, book
     teaser, …); the original padding shorthand ("10 0 10 10px") is malformed
     and renders lopsided — replace with one clean, even gutter */
  .kasten {
    padding: 20px !important;
  }

  /* the legacy markup floats/sizes content divs by hand; stack everything on small screens */
  #page div {
    float: none !important;
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    box-sizing: border-box;
  }

  #page img {
    max-width: 100% !important;
    height: auto !important;
    float: none !important;
    display: block;
    margin: 16px auto !important;
    border-radius: 6px;
  }

  #page table {
    width: 100% !important;
  }

  #page table td {
    display: block !important;
    width: 100% !important;
    padding: 4px 0 !important;
    box-sizing: border-box;
  }
}
