/* ==========================================================================
   Header & Hauptmenü – Design 2026
   Eine Zeile: Logo | Menü | Telefon | CTA. Unter 1280 px Burger-Menü.
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-white);
  box-shadow: 0 1px 0 var(--color-border), 0 6px 18px rgba(24, 32, 43, 0.04);
}

.site-header__inner {
  max-width: 1600px;
  padding-inline: clamp(1.25rem, 2.6vw, 2.75rem);
  display: flex;
  align-items: center;
  gap: 1.75rem;
  height: var(--header-height);
}

.site-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.site-logo__img,
.site-logo img {
  display: block;
  width: auto;
  height: 50px;
  max-width: 240px;
  object-fit: contain;
}

/* ---- Menü (Desktop) ---- */
.primary-nav {
  flex: 1;
  height: 100%;
}

.primary-nav__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.primary-nav__inner > ul {
  display: flex;
  align-items: stretch;
  gap: 1.5rem;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.primary-nav li {
  position: relative;
  list-style: none;
}

.primary-nav__inner > ul > li {
  display: flex;
  align-items: center;
}

.primary-nav a {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-ink);
  white-space: nowrap;
}

.primary-nav__inner > ul > li > a {
  height: 100%;
  position: relative;
}

.primary-nav__inner > ul > li > a::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--color-primary);
  transform: scaleX(0);
  transition: transform var(--duration-base) var(--ease-out);
}

.primary-nav__inner > ul > li > a:hover,
.primary-nav__inner > ul > li.current-menu-item > a,
.primary-nav__inner > ul > li.current-menu-ancestor > a {
  color: var(--color-primary);
}

.primary-nav__inner > ul > li > a:hover::before,
.primary-nav__inner > ul > li.current-menu-item > a::before,
.primary-nav__inner > ul > li.current-menu-ancestor > a::before {
  transform: scaleX(1);
}

/* kleiner Pfeil nach unten bei Untermenüs */
.menu-item-has-children > a::after {
  content: "";
  width: 5px;
  height: 5px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.7;
  margin: -3px 0 0 2px;
}

.sub-menu {
  position: absolute;
  top: 100%;
  left: -0.75rem;
  z-index: 20;
  min-width: 15rem;
  margin: 0;
  padding: 0.5rem;
  list-style: none;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out),
              visibility var(--duration-base);
}

.menu-item-has-children:hover > .sub-menu,
.menu-item-has-children:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sub-menu a {
  padding: 0.6rem 0.85rem;
  border-radius: 5px;
}

.sub-menu a:hover,
.sub-menu .current-menu-item > a {
  background: var(--color-gray-50);
  color: var(--color-primary);
}

.sub-menu a::before,
.sub-menu a::after {
  display: none;
}

/* ---- Telefon + CTA ---- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-shrink: 0;
}

.header-phone {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-ink);
  white-space: nowrap;
}

.header-phone svg {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--color-primary);
}

.header-phone__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.header-phone__text small {
  font-size: 0.7188rem;
  color: var(--color-muted);
}

.header-phone__text strong {
  font-size: 0.9375rem;
  font-weight: 700;
}

.header-phone:hover strong {
  color: var(--color-primary);
}

.header-cta {
  padding: 0.8rem 1.15rem;
  font-size: 0.875rem;
}

.header-actions-mobile {
  display: none;
}

.menu-toggle {
  display: none;
  position: relative;
  z-index: 200;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.menu-toggle span:not(.screen-reader-text) {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-ink);
  transition: transform var(--duration-base) var(--ease-out),
              opacity var(--duration-base) var(--ease-out);
}

body.has-open-menu .menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.has-open-menu .menu-toggle span:nth-child(2) { opacity: 0; }
body.has-open-menu .menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* etwas enger, bevor das Burger-Menü greift */
@media (max-width: 1500px) {
  .site-header__inner { gap: 1rem; }
  .primary-nav__inner > ul { gap: 0.8rem; }
  .primary-nav a { font-size: 0.8125rem; }
  .header-actions { gap: 1rem; }
  .site-logo__img, .site-logo img { height: 42px; }
}

/* zwischen 1280 und 1439 px: Telefon nur als Symbol */
@media (max-width: 1439px) {
  .header-phone__text { display: none; }
  .site-logo__img, .site-logo img { height: 40px; }
}

/* ---- Burger-Menü ---- */
@media (max-width: 1279px) {
  .primary-nav {
    position: fixed;
    inset: var(--header-height) 0 0 0; /* unter der Kopfzeile: Logo und Schließen-Knopf bleiben sichtbar */
    z-index: 150;
    height: auto;
    border-top: 1px solid var(--color-border);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background: var(--color-white);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity var(--duration-slow) var(--ease-out),
                transform var(--duration-slow) var(--ease-out),
                visibility var(--duration-slow);
  }

  .primary-nav.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .primary-nav__inner {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    height: auto;
    max-width: 40rem;
    margin-inline: auto;
    padding: 1.5rem var(--container-padding) 3rem;
  }

  .primary-nav__inner > ul {
    flex-direction: column;
    flex-shrink: 0;
    align-items: stretch;
    gap: 0;
    height: auto;
  }

  .primary-nav__inner > ul > li > a {
    height: auto;
  }

  /* Button im Menü: weiße Schrift trotz allgemeiner Menü-Linkfarbe */
  .primary-nav .header-actions-mobile .fp-btn {
    justify-content: center;
    padding: 0.95rem 1.4rem;
    font-size: 1rem;
    color: var(--color-white);
  }

  .primary-nav__inner > ul > li {
    display: block;
    border-bottom: 1px solid var(--color-border);
  }

  .primary-nav a {
    padding-block: 1rem;
    font-size: 1.125rem;
    font-weight: 600;
    white-space: normal;
  }

  .primary-nav__inner > ul > li > a::before { display: none; }

  .menu-item-has-children > a::after { margin-left: auto; }

  .sub-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    min-width: 0;
    margin: 0 0 0.75rem;
    padding: 0 0 0 1rem;
    border: none;
    box-shadow: none;
  }

  .sub-menu a {
    padding-block: 0.6rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-body);
  }

  .header-actions-mobile {
    display: grid;
    gap: 1rem;
    margin-top: 2rem;
  }

  .header-phone--mobile {
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 700;
  }

  .primary-nav__inner > ul ~ .header-actions-mobile .header-phone svg { width: 1.3rem; height: 1.3rem; }

  .site-header__inner { justify-content: space-between; }

  .menu-toggle { display: flex; }
}

@media (max-width: 760px) {
  .header-phone__text,
  .header-cta { display: none; }
  .site-logo__img, .site-logo img { height: 40px; max-width: 200px; }
}

/* Kompass-Akzent */
.menu-item--accent > a {
  color: var(--color-primary);
}


/* ==========================================================================
   Mega-Panel im Hauptmenü
   ========================================================================== */
@media (min-width: 1280px) {
  .sub-menu.mega {
    display: grid;
    grid-template-columns: repeat(var(--mega-cols, 2), minmax(13.5rem, 1fr));
    gap: 0.25rem 1.25rem;
    width: max-content;
    max-width: min(68rem, calc(100vw - 3rem));
    padding: 1.25rem 1.25rem 1.1rem;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(24, 32, 43, 0.14);
  }
  .sub-menu.mega--teaser { grid-template-columns: repeat(var(--mega-cols, 2), minmax(13.5rem, 1fr)) 15rem; }
  /* Panels mittig unter dem Menü statt am Menüpunkt – passen so bei jeder Fensterbreite */
  .primary-nav__inner { position: relative; }
  .primary-nav__inner > ul > li.menu-item-has-children { position: static; }
  .sub-menu.mega { left: 50%; right: auto; transform: translate(-50%, 6px); }
  .menu-item-has-children:hover > .sub-menu.mega,
  .menu-item-has-children:focus-within > .sub-menu.mega { transform: translate(-50%, 0); }
  /* Unsichtbare Brücke, damit das Panel beim Wechsel mit der Maus offen bleibt */
  .sub-menu.mega::before { content: ""; position: absolute; left: 0; right: 0; top: -1.25rem; height: 1.25rem; }
  .mega__col ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 0.1rem; }
  .mega__title { margin: 0 0 0.4rem 0.6rem; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-primary); }
  .sub-menu.mega a { display: flex; align-items: flex-start; gap: 0.7rem; padding: 0.55rem 0.6rem; border-radius: 9px; white-space: normal; }
  .sub-menu.mega a:hover, .sub-menu.mega .current-menu-item > a { background: var(--color-gray-50); color: inherit; }
  .mega__icon { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; border-radius: 9px; background: var(--color-primary-light); color: var(--color-primary); }
  .mega__icon svg { width: 1.1rem; height: 1.1rem; }
  .mega__text { display: flex; flex-direction: column; line-height: 1.3; }
  .mega__text strong { font-size: 0.9063rem; font-weight: 700; color: var(--color-ink); }
  .sub-menu.mega a:hover .mega__text strong { color: var(--color-primary); }
  .mega__text em { margin-top: 0.15rem; font-style: normal; font-size: 0.8125rem; font-weight: 400; color: var(--color-muted); }
  .mega__teaser { display: flex; flex-direction: column; gap: 0.5rem; align-self: stretch; padding: 1.1rem; border-radius: 12px; background: linear-gradient(160deg, #18202B, #2B3644); color: #fff; }
  .mega__teaser-title { margin: 0; font-family: var(--font-display); font-size: 1.0625rem; font-weight: 700; line-height: 1.3; color: #fff; }
  .mega__teaser p { margin: 0; font-size: 0.875rem; line-height: 1.5; color: #D5DAE1; }
  .mega__teaser .fp-btn { margin-top: auto; justify-content: center; font-size: 0.875rem; padding: 0.6rem 0.9rem; color: #fff; }
  .mega__teaser .fp-btn:hover { color: #fff; }
  .mega__teaser .fp-btn svg { width: 0.9rem; height: 0.9rem; }
}

@media (max-width: 1279px) {
  .sub-menu.mega { display: block; }
  .mega__col ul { margin: 0; padding: 0; list-style: none; }
  .mega__title { margin: 0.6rem 0 0.2rem; font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-primary); }
  .mega__icon, .mega__text em, .mega__teaser { display: none; }
  .sub-menu.mega a { display: block; }
}
