.page-subnav {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 110;
  background-color: #eceded;
  border-radius: 20px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 24px);
  pointer-events: none;
  transition:
    opacity 0.35s ease,
    transform 0.35s ease,
    visibility 0s linear 0.35s;

  max-width: calc(100% - 32px);
}

.page-subnav.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  pointer-events: auto;
  transition:
    opacity 0.35s ease,
    transform 0.35s ease,
    visibility 0s linear 0s;
}

/* Ausgeblendet, wenn die Subnav den Footer beruehrt (per JS gesetzt). */
.page-subnav.is-footer-hidden {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translate(-50%, 24px) !important;
  pointer-events: none !important;
}

/* Ausgeblendet, solange ein Menue offen ist (per JS gesetzt) –
   verhindert, dass die Pille ueber dem offenen Mobile-/Hauptmenue schwebt. */
.page-subnav.is-suppressed {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: translate(-50%, 24px) !important;
  pointer-events: none !important;
}

.page-subnav-inner {
  padding: 8px 28px;
}

.page-subnav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 32px;
  align-items: center;
}

.page-subnav-item {
  margin: 0;
}

/* Dropdown-Button: nur auf Mobile sichtbar (siehe Media Query unten) */
.page-subnav-toggle {
  display: none;
}

.page-subnav-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: #000000;
  font-weight: 800;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  padding: 4px 0;
  transition: color 0.2s ease;
}

.page-subnav-link:hover {
  color: #000000;
}

/* Aktiver Link (Scrollspy) */
.page-subnav-link.is-active {
  color: #000000;
  font-weight: 800;
}

html {
  scroll-behavior: smooth;
}

[id] {
  scroll-margin-top: calc(var(--subnav-top, 80px) + 24px);
}
body.page-id-9898 [id] {
  scroll-margin-top: calc(var(--subnav-top, 80px) + 60px);
}

/* =========================================================================
   Mobile (< 976px): Pille wird zu einem Dropdown-Button.
   Geschlossen zeigt der Button die aktive Section; Tippen klappt die
   Liste nach oben auf (Pille sitzt unten).
   ========================================================================= */
@media (max-width: 975px) {
  /* Die ganze Pille ist EIN zusammenhaengender Block, der nach oben aufklappt.
     Breite = automatisch so breit wie der laengste Eintrag (stabil, springt
     beim Scrollen nicht), da Button + Liste im selben Flex-Container liegen. */
  .page-subnav {
    /* Safe-Area beruecksichtigen (iPhone Home-Indicator) */
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100% - 24px);
    width: auto;
    display: flex;
    flex-direction: column-reverse; /* Button unten, Liste darueber */
    padding: 0;                     /* geschlossen = exakt Button-Hoehe */
    border-radius: 16px;
    overflow: hidden;               /* fuer das Auf-/Zuklappen */
  }

  /* Sichtbarer Button (geschlossener Zustand).
     Hoehe = Desktop-Leiste: gleiches vertikales Padding (8+4=12px) und
     gleiche Schriftmetrik wie die Desktop-Links. */
  .page-subnav-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
    padding: 12px 16px;
    margin: 0;
    background: none;
    border: 0;
    cursor: pointer;
    font: inherit;
    color: #000000;
    font-weight: 800;
    font-size: 14px;
    line-height: 1.2;
  }

  .page-subnav-current {
    white-space: nowrap;
  }

  .page-subnav-chevron {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;                    /* auf Zeilenhoehe begrenzt -> kein Aufblaehen */
    height: 16px;
    transition: transform 0.25s ease;
  }

  .page-subnav-chevron svg {
    width: 100%;
    height: 100%;
  }

  .page-subnav.is-open .page-subnav-chevron {
    transform: rotate(180deg);
  }

  /* Liste klappt per grid-template-rows 0fr -> 1fr auf/zu.
     Animiert exakt auf die Inhaltshoehe (kein Ueberschiessen wie bei
     max-height) und haelt die Breite stabil (Inhalt ist immer gelayoutet). */
  .page-subnav-inner {
    padding: 0;
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition:
      grid-template-rows 0.3s ease,
      opacity 0.25s ease;
  }

  .page-subnav.is-open .page-subnav-inner {
    grid-template-rows: 1fr;
    padding-top: 8px;
    opacity: 1;
  }

  .page-subnav-list {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 0;         /* kein Padding hier: bliebe bei 0fr stehen und
                           wuerde den geschlossenen Button oben dicker machen.
                           Vertikaler Abstand kommt aus dem Link-Padding. */
    overflow: hidden;   /* noetig fuer die grid-rows-Animation */
    min-height: 0;
  }

  .page-subnav-item {
    width: 100%;
  }

  .page-subnav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    white-space: nowrap;
  }

  /* Unsichtbarer Platzhalter rechts: reserviert in jeder Zeile denselben
     Platz wie das Chevron im Button. Dadurch ist die laengste Zeile genauso
     breit wie der Button mit dem laengsten Label + Chevron -> nichts wird
     rausgeschoben, Breite bleibt stabil. */
  .page-subnav-link::after {
    content: "";
    flex: 0 0 auto;
    width: 24px;
  }

  /* Kein hervorgehobenes aktives Element in der Liste –
     die aktive Section steht bereits im Button. */
  .page-subnav-link.is-active {
    background: none;
    font-weight: 800;
  }

  .page-subnav-link.is-active .group-underline {
    text-decoration: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .page-subnav {
    transform: translate(-50%, 0);
    transition: opacity 0.2s ease, visibility 0s;
  }

  .page-subnav.is-visible {
    transform: translate(-50%, 0);
  }
}
